1 /* Unit test suite for uxtheme API functions
3 * Copyright 2006 Paul Vriens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 static HRESULT (WINAPI
* pCloseThemeData
)(HTHEME
);
29 static HTHEME (WINAPI
* pGetWindowTheme
)(HWND
);
30 static BOOL (WINAPI
* pIsAppThemed
)(VOID
);
31 static BOOL (WINAPI
* pIsThemeActive
)(VOID
);
32 static HTHEME (WINAPI
* pOpenThemeData
)(HWND
, LPCWSTR
);
33 static HRESULT (WINAPI
* pSetWindowTheme
)(HWND
, LPCWSTR
, LPCWSTR
);
35 static HMODULE hUxtheme
= 0;
37 #define UXTHEME_GET_PROC(func) \
38 p ## func = (void*)GetProcAddress(hUxtheme, #func); \
40 trace("GetProcAddress(%s) failed\n", #func); \
41 FreeLibrary(hUxtheme); \
45 static BOOL
InitFunctionPtrs(void)
47 hUxtheme
= LoadLibraryA("uxtheme.dll");
49 trace("Could not load uxtheme.dll\n");
54 UXTHEME_GET_PROC(CloseThemeData
)
55 UXTHEME_GET_PROC(GetWindowTheme
)
56 UXTHEME_GET_PROC(IsAppThemed
)
57 UXTHEME_GET_PROC(IsThemeActive
)
58 UXTHEME_GET_PROC(OpenThemeData
)
59 UXTHEME_GET_PROC(SetWindowTheme
)
61 /* The following functions should be available, if not return FALSE. The Vista functions will
62 * be checked (at some point in time) within the single tests if needed. All used functions for
63 * now are present on WinXP, W2K3 and Wine.
65 if (!pCloseThemeData
|| !pGetWindowTheme
||
66 !pIsAppThemed
|| !pIsThemeActive
||
67 !pOpenThemeData
|| !pSetWindowTheme
)
73 static void test_IsThemed(void)
78 SetLastError(0xdeadbeef);
79 bThemeActive
= pIsThemeActive();
80 trace("Theming is %s\n", (bThemeActive
) ? "active" : "inactive");
82 ok( GetLastError() == ERROR_SUCCESS
,
83 "Expected ERROR_SUCCESS, got 0x%08lx\n",
86 /* This test is not themed */
87 SetLastError(0xdeadbeef);
88 bAppThemed
= pIsAppThemed();
92 ok( bAppThemed
== FALSE
, "Expected FALSE as this test executable is not (yet) themed.\n");
94 /* Although Wine currently returns FALSE, the logic behind it is wrong. It is not a todo_wine though in the testing sense */
95 ok( bAppThemed
== FALSE
, "Expected FALSE as this test executable is not (yet) themed.\n");
98 ok( GetLastError() == ERROR_SUCCESS
,
99 "Expected ERROR_SUCCESS, got 0x%08lx\n",
103 static void test_GetWindowTheme(void)
109 SetLastError(0xdeadbeef);
110 hTheme
= pGetWindowTheme(NULL
);
111 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
113 ok( GetLastError() == E_HANDLE
,
114 "Expected E_HANDLE, got 0x%08lx\n",
117 /* Only do the bare minumum to get a valid hwnd */
118 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
121 SetLastError(0xdeadbeef);
122 hTheme
= pGetWindowTheme(hWnd
);
123 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
124 ok( GetLastError() == 0xdeadbeef,
125 "Expected 0xdeadbeef, got 0x%08lx\n",
128 bDestroyed
= DestroyWindow(hWnd
);
130 trace("Window %p couldn't be destroyed : 0x%08lx\n",
131 hWnd
, GetLastError());
134 static void test_SetWindowTheme(void)
140 SetLastError(0xdeadbeef);
141 hRes
= pSetWindowTheme(NULL
, NULL
, NULL
);
144 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08lx\n", hRes
);
145 ok( GetLastError() == 0xdeadbeef,
146 "Expected 0xdeadbeef, got 0x%08lx\n",
150 /* Only do the bare minumum to get a valid hwnd */
151 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
154 SetLastError(0xdeadbeef);
155 hRes
= pSetWindowTheme(hWnd
, NULL
, NULL
);
156 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08lx\n", hRes
);
157 ok( GetLastError() == 0xdeadbeef,
158 "Expected 0xdeadbeef, got 0x%08lx\n",
161 bDestroyed
= DestroyWindow(hWnd
);
163 trace("Window %p couldn't be destroyed : 0x%08lx\n",
164 hWnd
, GetLastError());
167 static void test_OpenThemeData(void)
174 WCHAR szInvalidClassList
[] = {'D','E','A','D','B','E','E','F', 0 };
175 WCHAR szButtonClassList
[] = {'B','u','t','t','o','n', 0 };
176 WCHAR szButtonClassList2
[] = {'b','U','t','T','o','N', 0 };
177 WCHAR szClassList
[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
179 bThemeActive
= pIsThemeActive();
182 SetLastError(0xdeadbeef);
183 hTheme
= pOpenThemeData(NULL
, NULL
);
184 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
186 ok( GetLastError() == E_POINTER
,
187 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
190 /* A NULL hWnd and an invalid classlist */
191 SetLastError(0xdeadbeef);
192 hTheme
= pOpenThemeData(NULL
, szInvalidClassList
);
193 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
195 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
196 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
199 SetLastError(0xdeadbeef);
200 hTheme
= pOpenThemeData(NULL
, szClassList
);
203 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
205 ok( GetLastError() == ERROR_SUCCESS
,
206 "Expected ERROR_SUCCESS, got 0x%08lx\n",
211 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
213 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
214 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
218 /* Only do the bare minumum to get a valid hdc */
219 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
222 SetLastError(0xdeadbeef);
223 hTheme
= pOpenThemeData(hWnd
, NULL
);
224 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
226 ok( GetLastError() == E_POINTER
,
227 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
230 SetLastError(0xdeadbeef);
231 hTheme
= pOpenThemeData(hWnd
, szInvalidClassList
);
232 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
234 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
235 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
240 SetLastError(0xdeadbeef);
241 hTheme
= pOpenThemeData(hWnd
, szButtonClassList
);
242 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
244 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
245 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
247 trace("No active theme, skipping rest of OpenThemeData tests\n");
251 /* Only do the next checks if we have an active theme */
253 SetLastError(0xdeadbeef);
254 hTheme
= pOpenThemeData(hWnd
, szButtonClassList
);
255 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
257 ok( GetLastError() == ERROR_SUCCESS
,
258 "Expected ERROR_SUCCESS, got 0x%08lx\n",
261 /* Test with bUtToN instead of Button */
262 SetLastError(0xdeadbeef);
263 hTheme
= pOpenThemeData(hWnd
, szButtonClassList2
);
264 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
266 ok( GetLastError() == ERROR_SUCCESS
,
267 "Expected ERROR_SUCCESS, got 0x%08lx\n",
270 SetLastError(0xdeadbeef);
271 hTheme
= pOpenThemeData(hWnd
, szClassList
);
272 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
274 ok( GetLastError() == ERROR_SUCCESS
,
275 "Expected ERROR_SUCCESS, got 0x%08lx\n",
278 bDestroyed
= DestroyWindow(hWnd
);
280 trace("Window %p couldn't be destroyed : 0x%08lx\n",
281 hWnd
, GetLastError());
284 static void test_CloseThemeData(void)
288 SetLastError(0xdeadbeef);
289 hRes
= pCloseThemeData(NULL
);
290 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08lx\n", hRes
);
291 ok( GetLastError() == 0xdeadbeef,
292 "Expected 0xdeadbeef, got 0x%08lx\n",
298 if(!InitFunctionPtrs())
301 /* No real functional tests will be done (yet). The current tests
302 * only show input/return behaviour
305 /* IsThemeActive and IsAppThemed */
306 trace("Starting test_IsThemed()\n");
310 trace("Starting test_GetWindowTheme()\n");
311 test_GetWindowTheme();
314 trace("Starting test_SetWindowTheme()\n");
315 test_SetWindowTheme();
318 trace("Starting test_OpenThemeData()\n");
319 test_OpenThemeData();
322 trace("Starting test_CloseThemeData()\n");
323 test_CloseThemeData();
325 FreeLibrary(hUxtheme
);