Merge lp:~smspillaz/compiz-grid-plugin/oneiric.fix_891886_tests into lp:~3v1n0/compiz-grid-plugin/oneiric.fix_891886

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 94
Proposed branch: lp:~smspillaz/compiz-grid-plugin/oneiric.fix_891886_tests
Merge into: lp:~3v1n0/compiz-grid-plugin/oneiric.fix_891886
Diff against target: 208 lines (+142/-5)
6 files modified
CMakeLists.txt (+2/-0)
src/grabhandler.cpp (+47/-0)
src/grabhandler.h (+31/-0)
src/grid.cpp (+6/-5)
tests/grabhandler/CMakeLists.txt (+9/-0)
tests/grabhandler/test-grid-grab-handler.cpp (+47/-0)
To merge this branch: bzr merge lp:~smspillaz/compiz-grid-plugin/oneiric.fix_891886_tests
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+82843@code.launchpad.net

Description of the change

Tests for bug 981886

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Merged, thanks a lot!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-09-29 11:18:56 +0000
3+++ CMakeLists.txt 2011-11-21 04:15:29 +0000
4@@ -5,3 +5,5 @@
5 set (CMAKE_CXX_FLAGS -std=c++0x)
6
7 compiz_plugin(grid PLUGINDEPS composite opengl)
8+
9+add_subdirectory (tests/grabhandler)
10
11=== added file 'src/grabhandler.cpp'
12--- src/grabhandler.cpp 1970-01-01 00:00:00 +0000
13+++ src/grabhandler.cpp 2011-11-21 04:15:29 +0000
14@@ -0,0 +1,47 @@
15+/*
16+ * Compiz Fusion Grid plugin
17+ *
18+ * Copyright (c) 2008 Stephen Kennedy <suasol@gmail.com>
19+ * Copyright (c) 2010 Scott Moreau <oreaus@gmail.com>
20+ *
21+ * This program is free software; you can redistribute it and/or
22+ * modify it under the terms of the GNU General Public License
23+ * as published by the Free Software Foundation; either version 2
24+ * of the License, or (at your option) any later version.
25+ *
26+ * This program is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU General Public License for more details.
30+ *
31+ * Description:
32+ *
33+ * Plugin to act like winsplit revolution (http://www.winsplit-revolution.com/)
34+ * use <Control><Alt>NUMPAD_KEY to move and tile your windows.
35+ *
36+ * Press the tiling keys several times to cycle through some tiling options.
37+ */
38+
39+#include "grabhandler.h"
40+
41+compiz::grid::window::GrabWindowHandler::GrabWindowHandler (unsigned int mask) :
42+ mMask (mask)
43+{
44+}
45+
46+compiz::grid::window::GrabWindowHandler::~GrabWindowHandler ()
47+{
48+}
49+
50+bool
51+compiz::grid::window::GrabWindowHandler::track ()
52+{
53+ return ((mMask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) &&
54+ !(mMask & CompWindowGrabResizeMask));
55+}
56+
57+bool
58+compiz::grid::window::GrabWindowHandler::resetResize ()
59+{
60+ return (mMask & CompWindowGrabResizeMask);
61+}
62
63=== added file 'src/grabhandler.h'
64--- src/grabhandler.h 1970-01-01 00:00:00 +0000
65+++ src/grabhandler.h 2011-11-21 04:15:29 +0000
66@@ -0,0 +1,31 @@
67+#define CompWindowGrabKeyMask (1 << 0)
68+#define CompWindowGrabButtonMask (1 << 1)
69+#define CompWindowGrabMoveMask (1 << 2)
70+#define CompWindowGrabResizeMask (1 << 3)
71+#define CompWindowGrabExternalAppMask (1 << 4)
72+
73+namespace compiz
74+{
75+namespace grid
76+{
77+namespace window
78+{
79+
80+class GrabWindowHandler
81+{
82+ public:
83+
84+ GrabWindowHandler (unsigned int mask);
85+ ~GrabWindowHandler ();
86+
87+ bool track ();
88+ bool resetResize ();
89+
90+ private:
91+
92+ unsigned int mMask;
93+
94+};
95+}
96+}
97+}
98
99=== modified file 'src/grid.cpp'
100--- src/grid.cpp 2011-11-19 18:19:19 +0000
101+++ src/grid.cpp 2011-11-21 04:15:29 +0000
102@@ -23,6 +23,7 @@
103 */
104
105 #include "grid.h"
106+#include "grabhandler.h"
107
108 using namespace GridWindowType;
109
110@@ -766,8 +767,9 @@
111 unsigned int state,
112 unsigned int mask)
113 {
114- if ((mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) &&
115- !(mask & CompWindowGrabResizeMask))
116+ compiz::grid::window::GrabWindowHandler gwHandler (mask);
117+
118+ if (gwHandler.track ())
119 {
120 gScreen->o[0].value ().set ((int) window->id ());
121
122@@ -781,8 +783,7 @@
123 originalSize = gScreen->slotToRect(window,
124 window->serverBorderRect ());
125 }
126-
127- if (mask & CompWindowGrabResizeMask)
128+ else if (gwHandler.resetResize ())
129 {
130 isGridResized = false;
131 resizeCount = 0;
132@@ -1019,7 +1020,7 @@
133 gridProps[GridRight] = GridProps {1,0, 2,1};
134 gridProps[GridTopLeft] = GridProps{0,0, 2,2};
135 gridProps[GridTop] = GridProps {0,0, 1,2};
136- gridProps[GridTopRight] = GridProps {0,0, 1,2};
137+ gridProps[GridTopRight] = GridProps {1,0, 2,2};
138 gridProps[GridMaximize] = GridProps {0,0, 1,1};
139
140 animations.clear ();
141
142=== added directory 'tests'
143=== added directory 'tests/grabhandler'
144=== added file 'tests/grabhandler/CMakeLists.txt'
145--- tests/grabhandler/CMakeLists.txt 1970-01-01 00:00:00 +0000
146+++ tests/grabhandler/CMakeLists.txt 2011-11-21 04:15:29 +0000
147@@ -0,0 +1,9 @@
148+include_directories (${compiz_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/src)
149+
150+add_executable (test-grid-grab-handler
151+ test-grid-grab-handler.cpp
152+ ../../src/grabhandler.cpp)
153+
154+target_link_libraries (test-grid-grab-handler pthread dl)
155+
156+add_test (test-grid-grab-handler-test test-grid-grab-handler)
157
158=== added file 'tests/grabhandler/test-grid-grab-handler.cpp'
159--- tests/grabhandler/test-grid-grab-handler.cpp 1970-01-01 00:00:00 +0000
160+++ tests/grabhandler/test-grid-grab-handler.cpp 2011-11-21 04:15:29 +0000
161@@ -0,0 +1,47 @@
162+#include <stdlib.h>
163+#include <iostream>
164+#include <string>
165+#include <grabhandler.h>
166+
167+/* FIXME: Not entirely portable, but we can't
168+ * include window.h without pulling in bunch of
169+ * static initalizers */
170+
171+#define CompWindowGrabKeyMask (1 << 0)
172+#define CompWindowGrabButtonMask (1 << 1)
173+#define CompWindowGrabMoveMask (1 << 2)
174+#define CompWindowGrabResizeMask (1 << 3)
175+#define CompWindowGrabExternalAppMask (1 << 4)
176+
177+void pass (const std::string &message)
178+{
179+ std::cout << "PASS: " << message << std::endl;
180+}
181+
182+void fail (const std::string &message)
183+{
184+ std::cout << "FAIL: " << message << std::endl;
185+ exit (1);
186+}
187+
188+int main (void)
189+{
190+ compiz::grid::window::GrabWindowHandler moveHandler (CompWindowGrabMoveMask |
191+ CompWindowGrabButtonMask);
192+ compiz::grid::window::GrabWindowHandler resizeHandler (CompWindowGrabButtonMask |
193+ CompWindowGrabResizeMask);
194+
195+ std::cout << "TEST: compiz::grid::window::GrabHandler" << std::endl;
196+
197+ if (moveHandler.track () && !moveHandler.resetResize ())
198+ pass ("compiz::grid::window::GrabHandler CompWindowGrabMoveMask | CompWindowGrabButtonMask");
199+ else
200+ fail ("compiz::grid::window::GrabHandler CompWindowGrabMoveMask | CompWindowGrabButtonMask");
201+
202+ if (!resizeHandler.track () && resizeHandler.resetResize ())
203+ pass ("compiz::grid::window::GrabHandler CompWindowGrabResizeMask | CompWindowGrabButtonMask");
204+ else
205+ fail ("compiz::grid::window::GrabHandler CompWindowGrabResizeMask | CompWindowGrabButtonMask");
206+
207+ return 0;
208+}

Subscribers

People subscribed via source and target branches