2
* Compiz XOrg GTest, EWMH compliance
4
* Copyright (C) 2013 Sam Spilsbury
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.
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.
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
21
* Sam Spilsbury <smspillaz@gmail.com>
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>
35
#include <gtest_shared_tmpenv.h>
36
#include <gtest_shared_characterwrapper.h>
39
#include <X11/Xatom.h>
41
using ::testing::MatchResultListener;
42
using ::testing::MakeMatcher;
43
using ::testing::Matcher;
45
namespace ct = compiz::testing;
49
unsigned int DEFAULT_VIEWPORT_WIDTH = 4;
50
unsigned int DEFAULT_VIEWPORT_HEIGHT = 1;
52
bool Advance (Display *d, bool r)
54
return ct::AdvanceToNextEventOnSuccess (d, r);
59
class CompizXorgSystemEWMH :
60
public ct::CompizXorgSystemTest
66
ct::CompizXorgSystemTest::SetUp ();
68
::Display *dpy = Display ();
70
XSelectInput (dpy, DefaultRootWindow (dpy),
77
ASSERT_TRUE (XGetGeometry (dpy, DefaultRootWindow (dpy),
87
unsigned int screenWidth;
88
unsigned int screenHeight;
93
TEST_F (CompizXorgSystemEWMH, InitialViewportGeometry)
95
::Display *dpy = Display ();
96
StartCompiz (static_cast <ct::CompizProcess::StartupFlags> (
97
ct::CompizProcess::ReplaceCurrentWM));
99
ct::PropertyNotifyXEventMatcher desktopHintsProperty (dpy,
100
"_NET_DESKTOP_GEOMETRY");
102
/* Assert that we get the property update */
103
ASSERT_TRUE (Advance (dpy,
104
ct::WaitForEventOfTypeOnWindowMatching (dpy,
105
DefaultRootWindow (dpy),
109
desktopHintsProperty)));
111
unsigned int expectedDefaultWidth = screenWidth * DEFAULT_VIEWPORT_WIDTH;
112
unsigned int expectedDefaultHeight = screenHeight * DEFAULT_VIEWPORT_HEIGHT;
116
unsigned long nItems, bytesAfter;
117
unsigned char *property;
120
XGetWindowProperty (dpy,
121
DefaultRootWindow (dpy),
122
XInternAtom (dpy, "_NET_DESKTOP_GEOMETRY", False),
133
ASSERT_EQ (XA_CARDINAL, actualType);
134
ASSERT_EQ (32, actualFmt);
135
ASSERT_EQ (2, nItems);
137
unsigned long *geometry = reinterpret_cast <unsigned long *> (property);
139
EXPECT_EQ (expectedDefaultWidth, geometry[0]);
140
EXPECT_EQ (expectedDefaultHeight, geometry[1]);