~ubuntu-branches/ubuntu/saucy/compiz/saucy-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Automatic PS uploader, Brandon Schaefer, Sam Spilsbury, Automatic PS uploader
  • Date: 2013-01-21 04:01:41 UTC
  • mfrom: (3248.176.3)
  • Revision ID: package-import@ubuntu.com-20130121040141-4gvyct89sywzgsqq
Tags: 1:0.9.9~daily13.01.21-0ubuntu1
[ Brandon Schaefer ]
* Window Management - Implement maximize and semi-maximise transitions
  (LP: #689792)

[ Sam Spilsbury ]
* Several memory leaks in ccsIntegratedSettingListAppend() from
  ccsIntegratedSettingsStorageDefaultFindMatchingSettingsByPredicate()
  from
  ccsIntegratedSettingsStorageDefaultFindMatchingSettingsByPluginAndSe
  ttingName() (LP: #1100539)
* Several leaks in g_settings_new() [g_object_new()] from
  ccsGSettingsNewNoPath() [ccs_gsettings_interface_wrapper.c:184] (LP:
  #1097649)
* Compiz reports incorrect _NET_DESKTOP_GEOMETRY until first viewport
  switch (LP: #1096455)

[ Automatic PS uploader ]
* Automatic snapshot from revision 3569

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Compiz XOrg GTest, EWMH compliance
 
3
 *
 
4
 * Copyright (C) 2013 Sam Spilsbury
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 *
 
20
 * Authored By:
 
21
 * Sam Spilsbury <smspillaz@gmail.com>
 
22
 */
 
23
#include <list>
 
24
#include <string>
 
25
#include <stdexcept>
 
26
#include <boost/function.hpp>
 
27
#include <boost/bind.hpp>
 
28
#include <boost/shared_ptr.hpp>
 
29
#include <boost/make_shared.hpp>
 
30
#include <gtest/gtest.h>
 
31
#include <gmock/gmock.h>
 
32
#include <xorg/gtest/xorg-gtest.h>
 
33
#include <compiz-xorg-gtest.h>
 
34
 
 
35
#include <gtest_shared_tmpenv.h>
 
36
#include <gtest_shared_characterwrapper.h>
 
37
 
 
38
#include <X11/Xlib.h>
 
39
#include <X11/Xatom.h>
 
40
 
 
41
using ::testing::MatchResultListener;
 
42
using ::testing::MakeMatcher;
 
43
using ::testing::Matcher;
 
44
 
 
45
namespace ct = compiz::testing;
 
46
 
 
47
namespace
 
48
{
 
49
unsigned int DEFAULT_VIEWPORT_WIDTH = 4;
 
50
unsigned int DEFAULT_VIEWPORT_HEIGHT = 1;
 
51
 
 
52
bool Advance (Display *d, bool r)
 
53
{
 
54
    return ct::AdvanceToNextEventOnSuccess (d, r);
 
55
}
 
56
 
 
57
}
 
58
 
 
59
class CompizXorgSystemEWMH :
 
60
    public ct::CompizXorgSystemTest
 
61
{
 
62
    public:
 
63
 
 
64
        virtual void SetUp ()
 
65
        {
 
66
            ct::CompizXorgSystemTest::SetUp ();
 
67
 
 
68
            ::Display *dpy = Display ();
 
69
 
 
70
            XSelectInput (dpy, DefaultRootWindow (dpy),
 
71
                          PropertyChangeMask);
 
72
 
 
73
            Window wDummy;
 
74
            unsigned int uiDummy;
 
75
            int iDummy;
 
76
 
 
77
            ASSERT_TRUE (XGetGeometry (dpy, DefaultRootWindow (dpy),
 
78
                                       &wDummy,
 
79
                                       &iDummy,
 
80
                                       &iDummy,
 
81
                                       &screenWidth,
 
82
                                       &screenHeight,
 
83
                                       &uiDummy,
 
84
                                       &uiDummy));
 
85
        }
 
86
 
 
87
        unsigned int screenWidth;
 
88
        unsigned int screenHeight;
 
89
 
 
90
    private:
 
91
};
 
92
 
 
93
TEST_F (CompizXorgSystemEWMH, InitialViewportGeometry)
 
94
{
 
95
    ::Display *dpy = Display ();
 
96
    StartCompiz (static_cast <ct::CompizProcess::StartupFlags> (
 
97
                     ct::CompizProcess::ReplaceCurrentWM));
 
98
 
 
99
    ct::PropertyNotifyXEventMatcher desktopHintsProperty (dpy,
 
100
                                                          "_NET_DESKTOP_GEOMETRY");
 
101
 
 
102
    /* Assert that we get the property update */
 
103
    ASSERT_TRUE (Advance (dpy,
 
104
                          ct::WaitForEventOfTypeOnWindowMatching (dpy,
 
105
                                                                  DefaultRootWindow (dpy),
 
106
                                                                  PropertyNotify,
 
107
                                                                  -1,
 
108
                                                                  -1,
 
109
                                                                  desktopHintsProperty)));
 
110
 
 
111
    unsigned int expectedDefaultWidth = screenWidth * DEFAULT_VIEWPORT_WIDTH;
 
112
    unsigned int expectedDefaultHeight = screenHeight * DEFAULT_VIEWPORT_HEIGHT;
 
113
 
 
114
    Atom actualType;
 
115
    int  actualFmt;
 
116
    unsigned long nItems, bytesAfter;
 
117
    unsigned char *property;
 
118
 
 
119
    ASSERT_EQ (Success,
 
120
               XGetWindowProperty (dpy,
 
121
                                   DefaultRootWindow (dpy),
 
122
                                   XInternAtom (dpy, "_NET_DESKTOP_GEOMETRY", False),
 
123
                                   0L,
 
124
                                   8L,
 
125
                                   False,
 
126
                                   XA_CARDINAL,
 
127
                                   &actualType,
 
128
                                   &actualFmt,
 
129
                                   &nItems,
 
130
                                   &bytesAfter,
 
131
                                   &property));
 
132
 
 
133
    ASSERT_EQ (XA_CARDINAL, actualType);
 
134
    ASSERT_EQ (32, actualFmt);
 
135
    ASSERT_EQ (2, nItems);
 
136
 
 
137
    unsigned long *geometry = reinterpret_cast <unsigned long *> (property);
 
138
 
 
139
    EXPECT_EQ (expectedDefaultWidth, geometry[0]);
 
140
    EXPECT_EQ (expectedDefaultHeight, geometry[1]);
 
141
 
 
142
    if (property)
 
143
        XFree (property);
 
144
}