[PATCH] d2d1/tests: Add tests for effect context.

Nikolay Sivov nsivov at codeweavers.com
Tue May 24 00:58:00 CDT 2022


On 5/24/22 05:40, Ziqing Hui wrote:
> +    if (!init_test_context(&ctx, d3d11))
> +        return;
> +
> +    if (!(factory = (ID2D1Factory1 *)get_factory(ctx.rt, &IID_ID2D1Factory1, NULL)))
> +    {
> +        win_skip("ID2D1Factory1 is not supported.\n");
> +        release_test_context(&ctx);
> +        return;
> +    }
It's easier to extend context with additional fields for Factory1-3, try 
to set them all and then check for nulls when you want to skip.

> +    hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&device_context);
> +    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
Same here, we might as well keep device context pointer in the context.

> +    hr = ID2D1DeviceContext_CreateEffect(device_context, &CLSID_TestEffect, &effect);
> +    todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
> +    if (hr != S_OK)
> +        goto done;
> +    hr = ID2D1Effect_GetValueByName(effect, L"Context",
> +            D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
> +    todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
> +    if (hr != S_OK)
> +        goto done;
> +
> +    /* Test shader loading */
> +    loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestVertexShader);
> +    todo_wine ok(!loaded, "Shader is loaded.\n");
> +    loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader);
> +    todo_wine ok(!loaded, "Shader is loaded.\n");
Here only first todo_wine is ever triggered, so I'd remove the following 
ones.

> +    hr = ID2D1EffectContext_LoadVertexShader(effect_context,
> +            &GUID_TestVertexShader, (const BYTE *)test_ps, sizeof(test_ps));
> +    todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
> +    hr = ID2D1EffectContext_LoadVertexShader(effect_context,
> +            &GUID_TestVertexShader, (const BYTE *)test_vs, sizeof(test_vs));
> +    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
> +    loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestVertexShader);
> +    todo_wine ok(loaded, "Shader is not loaded.\n");
> +
> +    hr = ID2D1EffectContext_LoadVertexShader(effect_context,
> +            &GUID_TestVertexShader, (const BYTE *)test_ps, sizeof(test_ps));
> +    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);

That makes sense - it checks for guid first, before attempting to create 
a d3d object.



More information about the wine-devel mailing list