| 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 #include <cstdarg> | 6 #include <cstdarg> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 reparent_event->parent = 324324; // arbitrary number | 427 reparent_event->parent = 324324; // arbitrary number |
| 428 wm_->HandleEvent(&event); | 428 wm_->HandleEvent(&event); |
| 429 | 429 |
| 430 // After the window gets reparented away from the root, WindowManager | 430 // After the window gets reparented away from the root, WindowManager |
| 431 // should've unredirected it and should no longer be tracking it. | 431 // should've unredirected it and should no longer be tracking it. |
| 432 EXPECT_TRUE(wm_->GetWindow(xid) == NULL); | 432 EXPECT_TRUE(wm_->GetWindow(xid) == NULL); |
| 433 EXPECT_FALSE(info->redirected); | 433 EXPECT_FALSE(info->redirected); |
| 434 } | 434 } |
| 435 | 435 |
| 436 TEST_F(WindowManagerTest, RestackOverrideRedirectWindows) { | 436 TEST_F(WindowManagerTest, RestackOverrideRedirectWindows) { |
| 437 MockCompositor::StageActor* stage = compositor_->GetDefaultStage(); |
| 437 XEvent event; | 438 XEvent event; |
| 438 | 439 |
| 439 // Create two override-redirect windows and map them both. | 440 // Create two override-redirect windows and map them both. |
| 440 XWindow xid = xconn_->CreateWindow( | 441 XWindow xid = xconn_->CreateWindow( |
| 441 xconn_->GetRootWindow(), | 442 xconn_->GetRootWindow(), |
| 442 10, 20, // x, y | 443 10, 20, // x, y |
| 443 30, 40, // width, height | 444 30, 40, // width, height |
| 444 true, // override redirect | 445 true, // override redirect |
| 445 false, // input only | 446 false, // input only |
| 446 0); // event mask | 447 0); // event mask |
| 447 xconn_->InitCreateWindowEvent(&event, xid); | |
| 448 wm_->HandleEvent(&event); | |
| 449 xconn_->MapWindow(xid); | 448 xconn_->MapWindow(xid); |
| 450 xconn_->InitMapEvent(&event, xid); | 449 SendInitialEventsForWindow(xid); |
| 451 wm_->HandleEvent(&event); | |
| 452 Window* win = wm_->GetWindowOrDie(xid); | 450 Window* win = wm_->GetWindowOrDie(xid); |
| 453 | 451 |
| 454 XWindow xid2 = xconn_->CreateWindow( | 452 XWindow xid2 = xconn_->CreateWindow( |
| 455 xconn_->GetRootWindow(), | 453 xconn_->GetRootWindow(), |
| 456 10, 20, // x, y | 454 10, 20, // x, y |
| 457 30, 40, // width, height | 455 30, 40, // width, height |
| 458 true, // override redirect | 456 true, // override redirect |
| 459 false, // input only | 457 false, // input only |
| 460 0); // event mask | 458 0); // event mask |
| 461 xconn_->InitCreateWindowEvent(&event, xid2); | |
| 462 wm_->HandleEvent(&event); | |
| 463 xconn_->MapWindow(xid2); | 459 xconn_->MapWindow(xid2); |
| 464 xconn_->InitMapEvent(&event, xid2); | 460 SendInitialEventsForWindow(xid2); |
| 465 wm_->HandleEvent(&event); | |
| 466 Window* win2 = wm_->GetWindowOrDie(xid2); | 461 Window* win2 = wm_->GetWindowOrDie(xid2); |
| 467 | 462 |
| 468 // Send a ConfigureNotify saying that the second window has been stacked | 463 // The second window should initially be stacked above the first. |
| 469 // on top of the first and then make sure that the compositing actors are | |
| 470 // stacked in the same manner. | |
| 471 xconn_->InitConfigureNotifyEvent(&event, xid2); | |
| 472 event.xconfigure.above = xid; | |
| 473 wm_->HandleEvent(&event); | |
| 474 MockCompositor::StageActor* stage = compositor_->GetDefaultStage(); | |
| 475 EXPECT_LT(stage->GetStackingIndex(win2->actor()), | 464 EXPECT_LT(stage->GetStackingIndex(win2->actor()), |
| 476 stage->GetStackingIndex(win->actor())); | 465 stage->GetStackingIndex(win->actor())); |
| 477 | 466 |
| 478 // Now send a message saying that the first window is on top of the second. | 467 // Send a message saying that the first window is on top of the second. |
| 468 xconn_->StackWindow(xid, xid2, true); |
| 479 xconn_->InitConfigureNotifyEvent(&event, xid); | 469 xconn_->InitConfigureNotifyEvent(&event, xid); |
| 480 event.xconfigure.above = xid2; | 470 event.xconfigure.above = xid2; |
| 481 wm_->HandleEvent(&event); | 471 wm_->HandleEvent(&event); |
| 482 EXPECT_LT(stage->GetStackingIndex(win->actor()), | 472 EXPECT_LT(stage->GetStackingIndex(win->actor()), |
| 483 stage->GetStackingIndex(win2->actor())); | 473 stage->GetStackingIndex(win2->actor())); |
| 484 } | 474 } |
| 485 | 475 |
| 476 TEST_F(WindowManagerTest, StackOverrideRedirectWindowsAboveLayers) { |
| 477 MockCompositor::StageActor* stage = compositor_->GetDefaultStage(); |
| 478 XEvent event; |
| 479 |
| 480 // Create a normal, non-override-redirect window. |
| 481 XWindow normal_xid = CreateSimpleWindow(); |
| 482 SendInitialEventsForWindow(normal_xid); |
| 483 Window* normal_win = wm_->GetWindowOrDie(normal_xid); |
| 484 |
| 485 // Create an override-redirect window and map it. |
| 486 XWindow xid = xconn_->CreateWindow( |
| 487 xconn_->GetRootWindow(), |
| 488 10, 20, // x, y |
| 489 30, 40, // width, height |
| 490 true, // override redirect |
| 491 false, // input only |
| 492 0); // event mask |
| 493 xconn_->MapWindow(xid); |
| 494 SendInitialEventsForWindow(xid); |
| 495 Window* win = wm_->GetWindowOrDie(xid); |
| 496 |
| 497 // The override-redirect window's actor should initially be stacked above |
| 498 // the actor for the top stacking layer (and the normal window's actor, |
| 499 // of course). |
| 500 Compositor::Actor* debugging_layer_actor = |
| 501 wm_->stacking_manager()->layer_to_actor_[ |
| 502 StackingManager::LAYER_DEBUGGING].get(); |
| 503 ASSERT_TRUE(debugging_layer_actor != NULL); |
| 504 EXPECT_LT(stage->GetStackingIndex(win->actor()), |
| 505 stage->GetStackingIndex(debugging_layer_actor)); |
| 506 EXPECT_LT(stage->GetStackingIndex(win->actor()), |
| 507 stage->GetStackingIndex(normal_win->actor())); |
| 508 |
| 509 // Stack the override-redirect window slightly lower, but still above the |
| 510 // normal window. |
| 511 XWindow fullscreen_layer_xid = |
| 512 wm_->stacking_manager()->layer_to_xid_[ |
| 513 StackingManager::LAYER_FULLSCREEN_PANEL]; |
| 514 xconn_->StackWindow(xid, fullscreen_layer_xid, true); |
| 515 xconn_->InitConfigureNotifyEvent(&event, xid); |
| 516 event.xconfigure.above = fullscreen_layer_xid; |
| 517 wm_->HandleEvent(&event); |
| 518 |
| 519 // Create a second normal window and check that the override-redirect |
| 520 // window is above it. This protects against a regression of the issue |
| 521 // described at http://crosbug.com/3451. |
| 522 XWindow normal_xid2 = CreateSimpleWindow(); |
| 523 SendInitialEventsForWindow(normal_xid2); |
| 524 Window* normal_win2 = wm_->GetWindowOrDie(normal_xid2); |
| 525 EXPECT_LT(stage->GetStackingIndex(win->actor()), |
| 526 stage->GetStackingIndex(normal_win->actor())); |
| 527 EXPECT_LT(stage->GetStackingIndex(win->actor()), |
| 528 stage->GetStackingIndex(normal_win2->actor())); |
| 529 } |
| 530 |
| 486 // Test that we honor ConfigureRequest events that change an unmapped | 531 // Test that we honor ConfigureRequest events that change an unmapped |
| 487 // window's size, and that we ignore fields that are unset in its | 532 // window's size, and that we ignore fields that are unset in its |
| 488 // 'value_mask' field. | 533 // 'value_mask' field. |
| 489 TEST_F(WindowManagerTest, ConfigureRequestResize) { | 534 TEST_F(WindowManagerTest, ConfigureRequestResize) { |
| 490 XWindow xid = CreateSimpleWindow(); | 535 XWindow xid = CreateSimpleWindow(); |
| 491 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 536 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 492 const int orig_width = info->width; | 537 const int orig_width = info->width; |
| 493 const int orig_height = info->height; | 538 const int orig_height = info->height; |
| 494 | 539 |
| 495 XEvent event; | 540 XEvent event; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 xconn_->InitUnmapEvent(&event, xid); | 984 xconn_->InitUnmapEvent(&event, xid); |
| 940 wm_->HandleEvent(&event); | 985 wm_->HandleEvent(&event); |
| 941 EXPECT_EQ(initial_pixmap_discards + 2, actor->num_pixmap_discards()); | 986 EXPECT_EQ(initial_pixmap_discards + 2, actor->num_pixmap_discards()); |
| 942 } | 987 } |
| 943 | 988 |
| 944 } // namespace window_manager | 989 } // namespace window_manager |
| 945 | 990 |
| 946 int main(int argc, char** argv) { | 991 int main(int argc, char** argv) { |
| 947 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 992 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 948 } | 993 } |
| OLD | NEW |