[UXTHEME] -Add tests for SetWindowTheme to test the behavior that was changed in...
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Fri, 10 Mar 2017 17:56:18 +0000 (17:56 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Fri, 10 Mar 2017 17:56:18 +0000 (17:56 +0000)
svn path=/trunk/; revision=74144

rostests/apitests/uxtheme/CMakeLists.txt
rostests/apitests/uxtheme/SetWindowTheme.c [new file with mode: 0644]
rostests/apitests/uxtheme/testlist.c

index a807a46..333a874 100644 (file)
@@ -2,6 +2,7 @@
 list(APPEND SOURCE
     CloseThemeData.c
     DrawThemeParentBackground.c
+    SetWindowTheme.c
     ../include/msgtrace.c
     testlist.c)
 
diff --git a/rostests/apitests/uxtheme/SetWindowTheme.c b/rostests/apitests/uxtheme/SetWindowTheme.c
new file mode 100644 (file)
index 0000000..ce2b1ad
--- /dev/null
@@ -0,0 +1,80 @@
+/*\r
+ * PROJECT:         ReactOS api tests\r
+ * LICENSE:         GPL - See COPYING in the top level directory\r
+ * PURPOSE:         Test for SetWindowTheme\r
+ * PROGRAMMERS:     Giannis Adamopoulos\r
+ */\r
+\r
+#include <apitest.h>\r
+#include <stdio.h>\r
+#include <windows.h>\r
+#include <uxtheme.h>\r
+\r
+void TestParams(HWND hwnd)\r
+{\r
+    HRESULT hr;\r
+\r
+    hr = SetWindowTheme(0, NULL, NULL);\r
+    ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);\r
+\r
+    hr = SetWindowTheme((HWND)0xdeaddead, NULL, NULL);\r
+    ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);\r
+\r
+    hr = SetWindowTheme(hwnd, NULL, NULL);\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    hr = SetWindowTheme(hwnd, L"none", L"none");\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    hr = SetWindowTheme(hwnd, NULL, L"none");\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    hr = SetWindowTheme(hwnd, L"none", NULL);\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    hr = SetWindowTheme(hwnd, L"", L"");\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+}\r
+\r
+void TestTheme(HWND hwnd)\r
+{\r
+    HRESULT hr;\r
+    HTHEME htheme1, htheme2;\r
+\r
+    hr = SetWindowTheme(hwnd, NULL, NULL);\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    htheme1 = OpenThemeData(hwnd, L"Toolbar");\r
+    ok (htheme1 != NULL, "OpenThemeData failed\n");\r
+\r
+    hr = SetWindowTheme(hwnd, L"", L"");\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    htheme2 = OpenThemeData(hwnd, L"Toolbar");\r
+    ok (htheme2 == NULL, "Expected OpenThemeData to fail\n");\r
+\r
+    hr = SetWindowTheme(hwnd, L"TrayNotify", L"");\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    htheme2 = OpenThemeData(hwnd, L"Toolbar");\r
+    ok (htheme2 == NULL, "Expected OpenThemeData to fail\n");\r
+\r
+    hr = SetWindowTheme(hwnd, L"TrayNotify", NULL);\r
+    ok (hr == S_OK, "Expected S_OK got 0x%lx error\n", hr);\r
+\r
+    htheme2 = OpenThemeData(hwnd, L"Toolbar");\r
+    ok (htheme2 != NULL, "OpenThemeData failed\n");\r
+\r
+    ok(htheme1 != htheme2, "Expected different theme data\n");\r
+}\r
+\r
+START_TEST(SetWindowTheme)\r
+{\r
+    HWND hwnd;\r
+\r
+    hwnd = CreateWindowW(L"button", L"Test window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);\r
+    ok (hwnd != NULL, "Expected CreateWindowW to succeed\n");\r
+\r
+    TestParams(hwnd);\r
+    TestTheme(hwnd);\r
+}
\ No newline at end of file
index 97ee80e..7b06a3f 100644 (file)
@@ -3,12 +3,14 @@
 #define STANDALONE
 #include <apitest.h>
 
-extern void func_DrawThemeParentBackground(void);
 extern void func_CloseThemeData(void);
+extern void func_DrawThemeParentBackground(void);
+extern void func_SetWindowTheme(void);
 
 const struct test winetest_testlist[] =
 {
-    { "DrawThemeParentBackground", func_DrawThemeParentBackground },
     { "CloseThemeData", func_CloseThemeData },
+    { "DrawThemeParentBackground", func_DrawThemeParentBackground },
+    { "SetWindowTheme", func_SetWindowTheme },
     { 0, 0 }
 };