Commit 34a701f2 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

d2d1/tests: Test value size checking for custom properties.

parent 5a58ea8c
......@@ -10690,7 +10690,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);
......@@ -10703,7 +10703,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;
......@@ -10718,7 +10718,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;
......@@ -11248,12 +11248,22 @@ static void test_effect_properties(BOOL d3d11)
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);
ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef,
"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,
......@@ -11263,16 +11273,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment