| 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 <string> | 5 #include <string> |
| 6 #include <tr1/memory> | 6 #include <tr1/memory> |
| 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 // We should've sent it a synthetic ConfigureNotify event containing its | 704 // We should've sent it a synthetic ConfigureNotify event containing its |
| 705 // current position and size. | 705 // current position and size. |
| 706 ASSERT_EQ(static_cast<size_t>(1), info->configure_notify_events.size()); | 706 ASSERT_EQ(static_cast<size_t>(1), info->configure_notify_events.size()); |
| 707 EXPECT_EQ(lm_->x(), info->configure_notify_events[0].x); | 707 EXPECT_EQ(lm_->x(), info->configure_notify_events[0].x); |
| 708 EXPECT_EQ(lm_->y(), info->configure_notify_events[0].y); | 708 EXPECT_EQ(lm_->y(), info->configure_notify_events[0].y); |
| 709 EXPECT_EQ(lm_->width(), info->configure_notify_events[0].width); | 709 EXPECT_EQ(lm_->width(), info->configure_notify_events[0].width); |
| 710 EXPECT_EQ(lm_->height(), info->configure_notify_events[0].height); | 710 EXPECT_EQ(lm_->height(), info->configure_notify_events[0].height); |
| 711 } | 711 } |
| 712 | 712 |
| 713 TEST_F(LayoutManagerTest, ChangeCurrentSnapshot) { | 713 TEST_F(LayoutManagerTest, ChangeCurrentSnapshot) { |
| 714 XWindow toplevel1_xid = CreateToplevelWindow(2, 0, 0, 0, 640, 480); | 714 XWindow toplevel1_xid = CreateToplevelWindow(2, 0, Rect(0, 0, 640, 480)); |
| 715 SendInitialEventsForWindow(toplevel1_xid); | 715 SendInitialEventsForWindow(toplevel1_xid); |
| 716 MockXConnection::WindowInfo* info1 = | 716 MockXConnection::WindowInfo* info1 = |
| 717 xconn_->GetWindowInfoOrDie(toplevel1_xid); | 717 xconn_->GetWindowInfoOrDie(toplevel1_xid); |
| 718 XWindow toplevel2_xid = CreateToplevelWindow(2, 0, 0, 0, 640, 480); | 718 XWindow toplevel2_xid = CreateToplevelWindow(2, 0, Rect(0, 0, 640, 480)); |
| 719 SendInitialEventsForWindow(toplevel2_xid); | 719 SendInitialEventsForWindow(toplevel2_xid); |
| 720 MockXConnection::WindowInfo* info2 = | 720 MockXConnection::WindowInfo* info2 = |
| 721 xconn_->GetWindowInfoOrDie(toplevel2_xid); | 721 xconn_->GetWindowInfoOrDie(toplevel2_xid); |
| 722 | 722 |
| 723 // Create some snapshot windows for the first toplevel. | 723 // Create some snapshot windows for the first toplevel. |
| 724 XWindow xid11 = CreateSimpleSnapshotWindow(toplevel1_xid, 0); | 724 XWindow xid11 = CreateSimpleSnapshotWindow(toplevel1_xid, 0); |
| 725 SendInitialEventsForWindow(xid11); | 725 SendInitialEventsForWindow(xid11); |
| 726 XWindow xid12 = CreateSimpleSnapshotWindow(toplevel1_xid, 1); | 726 XWindow xid12 = CreateSimpleSnapshotWindow(toplevel1_xid, 1); |
| 727 SendInitialEventsForWindow(xid12); | 727 SendInitialEventsForWindow(xid12); |
| 728 ChangeTabInfo(toplevel1_xid, 2, 1, wm_->GetCurrentTimeFromServer()); | 728 ChangeTabInfo(toplevel1_xid, 2, 1, wm_->GetCurrentTimeFromServer()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 EXPECT_NE(lm_->GetSnapshotWindowByXid(xid11), lm_->current_snapshot_); | 862 EXPECT_NE(lm_->GetSnapshotWindowByXid(xid11), lm_->current_snapshot_); |
| 863 EXPECT_NE(lm_->snapshots_[0].get(), lm_->current_snapshot_); | 863 EXPECT_NE(lm_->snapshots_[0].get(), lm_->current_snapshot_); |
| 864 | 864 |
| 865 // The third snapshot (third one on first toplevel) should now be current. | 865 // The third snapshot (third one on first toplevel) should now be current. |
| 866 EXPECT_EQ(lm_->GetSnapshotWindowByXid(xid13), lm_->current_snapshot_); | 866 EXPECT_EQ(lm_->GetSnapshotWindowByXid(xid13), lm_->current_snapshot_); |
| 867 EXPECT_EQ(lm_->snapshots_[2].get(), lm_->current_snapshot_); | 867 EXPECT_EQ(lm_->snapshots_[2].get(), lm_->current_snapshot_); |
| 868 } | 868 } |
| 869 | 869 |
| 870 TEST_F(LayoutManagerTest, OverviewFocus) { | 870 TEST_F(LayoutManagerTest, OverviewFocus) { |
| 871 // Create and map a toplevel window. | 871 // Create and map a toplevel window. |
| 872 XWindow toplevel_xid = CreateToplevelWindow(2, 0, 0, 0, 640, 480); | 872 XWindow toplevel_xid = CreateToplevelWindow(2, 0, Rect(0, 0, 640, 480)); |
| 873 SendInitialEventsForWindow(toplevel_xid); | 873 SendInitialEventsForWindow(toplevel_xid); |
| 874 MockXConnection::WindowInfo* toplevel_info = | 874 MockXConnection::WindowInfo* toplevel_info = |
| 875 xconn_->GetWindowInfoOrDie(toplevel_xid); | 875 xconn_->GetWindowInfoOrDie(toplevel_xid); |
| 876 | 876 |
| 877 // The toplevel window should get the focus, the active window | 877 // The toplevel window should get the focus, the active window |
| 878 // property should be updated, and there shouldn't be a button grab | 878 // property should be updated, and there shouldn't be a button grab |
| 879 // on the window. | 879 // on the window. |
| 880 EXPECT_EQ(toplevel_xid, xconn_->focused_xid()); | 880 EXPECT_EQ(toplevel_xid, xconn_->focused_xid()); |
| 881 EXPECT_EQ(toplevel_xid, GetActiveWindowProperty()); | 881 EXPECT_EQ(toplevel_xid, GetActiveWindowProperty()); |
| 882 EXPECT_FALSE(toplevel_info->button_is_grabbed(AnyButton)); | 882 EXPECT_FALSE(toplevel_info->button_is_grabbed(AnyButton)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 TEST_F(LayoutManagerTest, OverviewSpacing) { | 947 TEST_F(LayoutManagerTest, OverviewSpacing) { |
| 948 const int window_width = 640; | 948 const int window_width = 640; |
| 949 const int window_height = 480; | 949 const int window_height = 480; |
| 950 | 950 |
| 951 // Create a background actor. | 951 // Create a background actor. |
| 952 Compositor::ColoredBoxActor* background = compositor_->CreateColoredBox( | 952 Compositor::ColoredBoxActor* background = compositor_->CreateColoredBox( |
| 953 window_width, window_height, Compositor::Color()); | 953 window_width, window_height, Compositor::Color()); |
| 954 lm_->SetBackground(background); | 954 lm_->SetBackground(background); |
| 955 | 955 |
| 956 // Create and map a toplevel window. | 956 // Create and map a toplevel window. |
| 957 XWindow toplevel_xid = CreateToplevelWindow(2, 0, 0, 0, | 957 XWindow toplevel_xid = |
| 958 window_width, window_height); | 958 CreateToplevelWindow(2, 0, Rect(0, 0, window_width, window_height)); |
| 959 SendInitialEventsForWindow(toplevel_xid); | 959 SendInitialEventsForWindow(toplevel_xid); |
| 960 | 960 |
| 961 // Create and map a second toplevel window. | 961 // Create and map a second toplevel window. |
| 962 XWindow toplevel_xid2 = CreateToplevelWindow(1, 0, 0, 0, | 962 XWindow toplevel_xid2 = |
| 963 window_width, window_height); | 963 CreateToplevelWindow(1, 0, Rect(0, 0, window_width, window_height)); |
| 964 SendInitialEventsForWindow(toplevel_xid2); | 964 SendInitialEventsForWindow(toplevel_xid2); |
| 965 | 965 |
| 966 // Create an associated snapshot window with some "realistic" | 966 // Create an associated snapshot window with some "realistic" |
| 967 // values. (The numbers here don't represent the values that Chrome | 967 // values. (The numbers here don't represent the values that Chrome |
| 968 // is using to make the snapshots, they're just reasonable values.) | 968 // is using to make the snapshots, they're just reasonable values.) |
| 969 const int snapshot_height = MockXConnection::kDisplayHeight / 2; | 969 const int snapshot_height = MockXConnection::kDisplayHeight / 2; |
| 970 const int snapshot_width = snapshot_height * 1024 / 1280; | 970 const int snapshot_width = snapshot_height * 1024 / 1280; |
| 971 XWindow snapshot = CreateSnapshotWindow(toplevel_xid, 0, 0, 0, | 971 XWindow snapshot = |
| 972 snapshot_width, snapshot_height); | 972 CreateSnapshotWindow( |
| 973 toplevel_xid, 0, Rect(0, 0, snapshot_width, snapshot_height)); |
| 973 SendInitialEventsForWindow(snapshot); | 974 SendInitialEventsForWindow(snapshot); |
| 974 XWindow snapshot_title = CreateTitleWindow(snapshot, snapshot_width, 16); | 975 XWindow snapshot_title = |
| 976 CreateTitleWindow(snapshot, Size(snapshot_width, 16)); |
| 975 SendInitialEventsForWindow(snapshot_title); | 977 SendInitialEventsForWindow(snapshot_title); |
| 976 XWindow snapshot_fav_icon = CreateFavIconWindow(snapshot, 16, 16); | 978 XWindow snapshot_fav_icon = CreateFavIconWindow(snapshot, Size(16, 16)); |
| 977 SendInitialEventsForWindow(snapshot_fav_icon); | 979 SendInitialEventsForWindow(snapshot_fav_icon); |
| 978 | 980 |
| 979 // This is the vertical offset to center the background. | 981 // This is the vertical offset to center the background. |
| 980 int centering_offset = -(MockXConnection::kDisplayHeight * | 982 int centering_offset = -(MockXConnection::kDisplayHeight * |
| 981 LayoutManager::kBackgroundExpansionFactor - | 983 LayoutManager::kBackgroundExpansionFactor - |
| 982 MockXConnection::kDisplayHeight) / 2; | 984 MockXConnection::kDisplayHeight) / 2; |
| 983 | 985 |
| 984 // The background should not be scrolled horizontally yet. | 986 // The background should not be scrolled horizontally yet. |
| 985 EXPECT_EQ(0, background->GetX()); | 987 EXPECT_EQ(0, background->GetX()); |
| 986 EXPECT_EQ(centering_offset, background->GetY()); | 988 EXPECT_EQ(centering_offset, background->GetY()); |
| 987 | 989 |
| 988 // Now switch to overview mode. | 990 // Now switch to overview mode. |
| 989 lm_->SetMode(LayoutManager::MODE_OVERVIEW); | 991 lm_->SetMode(LayoutManager::MODE_OVERVIEW); |
| 990 | 992 |
| 991 // Now create and map a second snapshot window. | 993 // Now create and map a second snapshot window. |
| 992 XWindow snapshot2 = CreateSnapshotWindow(toplevel_xid, 1, 0, 0, | 994 XWindow snapshot2 = |
| 993 snapshot_width, snapshot_height); | 995 CreateSnapshotWindow( |
| 996 toplevel_xid, 1, Rect(0, 0, snapshot_width, snapshot_height)); |
| 994 SendInitialEventsForWindow(snapshot2); | 997 SendInitialEventsForWindow(snapshot2); |
| 995 XWindow snapshot2_title = CreateTitleWindow(snapshot2, snapshot_width, 16); | 998 XWindow snapshot2_title = |
| 999 CreateTitleWindow(snapshot2, Size(snapshot_width, 16)); |
| 996 SendInitialEventsForWindow(snapshot2_title); | 1000 SendInitialEventsForWindow(snapshot2_title); |
| 997 XWindow snapshot2_fav_icon = CreateFavIconWindow(snapshot2, 16, 16); | 1001 XWindow snapshot2_fav_icon = CreateFavIconWindow(snapshot2, Size(16, 16)); |
| 998 SendInitialEventsForWindow(snapshot2_fav_icon); | 1002 SendInitialEventsForWindow(snapshot2_fav_icon); |
| 999 ChangeTabInfo(toplevel_xid, 2, 1, wm_->GetCurrentTimeFromServer()); | 1003 ChangeTabInfo(toplevel_xid, 2, 1, wm_->GetCurrentTimeFromServer()); |
| 1000 SendWindowTypeEvent(toplevel_xid); | 1004 SendWindowTypeEvent(toplevel_xid); |
| 1001 | 1005 |
| 1002 // Now create and map a third snapshot window, with the second | 1006 // Now create and map a third snapshot window, with the second |
| 1003 // toplevel as its parent. | 1007 // toplevel as its parent. |
| 1004 XWindow snapshot3 = CreateSnapshotWindow(toplevel_xid2, 0, 0, 0, | 1008 XWindow snapshot3 = |
| 1005 snapshot_width, snapshot_height); | 1009 CreateSnapshotWindow( |
| 1010 toplevel_xid2, 0, Rect(0, 0, snapshot_width, snapshot_height)); |
| 1006 SendInitialEventsForWindow(snapshot3); | 1011 SendInitialEventsForWindow(snapshot3); |
| 1007 XWindow snapshot3_title = CreateTitleWindow(snapshot3, snapshot_width, 16); | 1012 XWindow snapshot3_title = |
| 1013 CreateTitleWindow(snapshot3, Size(snapshot_width, 16)); |
| 1008 SendInitialEventsForWindow(snapshot3_title); | 1014 SendInitialEventsForWindow(snapshot3_title); |
| 1009 XWindow snapshot3_fav_icon = CreateFavIconWindow(snapshot3, 16, 16); | 1015 XWindow snapshot3_fav_icon = CreateFavIconWindow(snapshot3, Size(16, 16)); |
| 1010 SendInitialEventsForWindow(snapshot3_fav_icon); | 1016 SendInitialEventsForWindow(snapshot3_fav_icon); |
| 1011 ChangeTabInfo(toplevel_xid2, 1, 0, wm_->GetCurrentTimeFromServer()); | 1017 ChangeTabInfo(toplevel_xid2, 1, 0, wm_->GetCurrentTimeFromServer()); |
| 1012 SendWindowTypeEvent(toplevel_xid2); | 1018 SendWindowTypeEvent(toplevel_xid2); |
| 1013 | 1019 |
| 1014 EXPECT_EQ(-(lm_->current_snapshot_->overview_x() + | 1020 EXPECT_EQ(-(lm_->current_snapshot_->overview_x() + |
| 1015 (lm_->current_snapshot_->overview_width() - | 1021 (lm_->current_snapshot_->overview_width() - |
| 1016 lm_->width_) / 2), | 1022 lm_->width_) / 2), |
| 1017 lm_->overview_panning_offset_); | 1023 lm_->overview_panning_offset_); |
| 1018 | 1024 |
| 1019 // Make sure the fav icon and title got hooked up correctly. | 1025 // Make sure the fav icon and title got hooked up correctly. |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 wm_->HandleEvent(&net_active_win_event); | 1303 wm_->HandleEvent(&net_active_win_event); |
| 1298 EXPECT_EQ(LayoutManager::MODE_ACTIVE, lm_->mode()); | 1304 EXPECT_EQ(LayoutManager::MODE_ACTIVE, lm_->mode()); |
| 1299 EXPECT_EQ(xid, xconn_->focused_xid()); | 1305 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 1300 } | 1306 } |
| 1301 | 1307 |
| 1302 // Test that LayoutManager resizes non-Chrome and toplevel Chrome windows | 1308 // Test that LayoutManager resizes non-Chrome and toplevel Chrome windows |
| 1303 // to fill the screen as soon as it gets MapRequest events about them. | 1309 // to fill the screen as soon as it gets MapRequest events about them. |
| 1304 TEST_F(LayoutManagerTest, ResizeWindowsBeforeMapping) { | 1310 TEST_F(LayoutManagerTest, ResizeWindowsBeforeMapping) { |
| 1305 // Create a small non-Chrome window and check that it gets resized to the | 1311 // Create a small non-Chrome window and check that it gets resized to the |
| 1306 // layout manager's dimensions on MapRequest. | 1312 // layout manager's dimensions on MapRequest. |
| 1307 const XWindow nonchrome_xid = CreateBasicWindow(0, 0, 50, 40); | 1313 const XWindow nonchrome_xid = CreateBasicWindow(Rect(0, 0, 50, 40)); |
| 1308 MockXConnection::WindowInfo* nonchrome_info = | 1314 MockXConnection::WindowInfo* nonchrome_info = |
| 1309 xconn_->GetWindowInfoOrDie(nonchrome_xid); | 1315 xconn_->GetWindowInfoOrDie(nonchrome_xid); |
| 1310 XEvent event; | 1316 XEvent event; |
| 1311 xconn_->InitCreateWindowEvent(&event, nonchrome_xid); | 1317 xconn_->InitCreateWindowEvent(&event, nonchrome_xid); |
| 1312 wm_->HandleEvent(&event); | 1318 wm_->HandleEvent(&event); |
| 1313 xconn_->InitMapRequestEvent(&event, nonchrome_xid); | 1319 xconn_->InitMapRequestEvent(&event, nonchrome_xid); |
| 1314 wm_->HandleEvent(&event); | 1320 wm_->HandleEvent(&event); |
| 1315 EXPECT_EQ(lm_->width(), nonchrome_info->bounds.width); | 1321 EXPECT_EQ(lm_->width(), nonchrome_info->bounds.width); |
| 1316 EXPECT_EQ(lm_->height(), nonchrome_info->bounds.height); | 1322 EXPECT_EQ(lm_->height(), nonchrome_info->bounds.height); |
| 1317 | 1323 |
| 1318 // We should do the same thing with toplevel Chrome windows. | 1324 // We should do the same thing with toplevel Chrome windows. |
| 1319 const XWindow toplevel_xid = CreateToplevelWindow(1, 0, 0, 0, 50, 40); | 1325 const XWindow toplevel_xid = |
| 1326 CreateToplevelWindow(1, 0, Rect(0, 0, 50, 40)); |
| 1320 MockXConnection::WindowInfo* toplevel_info = | 1327 MockXConnection::WindowInfo* toplevel_info = |
| 1321 xconn_->GetWindowInfoOrDie(toplevel_xid); | 1328 xconn_->GetWindowInfoOrDie(toplevel_xid); |
| 1322 xconn_->InitCreateWindowEvent(&event, toplevel_xid); | 1329 xconn_->InitCreateWindowEvent(&event, toplevel_xid); |
| 1323 wm_->HandleEvent(&event); | 1330 wm_->HandleEvent(&event); |
| 1324 xconn_->InitMapRequestEvent(&event, toplevel_xid); | 1331 xconn_->InitMapRequestEvent(&event, toplevel_xid); |
| 1325 wm_->HandleEvent(&event); | 1332 wm_->HandleEvent(&event); |
| 1326 EXPECT_EQ(lm_->width(), toplevel_info->bounds.width); | 1333 EXPECT_EQ(lm_->width(), toplevel_info->bounds.width); |
| 1327 EXPECT_EQ(lm_->height(), toplevel_info->bounds.height); | 1334 EXPECT_EQ(lm_->height(), toplevel_info->bounds.height); |
| 1328 | 1335 |
| 1329 // Snapshot windows should retain their original dimensions. | 1336 // Snapshot windows should retain their original dimensions. |
| 1330 const int orig_width = 50, orig_height = 40; | 1337 const int orig_width = 50, orig_height = 40; |
| 1331 const XWindow snapshot_xid = | 1338 const XWindow snapshot_xid = |
| 1332 CreateSnapshotWindow(toplevel_xid, 0, 0, 0, orig_width, orig_height); | 1339 CreateSnapshotWindow( |
| 1340 toplevel_xid, 0, Rect(0, 0, orig_width, orig_height)); |
| 1333 MockXConnection::WindowInfo* snapshot_info = | 1341 MockXConnection::WindowInfo* snapshot_info = |
| 1334 xconn_->GetWindowInfoOrDie(snapshot_xid); | 1342 xconn_->GetWindowInfoOrDie(snapshot_xid); |
| 1335 xconn_->InitCreateWindowEvent(&event, snapshot_xid); | 1343 xconn_->InitCreateWindowEvent(&event, snapshot_xid); |
| 1336 wm_->HandleEvent(&event); | 1344 wm_->HandleEvent(&event); |
| 1337 xconn_->InitMapRequestEvent(&event, snapshot_xid); | 1345 xconn_->InitMapRequestEvent(&event, snapshot_xid); |
| 1338 wm_->HandleEvent(&event); | 1346 wm_->HandleEvent(&event); |
| 1339 EXPECT_EQ(orig_width, snapshot_info->bounds.width); | 1347 EXPECT_EQ(orig_width, snapshot_info->bounds.width); |
| 1340 EXPECT_EQ(orig_height, snapshot_info->bounds.height); | 1348 EXPECT_EQ(orig_height, snapshot_info->bounds.height); |
| 1341 | 1349 |
| 1342 // Transient windows should, too. | 1350 // Transient windows should, too. |
| 1343 const XWindow transient_xid = | 1351 const XWindow transient_xid = |
| 1344 CreateBasicWindow(0, 0, orig_width, orig_height); | 1352 CreateBasicWindow(Rect(0, 0, orig_width, orig_height)); |
| 1345 MockXConnection::WindowInfo* transient_info = | 1353 MockXConnection::WindowInfo* transient_info = |
| 1346 xconn_->GetWindowInfoOrDie(transient_xid); | 1354 xconn_->GetWindowInfoOrDie(transient_xid); |
| 1347 transient_info->transient_for = toplevel_xid; | 1355 transient_info->transient_for = toplevel_xid; |
| 1348 xconn_->InitCreateWindowEvent(&event, transient_xid); | 1356 xconn_->InitCreateWindowEvent(&event, transient_xid); |
| 1349 wm_->HandleEvent(&event); | 1357 wm_->HandleEvent(&event); |
| 1350 xconn_->InitMapRequestEvent(&event, transient_xid); | 1358 xconn_->InitMapRequestEvent(&event, transient_xid); |
| 1351 wm_->HandleEvent(&event); | 1359 wm_->HandleEvent(&event); |
| 1352 EXPECT_EQ(orig_width, transient_info->bounds.width); | 1360 EXPECT_EQ(orig_width, transient_info->bounds.width); |
| 1353 EXPECT_EQ(orig_height, transient_info->bounds.height); | 1361 EXPECT_EQ(orig_height, transient_info->bounds.height); |
| 1354 } | 1362 } |
| 1355 | 1363 |
| 1356 // Test that the layout manager handles windows that claim to be transient | 1364 // Test that the layout manager handles windows that claim to be transient |
| 1357 // for already-transient windows reasonably -- see http://crosbug.com/3316. | 1365 // for already-transient windows reasonably -- see http://crosbug.com/3316. |
| 1358 TEST_F(LayoutManagerTest, NestedTransients) { | 1366 TEST_F(LayoutManagerTest, NestedTransients) { |
| 1359 // Create a toplevel window. | 1367 // Create a toplevel window. |
| 1360 XWindow toplevel_xid = CreateSimpleWindow(); | 1368 XWindow toplevel_xid = CreateSimpleWindow(); |
| 1361 SendInitialEventsForWindow(toplevel_xid); | 1369 SendInitialEventsForWindow(toplevel_xid); |
| 1362 LayoutManager::ToplevelWindow* toplevel = | 1370 LayoutManager::ToplevelWindow* toplevel = |
| 1363 lm_->GetToplevelWindowByWindow(*(wm_->GetWindowOrDie(toplevel_xid))); | 1371 lm_->GetToplevelWindowByWindow(*(wm_->GetWindowOrDie(toplevel_xid))); |
| 1364 ASSERT_TRUE(toplevel != NULL); | 1372 ASSERT_TRUE(toplevel != NULL); |
| 1365 | 1373 |
| 1366 // Create a transient window. | 1374 // Create a transient window. |
| 1367 const int initial_width = 300, initial_height = 200; | 1375 const int initial_width = 300, initial_height = 200; |
| 1368 XWindow transient_xid = | 1376 XWindow transient_xid = |
| 1369 CreateBasicWindow(0, 0, initial_width, initial_height); | 1377 CreateBasicWindow(Rect(0, 0, initial_width, initial_height)); |
| 1370 MockXConnection::WindowInfo* transient_info = | 1378 MockXConnection::WindowInfo* transient_info = |
| 1371 xconn_->GetWindowInfoOrDie(transient_xid); | 1379 xconn_->GetWindowInfoOrDie(transient_xid); |
| 1372 transient_info->transient_for = toplevel_xid; | 1380 transient_info->transient_for = toplevel_xid; |
| 1373 SendInitialEventsForWindow(transient_xid); | 1381 SendInitialEventsForWindow(transient_xid); |
| 1374 | 1382 |
| 1375 // Check that its initial size is preserved. | 1383 // Check that its initial size is preserved. |
| 1376 EXPECT_EQ(initial_width, transient_info->bounds.width); | 1384 EXPECT_EQ(initial_width, transient_info->bounds.width); |
| 1377 EXPECT_EQ(initial_height, transient_info->bounds.height); | 1385 EXPECT_EQ(initial_height, transient_info->bounds.height); |
| 1378 EXPECT_TRUE(lm_->GetToplevelWindowOwningTransientWindow( | 1386 EXPECT_TRUE(lm_->GetToplevelWindowOwningTransientWindow( |
| 1379 *(wm_->GetWindowOrDie(transient_xid))) == toplevel);; | 1387 *(wm_->GetWindowOrDie(transient_xid))) == toplevel);; |
| 1380 | 1388 |
| 1381 // Now create a second transient window that says it's transient for the | 1389 // Now create a second transient window that says it's transient for the |
| 1382 // first transient window. | 1390 // first transient window. |
| 1383 XWindow nested_transient_xid = | 1391 XWindow nested_transient_xid = |
| 1384 CreateBasicWindow(0, 0, initial_width, initial_height); | 1392 CreateBasicWindow(Rect(0, 0, initial_width, initial_height)); |
| 1385 MockXConnection::WindowInfo* nested_transient_info = | 1393 MockXConnection::WindowInfo* nested_transient_info = |
| 1386 xconn_->GetWindowInfoOrDie(nested_transient_xid); | 1394 xconn_->GetWindowInfoOrDie(nested_transient_xid); |
| 1387 nested_transient_info->transient_for = transient_xid; | 1395 nested_transient_info->transient_for = transient_xid; |
| 1388 SendInitialEventsForWindow(nested_transient_xid); | 1396 SendInitialEventsForWindow(nested_transient_xid); |
| 1389 | 1397 |
| 1390 // The second transient window should be treated as a transient of the | 1398 // The second transient window should be treated as a transient of the |
| 1391 // toplevel instead. We check that it keeps its initial size rather than | 1399 // toplevel instead. We check that it keeps its initial size rather than |
| 1392 // being maximized. | 1400 // being maximized. |
| 1393 EXPECT_EQ(initial_width, nested_transient_info->bounds.width); | 1401 EXPECT_EQ(initial_width, nested_transient_info->bounds.width); |
| 1394 EXPECT_EQ(initial_height, nested_transient_info->bounds.height); | 1402 EXPECT_EQ(initial_height, nested_transient_info->bounds.height); |
| 1395 EXPECT_TRUE(lm_->GetToplevelWindowOwningTransientWindow( | 1403 EXPECT_TRUE(lm_->GetToplevelWindowOwningTransientWindow( |
| 1396 *(wm_->GetWindowOrDie(nested_transient_xid))) == toplevel);; | 1404 *(wm_->GetWindowOrDie(nested_transient_xid))) == toplevel);; |
| 1397 | 1405 |
| 1398 // For good measure, do it all again with another transient window nested | 1406 // For good measure, do it all again with another transient window nested |
| 1399 // one level deeper. | 1407 // one level deeper. |
| 1400 XWindow another_transient_xid = | 1408 XWindow another_transient_xid = |
| 1401 CreateBasicWindow(0, 0, initial_width, initial_height); | 1409 CreateBasicWindow(Rect(0, 0, initial_width, initial_height)); |
| 1402 MockXConnection::WindowInfo* another_transient_info = | 1410 MockXConnection::WindowInfo* another_transient_info = |
| 1403 xconn_->GetWindowInfoOrDie(another_transient_xid); | 1411 xconn_->GetWindowInfoOrDie(another_transient_xid); |
| 1404 another_transient_info->transient_for = nested_transient_xid; | 1412 another_transient_info->transient_for = nested_transient_xid; |
| 1405 SendInitialEventsForWindow(another_transient_xid); | 1413 SendInitialEventsForWindow(another_transient_xid); |
| 1406 EXPECT_EQ(initial_width, another_transient_info->bounds.width); | 1414 EXPECT_EQ(initial_width, another_transient_info->bounds.width); |
| 1407 EXPECT_EQ(initial_height, another_transient_info->bounds.height); | 1415 EXPECT_EQ(initial_height, another_transient_info->bounds.height); |
| 1408 EXPECT_TRUE(lm_->GetToplevelWindowOwningTransientWindow( | 1416 EXPECT_TRUE(lm_->GetToplevelWindowOwningTransientWindow( |
| 1409 *(wm_->GetWindowOrDie(another_transient_xid))) == toplevel);; | 1417 *(wm_->GetWindowOrDie(another_transient_xid))) == toplevel);; |
| 1410 } | 1418 } |
| 1411 | 1419 |
| 1412 // Check that the initial Chrome window appears onscreen immediately | 1420 // Check that the initial Chrome window appears onscreen immediately |
| 1413 // instead of sliding in from the side. | 1421 // instead of sliding in from the side. |
| 1414 TEST_F(LayoutManagerTest, NoSlideForInitialWindow) { | 1422 TEST_F(LayoutManagerTest, NoSlideForInitialWindow) { |
| 1415 // Create a window and check that it's in the expected location. | 1423 // Create a window and check that it's in the expected location. |
| 1416 XWindow xid = CreateToplevelWindow(0, 0, 0, 0, 640, 480); | 1424 XWindow xid = |
| 1425 CreateToplevelWindow(0, 0, Rect(0, 0, 640, 480)); |
| 1417 SendInitialEventsForWindow(xid); | 1426 SendInitialEventsForWindow(xid); |
| 1418 Window* win = wm_->GetWindowOrDie(xid); | 1427 Window* win = wm_->GetWindowOrDie(xid); |
| 1419 EXPECT_EQ(0, win->client_x()); | 1428 EXPECT_EQ(0, win->client_x()); |
| 1420 EXPECT_EQ(0, win->client_y()); | 1429 EXPECT_EQ(0, win->client_y()); |
| 1421 EXPECT_EQ(0, win->composited_x()); | 1430 EXPECT_EQ(0, win->composited_x()); |
| 1422 EXPECT_EQ(0, win->composited_y()); | 1431 EXPECT_EQ(0, win->composited_y()); |
| 1423 | 1432 |
| 1424 // The actor should've been moved immediately to its current location | 1433 // The actor should've been moved immediately to its current location |
| 1425 // instead of getting animated. | 1434 // instead of getting animated. |
| 1426 MockCompositor::Actor* actor = GetMockActorForWindow(win); | 1435 MockCompositor::Actor* actor = GetMockActorForWindow(win); |
| 1427 EXPECT_FALSE(actor->position_was_animated()); | 1436 EXPECT_FALSE(actor->position_was_animated()); |
| 1428 | 1437 |
| 1429 // Now create a second window and check that it *does* get animated. | 1438 // Now create a second window and check that it *does* get animated. |
| 1430 XWindow xid2 = CreateToplevelWindow(0, 0, 0, 0, 640, 480); | 1439 XWindow xid2 = |
| 1440 CreateToplevelWindow(0, 0, Rect(0, 0, 640, 480)); |
| 1431 SendInitialEventsForWindow(xid2); | 1441 SendInitialEventsForWindow(xid2); |
| 1432 Window* win2 = wm_->GetWindowOrDie(xid2); | 1442 Window* win2 = wm_->GetWindowOrDie(xid2); |
| 1433 EXPECT_EQ(0, win2->client_x()); | 1443 EXPECT_EQ(0, win2->client_x()); |
| 1434 EXPECT_EQ(0, win2->client_y()); | 1444 EXPECT_EQ(0, win2->client_y()); |
| 1435 EXPECT_EQ(0, win2->composited_x()); | 1445 EXPECT_EQ(0, win2->composited_x()); |
| 1436 EXPECT_EQ(0, win2->composited_y()); | 1446 EXPECT_EQ(0, win2->composited_y()); |
| 1437 MockCompositor::Actor* actor2 = GetMockActorForWindow(win2); | 1447 MockCompositor::Actor* actor2 = GetMockActorForWindow(win2); |
| 1438 EXPECT_TRUE(actor2->position_was_animated()); | 1448 EXPECT_TRUE(actor2->position_was_animated()); |
| 1439 } | 1449 } |
| 1440 | 1450 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 EXPECT_FALSE(win->wm_state_fullscreen()); | 1510 EXPECT_FALSE(win->wm_state_fullscreen()); |
| 1501 EXPECT_TRUE(WindowIsInLayer(win, StackingManager::LAYER_TOPLEVEL_WINDOW)); | 1511 EXPECT_TRUE(WindowIsInLayer(win, StackingManager::LAYER_TOPLEVEL_WINDOW)); |
| 1502 | 1512 |
| 1503 // Make the window fullscreen again and check that it stays that way if a | 1513 // Make the window fullscreen again and check that it stays that way if a |
| 1504 // transient window is opened for it. | 1514 // transient window is opened for it. |
| 1505 wm_->HandleEvent(&fullscreen_event); | 1515 wm_->HandleEvent(&fullscreen_event); |
| 1506 EXPECT_EQ(xid, xconn_->focused_xid()); | 1516 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 1507 EXPECT_TRUE(win->wm_state_fullscreen()); | 1517 EXPECT_TRUE(win->wm_state_fullscreen()); |
| 1508 EXPECT_TRUE(WindowIsInLayer(win, StackingManager::LAYER_FULLSCREEN_WINDOW)); | 1518 EXPECT_TRUE(WindowIsInLayer(win, StackingManager::LAYER_FULLSCREEN_WINDOW)); |
| 1509 | 1519 |
| 1510 XWindow transient_xid = CreateBasicWindow(0, 0, 300, 300); | 1520 XWindow transient_xid = CreateBasicWindow(Rect(0, 0, 300, 300)); |
| 1511 MockXConnection::WindowInfo* transient_info = | 1521 MockXConnection::WindowInfo* transient_info = |
| 1512 xconn_->GetWindowInfoOrDie(transient_xid); | 1522 xconn_->GetWindowInfoOrDie(transient_xid); |
| 1513 transient_info->transient_for = xid; | 1523 transient_info->transient_for = xid; |
| 1514 SendInitialEventsForWindow(transient_xid); | 1524 SendInitialEventsForWindow(transient_xid); |
| 1515 Window* transient_win = wm_->GetWindowOrDie(transient_xid); | 1525 Window* transient_win = wm_->GetWindowOrDie(transient_xid); |
| 1516 EXPECT_TRUE(win->wm_state_fullscreen()); | 1526 EXPECT_TRUE(win->wm_state_fullscreen()); |
| 1517 EXPECT_TRUE(WindowIsInLayer(win, StackingManager::LAYER_FULLSCREEN_WINDOW)); | 1527 EXPECT_TRUE(WindowIsInLayer(win, StackingManager::LAYER_FULLSCREEN_WINDOW)); |
| 1518 EXPECT_TRUE(WindowIsInLayer(transient_win, | 1528 EXPECT_TRUE(WindowIsInLayer(transient_win, |
| 1519 StackingManager::LAYER_FULLSCREEN_WINDOW)); | 1529 StackingManager::LAYER_FULLSCREEN_WINDOW)); |
| 1520 | 1530 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 lm_ = wm_->layout_manager_.get(); | 1635 lm_ = wm_->layout_manager_.get(); |
| 1626 ASSERT_TRUE(lm_ != NULL); | 1636 ASSERT_TRUE(lm_ != NULL); |
| 1627 ASSERT_TRUE(lm_->background_.get() != NULL); | 1637 ASSERT_TRUE(lm_->background_.get() != NULL); |
| 1628 MockCompositor::Actor* cast_lm_background = | 1638 MockCompositor::Actor* cast_lm_background = |
| 1629 dynamic_cast<MockCompositor::Actor*>(lm_->background_.get()); | 1639 dynamic_cast<MockCompositor::Actor*>(lm_->background_.get()); |
| 1630 CHECK(cast_lm_background); | 1640 CHECK(cast_lm_background); |
| 1631 EXPECT_FALSE(cast_lm_background->is_shown()); | 1641 EXPECT_FALSE(cast_lm_background->is_shown()); |
| 1632 | 1642 |
| 1633 // After the first Chrome window gets mapped, we should show the layout | 1643 // After the first Chrome window gets mapped, we should show the layout |
| 1634 // manager background. | 1644 // manager background. |
| 1635 XWindow toplevel_xid = CreateToplevelWindow(2, 0, 0, 0, 640, 480); | 1645 XWindow toplevel_xid = |
| 1646 CreateToplevelWindow(2, 0, Rect(0, 0, 640, 480)); |
| 1636 SendInitialEventsForWindow(toplevel_xid); | 1647 SendInitialEventsForWindow(toplevel_xid); |
| 1637 ASSERT_TRUE(lm_->background_.get() != NULL); | 1648 ASSERT_TRUE(lm_->background_.get() != NULL); |
| 1638 EXPECT_TRUE(cast_lm_background->is_shown()); | 1649 EXPECT_TRUE(cast_lm_background->is_shown()); |
| 1639 | 1650 |
| 1640 // And after the window gets closed, we should hide the layout manager | 1651 // And after the window gets closed, we should hide the layout manager |
| 1641 // background. | 1652 // background. |
| 1642 XEvent event; | 1653 XEvent event; |
| 1643 xconn_->InitUnmapEvent(&event, toplevel_xid); | 1654 xconn_->InitUnmapEvent(&event, toplevel_xid); |
| 1644 wm_->HandleEvent(&event); | 1655 wm_->HandleEvent(&event); |
| 1645 ASSERT_TRUE(lm_->background_.get() != NULL); | 1656 ASSERT_TRUE(lm_->background_.get() != NULL); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1656 EXPECT_TRUE(xconn_->KeyIsGrabbed(xconn_->GetKeyCodeFromKeySym(XK_F2), 0)); | 1667 EXPECT_TRUE(xconn_->KeyIsGrabbed(xconn_->GetKeyCodeFromKeySym(XK_F2), 0)); |
| 1657 | 1668 |
| 1658 lm_->SetMode(LayoutManager::MODE_ACTIVE); | 1669 lm_->SetMode(LayoutManager::MODE_ACTIVE); |
| 1659 EXPECT_FALSE(xconn_->KeyIsGrabbed(xconn_->GetKeyCodeFromKeySym(XK_F1), 0)); | 1670 EXPECT_FALSE(xconn_->KeyIsGrabbed(xconn_->GetKeyCodeFromKeySym(XK_F1), 0)); |
| 1660 EXPECT_FALSE(xconn_->KeyIsGrabbed(xconn_->GetKeyCodeFromKeySym(XK_F2), 0)); | 1671 EXPECT_FALSE(xconn_->KeyIsGrabbed(xconn_->GetKeyCodeFromKeySym(XK_F2), 0)); |
| 1661 } | 1672 } |
| 1662 | 1673 |
| 1663 // Check that shadows only get displayed for transient windows. | 1674 // Check that shadows only get displayed for transient windows. |
| 1664 TEST_F(LayoutManagerTest, Shadows) { | 1675 TEST_F(LayoutManagerTest, Shadows) { |
| 1665 // Chrome toplevel windows shouldn't have shadows. | 1676 // Chrome toplevel windows shouldn't have shadows. |
| 1666 XWindow toplevel_xid = CreateToplevelWindow(2, 0, 0, 0, 200, 200); | 1677 XWindow toplevel_xid = |
| 1678 CreateToplevelWindow(2, 0, Rect(0, 0, 200, 200)); |
| 1667 SendInitialEventsForWindow(toplevel_xid); | 1679 SendInitialEventsForWindow(toplevel_xid); |
| 1668 EXPECT_TRUE(wm_->GetWindowOrDie(toplevel_xid)->shadow() == NULL); | 1680 EXPECT_TRUE(wm_->GetWindowOrDie(toplevel_xid)->shadow() == NULL); |
| 1669 | 1681 |
| 1670 // Neither should non-Chrome toplevel windows. | 1682 // Neither should non-Chrome toplevel windows. |
| 1671 XWindow other_xid = CreateSimpleWindow(); | 1683 XWindow other_xid = CreateSimpleWindow(); |
| 1672 SendInitialEventsForWindow(other_xid); | 1684 SendInitialEventsForWindow(other_xid); |
| 1673 EXPECT_TRUE(wm_->GetWindowOrDie(other_xid)->shadow() == NULL); | 1685 EXPECT_TRUE(wm_->GetWindowOrDie(other_xid)->shadow() == NULL); |
| 1674 | 1686 |
| 1675 // Or snapshot windows, or their title and fav icons windows. | 1687 // Or snapshot windows, or their title and fav icons windows. |
| 1676 XWindow snapshot_xid = CreateSimpleSnapshotWindow(toplevel_xid, 0); | 1688 XWindow snapshot_xid = CreateSimpleSnapshotWindow(toplevel_xid, 0); |
| 1677 SendInitialEventsForWindow(snapshot_xid); | 1689 SendInitialEventsForWindow(snapshot_xid); |
| 1678 EXPECT_TRUE(wm_->GetWindowOrDie(snapshot_xid)->shadow() == NULL); | 1690 EXPECT_TRUE(wm_->GetWindowOrDie(snapshot_xid)->shadow() == NULL); |
| 1679 | 1691 |
| 1680 XWindow title_xid = CreateTitleWindow(snapshot_xid, 200, 16); | 1692 XWindow title_xid = CreateTitleWindow(snapshot_xid, Size(200, 16)); |
| 1681 SendInitialEventsForWindow(title_xid); | 1693 SendInitialEventsForWindow(title_xid); |
| 1682 EXPECT_TRUE(wm_->GetWindowOrDie(title_xid)->shadow() == NULL); | 1694 EXPECT_TRUE(wm_->GetWindowOrDie(title_xid)->shadow() == NULL); |
| 1683 | 1695 |
| 1684 XWindow fav_icon_xid = CreateFavIconWindow(snapshot_xid, 16, 16); | 1696 XWindow fav_icon_xid = CreateFavIconWindow(snapshot_xid, Size(16, 16)); |
| 1685 SendInitialEventsForWindow(fav_icon_xid); | 1697 SendInitialEventsForWindow(fav_icon_xid); |
| 1686 EXPECT_TRUE(wm_->GetWindowOrDie(fav_icon_xid)->shadow() == NULL); | 1698 EXPECT_TRUE(wm_->GetWindowOrDie(fav_icon_xid)->shadow() == NULL); |
| 1687 | 1699 |
| 1688 // Transient windows should get shadows, though... | 1700 // Transient windows should get shadows, though... |
| 1689 XWindow transient_xid = CreateSimpleWindow(); | 1701 XWindow transient_xid = CreateSimpleWindow(); |
| 1690 xconn_->GetWindowInfoOrDie(transient_xid)->transient_for = toplevel_xid; | 1702 xconn_->GetWindowInfoOrDie(transient_xid)->transient_for = toplevel_xid; |
| 1691 SendInitialEventsForWindow(transient_xid); | 1703 SendInitialEventsForWindow(transient_xid); |
| 1692 ASSERT_TRUE(wm_->GetWindowOrDie(transient_xid)->shadow() != NULL); | 1704 ASSERT_TRUE(wm_->GetWindowOrDie(transient_xid)->shadow() != NULL); |
| 1693 EXPECT_TRUE(wm_->GetWindowOrDie(transient_xid)->shadow()->is_shown()); | 1705 EXPECT_TRUE(wm_->GetWindowOrDie(transient_xid)->shadow()->is_shown()); |
| 1694 | 1706 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1709 rgba_info->depth = 32; | 1721 rgba_info->depth = 32; |
| 1710 SendInitialEventsForWindow(rgba_xid); | 1722 SendInitialEventsForWindow(rgba_xid); |
| 1711 EXPECT_TRUE(wm_->GetWindowOrDie(rgba_xid)->shadow() == NULL); | 1723 EXPECT_TRUE(wm_->GetWindowOrDie(rgba_xid)->shadow() == NULL); |
| 1712 } | 1724 } |
| 1713 | 1725 |
| 1714 // Check that we defer animating new windows onscreen until the client says | 1726 // Check that we defer animating new windows onscreen until the client says |
| 1715 // that they've been painted. | 1727 // that they've been painted. |
| 1716 TEST_F(LayoutManagerTest, DeferAnimationsUntilPainted) { | 1728 TEST_F(LayoutManagerTest, DeferAnimationsUntilPainted) { |
| 1717 // Create and map two windows. Make the second one say that it supports | 1729 // Create and map two windows. Make the second one say that it supports |
| 1718 // the _NET_WM_SYNC_REQUEST protocol. | 1730 // the _NET_WM_SYNC_REQUEST protocol. |
| 1719 XWindow xid1 = CreateToplevelWindow(2, 0, 0, 0, 200, 200); | 1731 XWindow xid1 = |
| 1732 CreateToplevelWindow(2, 0, Rect(0, 0, 200, 200)); |
| 1720 SendInitialEventsForWindow(xid1); | 1733 SendInitialEventsForWindow(xid1); |
| 1721 XWindow xid2 = CreateToplevelWindow(2, 0, 0, 0, 200, 200); | 1734 XWindow xid2 = |
| 1735 CreateToplevelWindow(2, 0, Rect(0, 0, 200, 200)); |
| 1722 ConfigureWindowForSyncRequestProtocol(xid2); | 1736 ConfigureWindowForSyncRequestProtocol(xid2); |
| 1723 SendInitialEventsForWindow(xid2); | 1737 SendInitialEventsForWindow(xid2); |
| 1724 | 1738 |
| 1725 // Check that the second window got the focus, but that the first still | 1739 // Check that the second window got the focus, but that the first still |
| 1726 // has its client window onscreen (since the second window hasn't said | 1740 // has its client window onscreen (since the second window hasn't said |
| 1727 // that it's been painted yet). | 1741 // that it's been painted yet). |
| 1728 EXPECT_FALSE(WindowIsOffscreen(xid1)); | 1742 EXPECT_FALSE(WindowIsOffscreen(xid1)); |
| 1729 EXPECT_TRUE(WindowIsOffscreen(xid2)); | 1743 EXPECT_TRUE(WindowIsOffscreen(xid2)); |
| 1730 EXPECT_EQ(xid2, xconn_->focused_xid()); | 1744 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 1731 | 1745 |
| 1732 // Tell the window manager that the second window has been painted and | 1746 // Tell the window manager that the second window has been painted and |
| 1733 // check that it moves it onscreen. | 1747 // check that it moves it onscreen. |
| 1734 SendSyncRequestProtocolAlarm(xid2); | 1748 SendSyncRequestProtocolAlarm(xid2); |
| 1735 EXPECT_TRUE(WindowIsOffscreen(xid1)); | 1749 EXPECT_TRUE(WindowIsOffscreen(xid1)); |
| 1736 EXPECT_FALSE(WindowIsOffscreen(xid2)); | 1750 EXPECT_FALSE(WindowIsOffscreen(xid2)); |
| 1737 EXPECT_EQ(xid2, xconn_->focused_xid()); | 1751 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 1738 } | 1752 } |
| 1739 | 1753 |
| 1740 // Check that we switch toplevel windows as needed when a modal transient | 1754 // Check that we switch toplevel windows as needed when a modal transient |
| 1741 // window gets mapped, or when the modal hint is set on an existing | 1755 // window gets mapped, or when the modal hint is set on an existing |
| 1742 // transient window. | 1756 // transient window. |
| 1743 TEST_F(LayoutManagerTest, SwitchToToplevelWithModalTransient) { | 1757 TEST_F(LayoutManagerTest, SwitchToToplevelWithModalTransient) { |
| 1744 // Create two toplevel windows. | 1758 // Create two toplevel windows. |
| 1745 XWindow xid1 = CreateToplevelWindow(2, 0, 0, 0, 200, 200); | 1759 XWindow xid1 = |
| 1760 CreateToplevelWindow(2, 0, Rect(0, 0, 200, 200)); |
| 1746 SendInitialEventsForWindow(xid1); | 1761 SendInitialEventsForWindow(xid1); |
| 1747 XWindow xid2 = CreateToplevelWindow(2, 0, 0, 0, 200, 200); | 1762 XWindow xid2 = |
| 1763 CreateToplevelWindow(2, 0, Rect(0, 0, 200, 200)); |
| 1748 SendInitialEventsForWindow(xid2); | 1764 SendInitialEventsForWindow(xid2); |
| 1749 | 1765 |
| 1750 // The second toplevel should be focused initially. | 1766 // The second toplevel should be focused initially. |
| 1751 EXPECT_TRUE(WindowIsOffscreen(xid1)); | 1767 EXPECT_TRUE(WindowIsOffscreen(xid1)); |
| 1752 EXPECT_EQ(xid2, xconn_->focused_xid()); | 1768 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 1753 EXPECT_EQ(xid2, GetActiveWindowProperty()); | 1769 EXPECT_EQ(xid2, GetActiveWindowProperty()); |
| 1754 EXPECT_FALSE(WindowIsOffscreen(xid2)); | 1770 EXPECT_FALSE(WindowIsOffscreen(xid2)); |
| 1755 | 1771 |
| 1756 // At first, the key bindings should be enabled. | 1772 // At first, the key bindings should be enabled. |
| 1757 EXPECT_TRUE(lm_->active_mode_key_bindings_group_->enabled()); | 1773 EXPECT_TRUE(lm_->active_mode_key_bindings_group_->enabled()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 LayoutManager::ToplevelWindow* toplevel = | 1907 LayoutManager::ToplevelWindow* toplevel = |
| 1892 lm_->GetToplevelWindowByXid(toplevel_xid); | 1908 lm_->GetToplevelWindowByXid(toplevel_xid); |
| 1893 ASSERT_TRUE(toplevel != NULL); | 1909 ASSERT_TRUE(toplevel != NULL); |
| 1894 EXPECT_EQ(toplevel, | 1910 EXPECT_EQ(toplevel, |
| 1895 lm_->GetToplevelWindowOwningTransientWindow( | 1911 lm_->GetToplevelWindowOwningTransientWindow( |
| 1896 *(wm_->GetWindowOrDie(transient_xid)))); | 1912 *(wm_->GetWindowOrDie(transient_xid)))); |
| 1897 } | 1913 } |
| 1898 | 1914 |
| 1899 // Test that we close transient windows when their owners are unmapped. | 1915 // Test that we close transient windows when their owners are unmapped. |
| 1900 TEST_F(LayoutManagerTest, CloseTransientWindowsWhenOwnerIsUnmapped) { | 1916 TEST_F(LayoutManagerTest, CloseTransientWindowsWhenOwnerIsUnmapped) { |
| 1901 XWindow owner_xid = CreateToplevelWindow(1, 0, 0, 0, 640, 480); | 1917 XWindow owner_xid = |
| 1918 CreateToplevelWindow(1, 0, Rect(0, 0, 640, 480)); |
| 1902 SendInitialEventsForWindow(owner_xid); | 1919 SendInitialEventsForWindow(owner_xid); |
| 1903 | 1920 |
| 1904 XWindow transient_xid = CreateSimpleWindow(); | 1921 XWindow transient_xid = CreateSimpleWindow(); |
| 1905 // Say that we support the WM_DELETE_WINDOW protocol. | 1922 // Say that we support the WM_DELETE_WINDOW protocol. |
| 1906 AppendAtomToProperty(transient_xid, | 1923 AppendAtomToProperty(transient_xid, |
| 1907 xconn_->GetAtomOrDie("WM_PROTOCOLS"), | 1924 xconn_->GetAtomOrDie("WM_PROTOCOLS"), |
| 1908 xconn_->GetAtomOrDie("WM_DELETE_WINDOW")); | 1925 xconn_->GetAtomOrDie("WM_DELETE_WINDOW")); |
| 1909 MockXConnection::WindowInfo* transient_info = | 1926 MockXConnection::WindowInfo* transient_info = |
| 1910 xconn_->GetWindowInfoOrDie(transient_xid); | 1927 xconn_->GetWindowInfoOrDie(transient_xid); |
| 1911 transient_info->transient_for = owner_xid; | 1928 transient_info->transient_for = owner_xid; |
| 1912 SendInitialEventsForWindow(transient_xid); | 1929 SendInitialEventsForWindow(transient_xid); |
| 1913 | 1930 |
| 1914 // After we unmap the owner, the transient should receive a delete request. | 1931 // After we unmap the owner, the transient should receive a delete request. |
| 1915 ASSERT_EQ(0, GetNumDeleteWindowMessagesForWindow(transient_xid)); | 1932 ASSERT_EQ(0, GetNumDeleteWindowMessagesForWindow(transient_xid)); |
| 1916 XEvent event; | 1933 XEvent event; |
| 1917 xconn_->InitUnmapEvent(&event, owner_xid); | 1934 xconn_->InitUnmapEvent(&event, owner_xid); |
| 1918 wm_->HandleEvent(&event); | 1935 wm_->HandleEvent(&event); |
| 1919 ASSERT_EQ(1, GetNumDeleteWindowMessagesForWindow(transient_xid)); | 1936 ASSERT_EQ(1, GetNumDeleteWindowMessagesForWindow(transient_xid)); |
| 1920 } | 1937 } |
| 1921 | 1938 |
| 1922 } // namespace window_manager | 1939 } // namespace window_manager |
| 1923 | 1940 |
| 1924 int main(int argc, char** argv) { | 1941 int main(int argc, char** argv) { |
| 1925 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 1942 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 1926 } | 1943 } |
| OLD | NEW |