~ps-jenkins/compiz/latestsnapshot-10.9.9daily13.06.1913.04-0ubuntu1

« back to all changes in this revision

Viewing changes to tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp

  • Committer: Sam Spilsbury
  • Date: 2013-03-06 12:31:24 UTC
  • mto: (3630.2.2 compiz.fix_1138517)
  • mto: This revision was merged to the branch mainline in revision 3633.
  • Revision ID: sam.spilsbury@canonical.com-20130306123124-82uf5tm171c67mch
Don't set lastFrameExtents unless the window geometry actually changed - as
that variable only exists to track changes in the actual geometry of
the window and not the apparant frame extents.
  
Added tests to verify that behaviour.
  
(LP: #1138517)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    return ct::AdvanceToNextEventOnSuccess (d, r);
56
56
}
57
57
 
 
58
Window GetImmediateParent (Display *display,
 
59
                           Window  w,
 
60
                           Window  &rootReturn)
 
61
{
 
62
    Window parentReturn = w;
 
63
    Window *childrenReturn;
 
64
    unsigned int nChildrenReturn;
 
65
 
 
66
    XQueryTree (display,
 
67
                w,
 
68
                &rootReturn,
 
69
                &parentReturn,
 
70
                &childrenReturn,
 
71
                &nChildrenReturn);
 
72
    XFree (childrenReturn);
 
73
 
 
74
    return parentReturn;
 
75
}
 
76
 
 
77
 
58
78
Window GetTopParent (Display *display,
59
79
                     Window w)
60
80
{
61
 
    Window rootReturn;
 
81
    Window rootReturn = 0;
62
82
    Window parentReturn = w;
63
 
    Window *childrenReturn;
64
 
    unsigned int nChildrenReturn;
65
 
 
66
83
    Window lastParent = 0;
67
84
 
68
85
    do
69
86
    {
70
87
        lastParent = parentReturn;
71
88
 
72
 
        XQueryTree (display,
73
 
                    lastParent,
74
 
                    &rootReturn,
75
 
                    &parentReturn,
76
 
                    &childrenReturn,
77
 
                    &nChildrenReturn);
78
 
        XFree (childrenReturn);
 
89
        parentReturn = GetImmediateParent (display,
 
90
                                           lastParent,
 
91
                                           rootReturn);
 
92
        
79
93
    } while (parentReturn != rootReturn);
80
94
 
81
95
    return lastParent;
565
579
                                   currentWidth + (left + right),
566
580
                                   currentHeight + (top + bottom)));
567
581
}
 
582
 
 
583
TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsUnmapped)
 
584
{
 
585
    ::Display *dpy = Display ();
 
586
 
 
587
    Window client = ct::CreateNormalWindow (dpy);
 
588
    WaitForWindowCreation (client);
 
589
 
 
590
    /* Set frame extents and get a response */
 
591
    int left = 1;
 
592
    int right = 1;
 
593
    int top = 1;
 
594
    int bottom = 1;
 
595
 
 
596
    int currentX, currentY;
 
597
    unsigned int currentWidth, currentHeight;
 
598
    ASSERT_TRUE (QueryGeometry (dpy,
 
599
                                client,
 
600
                                currentX,
 
601
                                currentY,
 
602
                                currentWidth,
 
603
                                currentHeight));
 
604
 
 
605
    /* We should get a response with our frame extents but it shouldn't actually
 
606
     * do anything to the client as it is unmapped */
 
607
    SendSetFrameExtentsRequest (client, left, right, top, bottom);
 
608
    ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));
 
609
 
 
610
    ASSERT_TRUE (VerifyWindowSize (client,
 
611
                                   currentX,
 
612
                                   currentY,
 
613
                                   currentWidth,
 
614
                                   currentHeight));
 
615
}
 
616
 
 
617
TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsCorrectMapBehaviour)
 
618
{
 
619
    ::Display *dpy = Display ();
 
620
 
 
621
    Window client = ct::CreateNormalWindow (dpy);
 
622
    WaitForWindowCreation (client);
 
623
 
 
624
    /* Set frame extents and get a response */
 
625
    int left = 1;
 
626
    int right = 1;
 
627
    int top = 1;
 
628
    int bottom = 1;
 
629
 
 
630
    int currentX, currentY;
 
631
    unsigned int currentWidth, currentHeight;
 
632
    ASSERT_TRUE (QueryGeometry (dpy,
 
633
                                client,
 
634
                                currentX,
 
635
                                currentY,
 
636
                                currentWidth,
 
637
                                currentHeight));
 
638
 
 
639
    SendSetFrameExtentsRequest (client, left, right, top, bottom);
 
640
    ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));
 
641
 
 
642
    /* Map the window */
 
643
    XMapRaised (dpy, client);
 
644
    WaitForReparentAndMap (dpy, client);
 
645
 
 
646
    /* Check the geometry of the frame */
 
647
    Window frame = GetTopParent (dpy, client);
 
648
    ASSERT_TRUE (VerifyWindowSize (frame,
 
649
                                   currentX,
 
650
                                   currentY,
 
651
                                   currentWidth + (left + right),
 
652
                                   currentHeight + (top + bottom)));
 
653
 
 
654
    /* Wrapper geometry is extents.xy, size.wh */
 
655
    Window root;
 
656
    Window wrapper = GetImmediateParent (dpy, client, root);
 
657
    ASSERT_TRUE (VerifyWindowSize (wrapper,
 
658
                                   left,
 
659
                                   top,
 
660
                                   currentWidth,
 
661
                                   currentHeight));
 
662
}
 
663
 
 
664
TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsConsistentBehaviourAfterMap)
 
665
{
 
666
    ::Display *dpy = Display ();
 
667
 
 
668
    Window client = ct::CreateNormalWindow (dpy);
 
669
    WaitForWindowCreation (client);
 
670
 
 
671
    /* Set frame extents and get a response */
 
672
    int left = 1;
 
673
    int right = 1;
 
674
    int top = 1;
 
675
    int bottom = 1;
 
676
 
 
677
    int currentX, currentY;
 
678
    unsigned int currentWidth, currentHeight;
 
679
    ASSERT_TRUE (QueryGeometry (dpy,
 
680
                                client,
 
681
                                currentX,
 
682
                                currentY,
 
683
                                currentWidth,
 
684
                                currentHeight));
 
685
 
 
686
    SendSetFrameExtentsRequest (client, left, right, top, bottom);
 
687
    ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));
 
688
 
 
689
    /* Map the window */
 
690
    XMapRaised (dpy, client);
 
691
    WaitForReparentAndMap (dpy, client);
 
692
 
 
693
    /* Send it another frame extents request */
 
694
    right = right + 1;
 
695
    bottom = bottom + 1;
 
696
 
 
697
    SendSetFrameExtentsRequest (client, left, right, top, bottom);
 
698
    ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));
 
699
 
 
700
    /* Check the geometry of the frame */
 
701
    Window frame = GetTopParent (dpy, client);
 
702
    ASSERT_TRUE (VerifyWindowSize (frame,
 
703
                                   currentX,
 
704
                                   currentY,
 
705
                                   currentWidth + (left + right),
 
706
                                   currentHeight + (top + bottom)));
 
707
 
 
708
    /* Wrapper geometry is extents.xy, size.wh */
 
709
    Window root;
 
710
    Window wrapper = GetImmediateParent (dpy, client, root);
 
711
    ASSERT_TRUE (VerifyWindowSize (wrapper,
 
712
                                   left,
 
713
                                   top,
 
714
                                   currentWidth,
 
715
                                   currentHeight));
 
716
}