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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 2739703003: Last sets of tests that can move to common_unittests (Closed)
Patch Set: comments Created 3 years, 9 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
« no previous file with comments | « ash/test/ash_test_base.cc ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/accessibility_delegate.h" 8 #include "ash/common/accessibility_delegate.h"
9 #include "ash/common/accessibility_types.h" 9 #include "ash/common/accessibility_types.h"
10 #include "ash/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 aura::test::TestWindowDelegate delegate_; 359 aura::test::TestWindowDelegate delegate_;
360 NonActivatableActivationDelegate non_activatable_activation_delegate_; 360 NonActivatableActivationDelegate non_activatable_activation_delegate_;
361 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; 361 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_;
362 362
363 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); 363 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest);
364 }; 364 };
365 365
366 // Tests that the text field in the overview menu is repositioned and resized 366 // Tests that the text field in the overview menu is repositioned and resized
367 // after a screen rotation. 367 // after a screen rotation.
368 TEST_F(WindowSelectorTest, OverviewScreenRotation) { 368 TEST_F(WindowSelectorTest, OverviewScreenRotation) {
369 // TODO: fails in mash because rotation is not supported.
370 // http://crbug.com/695556
371 if (WmShell::Get()->IsRunningInMash())
372 return;
373
369 gfx::Rect bounds(0, 0, 400, 300); 374 gfx::Rect bounds(0, 0, 400, 300);
370 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 375 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
371 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 376 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
372 377
373 // In overview mode the windows should no longer overlap and the text filter 378 // In overview mode the windows should no longer overlap and the text filter
374 // widget should be focused. 379 // widget should be focused.
375 ToggleOverview(); 380 ToggleOverview();
376 381
377 views::Widget* text_filter = text_filter_widget(); 382 views::Widget* text_filter = text_filter_widget();
378 UpdateDisplay("400x300"); 383 UpdateDisplay("400x300");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 438 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
434 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 439 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
435 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); 440 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds));
436 441
437 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); 442 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get()));
438 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); 443 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get()));
439 wm::ActivateWindow(window2.get()); 444 wm::ActivateWindow(window2.get());
440 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 445 EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
441 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 446 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
442 EXPECT_EQ(window2.get(), GetFocusedWindow()); 447 EXPECT_EQ(window2.get(), GetFocusedWindow());
443 // Hide the cursor before entering overview to test that it will be shown. 448 // TODO: mash doesn't support CursorClient. http://crbug.com/637853.
444 aura::client::GetCursorClient(root_window)->HideCursor(); 449 if (!WmShell::Get()->IsRunningInMash()) {
450 // Hide the cursor before entering overview to test that it will be shown.
451 aura::client::GetCursorClient(root_window)->HideCursor();
452 }
445 453
446 // In overview mode the windows should no longer overlap and the text filter 454 // In overview mode the windows should no longer overlap and the text filter
447 // widget should be focused. 455 // widget should be focused.
448 ToggleOverview(); 456 ToggleOverview();
449 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); 457 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
450 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); 458 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
451 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get())); 459 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get()));
452 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get())); 460 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get()));
453 461
454 // Clicking window 1 should activate it. 462 // Clicking window 1 should activate it.
455 ClickWindow(window1.get()); 463 ClickWindow(window1.get());
456 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 464 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
457 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 465 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
458 EXPECT_EQ(window1.get(), GetFocusedWindow()); 466 EXPECT_EQ(window1.get(), GetFocusedWindow());
459 467
460 // Cursor should have been unlocked. 468 // TODO: mash doesn't support CursorClient. http://crbug.com/637853.
461 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); 469 if (!WmShell::Get()->IsRunningInMash()) {
470 // Cursor should have been unlocked.
471 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked());
472 }
462 } 473 }
463 474
464 // Tests activating minimized window. 475 // Tests activating minimized window.
465 TEST_F(WindowSelectorTest, ActivateMinimized) { 476 TEST_F(WindowSelectorTest, ActivateMinimized) {
466 gfx::Rect bounds(0, 0, 400, 400); 477 gfx::Rect bounds(0, 0, 400, 400);
467 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); 478 std::unique_ptr<aura::Window> window(CreateWindow(bounds));
468 479
469 wm::WindowState* window_state = wm::GetWindowState(window.get()); 480 wm::WindowState* window_state = wm::GetWindowState(window.get());
470 wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE); 481 wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE);
471 window_state->OnWMEvent(&minimize_event); 482 window_state->OnWMEvent(&minimize_event);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 window2.get()); 857 window2.get());
847 generator.GestureTapAt( 858 generator.GestureTapAt(
848 GetTransformedTargetBounds(window2.get()).CenterPoint()); 859 GetTransformedTargetBounds(window2.get()).CenterPoint());
849 EXPECT_EQ(window2.get(), GetFocusedWindow()); 860 EXPECT_EQ(window2.get(), GetFocusedWindow());
850 } 861 }
851 862
852 // Tests that the user action WindowSelector_ActiveWindowChanged is 863 // Tests that the user action WindowSelector_ActiveWindowChanged is
853 // recorded when the mouse/touchscreen/keyboard are used to select a window 864 // recorded when the mouse/touchscreen/keyboard are used to select a window
854 // in overview mode which is different from the previously-active window. 865 // in overview mode which is different from the previously-active window.
855 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { 866 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) {
867 // TODO: fails because of metrics. http://crbug.com/698129.
868 if (WmShell::Get()->IsRunningInMash())
869 return;
870
856 base::UserActionTester user_action_tester; 871 base::UserActionTester user_action_tester;
857 gfx::Rect bounds(0, 0, 400, 400); 872 gfx::Rect bounds(0, 0, 400, 400);
858 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 873 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
859 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 874 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
860 875
861 // Tap on |window2| to activate it and exit overview. 876 // Tap on |window2| to activate it and exit overview.
862 wm::ActivateWindow(window1.get()); 877 wm::ActivateWindow(window1.get());
863 ToggleOverview(); 878 ToggleOverview();
864 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 879 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
865 window2.get()); 880 window2.get());
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 // Enter overview again and select window 2. Selecting window 2 should show 1232 // Enter overview again and select window 2. Selecting window 2 should show
1218 // the shelf bringing window2 back to the normal bounds. 1233 // the shelf bringing window2 back to the normal bounds.
1219 ToggleOverview(); 1234 ToggleOverview();
1220 ClickWindow(window2.get()); 1235 ClickWindow(window2.get());
1221 EXPECT_EQ(normal_window_bounds.ToString(), 1236 EXPECT_EQ(normal_window_bounds.ToString(),
1222 window2->GetTargetBounds().ToString()); 1237 window2->GetTargetBounds().ToString());
1223 } 1238 }
1224 1239
1225 // Tests that beginning window selection hides the app list. 1240 // Tests that beginning window selection hides the app list.
1226 TEST_F(WindowSelectorTest, SelectingHidesAppList) { 1241 TEST_F(WindowSelectorTest, SelectingHidesAppList) {
1242 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028.
1243 if (WmShell::Get()->IsRunningInMash())
1244 return;
1245
1227 gfx::Rect bounds(0, 0, 400, 400); 1246 gfx::Rect bounds(0, 0, 400, 400);
1228 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1247 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1229 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1248 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1230 1249
1231 // The tested behavior relies on the app list presenter delegate. 1250 // The tested behavior relies on the app list presenter delegate.
1232 test::TestAppListViewPresenterImpl app_list_presenter_impl; 1251 test::TestAppListViewPresenterImpl app_list_presenter_impl;
1233 1252
1234 app_list_presenter_impl.Show(display_manager()->first_display_id()); 1253 app_list_presenter_impl.Show(display_manager()->first_display_id());
1235 EXPECT_TRUE(app_list_presenter_impl.IsVisible()); 1254 EXPECT_TRUE(app_list_presenter_impl.IsVisible());
1236 1255
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 wm::ActivateWindow(window4); 1523 wm::ActivateWindow(window4);
1505 wm::ActivateWindow(window3); 1524 wm::ActivateWindow(window3);
1506 wm::ActivateWindow(window2); 1525 wm::ActivateWindow(window2);
1507 wm::ActivateWindow(window1); 1526 wm::ActivateWindow(window1);
1508 1527
1509 ToggleOverview(); 1528 ToggleOverview();
1510 } 1529 }
1511 1530
1512 // Tests removing a display during overview. 1531 // Tests removing a display during overview.
1513 TEST_F(WindowSelectorTest, RemoveDisplay) { 1532 TEST_F(WindowSelectorTest, RemoveDisplay) {
1533 // TODO: hits CHECK in stl as order of |ShelfModel::items_| is wrong.
1534 // http://crbug.com/698878.
1535 if (WmShell::Get()->IsRunningInMash())
1536 return;
1537
1514 UpdateDisplay("400x400,400x400"); 1538 UpdateDisplay("400x400,400x400");
1515 gfx::Rect bounds1(0, 0, 100, 100); 1539 gfx::Rect bounds1(0, 0, 100, 100);
1516 gfx::Rect bounds2(450, 0, 100, 100); 1540 gfx::Rect bounds2(450, 0, 100, 100);
1517 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); 1541 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1));
1518 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); 1542 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2));
1519 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); 1543 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1));
1520 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); 1544 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2));
1521 1545
1522 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1546 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1523 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 1547 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 // Labels are located based on target_bounds, not the actual window item 1609 // Labels are located based on target_bounds, not the actual window item
1586 // bounds. 1610 // bounds.
1587 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen(); 1611 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen();
1588 label_bounds.Inset(kWindowMargin, kWindowMargin); 1612 label_bounds.Inset(kWindowMargin, kWindowMargin);
1589 EXPECT_EQ(window_item->target_bounds(), label_bounds); 1613 EXPECT_EQ(window_item->target_bounds(), label_bounds);
1590 } 1614 }
1591 1615
1592 // Tests that overview updates the window positions if the display orientation 1616 // Tests that overview updates the window positions if the display orientation
1593 // changes. 1617 // changes.
1594 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { 1618 TEST_F(WindowSelectorTest, DisplayOrientationChanged) {
1619 // TODO: fails in mash because rotation is not supported.
1620 // http://crbug.com/695556
1621 if (WmShell::Get()->IsRunningInMash())
1622 return;
1623
1595 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 1624 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
1596 UpdateDisplay("600x200"); 1625 UpdateDisplay("600x200");
1597 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); 1626 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString());
1598 gfx::Rect window_bounds(0, 0, 150, 150); 1627 gfx::Rect window_bounds(0, 0, 150, 150);
1599 std::vector<std::unique_ptr<aura::Window>> windows; 1628 std::vector<std::unique_ptr<aura::Window>> windows;
1600 for (int i = 0; i < 3; i++) 1629 for (int i = 0; i < 3; i++)
1601 windows.push_back(base::WrapUnique(CreateWindow(window_bounds))); 1630 windows.push_back(base::WrapUnique(CreateWindow(window_bounds)));
1602 1631
1603 ToggleOverview(); 1632 ToggleOverview();
1604 for (const auto& window : windows) { 1633 for (const auto& window : windows) {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 2163 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
2135 ASSERT_TRUE(resizer.get()); 2164 ASSERT_TRUE(resizer.get());
2136 gfx::Point location = resizer->GetInitialLocation(); 2165 gfx::Point location = resizer->GetInitialLocation();
2137 location.Offset(20, 20); 2166 location.Offset(20, 20);
2138 resizer->Drag(location, 0); 2167 resizer->Drag(location, 0);
2139 ToggleOverview(); 2168 ToggleOverview();
2140 resizer->RevertDrag(); 2169 resizer->RevertDrag();
2141 } 2170 }
2142 2171
2143 } // namespace ash 2172 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_test_base.cc ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698