From 93bbc9d548fc23e989f08b995e2da2fd0bbeb660 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Tue, 7 Mar 2017 22:29:48 +0000 Subject: [PATCH] [USER32_APITEST] -Move the helper functions in the common include directory [UXTHEME_APITEST] -Use the helper functions to test the messages sent by DrawThemeParentBackground svn path=/trunk/; revision=74123 --- rostests/apitests/CMakeLists.txt | 1 + .../{user32/helper.c => include/msgtrace.c} | 19 +--- .../{user32/helper.h => include/msgtrace.h} | 6 +- rostests/apitests/include/user32testhelpers.h | 13 +++ rostests/apitests/user32/AttachThreadInput.c | 3 +- rostests/apitests/user32/CMakeLists.txt | 2 +- rostests/apitests/user32/DeferWindowPos.c | 3 +- rostests/apitests/user32/GetDCEx.c | 1 - rostests/apitests/user32/RegisterClassEx.c | 1 - rostests/apitests/user32/SendMessageTimeout.c | 4 +- rostests/apitests/user32/SetActiveWindow.c | 4 +- rostests/apitests/user32/SetParent.c | 3 +- rostests/apitests/user32/SetProp.c | 3 +- .../apitests/user32/SystemParametersInfo.c | 4 +- rostests/apitests/user32/TrackMouseEvent.c | 5 +- rostests/apitests/user32/desktop.c | 2 +- rostests/apitests/uxtheme/CMakeLists.txt | 11 ++ .../uxtheme/DrawThemeParentBackground.c | 105 ++++++++++++++++++ rostests/apitests/uxtheme/testlist.c | 12 ++ 19 files changed, 172 insertions(+), 30 deletions(-) rename rostests/apitests/{user32/helper.c => include/msgtrace.c} (93%) rename rostests/apitests/{user32/helper.h => include/msgtrace.h} (97%) create mode 100644 rostests/apitests/include/user32testhelpers.h create mode 100644 rostests/apitests/uxtheme/CMakeLists.txt create mode 100644 rostests/apitests/uxtheme/DrawThemeParentBackground.c create mode 100644 rostests/apitests/uxtheme/testlist.c diff --git a/rostests/apitests/CMakeLists.txt b/rostests/apitests/CMakeLists.txt index f240b57731e..3999bfc6c01 100644 --- a/rostests/apitests/CMakeLists.txt +++ b/rostests/apitests/CMakeLists.txt @@ -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) diff --git a/rostests/apitests/user32/helper.c b/rostests/apitests/include/msgtrace.c similarity index 93% rename from rostests/apitests/user32/helper.c rename to rostests/apitests/include/msgtrace.c index 1a8bc0f188c..1a09208ad3a 100644 --- a/rostests/apitests/user32/helper.c +++ b/rostests/apitests/include/msgtrace.c @@ -9,7 +9,7 @@ #include #include -#include "helper.h" +#include #include 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); -} diff --git a/rostests/apitests/user32/helper.h b/rostests/apitests/include/msgtrace.h similarity index 97% rename from rostests/apitests/user32/helper.h rename to rostests/apitests/include/msgtrace.h index 6edb13f8702..e43183d2227 100644 --- a/rostests/apitests/user32/helper.h +++ b/rostests/apitests/include/msgtrace.h @@ -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 index 00000000000..687af541a26 --- /dev/null +++ b/rostests/apitests/include/user32testhelpers.h @@ -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); +} diff --git a/rostests/apitests/user32/AttachThreadInput.c b/rostests/apitests/user32/AttachThreadInput.c index 8f77b4de721..78b461d0c61 100644 --- a/rostests/apitests/user32/AttachThreadInput.c +++ b/rostests/apitests/user32/AttachThreadInput.c @@ -9,7 +9,8 @@ #include #include -#include "helper.h" +#include +#include #define DESKTOP_ALL_ACCESS 0x01ff diff --git a/rostests/apitests/user32/CMakeLists.txt b/rostests/apitests/user32/CMakeLists.txt index 256566229f0..bc4b7693189 100644 --- a/rostests/apitests/user32/CMakeLists.txt +++ b/rostests/apitests/user32/CMakeLists.txt @@ -1,7 +1,7 @@ list(APPEND SOURCE AttachThreadInput.c - helper.c + ../include/msgtrace.c CreateDialog.c CreateIconFromResourceEx.c CreateWindowEx.c diff --git a/rostests/apitests/user32/DeferWindowPos.c b/rostests/apitests/user32/DeferWindowPos.c index debe2120919..223d4894960 100644 --- a/rostests/apitests/user32/DeferWindowPos.c +++ b/rostests/apitests/user32/DeferWindowPos.c @@ -8,8 +8,9 @@ #include #include -#include "helper.h" #include +#include +#include HWND hWnd1, hWnd2, hWnd3, hWnd4; diff --git a/rostests/apitests/user32/GetDCEx.c b/rostests/apitests/user32/GetDCEx.c index 0741434875c..b9a183fa3b7 100644 --- a/rostests/apitests/user32/GetDCEx.c +++ b/rostests/apitests/user32/GetDCEx.c @@ -8,7 +8,6 @@ #include #include #include -#include "helper.h" #define DCX_USESTYLE 0x00010000 diff --git a/rostests/apitests/user32/RegisterClassEx.c b/rostests/apitests/user32/RegisterClassEx.c index e07e76371a8..00cb0467074 100644 --- a/rostests/apitests/user32/RegisterClassEx.c +++ b/rostests/apitests/user32/RegisterClassEx.c @@ -12,7 +12,6 @@ #include #include #include -#include "helper.h" #include static ATOM _RegisterClass(LPCWSTR lpwszClassName, HINSTANCE hInstance, UINT style, WNDPROC lpfnWndProc) diff --git a/rostests/apitests/user32/SendMessageTimeout.c b/rostests/apitests/user32/SendMessageTimeout.c index 1bec5f3215e..90fcc316288 100644 --- a/rostests/apitests/user32/SendMessageTimeout.c +++ b/rostests/apitests/user32/SendMessageTimeout.c @@ -7,7 +7,9 @@ #include #include -#include "helper.h" + +#include +#include static DWORD dwThread1; static DWORD dwThread2; diff --git a/rostests/apitests/user32/SetActiveWindow.c b/rostests/apitests/user32/SetActiveWindow.c index fa4088c4ef8..4ba07cfd86f 100644 --- a/rostests/apitests/user32/SetActiveWindow.c +++ b/rostests/apitests/user32/SetActiveWindow.c @@ -9,9 +9,11 @@ #include #include -#include "helper.h" #include +#include +#include + HWND hWnd1, hWnd2; /* FIXME: test for HWND_TOP, etc...*/ diff --git a/rostests/apitests/user32/SetParent.c b/rostests/apitests/user32/SetParent.c index e8a503f60ac..7ee1e406dd9 100644 --- a/rostests/apitests/user32/SetParent.c +++ b/rostests/apitests/user32/SetParent.c @@ -8,7 +8,8 @@ #include #include -#include "helper.h" +#include +#include static HWND hWndList[5 + 1]; static const int hWndCount = sizeof(hWndList) / sizeof(hWndList[0]) - 1; diff --git a/rostests/apitests/user32/SetProp.c b/rostests/apitests/user32/SetProp.c index 6cc377c7694..de57337c230 100644 --- a/rostests/apitests/user32/SetProp.c +++ b/rostests/apitests/user32/SetProp.c @@ -6,9 +6,8 @@ */ #include - #include -#include "helper.h" +#include static ATOM Atom1, Atom2, Atom3; diff --git a/rostests/apitests/user32/SystemParametersInfo.c b/rostests/apitests/user32/SystemParametersInfo.c index 0ff12314920..2b845087154 100644 --- a/rostests/apitests/user32/SystemParametersInfo.c +++ b/rostests/apitests/user32/SystemParametersInfo.c @@ -9,9 +9,11 @@ #include #include -#include "helper.h" #include +#include +#include + HWND hWnd1, hWnd2; /* FIXME: test for HWND_TOP, etc...*/ diff --git a/rostests/apitests/user32/TrackMouseEvent.c b/rostests/apitests/user32/TrackMouseEvent.c index 70a857d276a..7cc76467e54 100644 --- a/rostests/apitests/user32/TrackMouseEvent.c +++ b/rostests/apitests/user32/TrackMouseEvent.c @@ -6,12 +6,13 @@ */ #include - #include #include -#include "helper.h" #include +#include +#include + HWND hWnd1, hWnd2, hWnd3; HHOOK hMouseHookLL, hMouseHook; int ignore_timer = 0, ignore_mouse = 0, ignore_mousell = 0; diff --git a/rostests/apitests/user32/desktop.c b/rostests/apitests/user32/desktop.c index e1ad9a698b2..5fd2343d0a8 100644 --- a/rostests/apitests/user32/desktop.c +++ b/rostests/apitests/user32/desktop.c @@ -12,7 +12,7 @@ #include #include #include -#include "helper.h" +#include #include #include diff --git a/rostests/apitests/uxtheme/CMakeLists.txt b/rostests/apitests/uxtheme/CMakeLists.txt new file mode 100644 index 00000000000..ec125a521de --- /dev/null +++ b/rostests/apitests/uxtheme/CMakeLists.txt @@ -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 index 00000000000..55e173ac291 --- /dev/null +++ b/rostests/apitests/uxtheme/DrawThemeParentBackground.c @@ -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 +#include +#include +#include +#include +#include +#include + +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 index 00000000000..ca9af1c2e5c --- /dev/null +++ b/rostests/apitests/uxtheme/testlist.c @@ -0,0 +1,12 @@ +#define __ROS_LONG64__ + +#define STANDALONE +#include + +extern void func_DrawThemeParentBackground(void); + +const struct test winetest_testlist[] = +{ + { "DrawThemeParentBackground", func_DrawThemeParentBackground }, + { 0, 0 } +}; -- 2.17.1