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
);
101 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08lx\n", hRes
);
102 ok( GetLastError() == 0xdeadbeef,
103 "Expected 0xdeadbeef, got 0x%08lx\n",
107 /* Only do the bare minumum to get a valid hwnd */
108 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
111 SetLastError(0xdeadbeef);
112 hRes
= pSetWindowTheme(hWnd
, NULL
, NULL
);
113 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08lx\n", hRes
);
114 ok( GetLastError() == 0xdeadbeef,
115 "Expected 0xdeadbeef, got 0x%08lx\n",
119 static void test_OpenThemeData(void)
125 WCHAR szInvalidClassList
[] = {'D','E','A','D','B','E','E','F', 0 };
126 WCHAR szButtonClassList
[] = {'B','u','t','t','o','n', 0 };
127 WCHAR szClassList
[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
129 bThemeActive
= pIsThemeActive();
132 SetLastError(0xdeadbeef);
133 hTheme
= pOpenThemeData(NULL
, NULL
);
134 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
136 ok( GetLastError() == E_POINTER
,
137 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
140 /* A NULL hWnd and an invalid classlist */
141 SetLastError(0xdeadbeef);
142 hTheme
= pOpenThemeData(NULL
, szInvalidClassList
);
143 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
145 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
146 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
149 SetLastError(0xdeadbeef);
150 hTheme
= pOpenThemeData(NULL
, szClassList
);
153 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
155 ok( GetLastError() == ERROR_SUCCESS
,
156 "Expected ERROR_SUCCESS, got 0x%08lx\n",
161 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
163 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
164 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
168 /* Only do the bare minumum to get a valid hdc */
169 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
172 SetLastError(0xdeadbeef);
173 hTheme
= pOpenThemeData(hWnd
, NULL
);
174 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
176 ok( GetLastError() == E_POINTER
,
177 "Expected GLE() to be E_POINTER, got 0x%08lx\n",
180 SetLastError(0xdeadbeef);
181 hTheme
= pOpenThemeData(hWnd
, szInvalidClassList
);
182 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
184 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
185 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
191 SetLastError(0xdeadbeef);
192 hTheme
= pOpenThemeData(hWnd
, szButtonClassList
);
193 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
195 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
196 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
198 trace("No active theme, skipping rest of OpenThemeData tests\n");
202 /* Only do the next checks if we have an active theme */
204 SetLastError(0xdeadbeef);
205 hTheme
= pOpenThemeData(hWnd
, szButtonClassList
);
206 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
208 ok( GetLastError() == ERROR_SUCCESS
,
209 "Expected ERROR_SUCCESS, got 0x%08lx\n",
212 SetLastError(0xdeadbeef);
213 hTheme
= pOpenThemeData(hWnd
, szClassList
);
214 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
216 ok( GetLastError() == ERROR_SUCCESS
,
217 "Expected ERROR_SUCCESS, got 0x%08lx\n",
221 static void test_CloseThemeData(void)
225 SetLastError(0xdeadbeef);
226 hRes
= pCloseThemeData(NULL
);
227 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08lx\n", hRes
);
228 ok( GetLastError() == 0xdeadbeef,
229 "Expected 0xdeadbeef, got 0x%08lx\n",
235 if(!InitFunctionPtrs())
238 /* No real functional tests will be done (yet). The current tests
239 * only show input/return behaviour
242 /* IsThemeActive and IsAppThemed */
243 trace("Starting test_IsThemed()\n");
244 if (pIsAppThemed
&& pIsThemeActive
)
248 trace("Starting test_SetWindowTheme()\n");
250 test_SetWindowTheme();
253 trace("Starting test_OpenThemeData()\n");
254 if (pOpenThemeData
&& pIsThemeActive
)
255 test_OpenThemeData();
258 trace("Starting test_CloseThemeData()\n");
260 test_CloseThemeData();
262 FreeLibrary(hUxtheme
);