uxtheme/tests: Mark XP SP1 behaviour as broken.
[wine/wine-gecko.git] / dlls / uxtheme / tests / system.c
bloba63b6c463234cf0c60d15ae437195d8091f28de5
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
21 #include <stdarg.h>
23 #include "windows.h"
24 #include "vfwmsgs.h"
25 #include "uxtheme.h"
27 #include "wine/test.h"
29 static HRESULT (WINAPI * pCloseThemeData)(HTHEME);
30 static HRESULT (WINAPI * pGetCurrentThemeName)(LPWSTR, int, LPWSTR, int, LPWSTR, int);
31 static HTHEME (WINAPI * pGetWindowTheme)(HWND);
32 static BOOL (WINAPI * pIsAppThemed)(VOID);
33 static BOOL (WINAPI * pIsThemeActive)(VOID);
34 static BOOL (WINAPI * pIsThemePartDefined)(HTHEME, int, int);
35 static HTHEME (WINAPI * pOpenThemeData)(HWND, LPCWSTR);
36 static HTHEME (WINAPI * pOpenThemeDataEx)(HWND, LPCWSTR, DWORD);
37 static HRESULT (WINAPI * pSetWindowTheme)(HWND, LPCWSTR, LPCWSTR);
39 static HMODULE hUxtheme = 0;
41 #define UXTHEME_GET_PROC(func) p ## func = (void*)GetProcAddress(hUxtheme, #func);
43 static BOOL InitFunctionPtrs(void)
45 hUxtheme = LoadLibraryA("uxtheme.dll");
46 if(!hUxtheme) {
47 trace("Could not load uxtheme.dll\n");
48 return FALSE;
50 if (hUxtheme)
52 UXTHEME_GET_PROC(CloseThemeData)
53 UXTHEME_GET_PROC(GetCurrentThemeName)
54 UXTHEME_GET_PROC(GetWindowTheme)
55 UXTHEME_GET_PROC(IsAppThemed)
56 UXTHEME_GET_PROC(IsThemeActive)
57 UXTHEME_GET_PROC(IsThemePartDefined)
58 UXTHEME_GET_PROC(OpenThemeData)
59 UXTHEME_GET_PROC(OpenThemeDataEx)
60 UXTHEME_GET_PROC(SetWindowTheme)
62 /* The following functions should be available, if not return FALSE. The Vista functions will
63 * be checked (at some point in time) within the single tests if needed. All used functions for
64 * now are present on WinXP, W2K3 and Wine.
66 if (!pCloseThemeData || !pGetCurrentThemeName ||
67 !pGetWindowTheme || !pIsAppThemed ||
68 !pIsThemeActive || !pIsThemePartDefined ||
69 !pOpenThemeData || !pSetWindowTheme)
71 FreeLibrary(hUxtheme);
72 return FALSE;
75 return TRUE;
78 static void test_IsThemed(void)
80 BOOL bThemeActive;
81 BOOL bAppThemed;
82 BOOL bTPDefined;
84 SetLastError(0xdeadbeef);
85 bThemeActive = pIsThemeActive();
86 trace("Theming is %s\n", (bThemeActive) ? "active" : "inactive");
88 /* This test is not themed */
89 SetLastError(0xdeadbeef);
90 bAppThemed = pIsAppThemed();
92 if (bThemeActive)
93 todo_wine
94 ok( bAppThemed == FALSE, "Expected FALSE as this test executable is not (yet) themed.\n");
95 else
96 /* Although Wine currently returns FALSE, the logic behind it is wrong. It is not a todo_wine though in the testing sense */
97 ok( bAppThemed == FALSE, "Expected FALSE as this test executable is not (yet) themed.\n");
99 ok( GetLastError() == ERROR_SUCCESS,
100 "Expected ERROR_SUCCESS, got 0x%08x\n",
101 GetLastError());
103 SetLastError(0xdeadbeef);
104 bTPDefined = pIsThemePartDefined(NULL, 0 , 0);
105 ok( bTPDefined == FALSE, "Expected FALSE\n");
106 ok( GetLastError() == E_HANDLE,
107 "Expected E_HANDLE, got 0x%08x\n",
108 GetLastError());
111 static void test_GetWindowTheme(void)
113 HTHEME hTheme;
114 HWND hWnd;
115 BOOL bDestroyed;
117 SetLastError(0xdeadbeef);
118 hTheme = pGetWindowTheme(NULL);
119 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
120 todo_wine
121 ok( GetLastError() == E_HANDLE,
122 "Expected E_HANDLE, got 0x%08x\n",
123 GetLastError());
125 /* Only do the bare minimum to get a valid hwnd */
126 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
127 if (!hWnd) return;
129 SetLastError(0xdeadbeef);
130 hTheme = pGetWindowTheme(hWnd);
131 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
132 ok( GetLastError() == 0xdeadbeef,
133 "Expected 0xdeadbeef, got 0x%08x\n",
134 GetLastError());
136 bDestroyed = DestroyWindow(hWnd);
137 if (!bDestroyed)
138 trace("Window %p couldn't be destroyed : 0x%08x\n",
139 hWnd, GetLastError());
142 static void test_SetWindowTheme(void)
144 HRESULT hRes;
145 HWND hWnd;
146 BOOL bDestroyed;
148 SetLastError(0xdeadbeef);
149 hRes = pSetWindowTheme(NULL, NULL, NULL);
150 todo_wine
152 ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
153 ok( GetLastError() == 0xdeadbeef,
154 "Expected 0xdeadbeef, got 0x%08x\n",
155 GetLastError());
158 /* Only do the bare minimum to get a valid hwnd */
159 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
160 if (!hWnd) return;
162 SetLastError(0xdeadbeef);
163 hRes = pSetWindowTheme(hWnd, NULL, NULL);
164 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
165 ok( GetLastError() == 0xdeadbeef,
166 "Expected 0xdeadbeef, got 0x%08x\n",
167 GetLastError());
169 bDestroyed = DestroyWindow(hWnd);
170 if (!bDestroyed)
171 trace("Window %p couldn't be destroyed : 0x%08x\n",
172 hWnd, GetLastError());
175 static void test_OpenThemeData(void)
177 HTHEME hTheme, hTheme2;
178 HWND hWnd;
179 BOOL bThemeActive;
180 HRESULT hRes;
181 BOOL bDestroyed;
182 BOOL bTPDefined;
184 WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
185 WCHAR szButtonClassList[] = {'B','u','t','t','o','n', 0 };
186 WCHAR szButtonClassList2[] = {'b','U','t','T','o','N', 0 };
187 WCHAR szClassList[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
189 bThemeActive = pIsThemeActive();
191 /* All NULL */
192 SetLastError(0xdeadbeef);
193 hTheme = pOpenThemeData(NULL, NULL);
194 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
195 todo_wine
196 ok( GetLastError() == E_POINTER,
197 "Expected GLE() to be E_POINTER, got 0x%08x\n",
198 GetLastError());
200 /* A NULL hWnd and an invalid classlist */
201 SetLastError(0xdeadbeef);
202 hTheme = pOpenThemeData(NULL, szInvalidClassList);
203 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
204 todo_wine
205 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
206 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
207 GetLastError());
209 SetLastError(0xdeadbeef);
210 hTheme = pOpenThemeData(NULL, szClassList);
211 if (bThemeActive)
213 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
214 todo_wine
215 ok( GetLastError() == ERROR_SUCCESS,
216 "Expected ERROR_SUCCESS, got 0x%08x\n",
217 GetLastError());
219 else
221 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
222 todo_wine
223 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
224 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
225 GetLastError());
228 /* Only do the bare minimum to get a valid hdc */
229 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
230 if (!hWnd) return;
232 SetLastError(0xdeadbeef);
233 hTheme = pOpenThemeData(hWnd, NULL);
234 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
235 todo_wine
236 ok( GetLastError() == E_POINTER,
237 "Expected GLE() to be E_POINTER, got 0x%08x\n",
238 GetLastError());
240 SetLastError(0xdeadbeef);
241 hTheme = pOpenThemeData(hWnd, szInvalidClassList);
242 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
243 todo_wine
244 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
245 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
246 GetLastError());
248 if (!bThemeActive)
250 SetLastError(0xdeadbeef);
251 hTheme = pOpenThemeData(hWnd, szButtonClassList);
252 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
253 todo_wine
254 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
255 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
256 GetLastError());
257 skip("No active theme, skipping rest of OpenThemeData tests\n");
258 return;
261 /* Only do the next checks if we have an active theme */
263 SetLastError(0xdeadbeef);
264 hTheme = pOpenThemeData(hWnd, szButtonClassList);
265 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
266 todo_wine
267 ok( GetLastError() == ERROR_SUCCESS,
268 "Expected ERROR_SUCCESS, got 0x%08x\n",
269 GetLastError());
271 /* Test with bUtToN instead of Button */
272 SetLastError(0xdeadbeef);
273 hTheme = pOpenThemeData(hWnd, szButtonClassList2);
274 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
275 todo_wine
276 ok( GetLastError() == ERROR_SUCCESS,
277 "Expected ERROR_SUCCESS, got 0x%08x\n",
278 GetLastError());
280 SetLastError(0xdeadbeef);
281 hTheme = pOpenThemeData(hWnd, szClassList);
282 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
283 todo_wine
284 ok( GetLastError() == ERROR_SUCCESS,
285 "Expected ERROR_SUCCESS, got 0x%08x\n",
286 GetLastError());
288 /* GetWindowTheme should return the last handle opened by OpenThemeData */
289 SetLastError(0xdeadbeef);
290 hTheme2 = pGetWindowTheme(hWnd);
291 ok( hTheme == hTheme2, "Expected the same HTHEME handle (%p<->%p)\n",
292 hTheme, hTheme2);
293 ok( GetLastError() == 0xdeadbeef,
294 "Expected 0xdeadbeef, got 0x%08x\n",
295 GetLastError());
297 SetLastError(0xdeadbeef);
298 hRes = pCloseThemeData(hTheme);
299 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
300 ok( GetLastError() == 0xdeadbeef,
301 "Expected 0xdeadbeef, got 0x%08x\n",
302 GetLastError());
304 /* Close a second time */
305 SetLastError(0xdeadbeef);
306 hRes = pCloseThemeData(hTheme);
307 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
308 ok( GetLastError() == 0xdeadbeef,
309 "Expected 0xdeadbeef, got 0x%08x\n",
310 GetLastError());
312 /* See if closing makes a difference for GetWindowTheme */
313 SetLastError(0xdeadbeef);
314 hTheme2 = NULL;
315 hTheme2 = pGetWindowTheme(hWnd);
316 ok( hTheme == hTheme2, "Expected the same HTHEME handle (%p<->%p)\n",
317 hTheme, hTheme2);
318 ok( GetLastError() == 0xdeadbeef,
319 "Expected 0xdeadbeef, got 0x%08x\n",
320 GetLastError());
322 SetLastError(0xdeadbeef);
323 bTPDefined = pIsThemePartDefined(hTheme, 0 , 0);
324 todo_wine
326 ok( bTPDefined == FALSE, "Expected FALSE\n");
327 ok( GetLastError() == ERROR_SUCCESS,
328 "Expected ERROR_SUCCESS, got 0x%08x\n",
329 GetLastError());
332 bDestroyed = DestroyWindow(hWnd);
333 if (!bDestroyed)
334 trace("Window %p couldn't be destroyed : 0x%08x\n",
335 hWnd, GetLastError());
338 static void test_OpenThemeDataEx(void)
340 HTHEME hTheme;
341 HWND hWnd;
342 BOOL bThemeActive;
343 BOOL bDestroyed;
345 WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
346 WCHAR szButtonClassList[] = {'B','u','t','t','o','n', 0 };
347 WCHAR szButtonClassList2[] = {'b','U','t','T','o','N', 0 };
348 WCHAR szClassList[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
350 if (!pOpenThemeDataEx)
352 win_skip("OpenThemeDataEx not available\n");
353 return;
356 bThemeActive = pIsThemeActive();
358 /* All NULL */
359 SetLastError(0xdeadbeef);
360 hTheme = pOpenThemeDataEx(NULL, NULL, 0);
361 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
362 todo_wine
363 ok( GetLastError() == E_POINTER,
364 "Expected GLE() to be E_POINTER, got 0x%08x\n",
365 GetLastError());
367 /* A NULL hWnd and an invalid classlist without flags */
368 SetLastError(0xdeadbeef);
369 hTheme = pOpenThemeDataEx(NULL, szInvalidClassList, 0);
370 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
371 todo_wine
372 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
373 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
374 GetLastError());
376 SetLastError(0xdeadbeef);
377 hTheme = pOpenThemeDataEx(NULL, szClassList, 0);
378 if (bThemeActive)
380 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
381 todo_wine
382 ok( GetLastError() == ERROR_SUCCESS,
383 "Expected ERROR_SUCCESS, got 0x%08x\n",
384 GetLastError());
386 else
388 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
389 todo_wine
390 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
391 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
392 GetLastError());
395 /* Only do the bare minimum to get a valid hdc */
396 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
397 if (!hWnd) return;
399 SetLastError(0xdeadbeef);
400 hTheme = pOpenThemeDataEx(hWnd, NULL, 0);
401 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
402 todo_wine
403 ok( GetLastError() == E_POINTER,
404 "Expected GLE() to be E_POINTER, got 0x%08x\n",
405 GetLastError());
407 SetLastError(0xdeadbeef);
408 hTheme = pOpenThemeDataEx(hWnd, szInvalidClassList, 0);
409 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
410 todo_wine
411 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
412 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
413 GetLastError());
415 if (!bThemeActive)
417 SetLastError(0xdeadbeef);
418 hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0);
419 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
420 todo_wine
421 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
422 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
423 GetLastError());
424 skip("No active theme, skipping rest of OpenThemeDataEx tests\n");
425 return;
428 /* Only do the next checks if we have an active theme */
430 SetLastError(0xdeadbeef);
431 hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0);
432 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
433 todo_wine
434 ok( GetLastError() == ERROR_SUCCESS,
435 "Expected ERROR_SUCCESS, got 0x%08x\n",
436 GetLastError());
438 SetLastError(0xdeadbeef);
439 hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, OTD_FORCE_RECT_SIZING);
440 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
441 todo_wine
442 ok( GetLastError() == ERROR_SUCCESS,
443 "Expected ERROR_SUCCESS, got 0x%08x\n",
444 GetLastError());
446 SetLastError(0xdeadbeef);
447 hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, OTD_NONCLIENT);
448 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
449 todo_wine
450 ok( GetLastError() == ERROR_SUCCESS,
451 "Expected ERROR_SUCCESS, got 0x%08x\n",
452 GetLastError());
454 SetLastError(0xdeadbeef);
455 hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0x3);
456 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
457 todo_wine
458 ok( GetLastError() == ERROR_SUCCESS,
459 "Expected ERROR_SUCCESS, got 0x%08x\n",
460 GetLastError());
462 /* Test with bUtToN instead of Button */
463 SetLastError(0xdeadbeef);
464 hTheme = pOpenThemeDataEx(hWnd, szButtonClassList2, 0);
465 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
466 todo_wine
467 ok( GetLastError() == ERROR_SUCCESS,
468 "Expected ERROR_SUCCESS, got 0x%08x\n",
469 GetLastError());
471 SetLastError(0xdeadbeef);
472 hTheme = pOpenThemeDataEx(hWnd, szClassList, 0);
473 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
474 todo_wine
475 ok( GetLastError() == ERROR_SUCCESS,
476 "Expected ERROR_SUCCESS, got 0x%08x\n",
477 GetLastError());
479 bDestroyed = DestroyWindow(hWnd);
480 if (!bDestroyed)
481 trace("Window %p couldn't be destroyed : 0x%08x\n",
482 hWnd, GetLastError());
485 static void test_GetCurrentThemeName(void)
487 BOOL bThemeActive;
488 HRESULT hRes;
489 WCHAR currentTheme[MAX_PATH];
490 WCHAR currentColor[MAX_PATH];
491 WCHAR currentSize[MAX_PATH];
493 bThemeActive = pIsThemeActive();
495 /* All NULLs */
496 SetLastError(0xdeadbeef);
497 hRes = pGetCurrentThemeName(NULL, 0, NULL, 0, NULL, 0);
498 if (bThemeActive)
499 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
500 else
501 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
502 ok( GetLastError() == 0xdeadbeef,
503 "Expected 0xdeadbeef, got 0x%08x\n",
504 GetLastError());
506 /* Number of characters given is 0 */
507 SetLastError(0xdeadbeef);
508 hRes = pGetCurrentThemeName(currentTheme, 0, NULL, 0, NULL, 0);
509 if (bThemeActive)
510 ok( hRes == S_OK || broken(hRes == E_FAIL /* WinXP SP1 */), "Expected S_OK, got 0x%08x\n", hRes);
511 else
512 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
513 ok( GetLastError() == 0xdeadbeef,
514 "Expected 0xdeadbeef, got 0x%08x\n",
515 GetLastError());
517 /* When the number of characters given is too small (not 0, see above), GetCurrentThemeName returns 0x8007007a.
518 * The only definition I found was in strsafe.h:
520 * #define STRSAFE_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // 0x7A = 122L = ERROR_INSUFFICIENT_BUFFER
522 SetLastError(0xdeadbeef);
523 hRes = pGetCurrentThemeName(currentTheme, 2, NULL, 0, NULL, 0);
524 if (bThemeActive)
525 todo_wine
526 ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
527 broken(hRes == E_FAIL /* WinXP SP1 */),
528 "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
529 else
530 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
531 ok( GetLastError() == 0xdeadbeef,
532 "Expected 0xdeadbeef, got 0x%08x\n",
533 GetLastError());
535 /* The same is true if the number of characters is too small for Color and/or Size */
536 SetLastError(0xdeadbeef);
537 hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR),
538 currentColor, 2,
539 currentSize, sizeof(currentSize) / sizeof(WCHAR));
540 if (bThemeActive)
541 todo_wine
542 ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
543 broken(hRes == E_FAIL /* WinXP SP1 */),
544 "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
545 else
546 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
547 ok( GetLastError() == 0xdeadbeef,
548 "Expected 0xdeadbeef, got 0x%08x\n",
549 GetLastError());
551 /* Given number of characters is correct */
552 SetLastError(0xdeadbeef);
553 hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), NULL, 0, NULL, 0);
554 if (bThemeActive)
555 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
556 else
557 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
558 ok( GetLastError() == 0xdeadbeef,
559 "Expected 0xdeadbeef, got 0x%08x\n",
560 GetLastError());
562 /* Given number of characters for the theme name is too large */
563 SetLastError(0xdeadbeef);
564 hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme), NULL, 0, NULL, 0);
565 if (bThemeActive)
566 ok( hRes == E_POINTER || hRes == S_OK, "Expected E_POINTER or S_OK, got 0x%08x\n", hRes);
567 else
568 ok( hRes == E_PROP_ID_UNSUPPORTED ||
569 hRes == E_POINTER, /* win2k3 */
570 "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
571 ok( GetLastError() == 0xdeadbeef,
572 "Expected 0xdeadbeef, got 0x%08x\n",
573 GetLastError());
575 /* The too large case is only for the theme name, not for color name or size name */
576 SetLastError(0xdeadbeef);
577 hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR),
578 currentColor, sizeof(currentTheme),
579 currentSize, sizeof(currentSize) / sizeof(WCHAR));
580 if (bThemeActive)
581 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
582 else
583 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
584 ok( GetLastError() == 0xdeadbeef,
585 "Expected 0xdeadbeef, got 0x%08x\n",
586 GetLastError());
588 SetLastError(0xdeadbeef);
589 hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR),
590 currentColor, sizeof(currentTheme) / sizeof(WCHAR),
591 currentSize, sizeof(currentSize));
592 if (bThemeActive)
593 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
594 else
595 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
596 ok( GetLastError() == 0xdeadbeef,
597 "Expected 0xdeadbeef, got 0x%08x\n",
598 GetLastError());
600 /* Correct call */
601 SetLastError(0xdeadbeef);
602 hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR),
603 currentColor, sizeof(currentColor) / sizeof(WCHAR),
604 currentSize, sizeof(currentSize) / sizeof(WCHAR));
605 if (bThemeActive)
606 ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
607 else
608 ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
609 ok( GetLastError() == 0xdeadbeef,
610 "Expected 0xdeadbeef, got 0x%08x\n",
611 GetLastError());
614 static void test_CloseThemeData(void)
616 HRESULT hRes;
618 SetLastError(0xdeadbeef);
619 hRes = pCloseThemeData(NULL);
620 ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
621 ok( GetLastError() == 0xdeadbeef,
622 "Expected 0xdeadbeef, got 0x%08x\n",
623 GetLastError());
626 START_TEST(system)
628 if(!InitFunctionPtrs())
629 return;
631 /* No real functional tests will be done (yet). The current tests
632 * only show input/return behaviour
635 /* IsThemeActive, IsAppThemed and IsThemePartDefined*/
636 trace("Starting test_IsThemed()\n");
637 test_IsThemed();
639 /* GetWindowTheme */
640 trace("Starting test_GetWindowTheme()\n");
641 test_GetWindowTheme();
643 /* SetWindowTheme */
644 trace("Starting test_SetWindowTheme()\n");
645 test_SetWindowTheme();
647 /* OpenThemeData, a bit more functional now */
648 trace("Starting test_OpenThemeData()\n");
649 test_OpenThemeData();
651 /* OpenThemeDataEx */
652 trace("Starting test_OpenThemeDataEx()\n");
653 test_OpenThemeDataEx();
655 /* GetCurrentThemeName */
656 trace("Starting test_GetCurrentThemeName()\n");
657 test_GetCurrentThemeName();
659 /* CloseThemeData */
660 trace("Starting test_CloseThemeData()\n");
661 test_CloseThemeData();
663 FreeLibrary(hUxtheme);