[USER32_APITEST] -Move the helper functions in the common include directory
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Tue, 7 Mar 2017 22:29:48 +0000 (22:29 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Tue, 7 Mar 2017 22:29:48 +0000 (22:29 +0000)
[UXTHEME_APITEST] -Use the helper functions to test the messages sent by DrawThemeParentBackground

svn path=/trunk/; revision=74123

19 files changed:
rostests/apitests/CMakeLists.txt
rostests/apitests/include/msgtrace.c [moved from rostests/apitests/user32/helper.c with 93% similarity]
rostests/apitests/include/msgtrace.h [moved from rostests/apitests/user32/helper.h with 97% similarity]
rostests/apitests/include/user32testhelpers.h [new file with mode: 0644]
rostests/apitests/user32/AttachThreadInput.c
rostests/apitests/user32/CMakeLists.txt
rostests/apitests/user32/DeferWindowPos.c
rostests/apitests/user32/GetDCEx.c
rostests/apitests/user32/RegisterClassEx.c
rostests/apitests/user32/SendMessageTimeout.c
rostests/apitests/user32/SetActiveWindow.c
rostests/apitests/user32/SetParent.c
rostests/apitests/user32/SetProp.c
rostests/apitests/user32/SystemParametersInfo.c
rostests/apitests/user32/TrackMouseEvent.c
rostests/apitests/user32/desktop.c
rostests/apitests/uxtheme/CMakeLists.txt [new file with mode: 0644]
rostests/apitests/uxtheme/DrawThemeParentBackground.c [new file with mode: 0644]
rostests/apitests/uxtheme/testlist.c [new file with mode: 0644]

index f240b57..3999bfc 100644 (file)
@@ -34,6 +34,7 @@ add_subdirectory(psapi)
 add_subdirectory(user32)
 add_subdirectory(user32_dynamic)
 add_subdirectory(userenv)
+add_subdirectory(uxtheme)
 if(NOT ARCH STREQUAL "amd64" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
     add_subdirectory(win32kdll)
     add_subdirectory(win32nt)
similarity index 93%
rename from rostests/apitests/user32/helper.c
rename to rostests/apitests/include/msgtrace.c
index 1a8bc0f..1a09208 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <stdio.h>
 #include <winuser.h>
-#include "helper.h"
+#include <msgtrace.h>
 #include <undocuser.h>
 
 MSG_CACHE default_cache = {
@@ -58,6 +58,10 @@ static char* get_msg_name(UINT msg)
         case WM_SETICON: return "WM_SETICON";
         case WM_KEYDOWN: return "WM_KEYDOWN";
         case WM_KEYUP: return "WM_KEYUP";
+        case WM_NOTIFY: return "WM_NOTIFY";
+        case WM_COMMAND: return "WM_COMMAND";
+        case WM_PRINTCLIENT: return "WM_PRINTCLIENT";
+        case WM_CTLCOLORSTATIC: return "WM_CTLCOLORSTATIC";
         default: return NULL;
     }
 }
@@ -203,16 +207,3 @@ void record_message(MSG_CACHE* cache, int iwnd, UINT message, MSG_TYPE type, int
 
     cache->count++;
 }
-
-ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
-{
-    WNDCLASSEXW wcex;
-
-    memset(&wcex, 0, sizeof(wcex));
-    wcex.cbSize = sizeof(WNDCLASSEX);
-    wcex.lpfnWndProc    = lpfnWndProc;
-    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
-    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
-    wcex.lpszClassName  = lpszClassName;
-    return RegisterClassExW(&wcex);
-}
similarity index 97%
rename from rostests/apitests/user32/helper.h
rename to rostests/apitests/include/msgtrace.h
index 6edb13f..e43183d 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef APITESTS_MSGTRACE_H
+#define APITESTS_MSGTRACE_H
 
 typedef enum _MSG_TYPE
 {
@@ -31,8 +33,6 @@ void compare_cache(MSG_CACHE* cache, const char* file, int line, MSG_ENTRY *msg_
 void trace_cache(MSG_CACHE* cache, const char* file, int line);
 void empty_message_cache(MSG_CACHE* cache);
 
-ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName);
-
 /* filter messages that are affected by dwm */
 static inline BOOL IsDWmMsg(UINT msg)
 {
@@ -68,3 +68,5 @@ static inline BOOL IseKeyMsg(UINT msg)
         if(notexpected)                                                                                                         \
             ok((status & (notexpected))!=(notexpected), "wrong queue status. got non expected %li\n", (DWORD)(notexpected));    \
     }
+
+#endif
\ No newline at end of file
diff --git a/rostests/apitests/include/user32testhelpers.h b/rostests/apitests/include/user32testhelpers.h
new file mode 100644 (file)
index 0000000..687af54
--- /dev/null
@@ -0,0 +1,13 @@
+
+static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
+{
+    WNDCLASSEXW wcex;
+
+    memset(&wcex, 0, sizeof(wcex));
+    wcex.cbSize = sizeof(WNDCLASSEX);
+    wcex.lpfnWndProc    = lpfnWndProc;
+    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
+    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
+    wcex.lpszClassName  = lpszClassName;
+    return RegisterClassExW(&wcex);
+}
index 8f77b4d..78b461d 100644 (file)
@@ -9,7 +9,8 @@
 
 #include <wingdi.h>
 #include <winuser.h>
-#include "helper.h"
+#include <msgtrace.h>
+#include <user32testhelpers.h>
 
 #define DESKTOP_ALL_ACCESS 0x01ff
 
index 2565662..bc4b769 100644 (file)
@@ -1,7 +1,7 @@
 
 list(APPEND SOURCE
     AttachThreadInput.c
-    helper.c
+    ../include/msgtrace.c
     CreateDialog.c
     CreateIconFromResourceEx.c
     CreateWindowEx.c
index debe212..223d489 100644 (file)
@@ -8,8 +8,9 @@
 #include <apitest.h>
 
 #include <winuser.h>
-#include "helper.h"
 #include <undocuser.h>
+#include <msgtrace.h>
+#include <user32testhelpers.h>
 
 HWND hWnd1, hWnd2, hWnd3, hWnd4;
 
index 0741434..b9a183f 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdio.h>
 #include <wine/test.h>
 #include <windows.h>
-#include "helper.h"
 
 #define DCX_USESTYLE 0x00010000
 
index e07e763..00cb046 100644 (file)
@@ -12,7 +12,6 @@
 #include <wchar.h>
 #include <wingdi.h>
 #include <winuser.h>
-#include "helper.h"
 #include <undocuser.h>
 
 static ATOM _RegisterClass(LPCWSTR lpwszClassName, HINSTANCE hInstance, UINT style, WNDPROC lpfnWndProc)
index 1bec5f3..90fcc31 100644 (file)
@@ -7,7 +7,9 @@
 
 #include <apitest.h>
 #include <winuser.h>
-#include "helper.h"
+
+#include <msgtrace.h>
+#include <user32testhelpers.h>
 
 static DWORD dwThread1;
 static DWORD dwThread2;
index fa4088c..4ba07cf 100644 (file)
@@ -9,9 +9,11 @@
 
 #include <wingdi.h>
 #include <winuser.h>
-#include "helper.h"
 #include <undocuser.h>
 
+#include <msgtrace.h>
+#include <user32testhelpers.h>
+
 HWND hWnd1, hWnd2;
 
 /* FIXME: test for HWND_TOP, etc...*/
index e8a503f..7ee1e40 100644 (file)
@@ -8,7 +8,8 @@
 #include <apitest.h>
 
 #include <winuser.h>
-#include "helper.h"
+#include <msgtrace.h>
+#include <user32testhelpers.h>
 
 static HWND hWndList[5 + 1];
 static const int hWndCount = sizeof(hWndList) / sizeof(hWndList[0]) - 1;
index 6cc377c..de57337 100644 (file)
@@ -6,9 +6,8 @@
  */
 
 #include <apitest.h>
-
 #include <winuser.h>
-#include "helper.h"
+#include <user32testhelpers.h>
 
 static ATOM Atom1, Atom2, Atom3;
 
index 0ff1231..2b84508 100644 (file)
@@ -9,9 +9,11 @@
 
 #include <wingdi.h>
 #include <winuser.h>
-#include "helper.h"
 #include <undocuser.h>
 
+#include <msgtrace.h>
+#include <user32testhelpers.h>
+
 HWND hWnd1, hWnd2;
 
 /* FIXME: test for HWND_TOP, etc...*/
index 70a857d..7cc7646 100644 (file)
@@ -6,12 +6,13 @@
  */
 
 #include <apitest.h>
-
 #include <wingdi.h>
 #include <winuser.h>
-#include "helper.h"
 #include <undocuser.h>
 
+#include <msgtrace.h>
+#include <user32testhelpers.h>
+
 HWND hWnd1, hWnd2, hWnd3;
 HHOOK hMouseHookLL, hMouseHook;
 int ignore_timer = 0, ignore_mouse = 0, ignore_mousell = 0;
index e1ad9a6..5fd2343 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdio.h>
 #include <wingdi.h>
 #include <winuser.h>
-#include "helper.h"
+#include <user32testhelpers.h>
 #include <ndk/umtypes.h>
 #include <ndk/obfuncs.h>
 
diff --git a/rostests/apitests/uxtheme/CMakeLists.txt b/rostests/apitests/uxtheme/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ec125a5
--- /dev/null
@@ -0,0 +1,11 @@
+
+list(APPEND SOURCE
+    DrawThemeParentBackground.c
+    ../include/msgtrace.c
+    testlist.c)
+
+add_executable(uxtheme_apitest ${SOURCE})
+target_link_libraries(uxtheme_apitest wine ${PSEH_LIB})
+set_module_type(uxtheme_apitest win32cui)
+add_importlibs(uxtheme_apitest uxtheme comctl32 user32 msvcrt kernel32)
+add_rostests_file(TARGET uxtheme_apitest)
diff --git a/rostests/apitests/uxtheme/DrawThemeParentBackground.c b/rostests/apitests/uxtheme/DrawThemeParentBackground.c
new file mode 100644 (file)
index 0000000..55e173a
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for DrawThemeParentBackground
+ * PROGRAMMERS:     Giannis Adamopoulos
+ */
+
+#include <apitest.h>
+#include <stdio.h>
+#include <windows.h>
+#include <uxtheme.h>
+#include <undocuser.h>
+#include <msgtrace.h>
+#include <user32testhelpers.h>
+
+HWND hWnd1, hWnd2;
+
+static int get_iwnd(HWND hWnd)
+{
+    if(hWnd == hWnd1) return 1;
+    else if(hWnd == hWnd2) return 2;
+    else return 0;
+}
+
+static LRESULT CALLBACK TestProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    int iwnd = get_iwnd(hwnd);
+    
+    if(message > WM_USER || !iwnd || message == WM_GETICON)
+        return DefWindowProc(hwnd, message, wParam, lParam);
+
+    RECORD_MESSAGE(iwnd, message, SENT, 0,0);
+    return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+static void FlushMessages()
+{
+    MSG msg;
+
+    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+    {
+        int iwnd = get_iwnd(msg.hwnd);
+        if(iwnd && msg.message <= WM_USER)
+            RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
+        DispatchMessageW( &msg );
+    }
+}
+
+MSG_ENTRY draw_parent_chain[]={{1, WM_ERASEBKGND},
+                               {1, WM_PRINTCLIENT},
+                               {0,0}};
+
+void Test_Messages()
+{
+    HDC hdc;
+    RECT rc;
+
+    RegisterSimpleClass(TestProc, L"testClass");
+
+    hWnd1 = CreateWindowW(L"testClass", L"Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);
+    ok (hWnd1 != NULL, "Expected CreateWindowW to succeed\n");
+    ShowWindow(hWnd1, SW_SHOW);
+    UpdateWindow(hWnd1);
+
+    hWnd2 = CreateWindowW(L"testClass", L"test window", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hWnd1, NULL, NULL, NULL);
+    ok (hWnd2 != NULL, "Expected CreateWindowW to succeed\n");
+    ShowWindow(hWnd2, SW_SHOW);
+    UpdateWindow(hWnd2);
+
+    FlushMessages();
+    EMPTY_CACHE();
+
+    DrawThemeParentBackground(hWnd2, NULL, NULL);
+    FlushMessages();
+    COMPARE_CACHE(empty_chain);
+
+    DrawThemeParentBackground(hWnd1, NULL, NULL);
+    FlushMessages();
+    COMPARE_CACHE(empty_chain);
+    
+    hdc = GetDC(hWnd1);
+    
+    DrawThemeParentBackground(hWnd2, hdc, NULL);
+    FlushMessages();
+    COMPARE_CACHE(draw_parent_chain);
+
+    DrawThemeParentBackground(hWnd1, hdc, NULL);
+    FlushMessages();
+    COMPARE_CACHE(empty_chain);
+    
+    memset(&rc, 0, sizeof(rc));
+    
+    DrawThemeParentBackground(hWnd2, hdc, &rc);
+    FlushMessages();
+    COMPARE_CACHE(draw_parent_chain);
+
+    DrawThemeParentBackground(hWnd1, hdc, &rc);
+    FlushMessages();
+    COMPARE_CACHE(empty_chain);
+}
+
+START_TEST(DrawThemeParentBackground)
+{
+    Test_Messages();
+}
\ No newline at end of file
diff --git a/rostests/apitests/uxtheme/testlist.c b/rostests/apitests/uxtheme/testlist.c
new file mode 100644 (file)
index 0000000..ca9af1c
--- /dev/null
@@ -0,0 +1,12 @@
+#define __ROS_LONG64__
+
+#define STANDALONE
+#include <apitest.h>
+
+extern void func_DrawThemeParentBackground(void);
+
+const struct test winetest_testlist[] =
+{
+    { "DrawThemeParentBackground", func_DrawThemeParentBackground },
+    { 0, 0 }
+};