Release 1.5.29.
[wine] / dlls / uxtheme / tests / system.c
1 /* Unit test suite for uxtheme API functions
2  *
3  * Copyright 2006 Paul Vriens
4  *
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.
9  *
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.
14  *
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
18  *
19  */
20
21 #include <stdarg.h>
22
23 #include "windows.h"
24 #include "vfwmsgs.h"
25 #include "uxtheme.h"
26
27 #include "wine/test.h"
28
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);
38
39 static HMODULE hUxtheme = 0;
40
41 #define UXTHEME_GET_PROC(func) p ## func = (void*)GetProcAddress(hUxtheme, #func);
42
43 static BOOL InitFunctionPtrs(void)
44 {
45     hUxtheme = LoadLibraryA("uxtheme.dll");
46     if(!hUxtheme) {
47       trace("Could not load uxtheme.dll\n");
48       return FALSE;
49     }
50     if (hUxtheme)
51     {
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)
61     }
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.
65      */
66     if (!pCloseThemeData || !pGetCurrentThemeName ||
67         !pGetWindowTheme || !pIsAppThemed ||
68         !pIsThemeActive || !pIsThemePartDefined ||
69         !pOpenThemeData || !pSetWindowTheme)
70     {
71         FreeLibrary(hUxtheme);
72         return FALSE;
73     }
74
75     return TRUE;
76 }
77
78 static void test_IsThemed(void)
79 {
80     BOOL bThemeActive;
81     BOOL bAppThemed;
82     BOOL bTPDefined;
83
84     bThemeActive = pIsThemeActive();
85     trace("Theming is %s\n", (bThemeActive) ? "active" : "inactive");
86
87     bAppThemed = pIsAppThemed();
88     trace("Test executable is %s\n", (bAppThemed) ? "themed" : "not themed");
89
90     SetLastError(0xdeadbeef);
91     bTPDefined = pIsThemePartDefined(NULL, 0 , 0);
92     ok( bTPDefined == FALSE, "Expected FALSE\n");
93     ok( GetLastError() == E_HANDLE,
94         "Expected E_HANDLE, got 0x%08x\n",
95         GetLastError());
96 }
97
98 static void test_GetWindowTheme(void)
99 {
100     HTHEME    hTheme;
101     HWND      hWnd;
102     BOOL    bDestroyed;
103
104     SetLastError(0xdeadbeef);
105     hTheme = pGetWindowTheme(NULL);
106     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
107     todo_wine
108         ok( GetLastError() == E_HANDLE,
109             "Expected E_HANDLE, got 0x%08x\n",
110             GetLastError());
111
112     /* Only do the bare minimum to get a valid hwnd */
113     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
114     if (!hWnd) return;
115
116     SetLastError(0xdeadbeef);
117     hTheme = pGetWindowTheme(hWnd);
118     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
119     ok( GetLastError() == 0xdeadbeef,
120         "Expected 0xdeadbeef, got 0x%08x\n",
121         GetLastError());
122
123     bDestroyed = DestroyWindow(hWnd);
124     if (!bDestroyed)
125         trace("Window %p couldn't be destroyed : 0x%08x\n",
126             hWnd, GetLastError());
127 }
128
129 static void test_SetWindowTheme(void)
130 {
131     HRESULT hRes;
132     HWND    hWnd;
133     BOOL    bDestroyed;
134
135     SetLastError(0xdeadbeef);
136     hRes = pSetWindowTheme(NULL, NULL, NULL);
137     todo_wine
138     {
139         ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
140         ok( GetLastError() == 0xdeadbeef,
141             "Expected 0xdeadbeef, got 0x%08x\n",
142             GetLastError());
143     }
144
145     /* Only do the bare minimum to get a valid hwnd */
146     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
147     if (!hWnd) return;
148
149     SetLastError(0xdeadbeef);
150     hRes = pSetWindowTheme(hWnd, NULL, NULL);
151     ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
152     ok( GetLastError() == 0xdeadbeef,
153         "Expected 0xdeadbeef, got 0x%08x\n",
154         GetLastError());
155
156     bDestroyed = DestroyWindow(hWnd);
157     if (!bDestroyed)
158         trace("Window %p couldn't be destroyed : 0x%08x\n",
159             hWnd, GetLastError());
160 }
161
162 static void test_OpenThemeData(void)
163 {
164     HTHEME    hTheme, hTheme2;
165     HWND      hWnd;
166     BOOL      bThemeActive;
167     HRESULT   hRes;
168     BOOL      bDestroyed;
169     BOOL      bTPDefined;
170
171     WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
172     WCHAR szButtonClassList[]  = {'B','u','t','t','o','n', 0 };
173     WCHAR szButtonClassList2[]  = {'b','U','t','T','o','N', 0 };
174     WCHAR szClassList[]        = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
175
176     bThemeActive = pIsThemeActive();
177
178     /* All NULL */
179     SetLastError(0xdeadbeef);
180     hTheme = pOpenThemeData(NULL, NULL);
181     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
182     ok( GetLastError() == E_POINTER,
183             "Expected GLE() to be E_POINTER, got 0x%08x\n",
184             GetLastError());
185
186     /* A NULL hWnd and an invalid classlist */
187     SetLastError(0xdeadbeef);
188     hTheme = pOpenThemeData(NULL, szInvalidClassList);
189     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
190     todo_wine
191         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
192             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
193             GetLastError());
194
195     SetLastError(0xdeadbeef);
196     hTheme = pOpenThemeData(NULL, szClassList);
197     if (bThemeActive)
198     {
199         ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
200         todo_wine
201             ok( GetLastError() == ERROR_SUCCESS,
202                 "Expected ERROR_SUCCESS, got 0x%08x\n",
203                 GetLastError());
204     }
205     else
206     {
207         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
208         todo_wine
209             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
210                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
211                 GetLastError());
212     }
213
214     /* Only do the bare minimum to get a valid hdc */
215     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
216     if (!hWnd) return;
217
218     SetLastError(0xdeadbeef);
219     hTheme = pOpenThemeData(hWnd, NULL);
220     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
221     ok( GetLastError() == E_POINTER,
222             "Expected GLE() to be E_POINTER, got 0x%08x\n",
223             GetLastError());
224
225     SetLastError(0xdeadbeef);
226     hTheme = pOpenThemeData(hWnd, szInvalidClassList);
227     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
228     todo_wine
229         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
230             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
231             GetLastError());
232
233     if (!bThemeActive)
234     {
235         SetLastError(0xdeadbeef);
236         hTheme = pOpenThemeData(hWnd, szButtonClassList);
237         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
238         todo_wine
239             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
240                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
241                 GetLastError());
242         skip("No active theme, skipping rest of OpenThemeData tests\n");
243         return;
244     }
245
246     /* Only do the next checks if we have an active theme */
247
248     SetLastError(0xdeadbeef);
249     hTheme = pOpenThemeData(hWnd, szButtonClassList);
250     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
251     todo_wine
252         ok( GetLastError() == ERROR_SUCCESS,
253             "Expected ERROR_SUCCESS, got 0x%08x\n",
254             GetLastError());
255
256     /* Test with bUtToN instead of Button */
257     SetLastError(0xdeadbeef);
258     hTheme = pOpenThemeData(hWnd, szButtonClassList2);
259     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
260     todo_wine
261         ok( GetLastError() == ERROR_SUCCESS,
262             "Expected ERROR_SUCCESS, got 0x%08x\n",
263             GetLastError());
264
265     SetLastError(0xdeadbeef);
266     hTheme = pOpenThemeData(hWnd, szClassList);
267     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
268     todo_wine
269         ok( GetLastError() == ERROR_SUCCESS,
270             "Expected ERROR_SUCCESS, got 0x%08x\n",
271             GetLastError());
272
273     /* GetWindowTheme should return the last handle opened by OpenThemeData */
274     SetLastError(0xdeadbeef);
275     hTheme2 = pGetWindowTheme(hWnd);
276     ok( hTheme == hTheme2, "Expected the same HTHEME handle (%p<->%p)\n",
277         hTheme, hTheme2);
278     ok( GetLastError() == 0xdeadbeef,
279         "Expected 0xdeadbeef, got 0x%08x\n",
280         GetLastError());
281
282     SetLastError(0xdeadbeef);
283     hRes = pCloseThemeData(hTheme);
284     ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
285     ok( GetLastError() == 0xdeadbeef,
286         "Expected 0xdeadbeef, got 0x%08x\n",
287         GetLastError());
288
289     /* Close a second time */
290     SetLastError(0xdeadbeef);
291     hRes = pCloseThemeData(hTheme);
292     ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
293     ok( GetLastError() == 0xdeadbeef,
294         "Expected 0xdeadbeef, got 0x%08x\n",
295         GetLastError());
296
297     /* See if closing makes a difference for GetWindowTheme */
298     SetLastError(0xdeadbeef);
299     hTheme2 = NULL;
300     hTheme2 = pGetWindowTheme(hWnd);
301     ok( hTheme == hTheme2, "Expected the same HTHEME handle (%p<->%p)\n",
302         hTheme, hTheme2);
303     ok( GetLastError() == 0xdeadbeef,
304         "Expected 0xdeadbeef, got 0x%08x\n",
305         GetLastError());
306
307     SetLastError(0xdeadbeef);
308     bTPDefined = pIsThemePartDefined(hTheme, 0 , 0);
309     todo_wine
310     {
311         ok( bTPDefined == FALSE, "Expected FALSE\n");
312         ok( GetLastError() == ERROR_SUCCESS,
313             "Expected ERROR_SUCCESS, got 0x%08x\n",
314             GetLastError());
315     }
316
317     bDestroyed = DestroyWindow(hWnd);
318     if (!bDestroyed)
319         trace("Window %p couldn't be destroyed : 0x%08x\n",
320             hWnd, GetLastError());
321 }
322
323 static void test_OpenThemeDataEx(void)
324 {
325     HTHEME    hTheme;
326     HWND      hWnd;
327     BOOL      bThemeActive;
328     BOOL      bDestroyed;
329
330     WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
331     WCHAR szButtonClassList[]  = {'B','u','t','t','o','n', 0 };
332     WCHAR szButtonClassList2[]  = {'b','U','t','T','o','N', 0 };
333     WCHAR szClassList[]        = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
334
335     if (!pOpenThemeDataEx)
336     {
337         win_skip("OpenThemeDataEx not available\n");
338         return;
339     }
340
341     bThemeActive = pIsThemeActive();
342
343     /* All NULL */
344     SetLastError(0xdeadbeef);
345     hTheme = pOpenThemeDataEx(NULL, NULL, 0);
346     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
347     ok( GetLastError() == E_POINTER,
348             "Expected GLE() to be E_POINTER, got 0x%08x\n",
349             GetLastError());
350
351     /* A NULL hWnd and an invalid classlist without flags */
352     SetLastError(0xdeadbeef);
353     hTheme = pOpenThemeDataEx(NULL, szInvalidClassList, 0);
354     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
355     todo_wine
356         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
357             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
358             GetLastError());
359
360     SetLastError(0xdeadbeef);
361     hTheme = pOpenThemeDataEx(NULL, szClassList, 0);
362     if (bThemeActive)
363     {
364         ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
365         todo_wine
366             ok( GetLastError() == ERROR_SUCCESS,
367                 "Expected ERROR_SUCCESS, got 0x%08x\n",
368                 GetLastError());
369     }
370     else
371     {
372         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
373         todo_wine
374             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
375                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
376                 GetLastError());
377     }
378
379     /* Only do the bare minimum to get a valid hdc */
380     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
381     if (!hWnd) return;
382
383     SetLastError(0xdeadbeef);
384     hTheme = pOpenThemeDataEx(hWnd, NULL, 0);
385     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
386     ok( GetLastError() == E_POINTER,
387             "Expected GLE() to be E_POINTER, got 0x%08x\n",
388             GetLastError());
389
390     SetLastError(0xdeadbeef);
391     hTheme = pOpenThemeDataEx(hWnd, szInvalidClassList, 0);
392     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
393     todo_wine
394         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
395             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
396             GetLastError());
397
398     if (!bThemeActive)
399     {
400         SetLastError(0xdeadbeef);
401         hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0);
402         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
403         todo_wine
404             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
405                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
406                 GetLastError());
407         skip("No active theme, skipping rest of OpenThemeDataEx tests\n");
408         return;
409     }
410
411     /* Only do the next checks if we have an active theme */
412
413     SetLastError(0xdeadbeef);
414     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0);
415     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
416     todo_wine
417         ok( GetLastError() == ERROR_SUCCESS,
418             "Expected ERROR_SUCCESS, got 0x%08x\n",
419             GetLastError());
420
421     SetLastError(0xdeadbeef);
422     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, OTD_FORCE_RECT_SIZING);
423     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
424     todo_wine
425         ok( GetLastError() == ERROR_SUCCESS,
426             "Expected ERROR_SUCCESS, got 0x%08x\n",
427             GetLastError());
428
429     SetLastError(0xdeadbeef);
430     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, OTD_NONCLIENT);
431     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
432     todo_wine
433         ok( GetLastError() == ERROR_SUCCESS,
434             "Expected ERROR_SUCCESS, got 0x%08x\n",
435             GetLastError());
436
437     SetLastError(0xdeadbeef);
438     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0x3);
439     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
440     todo_wine
441         ok( GetLastError() == ERROR_SUCCESS,
442             "Expected ERROR_SUCCESS, got 0x%08x\n",
443             GetLastError());
444
445     /* Test with bUtToN instead of Button */
446     SetLastError(0xdeadbeef);
447     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList2, 0);
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());
453
454     SetLastError(0xdeadbeef);
455     hTheme = pOpenThemeDataEx(hWnd, szClassList, 0);
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());
461
462     bDestroyed = DestroyWindow(hWnd);
463     if (!bDestroyed)
464         trace("Window %p couldn't be destroyed : 0x%08x\n",
465             hWnd, GetLastError());
466 }
467
468 static void test_GetCurrentThemeName(void)
469 {
470     BOOL    bThemeActive;
471     HRESULT hRes;
472     WCHAR currentTheme[MAX_PATH];
473     WCHAR currentColor[MAX_PATH];
474     WCHAR currentSize[MAX_PATH];
475
476     bThemeActive = pIsThemeActive();
477
478     /* All NULLs */
479     SetLastError(0xdeadbeef);
480     hRes = pGetCurrentThemeName(NULL, 0, NULL, 0, NULL, 0);
481     if (bThemeActive)
482         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
483     else
484         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
485     ok( GetLastError() == 0xdeadbeef,
486         "Expected 0xdeadbeef, got 0x%08x\n",
487         GetLastError());
488
489     /* Number of characters given is 0 */
490     SetLastError(0xdeadbeef);
491     hRes = pGetCurrentThemeName(currentTheme, 0, NULL, 0, NULL, 0);
492     if (bThemeActive)
493         ok( hRes == S_OK || broken(hRes == E_FAIL /* WinXP SP1 */), "Expected S_OK, got 0x%08x\n", hRes);
494     else
495         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
496     ok( GetLastError() == 0xdeadbeef,
497         "Expected 0xdeadbeef, got 0x%08x\n",
498         GetLastError());
499
500     SetLastError(0xdeadbeef);
501     hRes = pGetCurrentThemeName(currentTheme, 2, NULL, 0, NULL, 0);
502     if (bThemeActive)
503         todo_wine
504             ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
505                broken(hRes == E_FAIL /* WinXP SP1 */),
506                "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
507     else
508         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
509     ok( GetLastError() == 0xdeadbeef,
510         "Expected 0xdeadbeef, got 0x%08x\n",
511         GetLastError());
512
513     /* The same is true if the number of characters is too small for Color and/or Size */
514     SetLastError(0xdeadbeef);
515     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
516                                 currentColor, 2,
517                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
518     if (bThemeActive)
519         todo_wine
520             ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
521                broken(hRes == E_FAIL /* WinXP SP1 */),
522                "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
523     else
524         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
525     ok( GetLastError() == 0xdeadbeef,
526         "Expected 0xdeadbeef, got 0x%08x\n",
527         GetLastError());
528
529     /* Given number of characters is correct */
530     SetLastError(0xdeadbeef);
531     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), NULL, 0, NULL, 0);
532     if (bThemeActive)
533         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
534     else
535         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
536     ok( GetLastError() == 0xdeadbeef,
537         "Expected 0xdeadbeef, got 0x%08x\n",
538         GetLastError());
539
540     /* Given number of characters for the theme name is too large */
541     SetLastError(0xdeadbeef);
542     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme), NULL, 0, NULL, 0);
543     if (bThemeActive)
544         ok( hRes == E_POINTER || hRes == S_OK, "Expected E_POINTER or S_OK, got 0x%08x\n", hRes);
545     else
546         ok( hRes == E_PROP_ID_UNSUPPORTED ||
547             hRes == E_POINTER, /* win2k3 */
548             "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
549     ok( GetLastError() == 0xdeadbeef,
550         "Expected 0xdeadbeef, got 0x%08x\n",
551         GetLastError());
552  
553     /* The too large case is only for the theme name, not for color name or size name */
554     SetLastError(0xdeadbeef);
555     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
556                                 currentColor, sizeof(currentTheme),
557                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
558     if (bThemeActive)
559         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
560     else
561         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
562     ok( GetLastError() == 0xdeadbeef,
563         "Expected 0xdeadbeef, got 0x%08x\n",
564         GetLastError());
565
566     SetLastError(0xdeadbeef);
567     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
568                                 currentColor, sizeof(currentTheme) / sizeof(WCHAR),
569                                 currentSize,  sizeof(currentSize));
570     if (bThemeActive)
571         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
572     else
573         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
574     ok( GetLastError() == 0xdeadbeef,
575         "Expected 0xdeadbeef, got 0x%08x\n",
576         GetLastError());
577
578     /* Correct call */
579     SetLastError(0xdeadbeef);
580     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
581                                 currentColor, sizeof(currentColor) / sizeof(WCHAR),
582                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
583     if (bThemeActive)
584         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
585     else
586         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
587     ok( GetLastError() == 0xdeadbeef,
588         "Expected 0xdeadbeef, got 0x%08x\n",
589         GetLastError());
590 }
591
592 static void test_CloseThemeData(void)
593 {
594     HRESULT hRes;
595
596     SetLastError(0xdeadbeef);
597     hRes = pCloseThemeData(NULL);
598     ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
599     ok( GetLastError() == 0xdeadbeef,
600         "Expected 0xdeadbeef, got 0x%08x\n",
601         GetLastError());
602 }
603
604 START_TEST(system)
605 {
606     if(!InitFunctionPtrs())
607         return;
608
609     /* No real functional tests will be done (yet). The current tests
610      * only show input/return behaviour
611      */
612
613     /* IsThemeActive, IsAppThemed and IsThemePartDefined*/
614     trace("Starting test_IsThemed()\n");
615     test_IsThemed();
616
617     /* GetWindowTheme */
618     trace("Starting test_GetWindowTheme()\n");
619     test_GetWindowTheme();
620
621     /* SetWindowTheme */
622     trace("Starting test_SetWindowTheme()\n");
623     test_SetWindowTheme();
624
625     /* OpenThemeData, a bit more functional now */
626     trace("Starting test_OpenThemeData()\n");
627     test_OpenThemeData();
628
629     /* OpenThemeDataEx */
630     trace("Starting test_OpenThemeDataEx()\n");
631     test_OpenThemeDataEx();
632
633     /* GetCurrentThemeName */
634     trace("Starting test_GetCurrentThemeName()\n");
635     test_GetCurrentThemeName();
636
637     /* CloseThemeData */
638     trace("Starting test_CloseThemeData()\n");
639     test_CloseThemeData();
640
641     FreeLibrary(hUxtheme);
642 }