static void Test_DWP_SimpleMsg(HWND hWnd1, HWND hWnd2) { HDWP hdwp; BOOL ret; SetWindowPos(hWnd1, 0, 10,20,100,100,0); SetWindowPos(hWnd2, 0, 10,20,100,100,0); FlushMessages(); EMPTY_CACHE(); /* move hWnd1 */ hdwp = BeginDeferWindowPos(1); ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 20, 30, 100, 100, SWP_NOACTIVATE|SWP_NOOWNERZORDER); ok(hdwp != NULL, "DeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(empty_chain); ret = EndDeferWindowPos(hdwp); ok(ret != 0, "EndDeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(move1_chain); /* resize hWnd1 */ hdwp = BeginDeferWindowPos(1); ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 20, 30, 110, 110, SWP_NOACTIVATE|SWP_NOOWNERZORDER); ok(hdwp != NULL, "DeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(empty_chain); ret = EndDeferWindowPos(hdwp); ok(ret != 0, "EndDeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(resize1_chain); /* move both windows */ hdwp = BeginDeferWindowPos(1); ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 30, 40, 110, 110, SWP_NOACTIVATE|SWP_NOOWNERZORDER); ok(hdwp != NULL, "DeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd2, HWND_TOP, 30, 40, 100, 100, SWP_NOACTIVATE|SWP_NOOWNERZORDER); ok(hdwp != NULL, "DeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(empty_chain); ret = EndDeferWindowPos(hdwp); ok(ret != 0, "EndDeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(move1_2_chain); /* change the z-order of the first window */ hdwp = BeginDeferWindowPos(1); ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd1, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE); ok(hdwp != NULL, "DeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(empty_chain); ret = EndDeferWindowPos(hdwp); ok(ret != 0, "EndDeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(ZOrder1_chain); /* change the z-order of both windows */ hdwp = BeginDeferWindowPos(2); ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd1, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE); ok(hdwp != NULL, "DeferWindowPos failed\n"); hdwp = DeferWindowPos(hdwp, hWnd2, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOSIZE); ok(hdwp != NULL, "DeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(empty_chain); ret = EndDeferWindowPos(hdwp); ok(ret != 0, "EndDeferWindowPos failed\n"); FlushMessages(); COMPARE_CACHE(ZOrder1and2_chain); }
static void OnServerFrame(float /*delta*/) { // Flush any queued messages FlushMessages(); }
static void Test_DWP_Error(HWND hWnd, HWND hWnd2) { HDWP hDwp; BOOL ret; ok_windowpos(hWnd1, 10, 20, 200, 210, "Window 1"); ok_windowpos(hWnd2, 30, 40, 220, 230, "Window 2"); /* close invalid handles */ SetLastError(DNS_ERROR_RCODE_NXRRSET); ret = EndDeferWindowPos(NULL); ok(ret == 0, "EndDeferWindowPos succeeded with invalid handle\n"); ok_lasterr(ERROR_INVALID_DWP_HANDLE, "EndDeferWindowPos"); SetLastError(DNS_ERROR_RCODE_NXRRSET); ret = EndDeferWindowPos((HDWP)-1); ok(ret == 0, "EndDeferWindowPos succeeded with invalid handle\n"); ok_lasterr(ERROR_INVALID_DWP_HANDLE, "EndDeferWindowPos"); /* negative window count */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(-1); ok(hDwp == NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(ERROR_INVALID_PARAMETER, "BeginDeferWindowPos"); /* zero windows */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(0); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "EndDeferWindowPos"); /* more windows than expected */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(0); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok(GetLastError() == ERROR_SUCCESS /* win7 sp1/x64 */ || GetLastError() == ERROR_INVALID_WINDOW_HANDLE /* 2k3 sp1/x86 */, "EndDeferWindowPos error = %lu\n", GetLastError()); ok_windowpos(hWnd, 10, 20, 200, 210, "Window 1"); /* more windows than expected 2 */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(1); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 30, 20, 190, 195, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd2, NULL, 20, 30, 195, 190, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); ok_windowpos(hWnd, 30, 20, 190, 195, "Window 1"); ok_windowpos(hWnd2, 20, 30, 195, 190, "Window 2"); /* fewer windows than expected */ MoveWindow(hWnd, 10, 20, 200, 210, FALSE); SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(2); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 20, 10, 210, 200, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "EndDeferWindowPos"); ok_windowpos(hWnd, 10, 20, 200, 210, "Window 1"); /* no operation, 1 window */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(1); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 20, 10, 210, 200, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "EndDeferWindowPos"); ok_windowpos(hWnd, 10, 20, 200, 210, "Window 1"); /* same window twice */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(2); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 80, 90, 220, 210, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 100, 110, 230, 250, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); ok_windowpos(hWnd, 100, 110, 230, 250, "Window 1"); /* move & resize operation, 1 window */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(1); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 20, 10, 210, 200, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); ok_windowpos(hWnd, 20, 10, 210, 200, "Window 1"); /* move & resize operation, 2 windows */ SetLastError(DNS_ERROR_RCODE_NXRRSET); hDwp = BeginDeferWindowPos(2); ok(hDwp != NULL, "BeginDeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "BeginDeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd, NULL, 50, 60, 230, 240, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); hDwp = DeferWindowPos(hDwp, hWnd2, NULL, 70, 80, 250, 260, SWP_NOZORDER); ok(hDwp != NULL, "DeferWindowPos failed\n"); ok_lasterr(DNS_ERROR_RCODE_NXRRSET, "DeferWindowPos"); ret = EndDeferWindowPos(hDwp); ok(ret != 0, "EndDeferWindowPos failed\n"); ok_lasterr(ERROR_SUCCESS, "EndDeferWindowPos"); ok_windowpos(hWnd, 50, 60, 230, 240, "Window 1"); ok_windowpos(hWnd2, 70, 80, 250, 260, "Window 2"); FlushMessages(); EMPTY_CACHE(); }
void Test_SendInput() { MSG_ENTRY Thread1_chain[]={ {1,WM_KEYDOWN, POST, VK_SHIFT, 0}, {1,WM_KEYUP, POST, VK_SHIFT, 0}, {0,0}}; MSG_ENTRY Thread0_chain[]={ {0,WM_KEYDOWN, POST, VK_SHIFT, 0}, {0,WM_KEYUP, POST, VK_SHIFT, 0}, {0,0}}; BOOL ret; /* First try sending input without attaching. It will go to the foreground */ { SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); ok(GetForegroundWindow() == data[1].hWnd, "wrong foreground\n"); ok(GetActiveWindow() == data[0].hWnd, "wrong active\n"); FlushMessages(); EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); keybd_event(VK_SHIFT, 0,0,0); keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); Sleep(100); FlushMessages(); COMPARE_CACHE_(&data[0].cache, empty_chain); COMPARE_CACHE_(&data[1].cache, Thread1_chain); } /* Next attach and send input. It will go to the same thread as before */ { ret = AttachThreadInput( data[1].tid, data[0].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); keybd_event(VK_SHIFT, 0,0,0); keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); Sleep(100); FlushMessages(); COMPARE_CACHE_(&data[0].cache, empty_chain); COMPARE_CACHE_(&data[1].cache, Thread1_chain); } /* Now set foregroung and active again. Input will go to thread 0 */ { SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); FlushMessages(); EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); keybd_event(VK_SHIFT, 0,0,0); keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); Sleep(100); FlushMessages(); COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, empty_chain); ret = AttachThreadInput( data[1].tid, data[0].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } /* Attach in the opposite order and send input */ { ret = AttachThreadInput( data[0].tid, data[1].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); keybd_event(VK_SHIFT, 0,0,0); keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); Sleep(100); FlushMessages(); COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, empty_chain); } /* Now set foregroung and active again. Input will go to thread 0 */ { SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); FlushMessages(); EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); keybd_event(VK_SHIFT, 0,0,0); keybd_event(VK_SHIFT, 0,KEYEVENTF_KEYUP,0); Sleep(100); FlushMessages(); COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, empty_chain); ret = AttachThreadInput( data[0].tid, data[1].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } }
/* test some functions like PostMessage and SendMessage that shouldn't be affected */ void Test_UnaffectedMessages() { BOOL ret; LRESULT res; EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); /* test that messages posted before and after attachment are unaffected and that we don't receive a meassage from a window we shouldn't */ PostMessage(data[0].hWnd, WM_USER, 0,0); PostMessage(data[1].hWnd, WM_USER, 1,0); { MSG_ENTRY Thread0_chain[]={ {0,WM_USER, POST, 0, 0}, {0,WM_USER, POST, 2, 0}, {0,0}}; MSG_ENTRY Thread1_chain[]={ {1,WM_USER, POST, 1, 0}, {1,WM_USER, POST, 3, 0}, {0,0}}; ret = AttachThreadInput( data[1].tid, data[0].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); PostMessage(data[0].hWnd, WM_USER, 2,0); PostMessage(data[1].hWnd, WM_USER, 3,0); FlushMessages(); Sleep(100); COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, Thread1_chain); ret = AttachThreadInput( data[1].tid, data[0].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } /* test messages send to the wrong thread */ res = SendMessageTimeout(data[0].hWnd, WM_USER, 0,0, SMTO_NORMAL, 1000, NULL); ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); res = SendMessageTimeout(data[1].hWnd, WM_USER, 1,0, SMTO_NORMAL, 1000, NULL); ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); { MSG_ENTRY Thread0_chain[]={ {0,WM_USER, SENT, 0, 0}, {0,WM_USER, SENT, 2, 0}, {0,0}}; MSG_ENTRY Thread1_chain[]={ {1,WM_USER, SENT, 1, 0}, {1,WM_USER, SENT, 3, 0}, {1,WM_MOUSEMOVE, SENT, 0, 0}, {0,0}}; ret = AttachThreadInput( data[2].tid, data[1].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); res = SendMessageTimeout(data[0].hWnd, WM_USER, 2,0, SMTO_NORMAL, 1000, NULL); ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); res = SendMessageTimeout(data[1].hWnd, WM_USER, 3,0, SMTO_NORMAL, 1000, NULL); ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); /* Try to send a fake input message */ res = SendMessageTimeout(data[1].hWnd, WM_MOUSEMOVE, 0,0, SMTO_NORMAL, 1000, NULL); ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, Thread1_chain); ret = AttachThreadInput( data[2].tid, data[1].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } /* todo: test keyboard layout that shouldn't be affected */ }
void Test_Focus() //Focus Active Capture Foreground Capture { BOOL ret; /* Window 1 is in the foreground */ SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); FlushMessages(); EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(data[0].hWnd); /* attach thread 0 to 1 */ { ret = AttachThreadInput( data[0].tid, data[1].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(data[1].hWnd); ret = AttachThreadInput( data[0].tid, data[1].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(0); SetForegroundWindow(data[1].hWnd); SetActiveWindow(data[0].hWnd); FlushMessages(); EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(data[0].hWnd); /* attach thread 1 to 0 */ { ret = AttachThreadInput( data[1].tid, data[0].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(data[1].hWnd); ret = AttachThreadInput( data[1].tid, data[0].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } /* Window 0 is in the foreground */ SetForegroundWindow(data[0].hWnd); SetActiveWindow(data[1].hWnd); FlushMessages(); EXPECT_FOREGROUND(data[0].hWnd); EXPECT_ACTIVE(data[0].hWnd); /* attach thread 0 to 1 */ { ret = AttachThreadInput( data[0].tid, data[1].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EXPECT_FOREGROUND(data[0].hWnd); EXPECT_ACTIVE(data[0].hWnd); SetForegroundWindow(data[0].hWnd); SetActiveWindow(data[1].hWnd); FlushMessages(); EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(data[1].hWnd); ret = AttachThreadInput( data[0].tid, data[1].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(0); SetForegroundWindow(data[0].hWnd); SetActiveWindow(data[1].hWnd); FlushMessages(); EXPECT_FOREGROUND(data[0].hWnd); EXPECT_ACTIVE(data[0].hWnd); /* attach thread 1 to 0 */ { ret = AttachThreadInput( data[1].tid, data[0].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); FlushMessages(); EXPECT_FOREGROUND(data[0].hWnd); EXPECT_ACTIVE(data[0].hWnd); SetForegroundWindow(data[0].hWnd); SetActiveWindow(data[1].hWnd); FlushMessages(); EXPECT_FOREGROUND(data[1].hWnd); EXPECT_ACTIVE(data[1].hWnd); ret = AttachThreadInput( data[1].tid, data[0].tid , FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } }
static void Test_DWP_OwnerZOrder() { EXPECT_CHAIN(4,3,1,2); /* test how SetWindowPos can change the z order of owner windows */ /* note that SWP_NOACTIVATE must be used because otherwise SetWindowPos will call SetWindowPos again with different parameters */ SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderAParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder1A_chain); EXPECT_CHAIN(4,3,1,2); SetWindowPos(hWnd2, 0, 0,0,0,0, OwnerZOrderAParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder2A_chain); EXPECT_CHAIN(2,4,3,1); SetWindowPos(hWnd3, 0, 0,0,0,0, OwnerZOrderAParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder3A_chain); EXPECT_CHAIN(3,4,1,2); SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderAParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder4A_chain); EXPECT_CHAIN(3,4,1,2); SetWindowPos(hWnd4, 0, 0,0,0,0, OwnerZOrderAParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder5A_chain); EXPECT_CHAIN(4,3,1,2); /* now do the same thing one more time with SWP_NOOWNERZORDER */ /* SWP_NOACTIVATE is needed because without it SetActiveWindow will be calledit and it will call SetWindowPos again WITHOUT SWP_NOOWNERZORDER. that means that in order for SWP_NOOWNERZORDER to have effect we have to use SWP_NOACTIVATE as well */ set_default_pos(); EXPECT_CHAIN(4,3,2,1); SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderBParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder1B_chain); EXPECT_CHAIN(1,4,3,2); SetWindowPos(hWnd2, 0, 0,0,0,0, OwnerZOrderBParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder2B_chain); EXPECT_CHAIN(2,1,4,3); SetWindowPos(hWnd3, 0, 0,0,0,0, OwnerZOrderBParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder3B_chain); EXPECT_CHAIN(3,2,1,4); SetWindowPos(hWnd1, 0, 0,0,0,0, OwnerZOrderBParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder4B_chain); EXPECT_CHAIN(1,3,2,4); SetWindowPos(hWnd4, 0, 0,0,0,0, OwnerZOrderBParams); FlushMessages(); COMPARE_CACHE(OwnerZOrder5B_chain); EXPECT_CHAIN(4,1,3,2); }
void Test_TrackMouseEvent() { MOVE_CURSOR(0,0); create_test_windows(); FlushMessages(); EMPTY_CACHE(); /* the mouse moves over hwnd2 */ MOVE_CURSOR(220,220); FlushMessages(); COMPARE_CACHE(mousemove2_chain); EXPECT_TME_FLAGS(hWnd2, 0); /* Begin tracking mouse events for hWnd2 */ TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE); EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE); FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse hovers hwnd2 */ MOVE_CURSOR(221, 221); Sleep(100); EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); EXPECT_TME_FLAGS(hWnd2, TME_LEAVE); COMPARE_CACHE(mousehover2_chain); /* the mouse leaves hwnd2 and moves to hwnd1 */ MOVE_CURSOR(150, 150); EXPECT_TME_FLAGS(hWnd2, TME_LEAVE); FLUSH_MESSAGES(QS_MOUSEMOVE,QS_TIMER ); EXPECT_TME_FLAGS(hWnd2, 0); COMPARE_CACHE(mouseleave2to1_chain); FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse moves over hwnd2 */ MOVE_CURSOR(220,220); FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER); COMPARE_CACHE(mousemove2_chain); EXPECT_TME_FLAGS(hWnd2, 0); FlushMessages(); COMPARE_CACHE(empty_chain); /* Begin tracking mouse events for hWnd2 */ TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE); TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE); TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE); TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(0, QS_TIMER|QS_MOUSEMOVE); COMPARE_CACHE(empty_chain); EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE); /* the mouse moves from hwnd2 to the intersection of hwnd2 and hwnd3 */ MOVE_CURSOR(300,300); FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER); EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE); COMPARE_CACHE(mousemove2_chain); FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse moves from hwnd2 to hwnd3 */ MOVE_CURSOR(400,400); FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER); EXPECT_TME_FLAGS(hWnd2, 0); COMPARE_CACHE(mouseleave2to3_chain); FlushMessages(); COMPARE_CACHE(empty_chain); /* Begin tracking mouse events for hWnd3 */ TmeStartTracking(hWnd3, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(0, QS_TIMER|QS_MOUSEMOVE); COMPARE_CACHE(empty_chain); EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE); /* the mouse hovers hwnd3 */ MOVE_CURSOR(401,401); Sleep(100); EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); COMPARE_CACHE(mousehover3_chain); FlushMessages(); COMPARE_CACHE(empty_chain); /* Begin tracking mouse events for hWnd3 */ TmeStartTracking(hWnd3, TME_HOVER ); FLUSH_MESSAGES(0, QS_TIMER|QS_MOUSEMOVE); COMPARE_CACHE(empty_chain); EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); /* make sure that the timer will fire before the mouse moves */ Sleep(100); FlushMessages(); COMPARE_CACHE(mousehover3_nomove_chain); EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); Sleep(100); FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse hovers hwnd3 and the timer is not dispatched*/ TmeStartTracking(hWnd3, TME_HOVER ); ignore_timer = TRUE; MOVE_CURSOR(400,400); Sleep(100); EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); /* the loop drops WM_SYSTIMER */ EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); /* TME_HOVER is still active */ COMPARE_CACHE(mousehover3_droptimer_chain); /* we get no WM_MOUSEHOVER */ ignore_timer = FALSE; /* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE_LL */ ignore_mousell = TRUE; MOVE_CURSOR(402,402); Sleep(100); EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(QS_TIMER, QS_MOUSEMOVE); /* WH_MOUSE_LL drops WM_MOUSEMOVE */ EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); COMPARE_CACHE(mousehover3_dropmousell_chain); /* we get WM_MOUSEHOVER normaly */ ignore_mousell = FALSE; FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE */ ignore_mouse = TRUE; TmeStartTracking(hWnd3, TME_HOVER ); MOVE_CURSOR(401,401); Sleep(100); EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); /* WH_MOUSE drops WM_MOUSEMOVE */ EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); COMPARE_CACHE(mousehover3_dropmouse_chain); /* we get WM_MOUSEHOVER normaly */ ignore_mouse = FALSE; FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE_LL */ ignore_mousell = TRUE; TmeStartTracking(hWnd3, TME_LEAVE ); MOVE_CURSOR(220,220); FLUSH_MESSAGES(0, QS_MOUSEMOVE|QS_TIMER); /* WH_MOUSE drops WM_MOUSEMOVE */ EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); /* all flags are removed */ COMPARE_CACHE(mouseleave3to2_dropmousell_chain); /* we get no WM_MOUSELEAVE */ ignore_mousell = FALSE; FlushMessages(); COMPARE_CACHE(empty_chain); /* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE */ ignore_mouse = TRUE; MOVE_CURSOR(220,220); FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER); /* WH_MOUSE drops WM_MOUSEMOVE */ EXPECT_TME_FLAGS(hWnd3, 0); /* all flags are removed */ COMPARE_CACHE(mouseleave3to2_dropmouse_chain); /* we get no WM_MOUSELEAVE */ ignore_mouse = FALSE; /* after WH_MOUSE drops WM_MOUSEMOVE, WM_MOUSELEAVE is still in the queue */ FLUSH_MESSAGES(QS_POSTMESSAGE, QS_TIMER|QS_MOUSEMOVE); COMPARE_CACHE(mouseleave3_remainging_chain); FlushMessages(); COMPARE_CACHE(empty_chain); destroy_test_window(); }