crypt32: Add additional path for Solaris 11 Express.
[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     SetLastError(0xdeadbeef);
85     bThemeActive = pIsThemeActive();
86     trace("Theming is %s\n", (bThemeActive) ? "active" : "inactive");
87
88     /* This test is not themed */
89     SetLastError(0xdeadbeef);
90     bAppThemed = pIsAppThemed();
91
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");
98
99     ok( GetLastError() == ERROR_SUCCESS,
100         "Expected ERROR_SUCCESS, got 0x%08x\n",
101         GetLastError());
102
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());
109 }
110
111 static void test_GetWindowTheme(void)
112 {
113     HTHEME    hTheme;
114     HWND      hWnd;
115     BOOL    bDestroyed;
116
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());
124
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;
128
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());
135
136     bDestroyed = DestroyWindow(hWnd);
137     if (!bDestroyed)
138         trace("Window %p couldn't be destroyed : 0x%08x\n",
139             hWnd, GetLastError());
140 }
141
142 static void test_SetWindowTheme(void)
143 {
144     HRESULT hRes;
145     HWND    hWnd;
146     BOOL    bDestroyed;
147
148     SetLastError(0xdeadbeef);
149     hRes = pSetWindowTheme(NULL, NULL, NULL);
150     todo_wine
151     {
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());
156     }
157
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;
161
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());
168
169     bDestroyed = DestroyWindow(hWnd);
170     if (!bDestroyed)
171         trace("Window %p couldn't be destroyed : 0x%08x\n",
172             hWnd, GetLastError());
173 }
174
175 static void test_OpenThemeData(void)
176 {
177     HTHEME    hTheme, hTheme2;
178     HWND      hWnd;
179     BOOL      bThemeActive;
180     HRESULT   hRes;
181     BOOL      bDestroyed;
182     BOOL      bTPDefined;
183
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 };
188
189     bThemeActive = pIsThemeActive();
190
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());
199
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());
208
209     SetLastError(0xdeadbeef);
210     hTheme = pOpenThemeData(NULL, szClassList);
211     if (bThemeActive)
212     {
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());
218     }
219     else
220     {
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());
226     }
227
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;
231
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());
239
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());
247
248     if (!bThemeActive)
249     {
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;
259     }
260
261     /* Only do the next checks if we have an active theme */
262
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());
270
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());
279
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());
287
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());
296
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());
303
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());
311
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());
321
322     SetLastError(0xdeadbeef);
323     bTPDefined = pIsThemePartDefined(hTheme, 0 , 0);
324     todo_wine
325     {
326         ok( bTPDefined == FALSE, "Expected FALSE\n");
327         ok( GetLastError() == ERROR_SUCCESS,
328             "Expected ERROR_SUCCESS, got 0x%08x\n",
329             GetLastError());
330     }
331
332     bDestroyed = DestroyWindow(hWnd);
333     if (!bDestroyed)
334         trace("Window %p couldn't be destroyed : 0x%08x\n",
335             hWnd, GetLastError());
336 }
337
338 static void test_OpenThemeDataEx(void)
339 {
340     HTHEME    hTheme;
341     HWND      hWnd;
342     BOOL      bThemeActive;
343     BOOL      bDestroyed;
344
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 };
349
350     if (!pOpenThemeDataEx)
351     {
352         win_skip("OpenThemeDataEx not available\n");
353         return;
354     }
355
356     bThemeActive = pIsThemeActive();
357
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());
366
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());
375
376     SetLastError(0xdeadbeef);
377     hTheme = pOpenThemeDataEx(NULL, szClassList, 0);
378     if (bThemeActive)
379     {
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());
385     }
386     else
387     {
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());
393     }
394
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;
398
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());
406
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());
414
415     if (!bThemeActive)
416     {
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;
426     }
427
428     /* Only do the next checks if we have an active theme */
429
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());
437
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());
445
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());
453
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());
461
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());
470
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());
478
479     bDestroyed = DestroyWindow(hWnd);
480     if (!bDestroyed)
481         trace("Window %p couldn't be destroyed : 0x%08x\n",
482             hWnd, GetLastError());
483 }
484
485 static void test_GetCurrentThemeName(void)
486 {
487     BOOL    bThemeActive;
488     HRESULT hRes;
489     WCHAR currentTheme[MAX_PATH];
490     WCHAR currentColor[MAX_PATH];
491     WCHAR currentSize[MAX_PATH];
492
493     bThemeActive = pIsThemeActive();
494
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());
505
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());
516
517     SetLastError(0xdeadbeef);
518     hRes = pGetCurrentThemeName(currentTheme, 2, NULL, 0, NULL, 0);
519     if (bThemeActive)
520         todo_wine
521             ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
522                broken(hRes == E_FAIL /* WinXP SP1 */),
523                "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
524     else
525         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
526     ok( GetLastError() == 0xdeadbeef,
527         "Expected 0xdeadbeef, got 0x%08x\n",
528         GetLastError());
529
530     /* The same is true if the number of characters is too small for Color and/or Size */
531     SetLastError(0xdeadbeef);
532     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
533                                 currentColor, 2,
534                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
535     if (bThemeActive)
536         todo_wine
537             ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
538                broken(hRes == E_FAIL /* WinXP SP1 */),
539                "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
540     else
541         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
542     ok( GetLastError() == 0xdeadbeef,
543         "Expected 0xdeadbeef, got 0x%08x\n",
544         GetLastError());
545
546     /* Given number of characters is correct */
547     SetLastError(0xdeadbeef);
548     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), NULL, 0, NULL, 0);
549     if (bThemeActive)
550         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
551     else
552         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
553     ok( GetLastError() == 0xdeadbeef,
554         "Expected 0xdeadbeef, got 0x%08x\n",
555         GetLastError());
556
557     /* Given number of characters for the theme name is too large */
558     SetLastError(0xdeadbeef);
559     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme), NULL, 0, NULL, 0);
560     if (bThemeActive)
561         ok( hRes == E_POINTER || hRes == S_OK, "Expected E_POINTER or S_OK, got 0x%08x\n", hRes);
562     else
563         ok( hRes == E_PROP_ID_UNSUPPORTED ||
564             hRes == E_POINTER, /* win2k3 */
565             "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
566     ok( GetLastError() == 0xdeadbeef,
567         "Expected 0xdeadbeef, got 0x%08x\n",
568         GetLastError());
569  
570     /* The too large case is only for the theme name, not for color name or size name */
571     SetLastError(0xdeadbeef);
572     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
573                                 currentColor, sizeof(currentTheme),
574                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
575     if (bThemeActive)
576         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
577     else
578         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
579     ok( GetLastError() == 0xdeadbeef,
580         "Expected 0xdeadbeef, got 0x%08x\n",
581         GetLastError());
582
583     SetLastError(0xdeadbeef);
584     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
585                                 currentColor, sizeof(currentTheme) / sizeof(WCHAR),
586                                 currentSize,  sizeof(currentSize));
587     if (bThemeActive)
588         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
589     else
590         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
591     ok( GetLastError() == 0xdeadbeef,
592         "Expected 0xdeadbeef, got 0x%08x\n",
593         GetLastError());
594
595     /* Correct call */
596     SetLastError(0xdeadbeef);
597     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
598                                 currentColor, sizeof(currentColor) / sizeof(WCHAR),
599                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
600     if (bThemeActive)
601         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
602     else
603         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
604     ok( GetLastError() == 0xdeadbeef,
605         "Expected 0xdeadbeef, got 0x%08x\n",
606         GetLastError());
607 }
608
609 static void test_CloseThemeData(void)
610 {
611     HRESULT hRes;
612
613     SetLastError(0xdeadbeef);
614     hRes = pCloseThemeData(NULL);
615     ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
616     ok( GetLastError() == 0xdeadbeef,
617         "Expected 0xdeadbeef, got 0x%08x\n",
618         GetLastError());
619 }
620
621 START_TEST(system)
622 {
623     if(!InitFunctionPtrs())
624         return;
625
626     /* No real functional tests will be done (yet). The current tests
627      * only show input/return behaviour
628      */
629
630     /* IsThemeActive, IsAppThemed and IsThemePartDefined*/
631     trace("Starting test_IsThemed()\n");
632     test_IsThemed();
633
634     /* GetWindowTheme */
635     trace("Starting test_GetWindowTheme()\n");
636     test_GetWindowTheme();
637
638     /* SetWindowTheme */
639     trace("Starting test_SetWindowTheme()\n");
640     test_SetWindowTheme();
641
642     /* OpenThemeData, a bit more functional now */
643     trace("Starting test_OpenThemeData()\n");
644     test_OpenThemeData();
645
646     /* OpenThemeDataEx */
647     trace("Starting test_OpenThemeDataEx()\n");
648     test_OpenThemeDataEx();
649
650     /* GetCurrentThemeName */
651     trace("Starting test_GetCurrentThemeName()\n");
652     test_GetCurrentThemeName();
653
654     /* CloseThemeData */
655     trace("Starting test_CloseThemeData()\n");
656     test_CloseThemeData();
657
658     FreeLibrary(hUxtheme);
659 }