Signed-off-by: Ziqing Hui zhui@codeweavers.com
-- v3: d2d1/tests: Test value size checking for custom properties. d2d1/tests: Add tests for GetPropertyCount().
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 97 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 6ba4d8cec59..d31cd9cf1a3 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10314,7 +10314,85 @@ static void test_mt_factory(BOOL d3d11) ID2D1Factory_Release(factory); }
-static void test_effect(BOOL d3d11) +#define check_system_properties(effect, is_builtin) check_system_properties_(__LINE__, effect, is_builtin) +static void check_system_properties_(unsigned int line, ID2D1Effect *effect, BOOL is_builtin) +{ + UINT i, value_size, str_size; + WCHAR name[32], buffer[256]; + D2D1_PROPERTY_TYPE type; + HRESULT hr; + + const struct system_property_test + { + UINT32 index; + const WCHAR *name; + D2D1_PROPERTY_TYPE type; + UINT32 value_size; + } + system_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(BOOL)}, + {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)}, + }; + + hr = ID2D1Effect_GetPropertyName(effect, 0xdeadbeef, name, sizeof(name)); + ok_(__FILE__, line)(hr == D2DERR_INVALID_PROPERTY, "GetPropertyName() got unexpected hr %#lx for 0xdeadbeef.\n", hr); + type = ID2D1Effect_GetType(effect, 0xdeadbeef); + ok_(__FILE__, line)(type == D2D1_PROPERTY_TYPE_UNKNOWN, "Got unexpected property type %#x for 0xdeadbeef.\n", type); + value_size = ID2D1Effect_GetValueSize(effect, 0xdeadbeef); + ok_(__FILE__, line)(value_size == 0, "Got unexpected value size %u for 0xdeadbeef.\n", value_size); + + for (i = 0; i < ARRAY_SIZE(system_property_tests); ++i) + { + const struct system_property_test *test = &system_property_tests[i]; + winetest_push_context("Property %u", i); + + name[0] = 0; + hr = ID2D1Effect_GetPropertyName(effect, test->index, name, sizeof(name)); + todo_wine_if(test->type == D2D1_PROPERTY_TYPE_ARRAY || (is_builtin && test->type == D2D1_PROPERTY_TYPE_STRING)) + { + ok_(__FILE__, line)(hr == S_OK, "Failed to get property name, hr %#lx\n", hr); + ok_(__FILE__, line)(!wcscmp(name, test->name), "Got unexpected property name %s, expected %s.\n", + debugstr_w(name), debugstr_w(test->name)); + } + + type = D2D1_PROPERTY_TYPE_UNKNOWN; + type = ID2D1Effect_GetType(effect, test->index); + todo_wine_if(test->type == D2D1_PROPERTY_TYPE_ARRAY || (is_builtin && test->type == D2D1_PROPERTY_TYPE_STRING)) + ok_(__FILE__, line)(type == test->type, "Got unexpected property type %#x, expected %#x.\n", + type, test->type); + + value_size = 0; + value_size = ID2D1Effect_GetValueSize(effect, test->index); + if (test->value_size != 0) + { + todo_wine_if(test->type == D2D1_PROPERTY_TYPE_ARRAY) + ok_(__FILE__, line)(value_size == test->value_size, "Got unexpected value size %u, expected %u.\n", + value_size, test->value_size); + } + else if (test->type == D2D1_PROPERTY_TYPE_STRING) + { + hr = ID2D1Effect_GetValue(effect, test->index, D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer)); + todo_wine_if(is_builtin) + ok_(__FILE__, line)(hr == S_OK, "Failed to get value, hr %#lx.\n", hr); + str_size = (wcslen((WCHAR *)buffer) + 1) * sizeof(WCHAR); + todo_wine_if(is_builtin || buffer[0] == 0) + ok_(__FILE__, line)(value_size == str_size, "Got unexpected value size %u, expected %u.\n", + value_size, str_size); + } + winetest_pop_context(); + } +} + +static void test_builtin_effect(BOOL d3d11) { unsigned int i, j, min_inputs, max_inputs, str_size, input_count; D2D1_BITMAP_PROPERTIES bitmap_desc; @@ -10376,6 +10454,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); @@ -10383,6 +10462,7 @@ static void test_effect(BOOL d3d11) ID2D1Image_Release(image_b); ID2D1Image_Release(image_a);
+ /* 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);
@@ -10439,10 +10519,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) { @@ -10455,6 +10537,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) { @@ -10464,6 +10547,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; @@ -10490,6 +10574,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); @@ -10990,6 +11075,8 @@ static void test_effect_properties(BOOL d3d11) hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ check_system_properties(effect, FALSE); + hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CLSID, D2D1_PROPERTY_TYPE_CLSID, (BYTE *)&clsid, sizeof(clsid)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -11252,6 +11339,8 @@ static void test_effect_2d_affine(BOOL d3d11) hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D12DAffineTransform, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ check_system_properties(effect, TRUE); + for (i = 0; i < ARRAY_SIZE(effect_2d_affine_tests); ++i) { const struct effect_2d_affine_test *test = &effect_2d_affine_tests[i]; @@ -11362,6 +11451,8 @@ static void test_effect_crop(BOOL d3d11) hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D1Crop, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ check_system_properties(effect, TRUE); + for (i = 0; i < ARRAY_SIZE(crop_effect_tests); ++i) { const struct crop_effect_test *test = &crop_effect_tests[i]; @@ -11435,6 +11526,8 @@ static void test_effect_grayscale(BOOL d3d11) hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D1Grayscale, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ check_system_properties(effect, TRUE); + for (i = 0; i < ARRAY_SIZE(test_pixels); ++i) { DWORD pixel = test_pixels[i]; @@ -12288,7 +12381,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);
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index d31cd9cf1a3..51ed33701dc 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -11011,7 +11011,7 @@ static void test_effect_context(BOOL d3d11)
static void test_effect_properties(BOOL d3d11) { - UINT32 i, min_inputs, max_inputs, integer, index; + UINT32 i, min_inputs, max_inputs, integer, index, property_count; ID2D1EffectContext *effect_context; D2D1_BUFFER_PRECISION precision; struct d2d1_test_context ctx; @@ -11175,6 +11175,9 @@ static void test_effect_properties(BOOL d3d11) hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ property_count = ID2D1Effect_GetPropertyCount(effect); + ok(property_count == 2, "Got unexpected property count %u.\n", property_count); + index = ID2D1Effect_GetPropertyIndex(effect, L"Context"); ok(index == 0, "Got unexpected index %u.\n", index); index = ID2D1Effect_GetPropertyIndex(effect, L"Integer"); @@ -11257,12 +11260,12 @@ static void test_effect_properties(BOOL d3d11)
static void test_effect_2d_affine(BOOL d3d11) { + unsigned int i, x, y, w, h, property_count; D2D1_MATRIX_3X2_F rotate, scale, skew; D2D1_BITMAP_PROPERTIES1 bitmap_desc; D2D_RECT_F output_bounds = {0}; struct d2d1_test_context ctx; ID2D1DeviceContext *context; - unsigned int i, x, y, w, h; D2D1_SIZE_U input_size; ID2D1Factory1 *factory; D2D1_POINT_2F offset; @@ -11341,6 +11344,9 @@ static void test_effect_2d_affine(BOOL d3d11)
check_system_properties(effect, TRUE);
+ property_count = ID2D1Effect_GetPropertyCount(effect); + todo_wine ok(property_count == 4, "Got unexpected property count %u.\n", property_count); + for (i = 0; i < ARRAY_SIZE(effect_2d_affine_tests); ++i) { const struct effect_2d_affine_test *test = &effect_2d_affine_tests[i]; @@ -11406,6 +11412,7 @@ static void test_effect_2d_affine(BOOL d3d11) static void test_effect_crop(BOOL d3d11) { D2D1_BITMAP_PROPERTIES1 bitmap_desc; + unsigned int i, property_count; struct d2d1_test_context ctx; ID2D1DeviceContext *context; D2D_RECT_F output_bounds; @@ -11415,7 +11422,6 @@ static void test_effect_crop(BOOL d3d11) DWORD image[16 * 16]; ID2D1Effect *effect; ID2D1Image *output; - unsigned int i; HRESULT hr;
const struct crop_effect_test @@ -11453,6 +11459,9 @@ static void test_effect_crop(BOOL d3d11)
check_system_properties(effect, TRUE);
+ property_count = ID2D1Effect_GetPropertyCount(effect); + todo_wine ok(property_count == 2, "Got unexpected property count %u.\n", property_count); + for (i = 0; i < ARRAY_SIZE(crop_effect_tests); ++i) { const struct crop_effect_test *test = &crop_effect_tests[i]; @@ -11497,6 +11506,7 @@ static void test_effect_grayscale(BOOL d3d11) { DWORD colour, expected_colour, luminance; D2D1_BITMAP_PROPERTIES1 bitmap_desc; + unsigned int i, property_count; struct d2d1_test_context ctx; struct resource_readback rb; ID2D1DeviceContext *context; @@ -11505,7 +11515,6 @@ static void test_effect_grayscale(BOOL d3d11) ID2D1Bitmap1 *bitmap; ID2D1Effect *effect; ID2D1Image *output; - unsigned int i; HRESULT hr;
const DWORD test_pixels[] = {0xffffffff, 0x12345678, 0x89abcdef, 0x77777777, 0xdeadbeef}; @@ -11528,6 +11537,9 @@ static void test_effect_grayscale(BOOL d3d11)
check_system_properties(effect, TRUE);
+ property_count = ID2D1Effect_GetPropertyCount(effect); + ok(property_count == 0, "Got unexpected property count %u.\n", property_count); + for (i = 0; i < ARRAY_SIZE(test_pixels); ++i) { DWORD pixel = test_pixels[i];
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 51ed33701dc..2e31501afaf 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10682,7 +10682,7 @@ static HRESULT STDMETHODCALLTYPE effect_impl_set_integer(IUnknown *iface, const { struct effect_impl *effect_impl = impl_from_ID2D1EffectImpl((ID2D1EffectImpl *)iface);
- if (!data || data_size != sizeof(effect_impl->integer)) + if (!data) return E_INVALIDARG;
effect_impl->integer = *((UINT *)data); @@ -10695,7 +10695,7 @@ static HRESULT STDMETHODCALLTYPE effect_impl_get_integer(const IUnknown *iface, { struct effect_impl *effect_impl = impl_from_ID2D1EffectImpl((ID2D1EffectImpl *)iface);
- if (!data || data_size != sizeof(effect_impl->integer)) + if (!data) return E_INVALIDARG;
*((UINT *)data) = effect_impl->integer; @@ -10710,7 +10710,7 @@ static HRESULT STDMETHODCALLTYPE effect_impl_get_context(const IUnknown *iface, { struct effect_impl *effect_impl = impl_from_ID2D1EffectImpl((ID2D1EffectImpl *)iface);
- if (!data || data_size != sizeof(effect_impl->effect_context)) + if (!data) return E_INVALIDARG;
*((ID2D1EffectContext **)data) = effect_impl->effect_context; @@ -11184,6 +11184,12 @@ static void test_effect_properties(BOOL d3d11) ok(index == 1, "Got unexpected index %u.\n", index);
effect_context = (ID2D1EffectContext *)0xdeadbeef; + hr = ID2D1Effect_GetValueByName(effect, + L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context) - 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1Effect_GetValueByName(effect, + L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context) + 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); hr = ID2D1Effect_GetValueByName(effect, L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -11191,6 +11197,10 @@ static void test_effect_properties(BOOL d3d11) "Got unexpected effect context %p.\n", effect_context);
effect_context = (ID2D1EffectContext *)0xdeadbeef; + hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context) - 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context) + 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef, @@ -11200,16 +11210,28 @@ static void test_effect_properties(BOOL d3d11) ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
integer = 0xdeadbeef; + hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer) - 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer) + 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(integer == 10, "Got unexpected integer %u.", integer);
integer = 0xdeadbeef; + hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer) - 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer) + 1); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(integer == 10, "Got unexpected integer %u.", integer);
integer = 20; + hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer) - 1); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer) + 1); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); integer = 0xdeadbeef;
This merge request was approved by Nikolay Sivov.
Third patch crashes for me on Windows 10 21H1.
On Thu Jun 30 01:20:10 2022 +0000, Nikolay Sivov wrote:
Third patch crashes for me on Windows 10 21H1.
It passes all tests on testbot: https://testbot.winehq.org/JobDetails.pl?Key=117836
Of cause including win10 21H1 tests.
Also looks good on my local Win10 system.
On Thu Jun 30 02:04:39 2022 +0000, Ziqing Hui wrote:
It passes all tests on testbot: https://testbot.winehq.org/JobDetails.pl?Key=117836 Of cause including win10 21H1 tests. Also looks good on my local Win10 system. Update: I update my Win10 21H2 to lastest just now. And run the tests 20 times. Still no crashes happen.
Strange, I don't see it any longer here. I added contents of this MR to !347.
This merge request was closed by Ziqing Hui.