Signed-off-by: Ziqing Hui <zhui(a)codeweavers.com>
---
PS: I'll submit v2 version of the patch set I sent yesterday after this patch set is approved.
dlls/d2d1/tests/d2d1.c | 77 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 74 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index f1cec1d7a0b..68d2716a118 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -10310,19 +10310,21 @@ static void test_mt_factory(BOOL d3d11)
ID2D1Factory_Release(factory);
}
-static void test_effect(BOOL d3d11)
+static void test_builtin_effect(BOOL d3d11)
{
- unsigned int i, j, min_inputs, max_inputs, str_size, input_count;
+ unsigned int i, j, min_inputs, max_inputs, str_size, input_count, value_size;
D2D1_BITMAP_PROPERTIES bitmap_desc;
D2D1_BUFFER_PRECISION precision;
ID2D1Image *image_a, *image_b;
struct d2d1_test_context ctx;
ID2D1DeviceContext *context;
+ D2D1_PROPERTY_TYPE type;
ID2D1Factory1 *factory;
ID2D1Bitmap *bitmap;
ID2D1Effect *effect;
D2D1_SIZE_U size;
BYTE buffer[256];
+ WCHAR name[32];
BOOL cached;
CLSID clsid;
HRESULT hr;
@@ -10345,6 +10347,27 @@ static void test_effect(BOOL d3d11)
{&CLSID_D2D1Grayscale, 3, 1, 1, 1},
};
+ const struct property_test
+ {
+ UINT32 index;
+ const WCHAR *name;
+ D2D1_PROPERTY_TYPE type;
+ UINT32 value_size;
+ }
+ property_tests[] =
+ {
+ {D2D1_PROPERTY_CLSID, L"CLSID", D2D1_PROPERTY_TYPE_CLSID, sizeof(CLSID)},
+ {D2D1_PROPERTY_DISPLAYNAME, L"DisplayName", D2D1_PROPERTY_TYPE_STRING, 0},
+ {D2D1_PROPERTY_AUTHOR, L"Author", D2D1_PROPERTY_TYPE_STRING, 0},
+ {D2D1_PROPERTY_CATEGORY, L"Category", D2D1_PROPERTY_TYPE_STRING, 0},
+ {D2D1_PROPERTY_DESCRIPTION, L"Description", D2D1_PROPERTY_TYPE_STRING, 0},
+ {D2D1_PROPERTY_INPUTS, L"Inputs", D2D1_PROPERTY_TYPE_ARRAY, sizeof(UINT32)},
+ {D2D1_PROPERTY_CACHED, L"Cached", D2D1_PROPERTY_TYPE_BOOL, sizeof(UINT32)},
+ {D2D1_PROPERTY_PRECISION, L"Precision", D2D1_PROPERTY_TYPE_ENUM, sizeof(UINT32)},
+ {D2D1_PROPERTY_MIN_INPUTS, L"MinInputs", D2D1_PROPERTY_TYPE_UINT32, sizeof(UINT32)},
+ {D2D1_PROPERTY_MAX_INPUTS, L"MaxInputs", D2D1_PROPERTY_TYPE_UINT32, sizeof(UINT32)},
+ };
+
if (!init_test_context(&ctx, d3d11))
return;
@@ -10372,6 +10395,7 @@ static void test_effect(BOOL d3d11)
hr = ID2D1DeviceContext_CreateEffect(context, test->clsid, &effect);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ /* Test output image pointer */
hr = ID2D1Effect_QueryInterface(effect, &IID_ID2D1Image, (void **)&image_a);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ID2D1Effect_GetOutput(effect, &image_b);
@@ -10379,6 +10403,48 @@ static void test_effect(BOOL d3d11)
ID2D1Image_Release(image_b);
ID2D1Image_Release(image_a);
+ /* Test system property name, type, value size */
+ for (j = 0; j < ARRAY_SIZE(property_tests); ++j)
+ {
+ const struct property_test *property_test = &property_tests[j];
+ winetest_push_context("Property %u", j);
+
+ name[0] = 0;
+ hr = ID2D1Effect_GetPropertyName(effect, 0xdeadbeef, name, sizeof(name));
+ todo_wine ok(hr == D2DERR_INVALID_PROPERTY, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_GetPropertyName(effect, property_test->index, name, sizeof(name));
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ todo_wine ok(!wcscmp(name, property_test->name), "Got unexpected property name %s, expected %s.\n",
+ debugstr_w(name), debugstr_w(property_test->name));
+
+ type = ID2D1Effect_GetType(effect, 0xdeadbeef);
+ ok(type == D2D1_PROPERTY_TYPE_UNKNOWN, "Got unexpected property type %#x.\n", type);
+ type = ID2D1Effect_GetType(effect, property_test->index);
+ todo_wine ok(type == property_test->type, "Got unexpected property type %#x, expected %#x.\n",
+ type, property_test->type);
+
+ value_size = ID2D1Effect_GetValueSize(effect, 0xdeadbeef);
+ ok(value_size == 0, "Got unexpected value size %u.\n", value_size);
+ value_size = ID2D1Effect_GetValueSize(effect, property_test->index);
+ if (property_test->value_size != 0)
+ {
+ todo_wine ok(value_size == property_test->value_size, "Got unexpected value size %u, expected %u.\n",
+ value_size, property_test->value_size);
+ }
+ else if (property_test->type == D2D1_PROPERTY_TYPE_STRING)
+ {
+ hr = ID2D1Effect_GetValue(effect, property_test->index,
+ D2D1_PROPERTY_TYPE_STRING, buffer, sizeof(buffer));
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ str_size = (wcslen((WCHAR *)buffer) + 1) * sizeof(WCHAR);
+ todo_wine ok(value_size == str_size, "Got unexpected value size %u, expected %u.\n",
+ value_size, str_size);
+ }
+
+ winetest_pop_context();
+ }
+
+ /* Test GetValue() */
hr = ID2D1Effect_GetValue(effect, 0xdeadbeef, D2D1_PROPERTY_TYPE_CLSID, (BYTE *)&clsid, sizeof(clsid));
ok(hr == D2DERR_INVALID_PROPERTY, "Got unexpected hr %#lx.\n", hr);
@@ -10436,10 +10502,12 @@ static void test_effect(BOOL d3d11)
ok(max_inputs == test->max_inputs, "Got unexpected max inputs %u, expected %u.\n",
max_inputs, test->max_inputs);
+ /* Test default input count */
input_count = ID2D1Effect_GetInputCount(effect);
ok(input_count == test->default_input_count, "Got unexpected input count %u, expected %u.\n",
input_count, test->default_input_count);
+ /* Test SetInputCount() */
input_count = (test->max_inputs < 16 ? test->max_inputs : 16);
for (j = 0; j < input_count + 4; ++j)
{
@@ -10452,6 +10520,7 @@ static void test_effect(BOOL d3d11)
winetest_pop_context();
}
+ /* Test GetInput() before any input is set */
input_count = ID2D1Effect_GetInputCount(effect);
for (j = 0; j < input_count + 4; ++j)
{
@@ -10461,6 +10530,7 @@ static void test_effect(BOOL d3d11)
winetest_pop_context();
}
+ /* Test GetInput() after an input is set */
set_size_u(&size, 1, 1);
bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE;
@@ -10487,6 +10557,7 @@ static void test_effect(BOOL d3d11)
winetest_pop_context();
}
+ /* Test setting inputs with out-of-bounds index */
for (j = input_count; j < input_count + 4; ++j)
{
winetest_push_context("Input %u", j);
@@ -12304,7 +12375,7 @@ START_TEST(d2d1)
queue_test(test_effect_register);
queue_test(test_effect_context);
queue_test(test_effect_properties);
- queue_test(test_effect);
+ queue_test(test_builtin_effect);
queue_test(test_effect_2d_affine);
queue_test(test_effect_crop);
queue_test(test_effect_grayscale);
--
2.25.1