[uxtheme] Add framework and initial tests

Paul Vriens Paul.Vriens at xs4all.nl
Tue Jun 13 07:16:58 CDT 2006


Hi,

I've added the framework and some initial (simple) tests. No
functionality tests (yet), only parameter and return-value checking.

Only did system.c this time. Will use other files when more tests are
created to split things up link in uxtheme itself.

Changelog
  Added framework and initial tests

Cheers,

Paul.

---

 configure.ac                   |    1 
 dlls/uxtheme/tests/.gitignore  |    2 
 dlls/uxtheme/tests/Makefile.in |   13 ++
 dlls/uxtheme/tests/system.c    |  223 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 239 insertions(+), 0 deletions(-)
 create mode 100644 dlls/uxtheme/tests/.gitignore
 create mode 100644 dlls/uxtheme/tests/Makefile.in
 create mode 100644 dlls/uxtheme/tests/system.c

57eecb75d48af11c4d01268b7e10e8ad76a02611
diff --git a/configure.ac b/configure.ac
index 81c79b2..5b83b7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1724,6 +1724,7 @@ dlls/usp10/Makefile
 dlls/usp10/tests/Makefile
 dlls/uuid/Makefile
 dlls/uxtheme/Makefile
+dlls/uxtheme/tests/Makefile
 dlls/vdhcp.vxd/Makefile
 dlls/vdmdbg/Makefile
 dlls/version/Makefile
