[PATCH 3/3] d2d1/tests: Add tests for standard effect properties.
Ziqing Hui
zhui at codeweavers.com
Wed Jul 21 05:02:32 CDT 2021
Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---
dlls/d2d1/tests/d2d1.c | 133 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 124 insertions(+), 9 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 1ee4941da99..f9448f168ab 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -20,6 +20,7 @@
#include <limits.h>
#include <math.h>
#include <float.h>
+#include <wchar.h>
#include "d2d1_1.h"
#include "d3d11.h"
#include "wincrypt.h"
@@ -9680,13 +9681,47 @@ static void test_mt_factory(BOOL d3d11)
static void test_effect(BOOL d3d11)
{
+ unsigned int i, min_inputs, max_inputs;
+ D2D1_BUFFER_PRECISION precision;
ID2D1Image *image_a, *image_b;
struct d2d1_test_context ctx;
ID2D1DeviceContext *context;
ID2D1Factory1 *factory;
ID2D1Effect *effect;
+ WCHAR buffer[1024];
+ BOOL cached;
+ CLSID clsid;
HRESULT hr;
+ const WCHAR *expected_author = L"Microsoft Corporation";
+ const struct effect_test
+ {
+ const CLSID *clsid;
+ const WCHAR *name;
+ const WCHAR *category;
+ UINT32 min_inputs;
+ UINT32 max_inputs;
+ const WCHAR *description;
+ }
+ effect_tests[] =
+ {
+ /* 0: 2D Affine Transform */
+ {
+ &CLSID_D2D12DAffineTransform, L"2D Affine Transform", L"Transform", 1, 1,
+ L"Applies a 2D affine transform to a bitmap.",
+ },
+ /* 1: 3D Perspective Transform */
+ {
+ &CLSID_D2D13DPerspectiveTransform, L"3D Perspective Transform", L"Transform", 1, 1,
+ L"Applies a 3D perspective transform to a bitmap."
+ },
+ /* 2: Composite */
+ {
+ &CLSID_D2D1Composite, L"Composite", L"Composite", 1, 0xffffffff,
+ L"Composites foreground and background images using the selected composition mode."
+ }
+ };
+
if (!init_test_context(&ctx, d3d11))
return;
@@ -9699,17 +9734,97 @@ static void test_effect(BOOL d3d11)
hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D12DAffineTransform, &effect);
- ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- hr = ID2D1Effect_QueryInterface(effect, &IID_ID2D1Image, (void **)&image_a);
- ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- ID2D1Effect_GetOutput(effect, &image_b);
- ok(image_b == image_a, "Got unexpected image_b %p, expected %p.\n", image_b, image_a);
- ID2D1Image_Release(image_b);
- ID2D1Image_Release(image_a);
+ for (i = 0; i < ARRAY_SIZE(effect_tests); ++i)
+ {
+ const struct effect_test *test = effect_tests + i;
+
+ winetest_push_context("Test %u", i);
+
+ hr = ID2D1DeviceContext_CreateEffect(context, test->clsid, &effect);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = ID2D1Effect_QueryInterface(effect, &IID_ID2D1Image, (void **)&image_a);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ID2D1Effect_GetOutput(effect, &image_b);
+ ok(image_b == image_a, "Got unexpected image_b %p, expected %p.\n", image_b, image_a);
+ ID2D1Image_Release(image_b);
+ ID2D1Image_Release(image_a);
+
+ if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
+ {
+ todo_wine
+ {
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CLSID,
+ D2D1_PROPERTY_TYPE_CLSID, (BYTE *)&clsid, sizeof(clsid));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(IsEqualGUID(&clsid, test->clsid), "Got unexpected clsid %s, expected %s.\n",
+ debugstr_guid(&clsid), debugstr_guid(test->clsid));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_DISPLAYNAME,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(!wcscmp(buffer, test->name), "Got unexpected name %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->name));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_AUTHOR,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(!wcscmp(buffer, expected_author), "Got unexpected author %s.\n", debugstr_w(buffer));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CATEGORY,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(!wcscmp(buffer, test->category), "Got unexpected category %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->category));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_DESCRIPTION,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(!wcscmp(buffer, test->description), "Got unexpected description %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->description));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CACHED,
+ D2D1_PROPERTY_TYPE_BOOL, (BYTE *)&cached, sizeof(cached));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(cached == FALSE, "Got unexpected cached %d.\n", cached);
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_PRECISION,
+ D2D1_PROPERTY_TYPE_ENUM, (BYTE *)&precision, sizeof(precision));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(precision == D2D1_BUFFER_PRECISION_UNKNOWN, "Got unexpected precision %u.\n", precision);
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_MIN_INPUTS,
+ D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&min_inputs, sizeof(min_inputs));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(min_inputs == test->min_inputs, "Got unexpected min inputs %u, expected %u.\n",
+ min_inputs, test->min_inputs);
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_MAX_INPUTS,
+ D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&max_inputs, sizeof(max_inputs));
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ if (hr == S_OK)
+ ok(max_inputs == test->max_inputs, "Got unexpected max inputs %u, expected %u.\n",
+ max_inputs, test->max_inputs);
+ }
+ }
+ else
+ {
+ skip("Non-English locale.\n");
+ }
+
+ ID2D1Effect_Release(effect);
+ winetest_pop_context();
+ }
- ID2D1Effect_Release(effect);
ID2D1DeviceContext_Release(context);
ID2D1Factory1_Release(factory);
release_test_context(&ctx);
--
2.25.1
More information about the wine-devel
mailing list