ddraw/tests: Add some tests for DDSCL_CREATEDEVICEWINDOW.

This commit is contained in:
Henri Verbeet 2011-12-21 21:34:58 +01:00 committed by Alexandre Julliard
parent fe4e2bf60e
commit 654d53fa5f
5 changed files with 489 additions and 7 deletions

View File

@ -3,6 +3,8 @@ IMPORTS = ddraw user32 gdi32 ole32
C_SRCS = \ C_SRCS = \
d3d.c \ d3d.c \
ddraw1.c \
ddraw2.c \
ddraw4.c \ ddraw4.c \
ddraw7.c \ ddraw7.c \
ddrawmodes.c \ ddrawmodes.c \

130
dlls/ddraw/tests/ddraw1.c Normal file
View File

@ -0,0 +1,130 @@
/*
* Copyright 2011 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/test.h"
#include "d3d.h"
static IDirectDraw *create_ddraw(void)
{
IDirectDraw *ddraw;
if (FAILED(DirectDrawCreate(NULL, &ddraw, NULL)))
return NULL;
return ddraw;
}
static void test_coop_level_create_device_window(void)
{
HWND focus_window, device_window;
IDirectDraw *ddraw;
HRESULT hr;
focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
/* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
if (broken(hr == DDERR_INVALIDPARAMS))
{
win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
IDirectDraw_Release(ddraw);
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
IDirectDraw_Release(ddraw);
DestroyWindow(focus_window);
}
START_TEST(ddraw1)
{
test_coop_level_create_device_window();
}

137
dlls/ddraw/tests/ddraw2.c Normal file
View File

@ -0,0 +1,137 @@
/*
* Copyright 2011 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/test.h"
#include "d3d.h"
static IDirectDraw2 *create_ddraw(void)
{
IDirectDraw2 *ddraw2;
IDirectDraw *ddraw1;
HRESULT hr;
if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
return NULL;
hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
IDirectDraw_Release(ddraw1);
if (FAILED(hr))
return NULL;
return ddraw2;
}
static void test_coop_level_create_device_window(void)
{
HWND focus_window, device_window;
IDirectDraw2 *ddraw;
HRESULT hr;
focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
/* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
if (broken(hr == DDERR_INVALIDPARAMS))
{
win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
IDirectDraw2_Release(ddraw);
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
IDirectDraw2_Release(ddraw);
DestroyWindow(focus_window);
}
START_TEST(ddraw2)
{
test_coop_level_create_device_window();
}

View File

@ -54,14 +54,10 @@ static BOOL compare_vec4(struct vec4 *vec, float x, float y, float z, float w, u
&& compare_float(vec->w, w, ulps); && compare_float(vec->w, w, ulps);
} }
static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level) static IDirectDraw4 *create_ddraw(void)
{ {
IDirect3DDevice3 *device = NULL;
IDirectDrawSurface4 *surface;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw4; IDirectDraw4 *ddraw4;
IDirectDraw *ddraw1; IDirectDraw *ddraw1;
IDirect3D3 *d3d3;
HRESULT hr; HRESULT hr;
if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL))) if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
@ -72,6 +68,21 @@ static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
if (FAILED(hr)) if (FAILED(hr))
return NULL; return NULL;
return ddraw4;
}
static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
{
IDirect3DDevice3 *device = NULL;
IDirectDrawSurface4 *surface;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw4;
IDirect3D3 *d3d3;
HRESULT hr;
if (!(ddraw4 = create_ddraw()))
return NULL;
hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, coop_level); hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, coop_level);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
@ -321,7 +332,103 @@ static void test_process_vertices(void)
DestroyWindow(window); DestroyWindow(window);
} }
static void test_coop_level_create_device_window(void)
{
HWND focus_window, device_window;
IDirectDraw4 *ddraw;
HRESULT hr;
focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a ddraw object, skipping test.\n");
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
/* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
if (broken(hr == DDERR_INVALIDPARAMS))
{
win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
IDirectDraw4_Release(ddraw);
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
IDirectDraw4_Release(ddraw);
DestroyWindow(focus_window);
}
START_TEST(ddraw4) START_TEST(ddraw4)
{ {
test_process_vertices(); test_process_vertices();
test_coop_level_create_device_window();
} }

View File

@ -64,6 +64,16 @@ static BOOL compare_vec4(struct vec4 *vec, float x, float y, float z, float w, u
&& compare_float(vec->w, w, ulps); && compare_float(vec->w, w, ulps);
} }
static IDirectDraw7 *create_ddraw(void)
{
IDirectDraw7 *ddraw;
if (FAILED(pDirectDrawCreateEx(NULL, (void **)&ddraw, &IID_IDirectDraw7, NULL)))
return NULL;
return ddraw;
}
static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level) static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
{ {
IDirect3DDevice7 *device = NULL; IDirect3DDevice7 *device = NULL;
@ -73,7 +83,7 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
IDirect3D7 *d3d7; IDirect3D7 *d3d7;
HRESULT hr; HRESULT hr;
if (FAILED(pDirectDrawCreateEx(NULL, (void **)&ddraw, &IID_IDirectDraw7, NULL))) if (!(ddraw = create_ddraw()))
return NULL; return NULL;
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, coop_level); hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, coop_level);
@ -158,7 +168,7 @@ static void test_process_vertices(void)
0, 0, 640, 480, 0, 0, 0, 0); 0, 0, 640, 480, 0, 0, 0, 0);
if (!(device = create_device(window, DDSCL_NORMAL))) if (!(device = create_device(window, DDSCL_NORMAL)))
{ {
skip("Failed to create a 3D device, skipping test.\n"); skip("Failed to create a ddraw object, skipping test.\n");
DestroyWindow(window); DestroyWindow(window);
return; return;
} }
@ -315,6 +325,101 @@ static void test_process_vertices(void)
DestroyWindow(window); DestroyWindow(window);
} }
static void test_coop_level_create_device_window(void)
{
HWND focus_window, device_window;
IDirectDraw7 *ddraw;
HRESULT hr;
focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
if (!(ddraw = create_ddraw()))
{
skip("Failed to create a 3D device, skipping test.\n");
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
/* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
if (broken(hr == DDERR_INVALIDPARAMS))
{
win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
IDirectDraw7_Release(ddraw);
DestroyWindow(focus_window);
return;
}
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
| DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
ok(!device_window, "Unexpected device window found.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
todo_wine ok(!!device_window, "Device window not found.\n");
IDirectDraw7_Release(ddraw);
DestroyWindow(focus_window);
}
START_TEST(ddraw7) START_TEST(ddraw7)
{ {
HMODULE module = GetModuleHandleA("ddraw.dll"); HMODULE module = GetModuleHandleA("ddraw.dll");
@ -326,4 +431,5 @@ START_TEST(ddraw7)
} }
test_process_vertices(); test_process_vertices();
test_coop_level_create_device_window();
} }