windowscodecs: Implement JpegEncoder_Frame_Commit.
[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     ok( GetLastError() == E_POINTER,
196             "Expected GLE() to be E_POINTER, got 0x%08x\n",
197             GetLastError());
198
199     /* A NULL hWnd and an invalid classlist */
200     SetLastError(0xdeadbeef);
201     hTheme = pOpenThemeData(NULL, szInvalidClassList);
202     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
203     todo_wine
204         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
205             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
206             GetLastError());
207
208     SetLastError(0xdeadbeef);
209     hTheme = pOpenThemeData(NULL, szClassList);
210     if (bThemeActive)
211     {
212         ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
213         todo_wine
214             ok( GetLastError() == ERROR_SUCCESS,
215                 "Expected ERROR_SUCCESS, got 0x%08x\n",
216                 GetLastError());
217     }
218     else
219     {
220         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
221         todo_wine
222             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
223                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
224                 GetLastError());
225     }
226
227     /* Only do the bare minimum to get a valid hdc */
228     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
229     if (!hWnd) return;
230
231     SetLastError(0xdeadbeef);
232     hTheme = pOpenThemeData(hWnd, NULL);
233     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
234     ok( GetLastError() == E_POINTER,
235             "Expected GLE() to be E_POINTER, got 0x%08x\n",
236             GetLastError());
237
238     SetLastError(0xdeadbeef);
239     hTheme = pOpenThemeData(hWnd, szInvalidClassList);
240     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
241     todo_wine
242         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
243             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
244             GetLastError());
245
246     if (!bThemeActive)
247     {
248         SetLastError(0xdeadbeef);
249         hTheme = pOpenThemeData(hWnd, szButtonClassList);
250         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
251         todo_wine
252             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
253                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
254                 GetLastError());
255         skip("No active theme, skipping rest of OpenThemeData tests\n");
256         return;
257     }
258
259     /* Only do the next checks if we have an active theme */
260
261     SetLastError(0xdeadbeef);
262     hTheme = pOpenThemeData(hWnd, szButtonClassList);
263     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
264     todo_wine
265         ok( GetLastError() == ERROR_SUCCESS,
266             "Expected ERROR_SUCCESS, got 0x%08x\n",
267             GetLastError());
268
269     /* Test with bUtToN instead of Button */
270     SetLastError(0xdeadbeef);
271     hTheme = pOpenThemeData(hWnd, szButtonClassList2);
272     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
273     todo_wine
274         ok( GetLastError() == ERROR_SUCCESS,
275             "Expected ERROR_SUCCESS, got 0x%08x\n",
276             GetLastError());
277
278     SetLastError(0xdeadbeef);
279     hTheme = pOpenThemeData(hWnd, szClassList);
280     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
281     todo_wine
282         ok( GetLastError() == ERROR_SUCCESS,
283             "Expected ERROR_SUCCESS, got 0x%08x\n",
284             GetLastError());
285
286     /* GetWindowTheme should return the last handle opened by OpenThemeData */
287     SetLastError(0xdeadbeef);
288     hTheme2 = pGetWindowTheme(hWnd);
289     ok( hTheme == hTheme2, "Expected the same HTHEME handle (%p<->%p)\n",
290         hTheme, hTheme2);
291     ok( GetLastError() == 0xdeadbeef,
292         "Expected 0xdeadbeef, got 0x%08x\n",
293         GetLastError());
294
295     SetLastError(0xdeadbeef);
296     hRes = pCloseThemeData(hTheme);
297     ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
298     ok( GetLastError() == 0xdeadbeef,
299         "Expected 0xdeadbeef, got 0x%08x\n",
300         GetLastError());
301
302     /* Close a second time */
303     SetLastError(0xdeadbeef);
304     hRes = pCloseThemeData(hTheme);
305     ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
306     ok( GetLastError() == 0xdeadbeef,
307         "Expected 0xdeadbeef, got 0x%08x\n",
308         GetLastError());
309
310     /* See if closing makes a difference for GetWindowTheme */
311     SetLastError(0xdeadbeef);
312     hTheme2 = NULL;
313     hTheme2 = pGetWindowTheme(hWnd);
314     ok( hTheme == hTheme2, "Expected the same HTHEME handle (%p<->%p)\n",
315         hTheme, hTheme2);
316     ok( GetLastError() == 0xdeadbeef,
317         "Expected 0xdeadbeef, got 0x%08x\n",
318         GetLastError());
319
320     SetLastError(0xdeadbeef);
321     bTPDefined = pIsThemePartDefined(hTheme, 0 , 0);
322     todo_wine
323     {
324         ok( bTPDefined == FALSE, "Expected FALSE\n");
325         ok( GetLastError() == ERROR_SUCCESS,
326             "Expected ERROR_SUCCESS, got 0x%08x\n",
327             GetLastError());
328     }
329
330     bDestroyed = DestroyWindow(hWnd);
331     if (!bDestroyed)
332         trace("Window %p couldn't be destroyed : 0x%08x\n",
333             hWnd, GetLastError());
334 }
335
336 static void test_OpenThemeDataEx(void)
337 {
338     HTHEME    hTheme;
339     HWND      hWnd;
340     BOOL      bThemeActive;
341     BOOL      bDestroyed;
342
343     WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
344     WCHAR szButtonClassList[]  = {'B','u','t','t','o','n', 0 };
345     WCHAR szButtonClassList2[]  = {'b','U','t','T','o','N', 0 };
346     WCHAR szClassList[]        = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
347
348     if (!pOpenThemeDataEx)
349     {
350         win_skip("OpenThemeDataEx not available\n");
351         return;
352     }
353
354     bThemeActive = pIsThemeActive();
355
356     /* All NULL */
357     SetLastError(0xdeadbeef);
358     hTheme = pOpenThemeDataEx(NULL, NULL, 0);
359     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
360     ok( GetLastError() == E_POINTER,
361             "Expected GLE() to be E_POINTER, got 0x%08x\n",
362             GetLastError());
363
364     /* A NULL hWnd and an invalid classlist without flags */
365     SetLastError(0xdeadbeef);
366     hTheme = pOpenThemeDataEx(NULL, szInvalidClassList, 0);
367     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
368     todo_wine
369         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
370             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
371             GetLastError());
372
373     SetLastError(0xdeadbeef);
374     hTheme = pOpenThemeDataEx(NULL, szClassList, 0);
375     if (bThemeActive)
376     {
377         ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
378         todo_wine
379             ok( GetLastError() == ERROR_SUCCESS,
380                 "Expected ERROR_SUCCESS, got 0x%08x\n",
381                 GetLastError());
382     }
383     else
384     {
385         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
386         todo_wine
387             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
388                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
389                 GetLastError());
390     }
391
392     /* Only do the bare minimum to get a valid hdc */
393     hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
394     if (!hWnd) return;
395
396     SetLastError(0xdeadbeef);
397     hTheme = pOpenThemeDataEx(hWnd, NULL, 0);
398     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
399     ok( GetLastError() == E_POINTER,
400             "Expected GLE() to be E_POINTER, got 0x%08x\n",
401             GetLastError());
402
403     SetLastError(0xdeadbeef);
404     hTheme = pOpenThemeDataEx(hWnd, szInvalidClassList, 0);
405     ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
406     todo_wine
407         ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
408             "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
409             GetLastError());
410
411     if (!bThemeActive)
412     {
413         SetLastError(0xdeadbeef);
414         hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0);
415         ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
416         todo_wine
417             ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
418                 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
419                 GetLastError());
420         skip("No active theme, skipping rest of OpenThemeDataEx tests\n");
421         return;
422     }
423
424     /* Only do the next checks if we have an active theme */
425
426     SetLastError(0xdeadbeef);
427     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0);
428     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
429     todo_wine
430         ok( GetLastError() == ERROR_SUCCESS,
431             "Expected ERROR_SUCCESS, got 0x%08x\n",
432             GetLastError());
433
434     SetLastError(0xdeadbeef);
435     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, OTD_FORCE_RECT_SIZING);
436     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
437     todo_wine
438         ok( GetLastError() == ERROR_SUCCESS,
439             "Expected ERROR_SUCCESS, got 0x%08x\n",
440             GetLastError());
441
442     SetLastError(0xdeadbeef);
443     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, OTD_NONCLIENT);
444     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
445     todo_wine
446         ok( GetLastError() == ERROR_SUCCESS,
447             "Expected ERROR_SUCCESS, got 0x%08x\n",
448             GetLastError());
449
450     SetLastError(0xdeadbeef);
451     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList, 0x3);
452     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
453     todo_wine
454         ok( GetLastError() == ERROR_SUCCESS,
455             "Expected ERROR_SUCCESS, got 0x%08x\n",
456             GetLastError());
457
458     /* Test with bUtToN instead of Button */
459     SetLastError(0xdeadbeef);
460     hTheme = pOpenThemeDataEx(hWnd, szButtonClassList2, 0);
461     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
462     todo_wine
463         ok( GetLastError() == ERROR_SUCCESS,
464             "Expected ERROR_SUCCESS, got 0x%08x\n",
465             GetLastError());
466
467     SetLastError(0xdeadbeef);
468     hTheme = pOpenThemeDataEx(hWnd, szClassList, 0);
469     ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
470     todo_wine
471         ok( GetLastError() == ERROR_SUCCESS,
472             "Expected ERROR_SUCCESS, got 0x%08x\n",
473             GetLastError());
474
475     bDestroyed = DestroyWindow(hWnd);
476     if (!bDestroyed)
477         trace("Window %p couldn't be destroyed : 0x%08x\n",
478             hWnd, GetLastError());
479 }
480
481 static void test_GetCurrentThemeName(void)
482 {
483     BOOL    bThemeActive;
484     HRESULT hRes;
485     WCHAR currentTheme[MAX_PATH];
486     WCHAR currentColor[MAX_PATH];
487     WCHAR currentSize[MAX_PATH];
488
489     bThemeActive = pIsThemeActive();
490
491     /* All NULLs */
492     SetLastError(0xdeadbeef);
493     hRes = pGetCurrentThemeName(NULL, 0, NULL, 0, NULL, 0);
494     if (bThemeActive)
495         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
496     else
497         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
498     ok( GetLastError() == 0xdeadbeef,
499         "Expected 0xdeadbeef, got 0x%08x\n",
500         GetLastError());
501
502     /* Number of characters given is 0 */
503     SetLastError(0xdeadbeef);
504     hRes = pGetCurrentThemeName(currentTheme, 0, NULL, 0, NULL, 0);
505     if (bThemeActive)
506         ok( hRes == S_OK || broken(hRes == E_FAIL /* WinXP SP1 */), "Expected S_OK, 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     SetLastError(0xdeadbeef);
514     hRes = pGetCurrentThemeName(currentTheme, 2, NULL, 0, NULL, 0);
515     if (bThemeActive)
516         todo_wine
517             ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
518                broken(hRes == E_FAIL /* WinXP SP1 */),
519                "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
520     else
521         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
522     ok( GetLastError() == 0xdeadbeef,
523         "Expected 0xdeadbeef, got 0x%08x\n",
524         GetLastError());
525
526     /* The same is true if the number of characters is too small for Color and/or Size */
527     SetLastError(0xdeadbeef);
528     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
529                                 currentColor, 2,
530                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
531     if (bThemeActive)
532         todo_wine
533             ok(hRes == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) ||
534                broken(hRes == E_FAIL /* WinXP SP1 */),
535                "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got 0x%08x\n", hRes);
536     else
537         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
538     ok( GetLastError() == 0xdeadbeef,
539         "Expected 0xdeadbeef, got 0x%08x\n",
540         GetLastError());
541
542     /* Given number of characters is correct */
543     SetLastError(0xdeadbeef);
544     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), NULL, 0, NULL, 0);
545     if (bThemeActive)
546         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
547     else
548         ok( hRes == E_PROP_ID_UNSUPPORTED, "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     /* Given number of characters for the theme name is too large */
554     SetLastError(0xdeadbeef);
555     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme), NULL, 0, NULL, 0);
556     if (bThemeActive)
557         ok( hRes == E_POINTER || hRes == S_OK, "Expected E_POINTER or S_OK, got 0x%08x\n", hRes);
558     else
559         ok( hRes == E_PROP_ID_UNSUPPORTED ||
560             hRes == E_POINTER, /* win2k3 */
561             "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     /* The too large case is only for the theme name, not for color name or size name */
567     SetLastError(0xdeadbeef);
568     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
569                                 currentColor, sizeof(currentTheme),
570                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
571     if (bThemeActive)
572         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
573     else
574         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
575     ok( GetLastError() == 0xdeadbeef,
576         "Expected 0xdeadbeef, got 0x%08x\n",
577         GetLastError());
578
579     SetLastError(0xdeadbeef);
580     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
581                                 currentColor, sizeof(currentTheme) / sizeof(WCHAR),
582                                 currentSize,  sizeof(currentSize));
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     /* Correct call */
592     SetLastError(0xdeadbeef);
593     hRes = pGetCurrentThemeName(currentTheme, sizeof(currentTheme) / sizeof(WCHAR), 
594                                 currentColor, sizeof(currentColor) / sizeof(WCHAR),
595                                 currentSize,  sizeof(currentSize)  / sizeof(WCHAR));
596     if (bThemeActive)
597         ok( hRes == S_OK, "Expected S_OK, got 0x%08x\n", hRes);
598     else
599         ok( hRes == E_PROP_ID_UNSUPPORTED, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes);
600     ok( GetLastError() == 0xdeadbeef,
601         "Expected 0xdeadbeef, got 0x%08x\n",
602         GetLastError());
603 }
604
605 static void test_CloseThemeData(void)
606 {
607     HRESULT hRes;
608
609     SetLastError(0xdeadbeef);
610     hRes = pCloseThemeData(NULL);
611     ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
612     ok( GetLastError() == 0xdeadbeef,
613         "Expected 0xdeadbeef, got 0x%08x\n",
614         GetLastError());
615 }
616
617 START_TEST(system)
618 {
619     if(!InitFunctionPtrs())
620         return;
621
622     /* No real functional tests will be done (yet). The current tests
623      * only show input/return behaviour
624      */
625
626     /* IsThemeActive, IsAppThemed and IsThemePartDefined*/
627     trace("Starting test_IsThemed()\n");
628     test_IsThemed();
629
630     /* GetWindowTheme */
631     trace("Starting test_GetWindowTheme()\n");
632     test_GetWindowTheme();
633
634     /* SetWindowTheme */
635     trace("Starting test_SetWindowTheme()\n");
636     test_SetWindowTheme();
637
638     /* OpenThemeData, a bit more functional now */
639     trace("Starting test_OpenThemeData()\n");
640     test_OpenThemeData();
641
642     /* OpenThemeDataEx */
643     trace("Starting test_OpenThemeDataEx()\n");
644     test_OpenThemeDataEx();
645
646     /* GetCurrentThemeName */
647     trace("Starting test_GetCurrentThemeName()\n");
648     test_GetCurrentThemeName();
649
650     /* CloseThemeData */
651     trace("Starting test_CloseThemeData()\n");
652     test_CloseThemeData();
653
654     FreeLibrary(hUxtheme);
655 }