1 /* Unit test suite for uxtheme API functions
3 * Copyright 2006 Paul Vriens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 static HRESULT (WINAPI * pCloseThemeData)(HTHEME);
29 static BOOL (WINAPI * pIsAppThemed)(VOID);
30 static BOOL (WINAPI * pIsThemeActive)(VOID);
31 static HTHEME (WINAPI * pOpenThemeData)(HWND, LPCWSTR);
32 static HRESULT (WINAPI * pSetWindowTheme)(HWND, LPCWSTR, LPCWSTR);
34 static HMODULE hUxtheme = 0;
36 #define UXTHEME_GET_PROC(func) \
37 p ## func = (void*)GetProcAddress(hUxtheme, #func); \
39 trace("GetProcAddress(%s) failed\n", #func); \
40 FreeLibrary(hUxtheme); \
44 static BOOL InitFunctionPtrs(void)
46 hUxtheme = LoadLibraryA("uxtheme.dll");
48 trace("Could not load uxtheme.dll\n");
53 UXTHEME_GET_PROC(CloseThemeData)
54 UXTHEME_GET_PROC(IsAppThemed)
55 UXTHEME_GET_PROC(IsThemeActive)
56 UXTHEME_GET_PROC(OpenThemeData)
57 UXTHEME_GET_PROC(SetWindowTheme)
62 static void test_IsThemed(void)
67 SetLastError(0xdeadbeef);
68 bThemeActive = pIsThemeActive();
69 trace("Theming is %s\n", (bThemeActive) ? "active" : "inactive");
71 ok( GetLastError() == ERROR_SUCCESS,
72 "Expected ERROR_SUCCESS, got 0x%08lx\n",
75 /* This test is not themed */
76 SetLastError(0xdeadbeef);
77 bAppThemed = pIsAppThemed();
81 ok( bAppThemed == FALSE, "Expected FALSE as this test executable is not (yet) themed.\n");
83 /* Although Wine currently returns FALSE, the logic behind it is wrong. It is not a todo_wine though in the testing sense */
84 ok( bAppThemed == FALSE, "Expected FALSE as this test executable is not (yet) themed.\n");
87 ok( GetLastError() == ERROR_SUCCESS,
88 "Expected ERROR_SUCCESS, got 0x%08lx\n",
92 static void test_SetWindowTheme(void)
97 SetLastError(0xdeadbeef);
98 hRes = pSetWindowTheme(NULL, NULL, NULL);
100 ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes);
102 /* Only do the bare minumum to get a valid hwnd */
103 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
106 SetLastError(0xdeadbeef);
107 hRes = pSetWindowTheme(hWnd, NULL, NULL);
108 ok( hRes == S_OK, "Expected S_OK, got 0x%08lx\n", hRes);
111 static void test_OpenThemeData(void)
117 WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
118 WCHAR szButtonClassList[] = {'B','u','t','t','o','n', 0 };
119 WCHAR szClassList[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
121 SetLastError(0xdeadbeef);
122 bThemeActive = pIsThemeActive();
125 SetLastError(0xdeadbeef);
126 hTheme = pOpenThemeData(NULL, NULL);
127 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
129 ok( GetLastError() == E_POINTER,
130 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
133 /* A NULL hWnd and an invalid classlist */
134 SetLastError(0xdeadbeef);
135 hTheme = pOpenThemeData(NULL, szInvalidClassList);
136 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
138 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
139 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
142 SetLastError(0xdeadbeef);
143 hTheme = pOpenThemeData(NULL, szClassList);
146 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
148 ok( GetLastError() == ERROR_SUCCESS,
149 "Expected ERROR_SUCCESS, got 0x%08lx\n",
154 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
156 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
157 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
161 /* Only do the bare minumum to get a valid hdc */
162 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
165 SetLastError(0xdeadbeef);
166 hTheme = pOpenThemeData(hWnd, NULL);
167 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
169 ok( GetLastError() == E_POINTER,
170 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
173 SetLastError(0xdeadbeef);
174 hTheme = pOpenThemeData(hWnd, szInvalidClassList);
175 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
177 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
178 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
184 SetLastError(0xdeadbeef);
185 hTheme = pOpenThemeData(hWnd, szButtonClassList);
186 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
188 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
189 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
191 trace("No active theme, skipping rest of OpenThemeData tests\n");
195 /* Only do the next checks if we have an active theme */
197 SetLastError(0xdeadbeef);
198 hTheme = pOpenThemeData(hWnd, szButtonClassList);
199 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
201 ok( GetLastError() == ERROR_SUCCESS,
202 "Expected ERROR_SUCCESS, got 0x%08lx\n",
205 SetLastError(0xdeadbeef);
206 hTheme = pOpenThemeData(hWnd, szClassList);
207 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
209 ok( GetLastError() == ERROR_SUCCESS,
210 "Expected ERROR_SUCCESS, got 0x%08lx\n",
214 static void test_CloseThemeData(void)
218 SetLastError(0xdeadbeef);
219 hRes = pCloseThemeData(NULL);
220 ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes);
221 ok( GetLastError() == 0xdeadbeef,
222 "Expected 0xdeadbeef, got 0x%08lx\n",
228 if(!InitFunctionPtrs())
231 /* No real functional tests will be done (yet). The current tests
232 * only show input/return behaviour
235 /* IsThemeActive and IsAppThemed */
236 trace("Starting test_IsThemed()\n");
237 if (pIsAppThemed && pIsThemeActive)
241 trace("Starting test_SetWindowTheme()\n");
243 test_SetWindowTheme();
246 trace("Starting test_OpenThemeData()\n");
247 if (pOpenThemeData && pIsThemeActive)
248 test_OpenThemeData();
251 trace("Starting test_CloseThemeData()\n");
253 test_CloseThemeData();
255 FreeLibrary(hUxtheme);