2 * Copyright 2011 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wine/test.h"
22 static IDirectDraw2 *create_ddraw(void)
28 if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
31 hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw2);
32 IDirectDraw_Release(ddraw1);
39 static void test_coop_level_create_device_window(void)
41 HWND focus_window, device_window;
45 focus_window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
46 0, 0, 640, 480, 0, 0, 0, 0);
47 if (!(ddraw = create_ddraw()))
49 skip("Failed to create a ddraw object, skipping test.\n");
50 DestroyWindow(focus_window);
54 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
55 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
56 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
57 ok(!device_window, "Unexpected device window found.\n");
58 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
59 ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
60 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
61 ok(!device_window, "Unexpected device window found.\n");
62 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
63 ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
64 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
65 ok(!device_window, "Unexpected device window found.\n");
66 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
67 ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
68 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
69 ok(!device_window, "Unexpected device window found.\n");
70 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
71 ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
72 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
73 ok(!device_window, "Unexpected device window found.\n");
75 /* Windows versions before 98 / NT5 don't support DDSCL_CREATEDEVICEWINDOW. */
76 if (broken(hr == DDERR_INVALIDPARAMS))
78 win_skip("DDSCL_CREATEDEVICEWINDOW not supported, skipping test.\n");
79 IDirectDraw2_Release(ddraw);
80 DestroyWindow(focus_window);
84 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
85 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
86 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
87 ok(!device_window, "Unexpected device window found.\n");
88 hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
89 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
90 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
91 ok(!device_window, "Unexpected device window found.\n");
93 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
94 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
95 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
96 ok(!device_window, "Unexpected device window found.\n");
97 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
98 | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
99 ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
100 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
101 ok(!!device_window, "Device window not found.\n");
103 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
104 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
105 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
106 ok(!device_window, "Unexpected device window found.\n");
107 hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
108 | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
109 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
110 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
111 ok(!!device_window, "Device window not found.\n");
113 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
114 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
115 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
116 ok(!device_window, "Unexpected device window found.\n");
117 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
118 ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
119 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
120 ok(!device_window, "Unexpected device window found.\n");
121 hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
122 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
123 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
124 ok(!device_window, "Unexpected device window found.\n");
125 hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
126 ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
127 device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
128 ok(!!device_window, "Device window not found.\n");
130 IDirectDraw2_Release(ddraw);
131 DestroyWindow(focus_window);
136 test_coop_level_create_device_window();