diff --git a/dlls/uxtheme/tests/.gitignore b/dlls/uxtheme/tests/.gitignore
new file mode 100644
index 0000000..5a0e4ce
--- /dev/null
+++ b/dlls/uxtheme/tests/.gitignore
@@ -0,0 +1,2 @@
+Makefile
+system.ok
diff --git a/dlls/uxtheme/tests/Makefile.in b/dlls/uxtheme/tests/Makefile.in
new file mode 100644
index 0000000..bca257b
--- /dev/null
+++ b/dlls/uxtheme/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = uxtheme.dll
+IMPORTS   = user32 kernel32
+
+CTESTS = \
+        system.c
+
+ at MAKE_TEST_RULES@
+
+### Dependencies:
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c
new file mode 100644
index 0000000..fe93660
--- /dev/null
+++ b/dlls/uxtheme/tests/system.c
@@ -0,0 +1,223 @@
+/* Unit test suite for uxtheme API functions
+ *
+ * Copyright 2006 Paul Vriens
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include <stdarg.h>
+
+#include "windows.h"
+#include "uxtheme.h"
+
+#include "wine/test.h"
+
+static HRESULT (WINAPI * pCloseThemeData)(HTHEME);
+static BOOL    (WINAPI * pIsThemeActive)(VOID);
+static HTHEME  (WINAPI * pOpenThemeData)(HWND, LPCWSTR);
+static HRESULT (WINAPI * pSetWindowTheme)(HWND, LPCWSTR, LPCWSTR);
+
+static HMODULE hUxtheme = 0;
+
+#define UXTHEME_GET_PROC(func) \
+    p ## func = (void*)GetProcAddress(hUxtheme, #func); \
+    if(!p ## func) { \
+      trace("GetProcAddress(%s) failed\n", #func); \
+      FreeLibrary(hUxtheme); \
+      return FALSE; \
+    }
+
+static BOOL InitFunctionPtrs(void)
+{
+    hUxtheme = LoadLibraryA("uxtheme.dll");
+    if(!hUxtheme) {
+      trace("Could not load uxtheme.dll\n");
+      return FALSE;
+    }
+    if (hUxtheme)
+    {
+      UXTHEME_GET_PROC(CloseThemeData)
+      UXTHEME_GET_PROC(IsThemeActive)
+      UXTHEME_GET_PROC(OpenThemeData)
+      UXTHEME_GET_PROC(SetWindowTheme)
+    }
+    return TRUE;
+}
+
+static void test_SetWindowTheme(void)
+{
+    HRESULT hRes;
+    HWND    hWnd;
+
+    SetLastError(0xdeadbeef);
+    hRes = pSetWindowTheme(NULL, NULL, NULL);
+    todo_wine
+        ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes);
+
+    /* Only do the bare minumum to get a valid hwnd */
+    hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
+    if (!hWnd) return;
+
+    SetLastError(0xdeadbeef);
+    hRes = pSetWindowTheme(hWnd, NULL, NULL);
+    ok( hRes == S_OK, "Expected S_OK, got 0x%08lx\n", hRes);
+}
+
+static void test_OpenThemeData(void)
+{
+    HTHEME    hTheme;
+    HWND      hWnd;
+    BOOL      bThemeActive;
+
+    WCHAR szInvalidClassList[] = {'D','E','A','D','B','E','E','F', 0 };
+    WCHAR szButtonClassList[]  = {'B','u','t','t','o','n', 0 };
+    WCHAR szClassList[]        = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
+
+    SetLastError(0xdeadbeef);
+    bThemeActive = pIsThemeActive();
+    todo_wine
+        ok( GetLastError() == S_OK,
+            "Expected S_OK, got 0x%08lx\n",
+            GetLastError());
+
+    /* All NULL */
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(NULL, NULL);
+    ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
+    todo_wine
+        ok( GetLastError() == E_POINTER,
+            "Expected GLE() to be E_POINTER, got 0x%08lx\n",
+            GetLastError());
+
+    /* A NULL hWnd and an invalid classlist */
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(NULL, szInvalidClassList);
+    ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
+    todo_wine
+        ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
+            "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
+            GetLastError());
+
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(NULL, szClassList);
+    if (bThemeActive)
+    {
+        ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
+        todo_wine
+            ok( GetLastError() == S_OK,
+                "Expected S_OK, got 0x%08lx\n",
+                GetLastError());
+    }
+    else
+    {
+        ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
+        todo_wine
+            ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
+                "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
+                GetLastError());
+    }
+
+    /* Only do the bare minumum to get a valid hdc */
+    hWnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
+    if (!hWnd) return;
+
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(hWnd, NULL);
+    ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
+    todo_wine
+        ok( GetLastError() == E_POINTER,
+            "Expected GLE() to be E_POINTER, got 0x%08lx\n",
+            GetLastError());
+
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(hWnd, szInvalidClassList);
+    ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
+    todo_wine
+        ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
+            "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
+            GetLastError());
+
+
+    if (!bThemeActive)
+    {
+        SetLastError(0xdeadbeef);
+        hTheme = pOpenThemeData(hWnd, szButtonClassList);
+        ok( hTheme == NULL, "Expected a NULL return, got %p\n", hTheme);
+        todo_wine
+            ok( GetLastError() == E_PROP_ID_UNSUPPORTED,
+                "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08lx\n",
+                GetLastError());
+        trace("No active theme, skipping rest of OpenThemeData tests\n");
+        return;
+    }
+
+    /* Only do the next checks if we have an active theme */
+
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(hWnd, szButtonClassList);
+    ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
+    todo_wine
+        ok( GetLastError() == S_OK,
+            "Expected S_OK, got 0x%08lx\n",
+            GetLastError());
+
+    SetLastError(0xdeadbeef);
+    hTheme = pOpenThemeData(hWnd, szClassList);
+    ok( hTheme != NULL, "got NULL, expected a HTHEME handle\n");
+    todo_wine
+        ok( GetLastError() == S_OK,
+            "Expected S_OK, got 0x%08lx\n",
+            GetLastError());
+}
+
+static void test_CloseThemeData(void)
+{
+    HRESULT hRes;
+
+    SetLastError(0xdeadbeef);
+    hRes = pCloseThemeData(NULL);
+    ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx", hRes);
+    ok( GetLastError() == 0xdeadbeef,
+        "Expected 0xdeadbeef, got 0x%08lx\n",
+        GetLastError());
+}
+
+START_TEST(system)
+{
+    if(!InitFunctionPtrs())
+        return;
+
+    /* No real functional tests will be done (yet). The current tests
+     * only show input/return behaviour
+     */
+
+    /* SetWindowTheme */
+    trace("Starting test_SetWindowTheme()\n");
+    if (pSetWindowTheme)
+        test_SetWindowTheme();
+
+    /* OpenThemeData */
+    trace("Starting test_OpenThemeData()\n");
+    if (pOpenThemeData && pIsThemeActive) 
+        test_OpenThemeData();
+
+    /* CloseThemeData */
+    trace("Starting test_CloseThemeData()\n");
+    if (pCloseThemeData)
+        test_CloseThemeData();
+
+    FreeLibrary(hUxtheme);
+}
-- 
1.3.3




More information about the wine-patches mailing list