| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium 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 <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/accessibility_types.h" | 9 #include "ash/accessibility_types.h" |
| 10 #include "ash/drag_drop/drag_drop_controller.h" | 10 #include "ash/drag_drop/drag_drop_controller.h" |
| 11 #include "ash/public/cpp/config.h" |
| 11 #include "ash/shelf/wm_shelf.h" | 12 #include "ash/shelf/wm_shelf.h" |
| 12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 13 #include "ash/shell_port.h" | |
| 14 #include "ash/system/tray/system_tray.h" | 14 #include "ash/system/tray/system_tray.h" |
| 15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/shelf_view_test_api.h" | 16 #include "ash/test/shelf_view_test_api.h" |
| 17 #include "ash/test/shell_test_api.h" | 17 #include "ash/test/shell_test_api.h" |
| 18 #include "ash/test/test_app_list_view_presenter_impl.h" | 18 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 19 #include "ash/test/test_shelf_delegate.h" | 19 #include "ash/test/test_shelf_delegate.h" |
| 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 21 #include "ash/wm/overview/window_grid.h" | 21 #include "ash/wm/overview/window_grid.h" |
| 22 #include "ash/wm/overview/window_selector.h" | 22 #include "ash/wm/overview/window_selector.h" |
| 23 #include "ash/wm/overview/window_selector_controller.h" | 23 #include "ash/wm/overview/window_selector_controller.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 334 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 335 | 335 |
| 336 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); | 336 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 // Tests that the text field in the overview menu is repositioned and resized | 339 // Tests that the text field in the overview menu is repositioned and resized |
| 340 // after a screen rotation. | 340 // after a screen rotation. |
| 341 TEST_F(WindowSelectorTest, OverviewScreenRotation) { | 341 TEST_F(WindowSelectorTest, OverviewScreenRotation) { |
| 342 // TODO: fails in mash because rotation is not supported. | 342 // TODO: fails in mash because rotation is not supported. |
| 343 // http://crbug.com/695556 | 343 // http://crbug.com/695556 |
| 344 if (ShellPort::Get()->IsRunningInMash()) | 344 if (Shell::GetAshConfig() == Config::MASH) |
| 345 return; | 345 return; |
| 346 | 346 |
| 347 gfx::Rect bounds(0, 0, 400, 300); | 347 gfx::Rect bounds(0, 0, 400, 300); |
| 348 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 348 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 349 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 349 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
| 350 | 350 |
| 351 // In overview mode the windows should no longer overlap and the text filter | 351 // In overview mode the windows should no longer overlap and the text filter |
| 352 // widget should be focused. | 352 // widget should be focused. |
| 353 ToggleOverview(); | 353 ToggleOverview(); |
| 354 | 354 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 412 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
| 413 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); | 413 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); |
| 414 | 414 |
| 415 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); | 415 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); |
| 416 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); | 416 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); |
| 417 wm::ActivateWindow(window2.get()); | 417 wm::ActivateWindow(window2.get()); |
| 418 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 418 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 419 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 419 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 420 EXPECT_EQ(window2.get(), wm::GetFocusedWindow()); | 420 EXPECT_EQ(window2.get(), wm::GetFocusedWindow()); |
| 421 // TODO: mash doesn't support CursorClient. http://crbug.com/637853. | 421 // TODO: mash doesn't support CursorClient. http://crbug.com/637853. |
| 422 if (!ShellPort::Get()->IsRunningInMash()) { | 422 if (Shell::GetAshConfig() != Config::MASH) { |
| 423 // Hide the cursor before entering overview to test that it will be shown. | 423 // Hide the cursor before entering overview to test that it will be shown. |
| 424 aura::client::GetCursorClient(root_window)->HideCursor(); | 424 aura::client::GetCursorClient(root_window)->HideCursor(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 // In overview mode the windows should no longer overlap and the text filter | 427 // In overview mode the windows should no longer overlap and the text filter |
| 428 // widget should be focused. | 428 // widget should be focused. |
| 429 ToggleOverview(); | 429 ToggleOverview(); |
| 430 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), wm::GetFocusedWindow()); | 430 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), wm::GetFocusedWindow()); |
| 431 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); | 431 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); |
| 432 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get())); | 432 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get())); |
| 433 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get())); | 433 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get())); |
| 434 | 434 |
| 435 // Clicking window 1 should activate it. | 435 // Clicking window 1 should activate it. |
| 436 ClickWindow(window1.get()); | 436 ClickWindow(window1.get()); |
| 437 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 437 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 438 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 438 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 439 EXPECT_EQ(window1.get(), wm::GetFocusedWindow()); | 439 EXPECT_EQ(window1.get(), wm::GetFocusedWindow()); |
| 440 | 440 |
| 441 // TODO: mash doesn't support CursorClient. http://crbug.com/637853. | 441 // TODO: mash doesn't support CursorClient. http://crbug.com/637853. |
| 442 if (!ShellPort::Get()->IsRunningInMash()) { | 442 if (Shell::GetAshConfig() != Config::MASH) { |
| 443 // Cursor should have been unlocked. | 443 // Cursor should have been unlocked. |
| 444 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); | 444 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 // Tests activating minimized window. | 448 // Tests activating minimized window. |
| 449 TEST_F(WindowSelectorTest, ActivateMinimized) { | 449 TEST_F(WindowSelectorTest, ActivateMinimized) { |
| 450 gfx::Rect bounds(0, 0, 400, 400); | 450 gfx::Rect bounds(0, 0, 400, 400); |
| 451 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); | 451 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 452 | 452 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 generator.GestureTapAt( | 548 generator.GestureTapAt( |
| 549 GetTransformedTargetBounds(window2.get()).CenterPoint()); | 549 GetTransformedTargetBounds(window2.get()).CenterPoint()); |
| 550 EXPECT_EQ(window2.get(), wm::GetFocusedWindow()); | 550 EXPECT_EQ(window2.get(), wm::GetFocusedWindow()); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // Tests that the user action WindowSelector_ActiveWindowChanged is | 553 // Tests that the user action WindowSelector_ActiveWindowChanged is |
| 554 // recorded when the mouse/touchscreen/keyboard are used to select a window | 554 // recorded when the mouse/touchscreen/keyboard are used to select a window |
| 555 // in overview mode which is different from the previously-active window. | 555 // in overview mode which is different from the previously-active window. |
| 556 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { | 556 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { |
| 557 // TODO: fails because of metrics. http://crbug.com/698129. | 557 // TODO: fails because of metrics. http://crbug.com/698129. |
| 558 if (ShellPort::Get()->IsRunningInMash()) | 558 if (Shell::GetAshConfig() == Config::MASH) |
| 559 return; | 559 return; |
| 560 | 560 |
| 561 base::UserActionTester user_action_tester; | 561 base::UserActionTester user_action_tester; |
| 562 gfx::Rect bounds(0, 0, 400, 400); | 562 gfx::Rect bounds(0, 0, 400, 400); |
| 563 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 563 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 564 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 564 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 565 | 565 |
| 566 // Tap on |window2| to activate it and exit overview. | 566 // Tap on |window2| to activate it and exit overview. |
| 567 wm::ActivateWindow(window1.get()); | 567 wm::ActivateWindow(window1.get()); |
| 568 ToggleOverview(); | 568 ToggleOverview(); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 // the shelf bringing window2 back to the normal bounds. | 923 // the shelf bringing window2 back to the normal bounds. |
| 924 ToggleOverview(); | 924 ToggleOverview(); |
| 925 ClickWindow(window2.get()); | 925 ClickWindow(window2.get()); |
| 926 EXPECT_EQ(normal_window_bounds.ToString(), | 926 EXPECT_EQ(normal_window_bounds.ToString(), |
| 927 window2->GetTargetBounds().ToString()); | 927 window2->GetTargetBounds().ToString()); |
| 928 } | 928 } |
| 929 | 929 |
| 930 // Tests that beginning window selection hides the app list. | 930 // Tests that beginning window selection hides the app list. |
| 931 TEST_F(WindowSelectorTest, SelectingHidesAppList) { | 931 TEST_F(WindowSelectorTest, SelectingHidesAppList) { |
| 932 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. | 932 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. |
| 933 if (ShellPort::Get()->IsRunningInMash()) | 933 if (Shell::GetAshConfig() == Config::MASH) |
| 934 return; | 934 return; |
| 935 | 935 |
| 936 gfx::Rect bounds(0, 0, 400, 400); | 936 gfx::Rect bounds(0, 0, 400, 400); |
| 937 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 937 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 938 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 938 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 939 | 939 |
| 940 // The tested behavior relies on the app list presenter delegate. | 940 // The tested behavior relies on the app list presenter delegate. |
| 941 test::TestAppListViewPresenterImpl app_list_presenter_impl; | 941 test::TestAppListViewPresenterImpl app_list_presenter_impl; |
| 942 | 942 |
| 943 app_list_presenter_impl.Show( | 943 app_list_presenter_impl.Show( |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 wm::ActivateWindow(window2); | 1216 wm::ActivateWindow(window2); |
| 1217 wm::ActivateWindow(window1); | 1217 wm::ActivateWindow(window1); |
| 1218 | 1218 |
| 1219 ToggleOverview(); | 1219 ToggleOverview(); |
| 1220 } | 1220 } |
| 1221 | 1221 |
| 1222 // Tests removing a display during overview. | 1222 // Tests removing a display during overview. |
| 1223 TEST_F(WindowSelectorTest, RemoveDisplay) { | 1223 TEST_F(WindowSelectorTest, RemoveDisplay) { |
| 1224 // TODO: hits CHECK in stl as order of |ShelfModel::items_| is wrong. | 1224 // TODO: hits CHECK in stl as order of |ShelfModel::items_| is wrong. |
| 1225 // http://crbug.com/698878. | 1225 // http://crbug.com/698878. |
| 1226 if (ShellPort::Get()->IsRunningInMash()) | 1226 if (Shell::GetAshConfig() == Config::MASH) |
| 1227 return; | 1227 return; |
| 1228 | 1228 |
| 1229 UpdateDisplay("400x400,400x400"); | 1229 UpdateDisplay("400x400,400x400"); |
| 1230 gfx::Rect bounds1(0, 0, 100, 100); | 1230 gfx::Rect bounds1(0, 0, 100, 100); |
| 1231 gfx::Rect bounds2(450, 0, 100, 100); | 1231 gfx::Rect bounds2(450, 0, 100, 100); |
| 1232 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1232 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1233 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1233 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1234 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); | 1234 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); |
| 1235 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); | 1235 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); |
| 1236 | 1236 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen(); | 1302 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen(); |
| 1303 label_bounds.Inset(kWindowMargin, kWindowMargin); | 1303 label_bounds.Inset(kWindowMargin, kWindowMargin); |
| 1304 EXPECT_EQ(window_item->target_bounds(), label_bounds); | 1304 EXPECT_EQ(window_item->target_bounds(), label_bounds); |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 // Tests that overview updates the window positions if the display orientation | 1307 // Tests that overview updates the window positions if the display orientation |
| 1308 // changes. | 1308 // changes. |
| 1309 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { | 1309 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { |
| 1310 // TODO: fails in mash because rotation is not supported. | 1310 // TODO: fails in mash because rotation is not supported. |
| 1311 // http://crbug.com/695556 | 1311 // http://crbug.com/695556 |
| 1312 if (ShellPort::Get()->IsRunningInMash()) | 1312 if (Shell::GetAshConfig() == Config::MASH) |
| 1313 return; | 1313 return; |
| 1314 | 1314 |
| 1315 aura::Window* root_window = Shell::Get()->GetPrimaryRootWindow(); | 1315 aura::Window* root_window = Shell::Get()->GetPrimaryRootWindow(); |
| 1316 UpdateDisplay("600x200"); | 1316 UpdateDisplay("600x200"); |
| 1317 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); | 1317 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); |
| 1318 gfx::Rect window_bounds(0, 0, 150, 150); | 1318 gfx::Rect window_bounds(0, 0, 150, 150); |
| 1319 std::vector<std::unique_ptr<aura::Window>> windows; | 1319 std::vector<std::unique_ptr<aura::Window>> windows; |
| 1320 for (int i = 0; i < 3; i++) | 1320 for (int i = 0; i < 3; i++) |
| 1321 windows.push_back(base::WrapUnique(CreateWindow(window_bounds))); | 1321 windows.push_back(base::WrapUnique(CreateWindow(window_bounds))); |
| 1322 | 1322 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 SendKey(ui::VKEY_RIGHT); | 1437 SendKey(ui::VKEY_RIGHT); |
| 1438 EXPECT_EQ(GetSelectedWindow(), | 1438 EXPECT_EQ(GetSelectedWindow(), |
| 1439 WmWindow::GetAuraWindow(overview_root2[1]->GetWindow())); | 1439 WmWindow::GetAuraWindow(overview_root2[1]->GetWindow())); |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 // Tests first monitor when display order doesn't match left to right screen | 1442 // Tests first monitor when display order doesn't match left to right screen |
| 1443 // positions. | 1443 // positions. |
| 1444 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { | 1444 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { |
| 1445 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash. | 1445 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash. |
| 1446 // http://crbug.com/698043. | 1446 // http://crbug.com/698043. |
| 1447 if (ShellPort::Get()->IsRunningInMash()) | 1447 if (Shell::GetAshConfig() == Config::MASH) |
| 1448 return; | 1448 return; |
| 1449 | 1449 |
| 1450 UpdateDisplay("400x400,400x400"); | 1450 UpdateDisplay("400x400,400x400"); |
| 1451 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays( | 1451 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays( |
| 1452 display::test::CreateDisplayLayout(display_manager(), | 1452 display::test::CreateDisplayLayout(display_manager(), |
| 1453 display::DisplayPlacement::LEFT, 0)); | 1453 display::DisplayPlacement::LEFT, 0)); |
| 1454 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1454 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1455 gfx::Rect bounds1(-350, 0, 100, 100); | 1455 gfx::Rect bounds1(-350, 0, 100, 100); |
| 1456 gfx::Rect bounds2(0, 0, 100, 100); | 1456 gfx::Rect bounds2(0, 0, 100, 100); |
| 1457 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1457 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | 1854 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
| 1855 ASSERT_TRUE(resizer.get()); | 1855 ASSERT_TRUE(resizer.get()); |
| 1856 gfx::Point location = resizer->GetInitialLocation(); | 1856 gfx::Point location = resizer->GetInitialLocation(); |
| 1857 location.Offset(20, 20); | 1857 location.Offset(20, 20); |
| 1858 resizer->Drag(location, 0); | 1858 resizer->Drag(location, 0); |
| 1859 ToggleOverview(); | 1859 ToggleOverview(); |
| 1860 resizer->RevertDrag(); | 1860 resizer->RevertDrag(); |
| 1861 } | 1861 } |
| 1862 | 1862 |
| 1863 } // namespace ash | 1863 } // namespace ash |
| OLD | NEW |