ddraw/tests: Split up test_initialize().

This commit is contained in:
Henri Verbeet 2012-06-01 17:22:48 +02:00 committed by Alexandre Julliard
parent 4f85b3772d
commit d61d842630
5 changed files with 126 additions and 130 deletions

View File

@ -3626,135 +3626,6 @@ static void z_format_test(void)
ok(count, "Expected at least one supported Z Buffer format\n");
}
static void test_initialize(void)
{
IDirectDraw7 *ddraw7;
IDirectDraw4 *ddraw4;
IDirectDraw2 *ddraw2;
IDirectDraw *ddraw1;
IDirect3D *d3d1;
HRESULT hr;
/* IDirectDraw */
if (FAILED(hr = DirectDrawCreate(NULL, &ddraw1, NULL)))
{
skip("Failed to create IDirectDraw object (%#x), skipping tests.\n", hr);
return;
}
hr = IDirectDraw_Initialize(ddraw1, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw_Release(ddraw1);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw, (void **)&ddraw1);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw instance, hr %#x.\n", hr);
hr = IDirectDraw_Initialize(ddraw1, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw_Initialize(ddraw1, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw_Release(ddraw1);
CoUninitialize();
hr = DirectDrawCreate(NULL, &ddraw1, NULL);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw object, hr %#x.\n", hr);
/* IDirectDraw2 */
if (SUCCEEDED(IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2)))
{
hr = IDirectDraw2_Initialize(ddraw2, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw2_Release(ddraw2);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw2, (void **)&ddraw2);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw2 instance, hr %#x.\n", hr);
hr = IDirectDraw2_Initialize(ddraw2, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw2_Initialize(ddraw2, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw2_Release(ddraw2);
CoUninitialize();
}
else skip("Failed to query IDirectDraw2 interface, skipping tests.\n");
/* IDirectDraw4 */
if (SUCCEEDED(IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw4, (void **)&ddraw4)))
{
hr = IDirectDraw4_Initialize(ddraw4, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw4_Release(ddraw4);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw4, (void **)&ddraw4);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw4 instance, hr %#x.\n", hr);
hr = IDirectDraw4_Initialize(ddraw4, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw4_Initialize(ddraw4, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw4_Release(ddraw4);
CoUninitialize();
}
else skip("Failed to query IDirectDraw4 interface, skipping tests.\n");
/* IDirect3D */
if (SUCCEEDED(IDirectDraw_QueryInterface(ddraw1, &IID_IDirect3D, (void **)&d3d1)))
{
IDirectDraw *ddraw;
hr = IDirect3D_Initialize(d3d1, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirect3D_Release(d3d1);
if (0) /* This crashes on the W2KPROSP4 testbot. */
{
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirect3D, (void **)&d3d1);
ok(hr == E_NOINTERFACE, "CoCreateInstance returned hr %#x, expected E_NOINTERFACE.\n", hr);
CoUninitialize();
}
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw instance, hr %#x.\n", hr);
hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d1);
ok(SUCCEEDED(hr), "Failed to query IDirect3D interface, hr %#x.\n", hr);
IDirectDraw_Release(ddraw);
/* IDirect3D_Initialize() just returns DDERR_ALREADYINITIALIZED. */
hr = IDirect3D_Initialize(d3d1, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
hr = IDirectDraw_Initialize(ddraw, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirect3D_Release(d3d1);
CoUninitialize();
}
else skip("Failed to query IDirect3D interface, skipping tests.\n");
IDirectDraw_Release(ddraw1);
/* IDirectDraw7 */
if (FAILED(hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL)))
{
skip("Failed to create IDirectDraw7 object (%#x), skipping tests.\n", hr);
return;
}
hr = IDirectDraw7_Initialize(ddraw7, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw7_Release(ddraw7);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw7, (void **)&ddraw7);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw7 instance, hr %#x.\n", hr);
hr = IDirectDraw7_Initialize(ddraw7, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw7_Initialize(ddraw7, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw7_Release(ddraw7);
CoUninitialize();
}
static void test_coop_level_surf_create(void)
{
IDirectDrawSurface7 *surface7;
@ -4183,6 +4054,5 @@ START_TEST(d3d)
D3D1_releaseObjects();
}
test_initialize();
test_coop_level_surf_create();
}

View File

@ -2370,6 +2370,50 @@ done:
UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
}
static void test_initialize(void)
{
IDirectDraw *ddraw;
IDirect3D *d3d;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
return;
}
hr = IDirectDraw_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw_Release(ddraw);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw instance, hr %#x.\n", hr);
hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d);
if (SUCCEEDED(hr))
{
/* IDirect3D_Initialize() just returns DDERR_ALREADYINITIALIZED. */
hr = IDirect3D_Initialize(d3d, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirect3D_Release(d3d);
}
else skip("Failed to query IDirect3D interface, skipping tests.\n");
hr = IDirectDraw_Initialize(ddraw, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw_Release(ddraw);
CoUninitialize();
if (0) /* This crashes on the W2KPROSP4 testbot. */
{
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirect3D, (void **)&d3d);
ok(hr == E_NOINTERFACE, "CoCreateInstance returned hr %#x, expected E_NOINTERFACE.\n", hr);
CoUninitialize();
}
}
START_TEST(ddraw1)
{
test_coop_level_create_device_window();
@ -2387,4 +2431,5 @@ START_TEST(ddraw1)
test_window_style();
test_redundant_mode_set();
test_coop_level_mode_set();
test_initialize();
}

View File

@ -2507,6 +2507,32 @@ done:
UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
}
static void test_initialize(void)
{
IDirectDraw2 *ddraw;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
return;
}
hr = IDirectDraw2_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw2_Release(ddraw);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw2, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw2 instance, hr %#x.\n", hr);
hr = IDirectDraw2_Initialize(ddraw, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw2_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw2_Release(ddraw);
CoUninitialize();
}
START_TEST(ddraw2)
{
test_coop_level_create_device_window();
@ -2526,4 +2552,5 @@ START_TEST(ddraw2)
test_window_style();
test_redundant_mode_set();
test_coop_level_mode_set();
test_initialize();
}

View File

@ -2622,6 +2622,32 @@ static void test_coop_level_mode_set(void)
UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
}
static void test_initialize(void)
{
IDirectDraw4 *ddraw;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
return;
}
hr = IDirectDraw4_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw4_Release(ddraw);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw4, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw4 instance, hr %#x.\n", hr);
hr = IDirectDraw4_Initialize(ddraw, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw4_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw4_Release(ddraw);
CoUninitialize();
}
START_TEST(ddraw4)
{
test_process_vertices();
@ -2642,4 +2668,5 @@ START_TEST(ddraw4)
test_window_style();
test_redundant_mode_set();
test_coop_level_mode_set();
test_initialize();
}

View File

@ -2431,6 +2431,32 @@ static void test_coop_level_mode_set(void)
UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
}
static void test_initialize(void)
{
IDirectDraw7 *ddraw;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
return;
}
hr = IDirectDraw7_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
IDirectDraw7_Release(ddraw);
CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw7, (void **)&ddraw);
ok(SUCCEEDED(hr), "Failed to create IDirectDraw7 instance, hr %#x.\n", hr);
hr = IDirectDraw7_Initialize(ddraw, NULL);
ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
hr = IDirectDraw7_Initialize(ddraw, NULL);
ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
IDirectDraw7_Release(ddraw);
CoUninitialize();
}
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@ -2458,4 +2484,5 @@ START_TEST(ddraw7)
test_window_style();
test_redundant_mode_set();
test_coop_level_mode_set();
test_initialize();
}