| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include <gflags/gflags.h> | 7 #include <gflags/gflags.h> |
| 8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 // Ask the window manager to make the second (middle) panel fullscreen. | 270 // Ask the window manager to make the second (middle) panel fullscreen. |
| 271 XEvent fullscreen_event; | 271 XEvent fullscreen_event; |
| 272 xconn_->InitClientMessageEvent( | 272 xconn_->InitClientMessageEvent( |
| 273 &fullscreen_event, | 273 &fullscreen_event, |
| 274 panel2->content_xid(), | 274 panel2->content_xid(), |
| 275 wm_state_atom, | 275 wm_state_atom, |
| 276 1, // add | 276 1, // add |
| 277 fullscreen_atom, 0, 0, 0); | 277 fullscreen_atom, 0, 0, 0); |
| 278 wm_->HandleEvent(&fullscreen_event); | 278 wm_->HandleEvent(&fullscreen_event); |
| 279 NotifyWindowAboutSize(panel2->content_win()); | 279 SendConfigureNotifyEvent(panel2->content_xid()); |
| 280 | 280 |
| 281 // Check that the second panel is focused automatically, covering the | 281 // Check that the second panel is focused automatically, covering the |
| 282 // whole screen, and stacked above the other panels. | 282 // whole screen, and stacked above the other panels. |
| 283 EXPECT_TRUE(panel2->is_fullscreen()); | 283 EXPECT_TRUE(panel2->is_fullscreen()); |
| 284 EXPECT_EQ(panel2->content_xid(), xconn_->focused_xid()); | 284 EXPECT_EQ(panel2->content_xid(), xconn_->focused_xid()); |
| 285 TestPanelContentBounds(panel2, 0, 0, wm_->width(), wm_->height()); | 285 TestPanelContentBounds(panel2, 0, 0, wm_->width(), wm_->height()); |
| 286 EXPECT_TRUE(WindowIsInLayer(panel2->content_win(), | 286 EXPECT_TRUE(WindowIsInLayer(panel2->content_win(), |
| 287 StackingManager::LAYER_FULLSCREEN_WINDOW)); | 287 StackingManager::LAYER_FULLSCREEN_WINDOW)); |
| 288 TestIntArrayProperty( | 288 TestIntArrayProperty( |
| 289 panel2->content_xid(), wm_state_atom, 1, fullscreen_atom); | 289 panel2->content_xid(), wm_state_atom, 1, fullscreen_atom); |
| 290 | 290 |
| 291 // Now send a message making the third (leftmost) panel fullscreen. The | 291 // Now send a message making the third (leftmost) panel fullscreen. The |
| 292 // second panel should be made non-fullscreen. | 292 // second panel should be made non-fullscreen. |
| 293 fullscreen_event.xclient.window = panel3->content_xid(); | 293 fullscreen_event.xclient.window = panel3->content_xid(); |
| 294 wm_->HandleEvent(&fullscreen_event); | 294 wm_->HandleEvent(&fullscreen_event); |
| 295 NotifyWindowAboutSize(panel2->content_win()); | 295 SendConfigureNotifyEvent(panel2->content_xid()); |
| 296 NotifyWindowAboutSize(panel3->content_win()); | 296 SendConfigureNotifyEvent(panel3->content_xid()); |
| 297 | 297 |
| 298 EXPECT_TRUE(panel3->is_fullscreen()); | 298 EXPECT_TRUE(panel3->is_fullscreen()); |
| 299 EXPECT_EQ(panel3->content_xid(), xconn_->focused_xid()); | 299 EXPECT_EQ(panel3->content_xid(), xconn_->focused_xid()); |
| 300 TestPanelContentBounds(panel3, 0, 0, wm_->width(), wm_->height()); | 300 TestPanelContentBounds(panel3, 0, 0, wm_->width(), wm_->height()); |
| 301 EXPECT_TRUE(WindowIsInLayer(panel3->content_win(), | 301 EXPECT_TRUE(WindowIsInLayer(panel3->content_win(), |
| 302 StackingManager::LAYER_FULLSCREEN_WINDOW)); | 302 StackingManager::LAYER_FULLSCREEN_WINDOW)); |
| 303 TestIntArrayProperty( | 303 TestIntArrayProperty( |
| 304 panel3->content_xid(), wm_state_atom, 1, fullscreen_atom); | 304 panel3->content_xid(), wm_state_atom, 1, fullscreen_atom); |
| 305 | 305 |
| 306 EXPECT_FALSE(panel2->is_fullscreen()); | 306 EXPECT_FALSE(panel2->is_fullscreen()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 324 EXPECT_TRUE(WindowIsInLayer(panel3->content_win(), | 324 EXPECT_TRUE(WindowIsInLayer(panel3->content_win(), |
| 325 StackingManager::LAYER_FULLSCREEN_WINDOW)); | 325 StackingManager::LAYER_FULLSCREEN_WINDOW)); |
| 326 EXPECT_EQ(rightmost_panel_right, panel2->right()); | 326 EXPECT_EQ(rightmost_panel_right, panel2->right()); |
| 327 EXPECT_EQ(middle_panel_right, panel3->right()); | 327 EXPECT_EQ(middle_panel_right, panel3->right()); |
| 328 | 328 |
| 329 // Now send a message asking to unfullscreen the third panel and check | 329 // Now send a message asking to unfullscreen the third panel and check |
| 330 // that it gets restored to its regular middle position. It should still | 330 // that it gets restored to its regular middle position. It should still |
| 331 // keep the focus. | 331 // keep the focus. |
| 332 fullscreen_event.xclient.data.l[0] = 0; // remove | 332 fullscreen_event.xclient.data.l[0] = 0; // remove |
| 333 wm_->HandleEvent(&fullscreen_event); | 333 wm_->HandleEvent(&fullscreen_event); |
| 334 NotifyWindowAboutSize(panel3->content_win()); | 334 SendConfigureNotifyEvent(panel3->content_xid()); |
| 335 EXPECT_FALSE(panel3->is_fullscreen()); | 335 EXPECT_FALSE(panel3->is_fullscreen()); |
| 336 EXPECT_EQ(panel3->content_xid(), xconn_->focused_xid()); | 336 EXPECT_EQ(panel3->content_xid(), xconn_->focused_xid()); |
| 337 TestPanelContentBounds(panel3, | 337 TestPanelContentBounds(panel3, |
| 338 middle_panel_right - content_width, // x | 338 middle_panel_right - content_width, // x |
| 339 wm_->height() - content_height, // y | 339 wm_->height() - content_height, // y |
| 340 content_width, content_height); | 340 content_width, content_height); |
| 341 EXPECT_TRUE(WindowIsInLayer(panel3->content_win(), | 341 EXPECT_TRUE(WindowIsInLayer(panel3->content_win(), |
| 342 StackingManager::LAYER_PACKED_PANEL_IN_BAR)); | 342 StackingManager::LAYER_PACKED_PANEL_IN_BAR)); |
| 343 TestIntArrayProperty(panel3->content_xid(), wm_state_atom, 0); | 343 TestIntArrayProperty(panel3->content_xid(), wm_state_atom, 0); |
| 344 | 344 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 ASSERT_TRUE( | 486 ASSERT_TRUE( |
| 487 xconn_->GetWindowGeometry(xconn_->GetRootWindow(), &root_geometry)); | 487 xconn_->GetWindowGeometry(xconn_->GetRootWindow(), &root_geometry)); |
| 488 | 488 |
| 489 Panel* panel = CreatePanel(200, 400, 20); | 489 Panel* panel = CreatePanel(200, 400, 20); |
| 490 ASSERT_EQ(panel->content_xid(), xconn_->focused_xid()); | 490 ASSERT_EQ(panel->content_xid(), xconn_->focused_xid()); |
| 491 ASSERT_EQ(panel->content_xid(), GetActiveWindowProperty()); | 491 ASSERT_EQ(panel->content_xid(), GetActiveWindowProperty()); |
| 492 | 492 |
| 493 // Create a transient window owned by the panel. | 493 // Create a transient window owned by the panel. |
| 494 const int transient_x = 30, transient_y = 40; | 494 const int transient_x = 30, transient_y = 40; |
| 495 const int transient_width = 300, transient_height = 200; | 495 const int transient_width = 300, transient_height = 200; |
| 496 XWindow transient_xid = CreateBasicWindow(transient_x, transient_y, | 496 XWindow transient_xid = |
| 497 transient_width, transient_height); | 497 CreateBasicWindow( |
| 498 Rect(transient_x, transient_y, transient_width, transient_height)); |
| 498 // Say that we support the WM_DELETE_WINDOW protocol so that the window | 499 // Say that we support the WM_DELETE_WINDOW protocol so that the window |
| 499 // manager will try to close us when needed. | 500 // manager will try to close us when needed. |
| 500 AppendAtomToProperty(transient_xid, | 501 AppendAtomToProperty(transient_xid, |
| 501 xconn_->GetAtomOrDie("WM_PROTOCOLS"), | 502 xconn_->GetAtomOrDie("WM_PROTOCOLS"), |
| 502 xconn_->GetAtomOrDie("WM_DELETE_WINDOW")); | 503 xconn_->GetAtomOrDie("WM_DELETE_WINDOW")); |
| 503 MockXConnection::WindowInfo* transient_info = | 504 MockXConnection::WindowInfo* transient_info = |
| 504 xconn_->GetWindowInfoOrDie(transient_xid); | 505 xconn_->GetWindowInfoOrDie(transient_xid); |
| 505 transient_info->transient_for = panel->content_xid(); | 506 transient_info->transient_for = panel->content_xid(); |
| 506 SendInitialEventsForWindow(transient_xid); | 507 SendInitialEventsForWindow(transient_xid); |
| 507 Window* transient_win = wm_->GetWindowOrDie(transient_xid); | 508 Window* transient_win = wm_->GetWindowOrDie(transient_xid); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 EXPECT_GT(GetNumDeleteWindowMessagesForWindow(transient_xid), | 552 EXPECT_GT(GetNumDeleteWindowMessagesForWindow(transient_xid), |
| 552 initial_num_delete_messages); | 553 initial_num_delete_messages); |
| 553 | 554 |
| 554 // Unmap the transient window. | 555 // Unmap the transient window. |
| 555 xconn_->UnmapWindow(transient_xid); | 556 xconn_->UnmapWindow(transient_xid); |
| 556 XEvent event; | 557 XEvent event; |
| 557 xconn_->InitUnmapEvent(&event, transient_xid); | 558 xconn_->InitUnmapEvent(&event, transient_xid); |
| 558 wm_->HandleEvent(&event); | 559 wm_->HandleEvent(&event); |
| 559 | 560 |
| 560 // Now create a toplevel window, which should get focused. | 561 // Now create a toplevel window, which should get focused. |
| 561 XWindow toplevel_xid = CreateToplevelWindow(1, 0, 0, 0, 1024, 768); | 562 XWindow toplevel_xid = CreateToplevelWindow(1, 0, Rect(0, 0, 1024, 768)); |
| 562 SendInitialEventsForWindow(toplevel_xid); | 563 SendInitialEventsForWindow(toplevel_xid); |
| 563 ASSERT_EQ(toplevel_xid, xconn_->focused_xid()); | 564 ASSERT_EQ(toplevel_xid, xconn_->focused_xid()); |
| 564 ASSERT_EQ(toplevel_xid, GetActiveWindowProperty()); | 565 ASSERT_EQ(toplevel_xid, GetActiveWindowProperty()); |
| 565 | 566 |
| 566 // Create another transient with the CHROME_INFO_BUBBLE type, which | 567 // Create another transient with the CHROME_INFO_BUBBLE type, which |
| 567 // should allow us to place it wherever we want. | 568 // should allow us to place it wherever we want. |
| 568 const int infobubble_x = 40, infobubble_y = 50; | 569 const int infobubble_x = 40, infobubble_y = 50; |
| 569 const int infobubble_width = 200, infobubble_height = 20; | 570 const int infobubble_width = 200, infobubble_height = 20; |
| 570 XWindow infobubble_xid = CreateBasicWindow( | 571 XWindow infobubble_xid = CreateBasicWindow( |
| 571 infobubble_x, infobubble_y, infobubble_width, infobubble_height); | 572 Rect(infobubble_x, infobubble_y, infobubble_width, infobubble_height)); |
| 572 MockXConnection::WindowInfo* infobubble_info = | 573 MockXConnection::WindowInfo* infobubble_info = |
| 573 xconn_->GetWindowInfoOrDie(infobubble_xid); | 574 xconn_->GetWindowInfoOrDie(infobubble_xid); |
| 574 wm_->wm_ipc()->SetWindowType( | 575 wm_->wm_ipc()->SetWindowType( |
| 575 infobubble_xid, chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, NULL); | 576 infobubble_xid, chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, NULL); |
| 576 infobubble_info->transient_for = panel->content_xid(); | 577 infobubble_info->transient_for = panel->content_xid(); |
| 577 SendInitialEventsForWindow(infobubble_xid); | 578 SendInitialEventsForWindow(infobubble_xid); |
| 578 | 579 |
| 579 EXPECT_EQ(infobubble_x, infobubble_info->bounds.x); | 580 EXPECT_EQ(infobubble_x, infobubble_info->bounds.x); |
| 580 EXPECT_EQ(infobubble_y, infobubble_info->bounds.y); | 581 EXPECT_EQ(infobubble_y, infobubble_info->bounds.y); |
| 581 EXPECT_EQ(infobubble_width, infobubble_info->bounds.width); | 582 EXPECT_EQ(infobubble_width, infobubble_info->bounds.width); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 EXPECT_EQ(kNewTitlebarBounds, titlebar_info->bounds); | 695 EXPECT_EQ(kNewTitlebarBounds, titlebar_info->bounds); |
| 695 EXPECT_EQ(kNewContentBounds, content_actor->GetBounds()); | 696 EXPECT_EQ(kNewContentBounds, content_actor->GetBounds()); |
| 696 EXPECT_EQ(kNewContentBounds, content_info->bounds); | 697 EXPECT_EQ(kNewContentBounds, content_info->bounds); |
| 697 } | 698 } |
| 698 | 699 |
| 699 } // namespace window_manager | 700 } // namespace window_manager |
| 700 | 701 |
| 701 int main(int argc, char** argv) { | 702 int main(int argc, char** argv) { |
| 702 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 703 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 703 } | 704 } |
| OLD | NEW |