Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1408)

Side by Side Diff: test_lib.cc

Issue 6902072: wm: Update a lot of code to use structs from geometry.h. (Closed) Base URL: ssh://gitrw.chromium.org:9222/window_manager.git@master
Patch Set: move override-redirect stacking and visibility into Window Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "window_manager/test_lib.h" 5 #include "window_manager/test_lib.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 extern "C" { 9 extern "C" {
10 #include <X11/XF86keysym.h> 10 #include <X11/XF86keysym.h>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 compositor_.get(), 160 compositor_.get(),
161 dbus_.get())); 161 dbus_.get()));
162 } 162 }
163 163
164 void BasicWindowManagerTest::CreateAndInitNewWm() { 164 void BasicWindowManagerTest::CreateAndInitNewWm() {
165 CreateNewWm(); 165 CreateNewWm();
166 ASSERT_TRUE(wm_->Init()); 166 ASSERT_TRUE(wm_->Init());
167 } 167 }
168 168
169 XWindow BasicWindowManagerTest::CreateSimpleWindow() { 169 XWindow BasicWindowManagerTest::CreateSimpleWindow() {
170 return CreateBasicWindow(0, 0, 640, 480); 170 return CreateBasicWindow(Rect(0, 0, 640, 480));
171 } 171 }
172 172
173 XWindow BasicWindowManagerTest::CreateBasicWindow(int x, int y, 173 XWindow BasicWindowManagerTest::CreateBasicWindow(const Rect& bounds) {
174 int width, int height) {
175 return xconn_->CreateWindow( 174 return xconn_->CreateWindow(
176 xconn_->GetRootWindow(), 175 xconn_->GetRootWindow(),
177 Rect(x, y, width, height), 176 bounds,
178 false, // override redirect 177 false, // override redirect
179 false, // input only 178 false, // input only
180 0, 0); // event mask, visual 179 0, 0); // event mask, visual
181 } 180 }
182 181
183 XWindow BasicWindowManagerTest::CreateToplevelWindow(int tab_count, 182 XWindow BasicWindowManagerTest::CreateToplevelWindow(int tab_count,
184 int selected_tab, 183 int selected_tab,
185 int x, int y, 184 const Rect& bounds) {
186 int width, int height) { 185 XWindow xid = CreateBasicWindow(bounds);
187 XWindow xid = CreateBasicWindow(x, y, width, height);
188 ChangeTabInfo(xid, tab_count, selected_tab, wm_->GetCurrentTimeFromServer()); 186 ChangeTabInfo(xid, tab_count, selected_tab, wm_->GetCurrentTimeFromServer());
189 return xid; 187 return xid;
190 } 188 }
191 189
192 void BasicWindowManagerTest::ChangeTabInfo(XWindow toplevel_xid, 190 void BasicWindowManagerTest::ChangeTabInfo(XWindow toplevel_xid,
193 int tab_count, 191 int tab_count,
194 int selected_tab, 192 int selected_tab,
195 uint32_t timestamp) { 193 uint32_t timestamp) {
196 std::vector<int> params; 194 std::vector<int> params;
197 params.push_back(tab_count); 195 params.push_back(tab_count);
198 params.push_back(selected_tab); 196 params.push_back(selected_tab);
199 params.push_back(timestamp); 197 params.push_back(timestamp);
200 wm_->wm_ipc()->SetWindowType( 198 wm_->wm_ipc()->SetWindowType(
201 toplevel_xid, chromeos::WM_IPC_WINDOW_CHROME_TOPLEVEL, &params); 199 toplevel_xid, chromeos::WM_IPC_WINDOW_CHROME_TOPLEVEL, &params);
202 } 200 }
203 201
204 XWindow BasicWindowManagerTest::CreateFavIconWindow(XWindow snapshot_xid, 202 XWindow BasicWindowManagerTest::CreateFavIconWindow(XWindow snapshot_xid,
205 int width, int height) { 203 const Size& size) {
206 return CreateDecorationWindow(snapshot_xid, 204 return CreateDecorationWindow(snapshot_xid,
207 chromeos::WM_IPC_WINDOW_CHROME_TAB_FAV_ICON, 205 chromeos::WM_IPC_WINDOW_CHROME_TAB_FAV_ICON,
208 width, height); 206 size);
209 } 207 }
210 208
211 XWindow BasicWindowManagerTest::CreateTitleWindow(XWindow snapshot_xid, 209 XWindow BasicWindowManagerTest::CreateTitleWindow(XWindow snapshot_xid,
212 int width, int height) { 210 const Size& size) {
213 return CreateDecorationWindow(snapshot_xid, 211 return CreateDecorationWindow(snapshot_xid,
214 chromeos::WM_IPC_WINDOW_CHROME_TAB_TITLE, 212 chromeos::WM_IPC_WINDOW_CHROME_TAB_TITLE,
215 width, height); 213 size);
216 } 214 }
217 215
218 XWindow BasicWindowManagerTest::CreateDecorationWindow( 216 XWindow BasicWindowManagerTest::CreateDecorationWindow(
219 XWindow snapshot_xid, 217 XWindow snapshot_xid,
220 chromeos::WmIpcWindowType type, 218 chromeos::WmIpcWindowType type,
221 int width, int height) { 219 const Size& size) {
222 XWindow xid = CreateBasicWindow(0, 0, width, height); 220 XWindow xid = CreateBasicWindow(Rect(Point(0, 0), size));
223 std::vector<int> params; 221 std::vector<int> params;
224 params.push_back(snapshot_xid); 222 params.push_back(snapshot_xid);
225 wm_->wm_ipc()->SetWindowType(xid, type, &params); 223 wm_->wm_ipc()->SetWindowType(xid, type, &params);
226 224
227 return xid; 225 return xid;
228 } 226 }
229 227
230 XWindow BasicWindowManagerTest::CreateSnapshotWindow(XWindow parent_xid, 228 XWindow BasicWindowManagerTest::CreateSnapshotWindow(XWindow parent_xid,
231 int index, 229 int index,
232 int x, int y, 230 const Rect& bounds) {
233 int width, int height) { 231 XWindow xid = CreateBasicWindow(bounds);
234 XWindow xid = CreateBasicWindow(x, y, width, height);
235 std::vector<int> params; 232 std::vector<int> params;
236 params.push_back(parent_xid); 233 params.push_back(parent_xid);
237 params.push_back(index); 234 params.push_back(index);
238 wm_->wm_ipc()->SetWindowType( 235 wm_->wm_ipc()->SetWindowType(
239 xid, chromeos::WM_IPC_WINDOW_CHROME_TAB_SNAPSHOT, &params); 236 xid, chromeos::WM_IPC_WINDOW_CHROME_TAB_SNAPSHOT, &params);
240 237
241 return xid; 238 return xid;
242 } 239 }
243 240
244 XWindow BasicWindowManagerTest::CreateSimpleSnapshotWindow(XWindow parent_xid, 241 XWindow BasicWindowManagerTest::CreateSimpleSnapshotWindow(XWindow parent_xid,
245 int index) { 242 int index) {
246 return CreateSnapshotWindow(parent_xid, index, 0, 0, 320, 240); 243 return CreateSnapshotWindow(parent_xid, index, Rect(0, 0, 320, 240));
247 } 244 }
248 245
249 XWindow BasicWindowManagerTest::CreatePanelTitlebarWindow( 246 XWindow BasicWindowManagerTest::CreatePanelTitlebarWindow(const Size& size) {
250 int width, int height) { 247 XWindow xid = CreateBasicWindow(Rect(Point(0, 0), size));
251 XWindow xid = CreateBasicWindow(0, 0, width, height);
252 wm_->wm_ipc()->SetWindowType( 248 wm_->wm_ipc()->SetWindowType(
253 xid, chromeos::WM_IPC_WINDOW_CHROME_PANEL_TITLEBAR, NULL); 249 xid, chromeos::WM_IPC_WINDOW_CHROME_PANEL_TITLEBAR, NULL);
254 return xid; 250 return xid;
255 } 251 }
256 252
257 XWindow BasicWindowManagerTest::CreatePanelContentWindow( 253 XWindow BasicWindowManagerTest::CreatePanelContentWindow(const Size& size,
258 int width, int height, XWindow titlebar_xid) { 254 XWindow titlebar_xid) {
259 XWindow xid = CreateBasicWindow(0, 0, width, height); 255 XWindow xid = CreateBasicWindow(Rect(Point(0, 0), size));
260 std::vector<int> params; 256 std::vector<int> params;
261 params.push_back(titlebar_xid); 257 params.push_back(titlebar_xid);
262 params.push_back(new_panels_should_be_expanded_ ? 1 : 0); 258 params.push_back(new_panels_should_be_expanded_ ? 1 : 0);
263 params.push_back(new_panels_should_take_focus_ ? 1 : 0); 259 params.push_back(new_panels_should_take_focus_ ? 1 : 0);
264 params.push_back(creator_content_xid_for_new_panels_); 260 params.push_back(creator_content_xid_for_new_panels_);
265 params.push_back(resize_type_for_new_panels_); 261 params.push_back(resize_type_for_new_panels_);
266 wm_->wm_ipc()->SetWindowType( 262 wm_->wm_ipc()->SetWindowType(
267 xid, chromeos::WM_IPC_WINDOW_CHROME_PANEL_CONTENT, &params); 263 xid, chromeos::WM_IPC_WINDOW_CHROME_PANEL_CONTENT, &params);
268 return xid; 264 return xid;
269 } 265 }
270 266
271 Panel* BasicWindowManagerTest::CreatePanel( 267 Panel* BasicWindowManagerTest::CreatePanel(
272 int width, int titlebar_height, int content_height) { 268 int width, int titlebar_height, int content_height) {
273 XWindow titlebar_xid = CreatePanelTitlebarWindow(width, titlebar_height); 269 XWindow titlebar_xid =
270 CreatePanelTitlebarWindow(Size(width, titlebar_height));
274 SendInitialEventsForWindow(titlebar_xid); 271 SendInitialEventsForWindow(titlebar_xid);
275 XWindow content_xid = CreatePanelContentWindow( 272 XWindow content_xid =
276 width, content_height, titlebar_xid); 273 CreatePanelContentWindow(Size(width, content_height), titlebar_xid);
277 SendInitialEventsForWindow(content_xid); 274 SendInitialEventsForWindow(content_xid);
278 Panel* panel = wm_->panel_manager_->panel_bar_->GetPanelByWindow( 275 Panel* panel = wm_->panel_manager_->panel_bar_->GetPanelByWindow(
279 *(wm_->GetWindow(content_xid))); 276 *(wm_->GetWindow(content_xid)));
280 CHECK(panel); 277 CHECK(panel);
281 return panel; 278 return panel;
282 } 279 }
283 280
284 void BasicWindowManagerTest::SendInitialEventsForWindow(XWindow xid) { 281 void BasicWindowManagerTest::SendInitialEventsForWindow(XWindow xid) {
285 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); 282 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid);
286 XEvent event; 283 XEvent event;
287 284
288 // Send a CreateWindowEvent, a MapRequest event (if this is a 285 // Send a CreateWindowEvent, a MapRequest event (if this is a
289 // non-override-redirect window), and a MapNotify event (if the window 286 // non-override-redirect window), and a MapNotify event (if the window
290 // got mapped). After each event, send a ConfigureNotify if the window 287 // got mapped). After each event, send a ConfigureNotify if the window
291 // was configured by the window manager. 288 // was configured by the window manager.
292 xconn_->InitCreateWindowEvent(&event, xid); 289 xconn_->InitCreateWindowEvent(&event, xid);
293 int initial_num_configures = info->num_configures; 290 int initial_num_configures = info->num_configures;
294 wm_->HandleEvent(&event); 291 wm_->HandleEvent(&event);
295 if (info->num_configures != initial_num_configures) { 292 if (info->num_configures != initial_num_configures) {
296 xconn_->InitConfigureNotifyEvent(&event, xid); 293 SendConfigureNotifyEvent(xid);
297 wm_->HandleEvent(&event);
298 initial_num_configures = info->num_configures; 294 initial_num_configures = info->num_configures;
299 } 295 }
300 296
301 if (!info->override_redirect) { 297 if (!info->override_redirect) {
302 xconn_->InitMapRequestEvent(&event, xid); 298 xconn_->InitMapRequestEvent(&event, xid);
303 wm_->HandleEvent(&event); 299 wm_->HandleEvent(&event);
304 EXPECT_TRUE(info->mapped); 300 EXPECT_TRUE(info->mapped);
305 301
306 if (info->num_configures != initial_num_configures) { 302 if (info->num_configures != initial_num_configures) {
307 xconn_->InitConfigureNotifyEvent(&event, xid); 303 SendConfigureNotifyEvent(xid);
308 wm_->HandleEvent(&event);
309 initial_num_configures = info->num_configures; 304 initial_num_configures = info->num_configures;
310 } 305 }
311 } 306 }
312 307
313 if (info->mapped) { 308 if (info->mapped) {
314 xconn_->InitMapEvent(&event, xid); 309 xconn_->InitMapEvent(&event, xid);
315 wm_->HandleEvent(&event); 310 wm_->HandleEvent(&event);
316 if (info->num_configures != initial_num_configures) { 311 if (info->num_configures != initial_num_configures) {
317 xconn_->InitConfigureNotifyEvent(&event, xid); 312 SendConfigureNotifyEvent(xid);
318 wm_->HandleEvent(&event);
319 initial_num_configures = info->num_configures; 313 initial_num_configures = info->num_configures;
320 } 314 }
321 } 315 }
322 } 316 }
323 317
324 void BasicWindowManagerTest::SendUnmapAndDestroyEventsForWindow(XWindow xid) { 318 void BasicWindowManagerTest::SendUnmapAndDestroyEventsForWindow(XWindow xid) {
325 XEvent event; 319 XEvent event;
326 xconn_->InitUnmapEvent(&event, xid); 320 xconn_->InitUnmapEvent(&event, xid);
327 wm_->HandleEvent(&event); 321 wm_->HandleEvent(&event);
328 xconn_->InitDestroyWindowEvent(&event, xid); 322 xconn_->InitDestroyWindowEvent(&event, xid);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 XEvent event; 394 XEvent event;
401 xconn_->InitClientMessageEvent( 395 xconn_->InitClientMessageEvent(
402 &event, xid, xconn_->GetAtomOrDie("_NET_ACTIVE_WINDOW"), 396 &event, xid, xconn_->GetAtomOrDie("_NET_ACTIVE_WINDOW"),
403 1, // source indication (1 is from application) 397 1, // source indication (1 is from application)
404 0, // timestamp 398 0, // timestamp
405 0, // requestor's currently-active window 399 0, // requestor's currently-active window
406 0, 0); // unused 400 0, 0); // unused
407 wm_->HandleEvent(&event); 401 wm_->HandleEvent(&event);
408 } 402 }
409 403
410 void BasicWindowManagerTest::NotifyWindowAboutSize(Window* win) { 404 void BasicWindowManagerTest::SendConfigureNotifyEvent(XWindow xid) {
411 win->HandleConfigureNotify(win->client_width(), win->client_height()); 405 XEvent event;
406 xconn_->InitConfigureNotifyEvent(&event, xid);
407 if (xconn_->stacked_xids().Contains(xid)) {
408 const XWindow* above_xid = xconn_->stacked_xids().GetUnder(xid);
409 event.xconfigure.above = above_xid ? *above_xid : 0;
410 }
411 wm_->HandleEvent(&event);
412 } 412 }
413 413
414 void BasicWindowManagerTest::SetLoggedInState(bool logged_in) { 414 void BasicWindowManagerTest::SetLoggedInState(bool logged_in) {
415 XAtom logged_in_xatom = xconn_->GetAtomOrDie("_CHROME_LOGGED_IN"); 415 XAtom logged_in_xatom = xconn_->GetAtomOrDie("_CHROME_LOGGED_IN");
416 xconn_->SetIntProperty(xconn_->GetRootWindow(), 416 xconn_->SetIntProperty(xconn_->GetRootWindow(),
417 logged_in_xatom, 417 logged_in_xatom,
418 logged_in_xatom, // type; arbitrary 418 logged_in_xatom, // type; arbitrary
419 logged_in ? 1 : 0); 419 logged_in ? 1 : 0);
420 420
421 if (wm_.get()) { 421 if (wm_.get()) {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 stage_->AddActor(group1_.get()); 676 stage_->AddActor(group1_.get());
677 stage_->AddActor(group3_.get()); 677 stage_->AddActor(group3_.get());
678 group1_->AddActor(group2_.get()); 678 group1_->AddActor(group2_.get());
679 group2_->AddActor(rect1_.get()); 679 group2_->AddActor(rect1_.get());
680 group3_->AddActor(group4_.get()); 680 group3_->AddActor(group4_.get());
681 group4_->AddActor(rect2_.get()); 681 group4_->AddActor(rect2_.get());
682 group4_->AddActor(rect3_.get()); 682 group4_->AddActor(rect3_.get());
683 } 683 }
684 684
685 } // namespace window_manager 685 } // namespace window_manager
OLDNEW
« no previous file with comments | « test_lib.h ('k') | transient_window_collection.h » ('j') | window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698