From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 122 ++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index fe7a118cec9..7eead7deb4c 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -24,6 +24,32 @@
#define D3DERR_INVALIDCALL 0x8876086c
+#define DEFINE_EXPECT(func) \ + static BOOL expect_ ## func = FALSE, called_ ## func = FALSE + +#define SET_EXPECT(func) \ + do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0) + +#define CHECK_EXPECT2(func) \ + do { \ + ok(expect_ ##func, "unexpected call " #func "\n"); \ + called_ ## func = TRUE; \ + }while(0) + +#define CHECK_EXPECT(func) \ + do { \ + CHECK_EXPECT2(func); \ + expect_ ## func = FALSE; \ + }while(0) + +#define CHECK_CALLED(func) \ + do { \ + ok(called_ ## func, "expected " #func "\n"); \ + expect_ ## func = called_ ## func = FALSE; \ + }while(0) + +DEFINE_EXPECT(D3DX10ThreadPump_AddWorkItem); + /* 1x1 1bpp bmp image */ static const BYTE test_bmp_1bpp[] = { @@ -822,6 +848,94 @@ static unsigned int get_bpp_from_format(DXGI_FORMAT format) } }
+static HRESULT WINAPI D3DX10ThreadPump_QueryInterface(ID3DX10ThreadPump *iface, REFIID riid, void **out) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static ULONG WINAPI D3DX10ThreadPump_AddRef(ID3DX10ThreadPump *iface) +{ + return 2; +} + +static ULONG WINAPI D3DX10ThreadPump_Release(ID3DX10ThreadPump *iface) +{ + return 1; +} + +static HRESULT WINAPI D3DX10ThreadPump_AddWorkItem(ID3DX10ThreadPump *iface, ID3DX10DataLoader *loader, + ID3DX10DataProcessor *processor, HRESULT *result, void **object) +{ + SIZE_T size; + void *data; + HRESULT hr; + + CHECK_EXPECT(D3DX10ThreadPump_AddWorkItem); + ok(!object, "object = %p\n", object); + + hr = ID3DX10DataLoader_Load(loader); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataLoader_Decompress(loader, &data, &size); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataProcessor_Process(processor, data, size); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataProcessor_CreateDeviceObject(processor, object); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataProcessor_Destroy(processor); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10DataLoader_Destroy(loader); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + if (result) *result = S_OK; + return S_OK; +} + +static UINT WINAPI D3DX10ThreadPump_GetWorkItemCount(ID3DX10ThreadPump *iface) +{ + ok(0, "unexpected call\n"); + return 0; +} + +static HRESULT WINAPI D3DX10ThreadPump_WaitForAllItems(ID3DX10ThreadPump *iface) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DX10ThreadPump_ProcessDeviceWorkItems(ID3DX10ThreadPump *iface, UINT count) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DX10ThreadPump_PurgeAllItems(ID3DX10ThreadPump *iface) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DX10ThreadPump_GetQueueStatus(ID3DX10ThreadPump *iface, UINT *queue, + UINT *processqueue, UINT *devicequeue) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static ID3DX10ThreadPumpVtbl D3DX10ThreadPumpVtbl = +{ + D3DX10ThreadPump_QueryInterface, + D3DX10ThreadPump_AddRef, + D3DX10ThreadPump_Release, + D3DX10ThreadPump_AddWorkItem, + D3DX10ThreadPump_GetWorkItemCount, + D3DX10ThreadPump_WaitForAllItems, + D3DX10ThreadPump_ProcessDeviceWorkItems, + D3DX10ThreadPump_PurgeAllItems, + D3DX10ThreadPump_GetQueueStatus +}; +static ID3DX10ThreadPump thread_pump = { &D3DX10ThreadPumpVtbl }; + static ULONG get_refcount(void *iface) { IUnknown *unknown = iface; @@ -1954,6 +2068,14 @@ static void test_get_image_info(void) winetest_pop_context(); }
+ hr2 = 0xdeadbeef; + SET_EXPECT(D3DX10ThreadPump_AddWorkItem); + hr = D3DX10GetImageInfoFromMemory(test_image[0].data, test_image[0].size, &thread_pump, &image_info, &hr2); + CHECK_CALLED(D3DX10ThreadPump_AddWorkItem); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#x.\n", hr2); + check_image_info(&image_info, test_image, __LINE__); + hr2 = 0xdeadbeef; hr = D3DX10GetImageInfoFromFileW(NULL, NULL, &image_info, &hr2); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);