advapi: Add a stub for SystemFunction035.
[wine/testsucceed.git] / dlls / uxtheme / tests / system.c
blob9a1c558f22917b6566737b1261618f703b1a6059
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 "uxtheme.h"
26 #include "wine/test.h"
28 static HRESULT (WINAPI * pCloseThemeData)(HTHEME);
29 static HTHEME (WINAPI * pGetWindowTheme)(HWND);
30 static BOOL (WINAPI * pIsAppThemed)(VOID);
31 static BOOL (WINAPI * pIsThemeActive)(VOID);
32 static HTHEME (WINAPI * pOpenThemeData)(HWND, LPCWSTR);
33 static HRESULT (WINAPI * pSetWindowTheme)(HWND, LPCWSTR, LPCWSTR);
35 static HMODULE hUxtheme = 0;
37 #define UXTHEME_GET_PROC(func) \
38 p ## func = (void*)GetProcAddress(hUxtheme, #func); \
39 if(!p ## func) { \
40 trace("GetProcAddress(%s) failed\n", #func); \
41 FreeLibrary(hUxtheme); \
42 return FALSE; \
45 static BOOL InitFunctionPtrs(void)
47 hUxtheme = LoadLibraryA("uxtheme.dll");
48 if(!hUxtheme) {
49 trace("Could not load uxtheme.dll\n");
50 return FALSE;
52 if (hUxtheme)
54 UXTHEME_GET_PROC(CloseThemeData)
55 UXTHEME_GET_PROC(GetWindowTheme)
56 UXTHEME_GET_PROC(IsAppThemed)
57 UXTHEME_GET_PROC(IsThemeActive)
58 UXTHEME_GET_PROC(OpenThemeData)
59 UXTHEME_GET_PROC(SetWindowTheme)
61 /* The following functions should be available, if not return FALSE. The Vista functions will
62 * be checked (at some point in time) within the single tests if needed. All used functions for
63 * now are present on WinXP, W2K3 and Wine.
65 if (!pCloseThemeData || !pGetWindowTheme ||
66 !pIsAppThemed || !pIsThemeActive ||
67 !pOpenThemeData || !pSetWindowTheme)
68 return FALSE;
70 return TRUE;
73 static void test_IsThemed(void)
75 BOOL bThemeActive;
76 BOOL bAppThemed;
78 SetLastError(0xdeadbeef);
79 bThemeActive = pIsThemeActive();
80 trace("Theming is %s\n", (bThemeActive) ? "active" : "inactive");
81 todo_wine
82 ok( GetLastError() == ERROR_SUCCESS,
83 "Expected ERROR_SUCCESS, got 0x%08lx\n",
84 GetLastError());
86 /* This test is not themed */
87 SetLastError(0xdeadbeef);
88 bAppThemed = pIsAppThemed();
90 if (bThemeActive)
91 todo_wine
92 ok( bAppThemed == FALSE, "Expected FALSE as this test executable is not (yet) themed.\n");
93 else
94 /* Although Wine currently returns FALSE, the logic behind it is wrong. It is not a todo_wine though in the testing sense */
95 ok( bAppThemed == FALSE, "Expected FALSE as this test executable is not (yet) themed.\n");
97 todo_wine
98 ok( GetLastError() == ERROR_SUCCESS,
99 "Expected ERROR_SUCCESS, got 0x%08lx\n",
100 GetLastError());
103 static void test_GetWindowTheme(void)
105 HTHEME hTheme;
106 HWND hWnd;
107 BOOL bDestroyed;
109 SetLastError(0xdeadbeef);
110 hTheme = pGetWindowTheme(NULL);
111 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
112 todo_wine
113 ok( GetLastError() == E_HANDLE,
114 "Expected E_HANDLE, got 0x%08lx\n",
115 GetLastError());
117 /* Only do the bare minumum to get a valid hwnd */
118 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
119 if (!hWnd) return;
121 SetLastError(0xdeadbeef);
122 hTheme = pGetWindowTheme(hWnd);
123 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
124 ok( GetLastError() == 0xdeadbeef,
125 "Expected 0xdeadbeef, got 0x%08lx\n",
126 GetLastError());
128 bDestroyed = DestroyWindow(hWnd);
129 if (!bDestroyed)
130 trace("Window %p couldn't be destroyed : 0x%08lx\n",
131 hWnd, GetLastError());
134 static void test_SetWindowTheme(void)
136 HRESULT hRes;
137 HWND hWnd;
138 BOOL bDestroyed;
140 SetLastError(0xdeadbeef);
141 hRes = pSetWindowTheme(NULL, NULL, NULL);
142 todo_wine
144 ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes);
145 ok( GetLastError() == 0xdeadbeef,
146 "Expected 0xdeadbeef, got 0x%08lx\n",
147 GetLastError());
150 /* Only do the bare minumum to get a valid hwnd */
151 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
152 if (!hWnd) return;
154 SetLastError(0xdeadbeef);
155 hRes = pSetWindowTheme(hWnd, NULL, NULL);
156 ok( hRes == S_OK, "Expected S_OK, got 0x%08lx\n", hRes);
157 ok( GetLastError() == 0xdeadbeef,
158 "Expected 0xdeadbeef, got 0x%08lx\n",
159 GetLastError());
161 bDestroyed = DestroyWindow(hWnd);
162 if (!bDestroyed)
163 trace("Window %p couldn't be destroyed : 0x%08lx\n",
164 hWnd, GetLastError());
167 static void test_OpenThemeData(void)
169 HTHEME hTheme;
170 HWND hWnd;
171 BOOL bThemeActive;
172 BOOL bDestroyed;
174 WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
175 WCHAR szButtonClassList[] = {'B','u','t','t','o','n', 0 };
176 WCHAR szButtonClassList2[] = {'b','U','t','T','o','N', 0 };
177 WCHAR szClassList[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
179 bThemeActive = pIsThemeActive();
181 /* All NULL */
182 SetLastError(0xdeadbeef);
183 hTheme = pOpenThemeData(NULL, NULL);
184 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
185 todo_wine
186 ok( GetLastError() == E_POINTER,
187 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
188 GetLastError());
190 /* A NULL hWnd and an invalid classlist */
191 SetLastError(0xdeadbeef);
192 hTheme = pOpenThemeData(NULL, szInvalidClassList);
193 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
194 todo_wine
195 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
196 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
197 GetLastError());
199 SetLastError(0xdeadbeef);
200 hTheme = pOpenThemeData(NULL, szClassList);
201 if (bThemeActive)
203 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
204 todo_wine
205 ok( GetLastError() == ERROR_SUCCESS,
206 "Expected ERROR_SUCCESS, got 0x%08lx\n",
207 GetLastError());
209 else
211 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
212 todo_wine
213 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
214 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
215 GetLastError());
218 /* Only do the bare minumum to get a valid hdc */
219 hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
220 if (!hWnd) return;
222 SetLastError(0xdeadbeef);
223 hTheme = pOpenThemeData(hWnd, NULL);
224 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
225 todo_wine
226 ok( GetLastError() == E_POINTER,
227 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
228 GetLastError());
230 SetLastError(0xdeadbeef);
231 hTheme = pOpenThemeData(hWnd, szInvalidClassList);
232 ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
233 todo_wine
234 ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
235 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
236 GetLastError());
238 if (!bThemeActive)
240 SetLastError(0xdeadbeef);
241 hTheme = pOpenThemeData(hWnd, szButtonClassList);
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%08lx\n",
246 GetLastError());
247 trace("No active theme, skipping rest of OpenThemeData tests\n");
248 return;
251 /* Only do the next checks if we have an active theme */
253 SetLastError(0xdeadbeef);
254 hTheme = pOpenThemeData(hWnd, szButtonClassList);
255 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
256 todo_wine
257 ok( GetLastError() == ERROR_SUCCESS,
258 "Expected ERROR_SUCCESS, got 0x%08lx\n",
259 GetLastError());
261 /* Test with bUtToN instead of Button */
262 SetLastError(0xdeadbeef);
263 hTheme = pOpenThemeData(hWnd, szButtonClassList2);
264 ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
265 todo_wine
266 ok( GetLastError() == ERROR_SUCCESS,
267 "Expected ERROR_SUCCESS, got 0x%08lx\n",
268 GetLastError());
270 SetLastError(0xdeadbeef);
271 hTheme = pOpenThemeData(hWnd, szClassList);
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%08lx\n",
276 GetLastError());
278 bDestroyed = DestroyWindow(hWnd);
279 if (!bDestroyed)
280 trace("Window %p couldn't be destroyed : 0x%08lx\n",
281 hWnd, GetLastError());
284 static void test_CloseThemeData(void)
286 HRESULT hRes;
288 SetLastError(0xdeadbeef);
289 hRes = pCloseThemeData(NULL);
290 ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes);
291 ok( GetLastError() == 0xdeadbeef,
292 "Expected 0xdeadbeef, got 0x%08lx\n",
293 GetLastError());
296 START_TEST(system)
298 if(!InitFunctionPtrs())
299 return;
301 /* No real functional tests will be done (yet). The current tests
302 * only show input/return behaviour
305 /* IsThemeActive and IsAppThemed */
306 trace("Starting test_IsThemed()\n");
307 test_IsThemed();
309 /* GetWindowTheme */
310 trace("Starting test_GetWindowTheme()\n");
311 test_GetWindowTheme();
313 /* SetWindowTheme */
314 trace("Starting test_SetWindowTheme()\n");
315 test_SetWindowTheme();
317 /* OpenThemeData */
318 trace("Starting test_OpenThemeData()\n");
319 test_OpenThemeData();
321 /* CloseThemeData */
322 trace("Starting test_CloseThemeData()\n");
323 test_CloseThemeData();
325 FreeLibrary(hUxtheme);