d3d8/tests: Add some lost device tests.

This commit is contained in:
Henri Verbeet 2014-06-27 08:26:57 +02:00 committed by Alexandre Julliard
parent 04acac207a
commit e6de1cbdc9
1 changed files with 89 additions and 0 deletions

View File

@ -6248,6 +6248,94 @@ static void test_writeonly_resource(void)
DestroyWindow(window);
}
static void test_lost_device(void)
{
IDirect3DDevice8 *device;
IDirect3D8 *d3d;
ULONG refcount;
HWND window;
HRESULT hr;
BOOL ret;
window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, NULL, NULL, NULL, NULL);
d3d = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, window, FALSE)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
}
hr = IDirect3DDevice8_TestCooperativeLevel(device);
if (hr == D3DERR_DEVICELOST)
{
win_skip("Broken TestCooperativeLevel(), skipping test.\n");
IDirect3DDevice8_Release(device);
goto done;
}
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow());
ok(ret, "Failed to set foreground window.\n");
hr = IDirect3DDevice8_TestCooperativeLevel(device);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
ret = ShowWindow(window, SW_RESTORE);
ok(ret, "Failed to restore window.\n");
ret = SetForegroundWindow(window);
ok(ret, "Failed to set foreground window.\n");
hr = IDirect3DDevice8_TestCooperativeLevel(device);
todo_wine ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
hr = reset_device(device, window, FALSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = reset_device(device, window, TRUE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow());
ok(ret, "Failed to set foreground window.\n");
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ret = ShowWindow(window, SW_RESTORE);
ok(ret, "Failed to restore window.\n");
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = reset_device(device, window, FALSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D8_Release(d3d);
DestroyWindow(window);
}
START_TEST(device)
{
HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" );
@ -6333,6 +6421,7 @@ START_TEST(device)
test_resource_type();
test_mipmap_lock();
test_writeonly_resource();
test_lost_device();
UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL));
}