Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
v2: fixed ddraw7 failure on 64 bit
dlls/ddraw/tests/ddraw1.c | 76 ++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw2.c | 76 ++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw4.c | 76 ++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/dsurface.c | 42 ----------------------- 5 files changed, 309 insertions(+), 42 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index d416cf55a3..b96bee8600 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -10913,6 +10913,81 @@ static void test_depth_readback(void) DestroyWindow(window); }
+struct enum_surfaces_param +{ + IDirectDrawSurface *surfaces[8]; + UINT count; +}; + +static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context) +{ + struct enum_surfaces_param *param = (struct enum_surfaces_param *)context; + BOOL found = FALSE; + int i; + + for (i = 0; i < sizeof(param->surfaces)/sizeof(param->surfaces[0]); i++) + { + if (param->surfaces[i] == surface) + { + found = TRUE; + break; + } + } + + ok(found, "Unexpected surface %p enumerated.\n", surface); + param->count++; + IDirectDrawSurface_Release(surface); + return DDENUMRET_OK; +} + +static void test_enum_surfaces(void) +{ + struct enum_surfaces_param param; + IDirectDrawSurface *surface; + IDirectDraw *ddraw; + DDSURFACEDESC desc; + HRESULT hr; + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; + U2(desc).dwMipMapCount = 3; + desc.dwWidth = 32; + desc.dwHeight = 32; + hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL); + ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr); + + memset(¶m, 0, sizeof(param)); + param.surfaces[0] = surface; + hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, ¶m.surfaces[1]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, ¶m.surfaces[2]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]); + ok(hr == DDERR_NOTFOUND, "Unexpected hr %#x.\n", hr); + ok(!param.surfaces[3], "expected NULL pointer\n"); + + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + IDirectDrawSurface_Release(param.surfaces[2]); + IDirectDrawSurface_Release(param.surfaces[1]); + IDirectDrawSurface_Release(surface); + IDirectDraw_Release(ddraw); +} + START_TEST(ddraw1) { DDDEVICEIDENTIFIER identifier; @@ -11012,4 +11087,5 @@ START_TEST(ddraw1) test_texture_load(); test_ck_operation(); test_depth_readback(); + test_enum_surfaces(); } diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 2186c314ac..143230085f 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -12287,6 +12287,81 @@ static void test_depth_readback(void) DestroyWindow(window); }
+struct enum_surfaces_param +{ + IDirectDrawSurface *surfaces[8]; + UINT count; +}; + +static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context) +{ + struct enum_surfaces_param *param = (struct enum_surfaces_param *)context; + BOOL found = FALSE; + int i; + + for (i = 0; i < sizeof(param->surfaces)/sizeof(param->surfaces[0]); i++) + { + if (param->surfaces[i] == surface) + { + found = TRUE; + break; + } + } + + ok(found, "Unexpected surface %p enumerated.\n", surface); + param->count++; + IDirectDrawSurface_Release(surface); + return DDENUMRET_OK; +} + +static void test_enum_surfaces(void) +{ + struct enum_surfaces_param param; + IDirectDrawSurface *surface; + IDirectDraw2 *ddraw; + DDSURFACEDESC desc; + HRESULT hr; + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; + U2(desc).dwMipMapCount = 3; + desc.dwWidth = 32; + desc.dwHeight = 32; + hr = IDirectDraw2_CreateSurface(ddraw, &desc, &surface, NULL); + ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr); + + memset(¶m, 0, sizeof(param)); + param.surfaces[0] = surface; + hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, ¶m.surfaces[1]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, ¶m.surfaces[2]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]); + ok(hr == DDERR_NOTFOUND, "Unexpected hr %#x.\n", hr); + ok(!param.surfaces[3], "expected NULL pointer\n"); + + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + IDirectDrawSurface_Release(param.surfaces[2]); + IDirectDrawSurface_Release(param.surfaces[1]); + IDirectDrawSurface_Release(surface); + IDirectDraw2_Release(ddraw); +} + START_TEST(ddraw2) { DDDEVICEIDENTIFIER identifier; @@ -12394,4 +12469,5 @@ START_TEST(ddraw2) test_surface_desc_size(); test_ck_operation(); test_depth_readback(); + test_enum_surfaces(); } diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 4c1bd78eef..cc8b6e8ace 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -14355,6 +14355,81 @@ static void test_depth_readback(void) DestroyWindow(window); }
+struct enum_surfaces_param +{ + IDirectDrawSurface4 *surfaces[8]; + UINT count; +}; + +static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface4 *surface, DDSURFACEDESC2 *desc, void *context) +{ + struct enum_surfaces_param *param = (struct enum_surfaces_param *)context; + BOOL found = FALSE; + int i; + + for (i = 0; i < sizeof(param->surfaces)/sizeof(param->surfaces[0]); i++) + { + if (param->surfaces[i] == surface) + { + found = TRUE; + break; + } + } + + ok(found, "Unexpected surface %p enumerated.\n", surface); + param->count++; + IDirectDrawSurface4_Release(surface); + return DDENUMRET_OK; +} + +static void test_enum_surfaces(void) +{ + struct enum_surfaces_param param; + IDirectDrawSurface4 *surface; + DDSURFACEDESC2 desc; + IDirectDraw4 *ddraw; + HRESULT hr; + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; + U2(desc).dwMipMapCount = 3; + desc.dwWidth = 32; + desc.dwHeight = 32; + hr = IDirectDraw4_CreateSurface(ddraw, &desc, &surface, NULL); + ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr); + + memset(¶m, 0, sizeof(param)); + param.surfaces[0] = surface; + hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, ¶m.surfaces[1]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, ¶m.surfaces[2]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]); + ok(hr == DDERR_NOTFOUND, "Unexpected hr %#x.\n", hr); + ok(!param.surfaces[3], "expected NULL pointer\n"); + + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + IDirectDrawSurface4_Release(param.surfaces[2]); + IDirectDrawSurface4_Release(param.surfaces[1]); + IDirectDrawSurface4_Release(surface); + IDirectDraw4_Release(ddraw); +} + START_TEST(ddraw4) { DDDEVICEIDENTIFIER identifier; @@ -14475,4 +14550,5 @@ START_TEST(ddraw4) test_compute_sphere_visibility(); test_map_synchronisation(); test_depth_readback(); + test_enum_surfaces(); } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index d7355cf0ea..b162aa3b70 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -13726,6 +13726,86 @@ static void test_depth_readback(void) DestroyWindow(window); }
+struct enum_surfaces_param +{ + IDirectDrawSurface7 *surfaces[8]; + UINT count; +}; + +static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context) +{ + struct enum_surfaces_param *param = (struct enum_surfaces_param *)context; + BOOL found = FALSE; + int i; + + for (i = 0; i < sizeof(param->surfaces)/sizeof(param->surfaces[0]); i++) + { + if (param->surfaces[i] == surface) + { + found = TRUE; + break; + } + } + + ok(found, "Unexpected surface %p enumerated.\n", surface); + param->count++; + IDirectDrawSurface7_Release(surface); + return DDENUMRET_OK; +} + +static void test_enum_surfaces(void) +{ + struct enum_surfaces_param param; + IDirectDrawSurface7 *surface; + DDSURFACEDESC2 desc; + IDirectDraw7 *ddraw; + HRESULT hr; + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + + hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); + ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; + U2(desc).dwMipMapCount = 3; + desc.dwWidth = 32; + desc.dwHeight = 32; + if (FAILED(IDirectDraw7_CreateSurface(ddraw, &desc, &surface, NULL))) + { + win_skip("Failed to create a texture, skipping tests.\n"); + IDirectDraw7_Release(ddraw); + return; + } + + memset(¶m, 0, sizeof(param)); + param.surfaces[0] = surface; + hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, ¶m.surfaces[1]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, ¶m.surfaces[2]); + ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]); + ok(hr == DDERR_NOTFOUND, "Unexpected hr %#x.\n", hr); + ok(!param.surfaces[3], "expected NULL pointer\n"); + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, ¶m, enum_surfaces_cb); + ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Unexpected number of surfaces enumerated - %d, expected 3\n", param.count); + + IDirectDrawSurface7_Release(param.surfaces[2]); + IDirectDrawSurface7_Release(param.surfaces[1]); + IDirectDrawSurface7_Release(surface); + IDirectDraw7_Release(ddraw); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -13856,4 +13936,5 @@ START_TEST(ddraw7) test_clip_planes_limits(); test_map_synchronisation(); test_depth_readback(); + test_enum_surfaces(); } diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c index 90e7fcf781..0f775a0062 100644 --- a/dlls/ddraw/tests/dsurface.c +++ b/dlls/ddraw/tests/dsurface.c @@ -368,47 +368,6 @@ static HRESULT WINAPI enumCB(IDirectDrawSurface *surf, DDSURFACEDESC *desc, void return DDENUMRET_OK; }
-static void EnumTest(void) -{ - HRESULT rc; - DDSURFACEDESC ddsd; - IDirectDrawSurface *surface; - struct enumstruct ctx; - - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT; - ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; - U2(ddsd).dwMipMapCount = 3; - ddsd.dwWidth = 32; - ddsd.dwHeight = 32; - rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL); - ok(rc==DD_OK,"CreateSurface returned: %x\n",rc); - - memset(&ctx, 0, sizeof(ctx)); - ctx.expected[0] = surface; - rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[0], &ddsd.ddsCaps, &ctx.expected[1]); - ok(rc == DD_OK, "GetAttachedSurface returned %08x\n", rc); - rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[1], &ddsd.ddsCaps, &ctx.expected[2]); - ok(rc == DD_OK, "GetAttachedSurface returned %08x\n", rc); - rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[2], &ddsd.ddsCaps, &ctx.expected[3]); - ok(rc == DDERR_NOTFOUND, "GetAttachedSurface returned %08x\n", rc); - ok(!ctx.expected[3], "expected NULL pointer\n"); - ctx.count = 0; - - rc = IDirectDraw_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &ddsd, &ctx, enumCB); - ok(rc == DD_OK, "IDirectDraw_EnumSurfaces returned %08x\n", rc); - ok(ctx.count == 3, "%d surfaces enumerated, expected 3\n", ctx.count); - - ctx.count = 0; - rc = IDirectDraw_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, &ctx, enumCB); - ok(rc == DD_OK, "IDirectDraw_EnumSurfaces returned %08x\n", rc); - ok(ctx.count == 3, "%d surfaces enumerated, expected 3\n", ctx.count); - - IDirectDrawSurface_Release(ctx.expected[2]); - IDirectDrawSurface_Release(ctx.expected[1]); - IDirectDrawSurface_Release(surface); -} - struct compare { DWORD width, height; @@ -2609,7 +2568,6 @@ START_TEST(dsurface) GetDDInterface_2(); GetDDInterface_4(); GetDDInterface_7(); - EnumTest(); CubeMapTest(); CompressedTest(); SizeTest();
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=35176
Your paranoid android.
=== w8 (32 bit ddraw7) === ddraw7.c:3735: Test failed: Lit quad without normals has color 0x00ff0000, expected 0x00000000. ddraw7.c:3739: Test failed: Lit quad with normals has color 0x00ff0000, expected 0x00000000. ddraw7.c:3763: Test failed: Lit quad with light has color 0x00ff00ff. ddraw7.c:3763: Test failed: Lit quad with singular world matrix has color 0x00ff00ff. ddraw7.c:3763: Test failed: Lit quad with transformation matrix has color 0x00ff00ff. ddraw7.c:3763: Test failed: Lit quad with non-affine matrix has color 0x00ff0000.
On 1/8/2018 1:14 PM, Marvin wrote:
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=35176
Your paranoid android.
=== w8 (32 bit ddraw7) === ddraw7.c:3735: Test failed: Lit quad without normals has color 0x00ff0000, expected 0x00000000. ddraw7.c:3739: Test failed: Lit quad with normals has color 0x00ff0000, expected 0x00000000. ddraw7.c:3763: Test failed: Lit quad with light has color 0x00ff00ff. ddraw7.c:3763: Test failed: Lit quad with singular world matrix has color 0x00ff00ff. ddraw7.c:3763: Test failed: Lit quad with transformation matrix has color 0x00ff00ff. ddraw7.c:3763: Test failed: Lit quad with non-affine matrix has color 0x00ff0000.
I don't think it's related, new test is executed last.