mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 19:18:42 +00:00
ddraw/tests: Move the surface enumeration test.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
dcb0d32bfa
commit
f6039736dd
5 changed files with 309 additions and 42 deletions
|
@ -11146,6 +11146,81 @@ static void test_clear(void)
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
struct enum_surfaces_param
|
||||
{
|
||||
IDirectDrawSurface *surfaces[8];
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
|
||||
{
|
||||
struct enum_surfaces_param *param = context;
|
||||
BOOL found = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(param->surfaces); ++i)
|
||||
{
|
||||
if (param->surfaces[i] == surface)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ok(found, "Unexpected surface %p enumerated.\n", surface);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
++param->count;
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
static void test_enum_surfaces(void)
|
||||
{
|
||||
struct enum_surfaces_param param = {{0}};
|
||||
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, ¶m.surfaces[0], NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
|
||||
|
||||
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, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||
|
||||
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, "Got unexpected number of enumerated surfaces %u.\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, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||
|
||||
IDirectDrawSurface_Release(param.surfaces[2]);
|
||||
IDirectDrawSurface_Release(param.surfaces[1]);
|
||||
IDirectDrawSurface_Release(param.surfaces[0]);
|
||||
IDirectDraw_Release(ddraw);
|
||||
}
|
||||
|
||||
START_TEST(ddraw1)
|
||||
{
|
||||
DDDEVICEIDENTIFIER identifier;
|
||||
|
@ -11246,4 +11321,5 @@ START_TEST(ddraw1)
|
|||
test_ck_operation();
|
||||
test_depth_readback();
|
||||
test_clear();
|
||||
test_enum_surfaces();
|
||||
}
|
||||
|
|
|
@ -12502,6 +12502,81 @@ static void test_clear(void)
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
struct enum_surfaces_param
|
||||
{
|
||||
IDirectDrawSurface *surfaces[8];
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
|
||||
{
|
||||
struct enum_surfaces_param *param = context;
|
||||
BOOL found = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(param->surfaces); ++i)
|
||||
{
|
||||
if (param->surfaces[i] == surface)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ok(found, "Unexpected surface %p enumerated.\n", surface);
|
||||
IDirectDrawSurface_Release(surface);
|
||||
++param->count;
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
static void test_enum_surfaces(void)
|
||||
{
|
||||
struct enum_surfaces_param param = {{0}};
|
||||
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, ¶m.surfaces[0], NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
|
||||
|
||||
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, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||
|
||||
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, "Got unexpected number of enumerated surfaces %u.\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, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||
|
||||
IDirectDrawSurface_Release(param.surfaces[2]);
|
||||
IDirectDrawSurface_Release(param.surfaces[1]);
|
||||
IDirectDrawSurface_Release(param.surfaces[0]);
|
||||
IDirectDraw2_Release(ddraw);
|
||||
}
|
||||
|
||||
START_TEST(ddraw2)
|
||||
{
|
||||
DDDEVICEIDENTIFIER identifier;
|
||||
|
@ -12610,4 +12685,5 @@ START_TEST(ddraw2)
|
|||
test_ck_operation();
|
||||
test_depth_readback();
|
||||
test_clear();
|
||||
test_enum_surfaces();
|
||||
}
|
||||
|
|
|
@ -14556,6 +14556,81 @@ static void test_clear(void)
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
struct enum_surfaces_param
|
||||
{
|
||||
IDirectDrawSurface4 *surfaces[8];
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface4 *surface, DDSURFACEDESC2 *desc, void *context)
|
||||
{
|
||||
struct enum_surfaces_param *param = context;
|
||||
BOOL found = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(param->surfaces); ++i)
|
||||
{
|
||||
if (param->surfaces[i] == surface)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ok(found, "Unexpected surface %p enumerated.\n", surface);
|
||||
IDirectDrawSurface4_Release(surface);
|
||||
++param->count;
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
static void test_enum_surfaces(void)
|
||||
{
|
||||
struct enum_surfaces_param param = {{0}};
|
||||
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, ¶m.surfaces[0], NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
|
||||
|
||||
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, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||
|
||||
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, "Got unexpected number of enumerated surfaces %u.\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, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||
|
||||
IDirectDrawSurface4_Release(param.surfaces[2]);
|
||||
IDirectDrawSurface4_Release(param.surfaces[1]);
|
||||
IDirectDrawSurface4_Release(param.surfaces[0]);
|
||||
IDirectDraw4_Release(ddraw);
|
||||
}
|
||||
|
||||
START_TEST(ddraw4)
|
||||
{
|
||||
DDDEVICEIDENTIFIER identifier;
|
||||
|
@ -14677,4 +14752,5 @@ START_TEST(ddraw4)
|
|||
test_map_synchronisation();
|
||||
test_depth_readback();
|
||||
test_clear();
|
||||
test_enum_surfaces();
|
||||
}
|
||||
|
|
|
@ -13884,6 +13884,86 @@ static void test_clear(void)
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
struct enum_surfaces_param
|
||||
{
|
||||
IDirectDrawSurface7 *surfaces[8];
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context)
|
||||
{
|
||||
struct enum_surfaces_param *param = context;
|
||||
BOOL found = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(param->surfaces); ++i)
|
||||
{
|
||||
if (param->surfaces[i] == surface)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ok(found, "Unexpected surface %p enumerated.\n", surface);
|
||||
IDirectDrawSurface7_Release(surface);
|
||||
++param->count;
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
static void test_enum_surfaces(void)
|
||||
{
|
||||
struct enum_surfaces_param param = {{0}};
|
||||
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, ¶m.surfaces[0], NULL)))
|
||||
{
|
||||
win_skip("Failed to create a texture, skipping tests.\n");
|
||||
IDirectDraw7_Release(ddraw);
|
||||
return;
|
||||
}
|
||||
|
||||
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, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||
|
||||
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, "Got unexpected number of enumerated surfaces %u.\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, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||
|
||||
IDirectDrawSurface7_Release(param.surfaces[2]);
|
||||
IDirectDrawSurface7_Release(param.surfaces[1]);
|
||||
IDirectDrawSurface7_Release(param.surfaces[0]);
|
||||
IDirectDraw7_Release(ddraw);
|
||||
}
|
||||
|
||||
START_TEST(ddraw7)
|
||||
{
|
||||
DDDEVICEIDENTIFIER2 identifier;
|
||||
|
@ -14015,4 +14095,5 @@ START_TEST(ddraw7)
|
|||
test_map_synchronisation();
|
||||
test_depth_readback();
|
||||
test_clear();
|
||||
test_enum_surfaces();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue