Exemple #1
0
void Test_msg_simple()
{
    SetCursorPos(0,0);

    create_test_windows();
    set_default_zorder();

    SetActiveWindow(hWnd1);
    FlushMessages();
    COMPARE_CACHE(activate2to1_chain);

    SetActiveWindow(hWnd2);
    FlushMessages();
    COMPARE_CACHE(activate1to2_chain);

    destroy_test_window();
}
Exemple #2
0
static void Test_NonClientMetrics()
{
    NONCLIENTMETRICS NonClientMetrics;

    /* WARNING: this test requires themes and dwm to be disabled */

    SetCursorPos(0,0);

    /* Retrieve th non client metrics */
    NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
    FlushMessages();
    COMPARE_CACHE(empty_chain);

    /* Set the non client metric without making any change */
    SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
    FlushMessages();
    COMPARE_CACHE(NcMetricsChange_chain);

    /* Set the same metrics again with the SPIF_SENDCHANGE param */
    SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
    FlushMessages();
    COMPARE_CACHE(NcMetricsChange1_chain);

    /* Slightly change the caption height */
    NonClientMetrics.iCaptionHeight += 1;
    SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
    FlushMessages();
    COMPARE_CACHE(CaptionHeight_chain);

    /* Restore the original caption height */
    NonClientMetrics.iCaptionHeight -= 1;
    SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
    FlushMessages();
    COMPARE_CACHE(CaptionHeight_chain);
}
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);

}
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);

}
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();
}