Author: mjansen
Date: Sun May 28 17:40:48 2017
New Revision: 74691
URL:
http://svn.reactos.org/svn/reactos?rev=74691&view=rev
Log:
[USER32_APITEST] Add more tests to validate messages sent during window creation /
modifying of styles. CORE-12052
Modified:
trunk/rostests/apitests/user32/CreateWindowEx.c
Modified: trunk/rostests/apitests/user32/CreateWindowEx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/CreateWin…
==============================================================================
--- trunk/rostests/apitests/user32/CreateWindowEx.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/user32/CreateWindowEx.c [iso-8859-1] Sun May 28 17:40:48 2017
@@ -69,13 +69,20 @@
}
HWND g_TestWindow = NULL;
+HWND g_ChildWindow = NULL;
static int get_iwnd(HWND hWnd)
{
if (!g_TestWindow)
g_TestWindow = hWnd;
-
- return hWnd == g_TestWindow ? 1 : 0;
+ if (!g_ChildWindow && hWnd != g_TestWindow)
+ g_ChildWindow = hWnd;
+
+ if (hWnd == g_TestWindow)
+ return 1;
+ else if (hWnd == g_ChildWindow)
+ return 2;
+ return 0;
}
DWORD g_FaultLine = 0;
@@ -83,6 +90,11 @@
DWORD g_NcExpectExStyle = 0;
DWORD g_ExpectStyle = 0;
DWORD g_ExpectExStyle = 0;
+
+DWORD g_ChildNcExpectStyle = 0;
+DWORD g_ChildNcExpectExStyle = 0;
+DWORD g_ChildExpectStyle = 0;
+DWORD g_ChildExpectExStyle = 0;
#define ok_hex_(expression, result) \
do { \
@@ -265,6 +277,8 @@
RegisterSimpleClass(MSGTestProc, L"Test_Message_Window_XX");
+ g_ChangeStyle = 0;
+
g_ExpectStyle = g_NcExpectStyle = 0;
g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
g_FaultLine = __LINE__ + 1;
@@ -274,7 +288,7 @@
ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
COMPARE_CACHE(create_chain);
DestroyWindow(hWnd);
- g_TestWindow = NULL;
+ g_TestWindow = g_ChildWindow = NULL;
EMPTY_CACHE();
g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
@@ -286,7 +300,7 @@
ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
COMPARE_CACHE(create_chain);
DestroyWindow(hWnd);
- g_TestWindow = NULL;
+ g_TestWindow = g_ChildWindow = NULL;
EMPTY_CACHE();
g_ChangeStyle = 1;
@@ -300,7 +314,7 @@
ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
COMPARE_CACHE(Below8NonServer ? create_chain_modify_below8_nonsrv :
create_chain_modify);
DestroyWindow(hWnd);
- g_TestWindow = NULL;
+ g_TestWindow = g_ChildWindow = NULL;
EMPTY_CACHE();
g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
@@ -312,8 +326,326 @@
ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
COMPARE_CACHE(Below8NonServer ? create_chain_modify_below8_nonsrv :
create_chain_modify);
DestroyWindow(hWnd);
- g_TestWindow = NULL;
- EMPTY_CACHE();
+ g_TestWindow = g_ChildWindow = NULL;
+ EMPTY_CACHE();
+
+ UnregisterClassW(L"Test_Message_Window_XX", NULL);
+}
+
+
+static LRESULT CALLBACK MSGChildProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
+{
+ LRESULT lRet;
+ int iwnd = get_iwnd(hWnd);
+
+ if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
+ return DefWindowProc(hWnd, message, wParam, lParam);
+
+ switch(message)
+ {
+ case WM_IME_SETCONTEXT:
+ case WM_IME_NOTIFY:
+ case WM_GETICON:
+ case WM_GETTEXT:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ break;
+ case WM_NCCREATE:
+ {
+ LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ ok_hex_(create->style, g_ChildNcExpectStyle);
+ ok_hex_(create->dwExStyle, g_ChildNcExpectExStyle);
+
+ if (g_ChangeStyle)
+ {
+ DWORD dwStyle = GetWindowLong(g_TestWindow, GWL_EXSTYLE);
+ dwStyle &= ~(WS_EX_CLIENTEDGE);
+ SetWindowLong(g_TestWindow, GWL_EXSTYLE, dwStyle);
+ RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
+ SetWindowPos(g_TestWindow, NULL, 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE |
SWP_DRAWFRAME);
+
+ RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
+ ok_hex_(create->style, g_ChildNcExpectStyle);
+ ok_hex_(create->dwExStyle, g_ChildNcExpectExStyle);
+ }
+ }
+ break;
+ case WM_CREATE:
+ {
+ LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ ok_hex_(create->style, g_ChildExpectStyle);
+ ok_hex_(create->dwExStyle, g_ChildExpectExStyle);
+ }
+ break;
+ case WM_NCCALCSIZE:
+ case WM_STYLECHANGING:
+ case WM_STYLECHANGED:
+ case WM_SIZE:
+ RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
+ break;
+ case WM_WINDOWPOSCHANGING:
+ case WM_WINDOWPOSCHANGED:
+ ok(wParam == 0,"expected wParam=0\n");
+ RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
+ break;
+ default:
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ break;
+ }
+ lRet = DefWindowProc(hWnd, message, wParam, lParam);
+ RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
+ return lRet;
+}
+
+
+static LRESULT CALLBACK MSGTestProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
+{
+ LRESULT lRet;
+ int iwnd = get_iwnd(hWnd);
+
+ if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
+ return DefWindowProc(hWnd, message, wParam, lParam);
+
+ switch(message)
+ {
+ case WM_IME_SETCONTEXT:
+ case WM_IME_NOTIFY:
+ case WM_GETICON:
+ case WM_GETTEXT:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ break;
+ case WM_NCCREATE:
+ {
+ HWND child;
+ LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ ok_hex_(create->style, g_NcExpectStyle);
+ ok_hex_(create->dwExStyle, g_NcExpectExStyle);
+
+ child = CreateWindowExW(0, L"Test_Message_Window_Child2",
L"", WS_CHILD, 0, 0, 10, 10, hWnd, NULL, 0, NULL);
+ RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
+ ok_(__FILE__, g_FaultLine)(g_ChildWindow == child, "Testing against the
wrong child!\n");
+ }
+ break;
+ case WM_NCDESTROY:
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ DestroyWindow(g_ChildWindow);
+ break;
+ case WM_CREATE:
+ {
+ LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ ok_hex_(create->style, g_ExpectStyle);
+ ok_hex_(create->dwExStyle, g_ExpectExStyle);
+ }
+ break;
+ case WM_NCCALCSIZE:
+ case WM_STYLECHANGING:
+ case WM_STYLECHANGED:
+ case WM_SIZE:
+ RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
+ break;
+ case WM_WINDOWPOSCHANGING:
+ case WM_WINDOWPOSCHANGED:
+ ok(wParam == 0,"expected wParam=0\n");
+ RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
+ break;
+ default:
+ RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
+ break;
+ }
+ lRet = DefWindowProc(hWnd, message, wParam, lParam);
+ RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
+ return lRet;
+}
+
+
+MSG_ENTRY child_create_chain[] =
+{
+ { 1, WM_GETMINMAXINFO, SENT },
+ { 1, WM_GETMINMAXINFO, SENT_RET },
+ { 1, WM_NCCREATE, SENT },
+ { 2, WM_NCCREATE, SENT },
+ { 2, WM_NCCREATE, SENT_RET },
+ { 2, WM_NCCALCSIZE, SENT },
+ { 2, WM_NCCALCSIZE, SENT_RET },
+ { 2, WM_CREATE, SENT },
+ { 2, WM_CREATE, SENT_RET },
+ { 2, WM_SIZE, SENT },
+ { 2, WM_SIZE, SENT_RET },
+ { 2, WM_MOVE, SENT },
+ { 2, WM_MOVE, SENT_RET },
+ { 1, WM_PARENTNOTIFY, SENT },
+ { 1, WM_PARENTNOTIFY, SENT_RET },
+ { 1, WM_NCCREATE, MARKER },
+ { 1, WM_NCCREATE, SENT_RET },
+ { 1, WM_NCCALCSIZE, SENT },
+ { 1, WM_NCCALCSIZE, SENT_RET },
+ { 1, WM_CREATE, SENT },
+ { 1, WM_CREATE, SENT_RET },
+ { 0, 0 }
+};
+
+MSG_ENTRY child_create_chain_modify[] =
+{
+ { 1, WM_GETMINMAXINFO, SENT },
+ { 1, WM_GETMINMAXINFO, SENT_RET },
+ { 1, WM_NCCREATE, SENT },
+ { 2, WM_NCCREATE, SENT },
+ { 1, WM_STYLECHANGING, SENT, GWL_EXSTYLE },
+ { 1, WM_STYLECHANGING, SENT_RET },
+ { 1, WM_STYLECHANGED, SENT, GWL_EXSTYLE },
+ { 1, WM_STYLECHANGED, SENT_RET },
+ { 2, WM_NCCREATE, MARKER },
+ { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOACTIVATE | SWP_FRAMECHANGED },
+ { 1, WM_WINDOWPOSCHANGING, SENT_RET },
+ { 1, WM_NCCALCSIZE, SENT, TRUE },
+ { 1, WM_NCCALCSIZE, SENT_RET },
+ { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED },
+ { 1, WM_MOVE, SENT },
+ { 1, WM_MOVE, SENT_RET },
+ { 1, WM_SIZE, SENT },
+ { 1, WM_SIZE, SENT_RET },
+ { 1, WM_WINDOWPOSCHANGED, SENT_RET },
+ { 2, WM_NCCREATE, MARKER },
+ { 2, WM_NCCREATE, SENT_RET },
+ { 2, WM_NCCALCSIZE, SENT },
+ { 2, WM_NCCALCSIZE, SENT_RET },
+ { 2, WM_CREATE, SENT },
+ { 2, WM_CREATE, SENT_RET },
+ { 2, WM_SIZE, SENT },
+ { 2, WM_SIZE, SENT_RET },
+ { 2, WM_MOVE, SENT },
+ { 2, WM_MOVE, SENT_RET },
+ { 1, WM_PARENTNOTIFY, SENT },
+ { 1, WM_PARENTNOTIFY, SENT_RET },
+ { 1, WM_NCCREATE, MARKER },
+ { 1, WM_NCCREATE, SENT_RET },
+ { 1, WM_NCCALCSIZE, SENT },
+ { 1, WM_NCCALCSIZE, SENT_RET },
+ { 1, WM_CREATE, SENT },
+ { 1, WM_CREATE, SENT_RET },
+ { 0, 0 }
+};
+
+MSG_ENTRY child_create_chain_modify_below8_nonsrv[] =
+{
+ { 1, WM_GETMINMAXINFO, SENT },
+ { 1, WM_GETMINMAXINFO, SENT_RET },
+ { 1, WM_NCCREATE, SENT },
+ { 2, WM_NCCREATE, SENT },
+ { 1, WM_STYLECHANGING, SENT, GWL_EXSTYLE },
+ { 1, WM_STYLECHANGING, SENT_RET },
+ { 1, WM_STYLECHANGED, SENT, GWL_EXSTYLE },
+ { 1, WM_STYLECHANGED, SENT_RET },
+ { 2, WM_NCCREATE, MARKER },
+ { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOACTIVATE | SWP_FRAMECHANGED },
+ { 1, WM_WINDOWPOSCHANGING, SENT_RET },
+ { 1, WM_NCCALCSIZE, SENT, TRUE },
+ { 1, WM_NCCALCSIZE, SENT_RET },
+ { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED },
+ { 1, WM_MOVE, SENT },
+ { 1, WM_MOVE, SENT_RET },
+ { 1, WM_SIZE, SENT },
+ { 1, WM_SIZE, SENT_RET },
+ { 1, WM_WINDOWPOSCHANGED, SENT_RET },
+ { 1, WM_NCCALCSIZE, SENT, TRUE },
+ { 1, WM_NCCALCSIZE, SENT_RET },
+ { 2, WM_NCCREATE, MARKER },
+ { 2, WM_NCCREATE, SENT_RET },
+ { 2, WM_NCCALCSIZE, SENT },
+ { 2, WM_NCCALCSIZE, SENT_RET },
+ { 2, WM_CREATE, SENT },
+ { 2, WM_CREATE, SENT_RET },
+ { 2, WM_SIZE, SENT },
+ { 2, WM_SIZE, SENT_RET },
+ { 2, WM_MOVE, SENT },
+ { 2, WM_MOVE, SENT_RET },
+ { 1, WM_PARENTNOTIFY, SENT },
+ { 1, WM_PARENTNOTIFY, SENT_RET },
+ { 1, WM_NCCREATE, MARKER },
+ { 1, WM_NCCREATE, SENT_RET },
+ { 1, WM_NCCALCSIZE, SENT },
+ { 1, WM_NCCALCSIZE, SENT_RET },
+ { 1, WM_CREATE, SENT },
+ { 1, WM_CREATE, SENT_RET },
+ { 0, 0 }
+};
+
+
+
+static void Test_Messages_Child(void)
+{
+ HWND hWnd;
+ BOOL Below8NonServer = !IsWindows8OrGreater() && !IsWindowsServer();
+
+ RegisterSimpleClass(MSGTestProc2, L"Test_Message_Window_X2");
+ RegisterSimpleClass(MSGChildProc2, L"Test_Message_Window_Child2");
+
+ g_ChangeStyle = 0;
+
+ g_ExpectStyle = g_NcExpectStyle = 0;
+ g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
+ g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
+ g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
+ g_FaultLine = __LINE__ + 1;
+ hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2",
L"", 0, 10, 20,
+ 200, 210, NULL, NULL, 0, NULL);
+
+ ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
+ COMPARE_CACHE(child_create_chain);
+ DestroyWindow(hWnd);
+ g_TestWindow = g_ChildWindow = NULL;
+ EMPTY_CACHE();
+
+ g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
+ g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
+ g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
+ g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
+ g_FaultLine = __LINE__ + 1;
+ hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2",
L"", WS_OVERLAPPEDWINDOW, 10, 20,
+ 200, 210, NULL, NULL, 0, NULL);
+
+ ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
+ COMPARE_CACHE(child_create_chain);
+ DestroyWindow(hWnd);
+ g_TestWindow = g_ChildWindow = NULL;
+ EMPTY_CACHE();
+
+ g_ChangeStyle = 1;
+
+ g_ExpectStyle = g_NcExpectStyle = 0;
+ g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
+ g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
+ g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
+ g_FaultLine = __LINE__ + 1;
+ hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2",
L"", 0, 10, 20,
+ 200, 210, NULL, NULL, 0, NULL);
+
+ ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
+ COMPARE_CACHE(Below8NonServer ? child_create_chain_modify_below8_nonsrv :
child_create_chain_modify);
+ DestroyWindow(hWnd);
+ g_TestWindow = g_ChildWindow = NULL;
+ EMPTY_CACHE();
+
+ g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
+ g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
+ g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
+ g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
+ g_FaultLine = __LINE__ + 1;
+ hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2",
L"", WS_OVERLAPPEDWINDOW, 10, 20,
+ 200, 210, NULL, NULL, 0, NULL);
+
+ ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n",
g_TestWindow, hWnd);
+ COMPARE_CACHE(Below8NonServer ? child_create_chain_modify_below8_nonsrv :
child_create_chain_modify);
+ DestroyWindow(hWnd);
+ g_TestWindow = g_ChildWindow = NULL;
+ EMPTY_CACHE();
+
+ UnregisterClassW(L"Test_Message_Window_X2", NULL);
+ UnregisterClassW(L"Test_Message_Window_Child2", NULL);
}
@@ -321,4 +653,5 @@
{
Test_Params();
Test_Messages();
-}
+ Test_Messages_Child();
+}