Chromium Code Reviews| 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/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
| 9 #include "ash/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
| 10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 return ScopedTransformOverviewWindow::GetItemScale( | 97 return ScopedTransformOverviewWindow::GetItemScale( |
| 98 source.size(), target.size(), top_view_inset, title_height); | 98 source.size(), target.size(), top_view_inset, title_height); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace | 101 } // namespace |
| 102 | 102 |
| 103 // TODO(bruthig): Move all non-simple method definitions out of class | 103 // TODO(bruthig): Move all non-simple method definitions out of class |
| 104 // declaration. | 104 // declaration. |
| 105 class WindowSelectorTest | 105 class WindowSelectorTest |
| 106 : public test::AshTestBase, | 106 : public test::AshTestBase, |
| 107 public testing::WithParamInterface<ash::MaterialDesignController::Mode> { | 107 public testing::WithParamInterface<MaterialDesignController::Mode> { |
|
James Cook
2016/06/28 22:34:25
I would leave the MaterialDesignController ones. T
msw
2016/06/28 22:49:50
Done.
| |
| 108 public: | 108 public: |
| 109 WindowSelectorTest() {} | 109 WindowSelectorTest() {} |
| 110 ~WindowSelectorTest() override {} | 110 ~WindowSelectorTest() override {} |
| 111 | 111 |
| 112 void SetUp() override { | 112 void SetUp() override { |
| 113 test::AshTestBase::SetUp(); | 113 test::AshTestBase::SetUp(); |
| 114 material_design_state_.reset( | 114 material_design_state_.reset( |
| 115 new test::MaterialDesignControllerTestAPI(GetParam())); | 115 new test::MaterialDesignControllerTestAPI(GetParam())); |
| 116 if (!ash::MaterialDesignController::IsOverviewMaterial()) { | 116 if (!MaterialDesignController::IsOverviewMaterial()) { |
| 117 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 117 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 118 switches::kAshEnableStableOverviewOrder); | 118 switches::kAshEnableStableOverviewOrder); |
| 119 } | 119 } |
| 120 ASSERT_TRUE(test::TestShelfDelegate::instance()); | 120 ASSERT_TRUE(test::TestShelfDelegate::instance()); |
| 121 | 121 |
| 122 shelf_view_test_.reset(new test::ShelfViewTestAPI( | 122 shelf_view_test_.reset(new test::ShelfViewTestAPI( |
| 123 test::ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_view())); | 123 test::ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_view())); |
| 124 shelf_view_test_->SetAnimationDuration(1); | 124 shelf_view_test_->SetAnimationDuration(1); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void TearDown() override { | 127 void TearDown() override { |
| 128 material_design_state_.reset(); | 128 material_design_state_.reset(); |
| 129 test::AshTestBase::TearDown(); | 129 test::AshTestBase::TearDown(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 aura::Window* CreateWindow(const gfx::Rect& bounds) { | 132 aura::Window* CreateWindow(const gfx::Rect& bounds) { |
| 133 return CreateTestWindowInShellWithDelegate(&delegate_, -1, bounds); | 133 return CreateTestWindowInShellWithDelegate(&delegate_, -1, bounds); |
| 134 } | 134 } |
| 135 | 135 |
| 136 aura::Window* CreateWindowWithId(const gfx::Rect& bounds, int id) { | 136 aura::Window* CreateWindowWithId(const gfx::Rect& bounds, int id) { |
| 137 return CreateTestWindowInShellWithDelegate(&delegate_, id, bounds); | 137 return CreateTestWindowInShellWithDelegate(&delegate_, id, bounds); |
| 138 } | 138 } |
| 139 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) { | 139 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) { |
| 140 aura::Window* window = CreateWindow(bounds); | 140 aura::Window* window = CreateWindow(bounds); |
| 141 aura::client::SetActivationDelegate(window, | 141 aura::client::SetActivationDelegate(window, |
| 142 &non_activatable_activation_delegate_); | 142 &non_activatable_activation_delegate_); |
| 143 EXPECT_FALSE(ash::wm::CanActivateWindow(window)); | 143 EXPECT_FALSE(wm::CanActivateWindow(window)); |
| 144 return window; | 144 return window; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Creates a Widget containing a Window with the given |bounds|. This should | 147 // Creates a Widget containing a Window with the given |bounds|. This should |
| 148 // be used when the test requires a Widget. For example any test that will | 148 // be used when the test requires a Widget. For example any test that will |
| 149 // cause a window to be closed via | 149 // cause a window to be closed via |
| 150 // views::Widget::GetWidgetForNativeView(window)->Close(). | 150 // views::Widget::GetWidgetForNativeView(window)->Close(). |
| 151 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { | 151 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { |
| 152 std::unique_ptr<views::Widget> widget(new views::Widget); | 152 std::unique_ptr<views::Widget> widget(new views::Widget); |
| 153 views::Widget::InitParams params; | 153 views::Widget::InitParams params; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool showing_filter_widget() { | 285 bool showing_filter_widget() { |
| 286 return window_selector() | 286 return window_selector() |
| 287 ->text_filter_widget_->GetNativeWindow() | 287 ->text_filter_widget_->GetNativeWindow() |
| 288 ->layer() | 288 ->layer() |
| 289 ->GetTargetTransform() | 289 ->GetTargetTransform() |
| 290 .IsIdentity(); | 290 .IsIdentity(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 views::Widget* GetCloseButton(ash::WindowSelectorItem* window) { | 293 views::Widget* GetCloseButton(WindowSelectorItem* window) { |
| 294 return window->close_button_->GetWidget(); | 294 return window->close_button_->GetWidget(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 views::LabelButton* GetLabelButtonView(ash::WindowSelectorItem* window) { | 297 views::LabelButton* GetLabelButtonView(WindowSelectorItem* window) { |
| 298 return window->window_label_button_view_; | 298 return window->window_label_button_view_; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Tests that a window is contained within a given WindowSelectorItem, and | 301 // Tests that a window is contained within a given WindowSelectorItem, and |
| 302 // that both the window and its matching close button are within the same | 302 // that both the window and its matching close button are within the same |
| 303 // screen. | 303 // screen. |
| 304 void IsWindowAndCloseButtonInScreen(aura::Window* window, | 304 void IsWindowAndCloseButtonInScreen(aura::Window* window, |
| 305 WindowSelectorItem* window_item) { | 305 WindowSelectorItem* window_item) { |
| 306 aura::Window* root_window = | 306 aura::Window* root_window = |
| 307 WmWindowAura::GetAuraWindow(window_item->root_window()); | 307 WmWindowAura::GetAuraWindow(window_item->root_window()); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 330 std::unique_ptr<test::MaterialDesignControllerTestAPI> material_design_state_; | 330 std::unique_ptr<test::MaterialDesignControllerTestAPI> material_design_state_; |
| 331 | 331 |
| 332 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); | 332 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); |
| 333 }; | 333 }; |
| 334 | 334 |
| 335 // Note: First argument is optional and intentionally left blank. | 335 // Note: First argument is optional and intentionally left blank. |
| 336 // (it's a prefix for the generated test cases) | 336 // (it's a prefix for the generated test cases) |
| 337 INSTANTIATE_TEST_CASE_P( | 337 INSTANTIATE_TEST_CASE_P( |
| 338 , | 338 , |
| 339 WindowSelectorTest, | 339 WindowSelectorTest, |
| 340 testing::Values(ash::MaterialDesignController::NON_MATERIAL, | 340 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 341 ash::MaterialDesignController::MATERIAL_NORMAL, | 341 MaterialDesignController::MATERIAL_NORMAL, |
| 342 ash::MaterialDesignController::MATERIAL_EXPERIMENTAL)); | 342 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 343 | 343 |
| 344 #if !defined(OS_WIN) || defined(USE_ASH) | 344 #if !defined(OS_WIN) || defined(USE_ASH) |
| 345 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 345 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 346 // Tests that the text field in the overview menu is repositioned and resized | 346 // Tests that the text field in the overview menu is repositioned and resized |
| 347 // after a screen rotation. | 347 // after a screen rotation. |
| 348 TEST_P(WindowSelectorTest, OverviewScreenRotation) { | 348 TEST_P(WindowSelectorTest, OverviewScreenRotation) { |
| 349 gfx::Rect bounds(0, 0, 400, 300); | 349 gfx::Rect bounds(0, 0, 400, 300); |
| 350 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 350 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 351 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 351 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
| 352 | 352 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 363 // y: -kTextFilterHeight (since there's no text in the filter). | 363 // y: -kTextFilterHeight (since there's no text in the filter). |
| 364 // w: root_window->bounds().width() * kTextFilterScreenProportion. | 364 // w: root_window->bounds().width() * kTextFilterScreenProportion. |
| 365 // h: kTextFilterHeight. | 365 // h: kTextFilterHeight. |
| 366 // | 366 // |
| 367 // With Material Design the text filter position is calculated as: | 367 // With Material Design the text filter position is calculated as: |
| 368 // x: 0.5 * (total_bounds.width() - | 368 // x: 0.5 * (total_bounds.width() - |
| 369 // std::min(kTextFilterWidthMD, total_bounds.width())). | 369 // std::min(kTextFilterWidthMD, total_bounds.width())). |
| 370 // y: -kTextFilterHeightMD (since there's no text in the filter). | 370 // y: -kTextFilterHeightMD (since there's no text in the filter). |
| 371 // w: std::min(kTextFilterWidthMD, total_bounds.width()). | 371 // w: std::min(kTextFilterWidthMD, total_bounds.width()). |
| 372 // h: kTextFilterHeightMD. | 372 // h: kTextFilterHeightMD. |
| 373 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); | 373 const bool material = MaterialDesignController::IsOverviewMaterial(); |
| 374 gfx::Rect expected_bounds(150, -32, 100, 32); | 374 gfx::Rect expected_bounds(150, -32, 100, 32); |
| 375 gfx::Rect expected_bounds_MD(60, -40, 280, 40); | 375 gfx::Rect expected_bounds_MD(60, -40, 280, 40); |
| 376 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(), | 376 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(), |
| 377 text_filter->GetClientAreaBoundsInScreen().ToString()); | 377 text_filter->GetClientAreaBoundsInScreen().ToString()); |
| 378 | 378 |
| 379 // Rotates the display, which triggers the WindowSelector's | 379 // Rotates the display, which triggers the WindowSelector's |
| 380 // RepositionTextFilterOnDisplayMetricsChange method. | 380 // RepositionTextFilterOnDisplayMetricsChange method. |
| 381 UpdateDisplay("400x300/r"); | 381 UpdateDisplay("400x300/r"); |
| 382 | 382 |
| 383 // Uses the same formulas as above using width = 300, height = 400. | 383 // Uses the same formulas as above using width = 300, height = 400. |
| 384 expected_bounds = gfx::Rect(112, -32, 75, 32); | 384 expected_bounds = gfx::Rect(112, -32, 75, 32); |
| 385 expected_bounds_MD = gfx::Rect(10, -40, 280, 40); | 385 expected_bounds_MD = gfx::Rect(10, -40, 280, 40); |
| 386 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(), | 386 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(), |
| 387 text_filter->GetClientAreaBoundsInScreen().ToString()); | 387 text_filter->GetClientAreaBoundsInScreen().ToString()); |
| 388 } | 388 } |
| 389 #endif | 389 #endif |
| 390 | 390 |
| 391 // Tests that an a11y alert is sent on entering overview mode. | 391 // Tests that an a11y alert is sent on entering overview mode. |
| 392 TEST_P(WindowSelectorTest, A11yAlertOnOverviewMode) { | 392 TEST_P(WindowSelectorTest, A11yAlertOnOverviewMode) { |
| 393 gfx::Rect bounds(0, 0, 400, 400); | 393 gfx::Rect bounds(0, 0, 400, 400); |
| 394 AccessibilityDelegate* delegate = | 394 AccessibilityDelegate* delegate = WmShell::Get()->GetAccessibilityDelegate(); |
| 395 ash::Shell::GetInstance()->accessibility_delegate(); | |
| 396 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 395 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 397 EXPECT_NE(delegate->GetLastAccessibilityAlert(), | 396 EXPECT_NE(delegate->GetLastAccessibilityAlert(), |
| 398 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 397 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 399 ToggleOverview(); | 398 ToggleOverview(); |
| 400 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), | 399 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), |
| 401 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 400 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 402 } | 401 } |
| 403 | 402 |
| 404 // Tests that there are no crashes when there is not enough screen space | 403 // Tests that there are no crashes when there is not enough screen space |
| 405 // available to show all of the windows. | 404 // available to show all of the windows. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 444 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 446 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 445 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 447 | 446 |
| 448 // Cursor should have been unlocked. | 447 // Cursor should have been unlocked. |
| 449 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); | 448 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); |
| 450 } | 449 } |
| 451 | 450 |
| 452 // Tests that the ordering of windows is near the windows' original positions. | 451 // Tests that the ordering of windows is near the windows' original positions. |
| 453 TEST_P(WindowSelectorTest, MinimizeMovement) { | 452 TEST_P(WindowSelectorTest, MinimizeMovement) { |
| 454 // With Material Design the order of windows in overview mode is MRU. | 453 // With Material Design the order of windows in overview mode is MRU. |
| 455 if (ash::MaterialDesignController::IsOverviewMaterial()) | 454 if (MaterialDesignController::IsOverviewMaterial()) |
| 456 return; | 455 return; |
| 457 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 456 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 458 gfx::Rect left_bounds(0, 0, root_window->bounds().width() / 2, | 457 gfx::Rect left_bounds(0, 0, root_window->bounds().width() / 2, |
| 459 root_window->bounds().height()); | 458 root_window->bounds().height()); |
| 460 gfx::Rect right_bounds(root_window->bounds().width() / 2, 0, | 459 gfx::Rect right_bounds(root_window->bounds().width() / 2, 0, |
| 461 root_window->bounds().width() / 2, | 460 root_window->bounds().width() / 2, |
| 462 root_window->bounds().height()); | 461 root_window->bounds().height()); |
| 463 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds)); | 462 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds)); |
| 464 WmWindow* left_window_wm = WmWindowAura::Get(left_window.get()); | 463 WmWindow* left_window_wm = WmWindowAura::Get(left_window.get()); |
| 465 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds)); | 464 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 489 const std::vector<WindowSelectorItem*>& overview3(GetWindowItemsForRoot(0)); | 488 const std::vector<WindowSelectorItem*>& overview3(GetWindowItemsForRoot(0)); |
| 490 EXPECT_EQ(overview3[0]->GetWindow(), right_window_wm); | 489 EXPECT_EQ(overview3[0]->GetWindow(), right_window_wm); |
| 491 EXPECT_EQ(overview3[1]->GetWindow(), left_window_wm); | 490 EXPECT_EQ(overview3[1]->GetWindow(), left_window_wm); |
| 492 ToggleOverview(); | 491 ToggleOverview(); |
| 493 } | 492 } |
| 494 | 493 |
| 495 // Tests that the ordering of windows is near the windows' original positions | 494 // Tests that the ordering of windows is near the windows' original positions |
| 496 // on a second display. | 495 // on a second display. |
| 497 TEST_P(WindowSelectorTest, MinimizeMovementSecondDisplay) { | 496 TEST_P(WindowSelectorTest, MinimizeMovementSecondDisplay) { |
| 498 // With Material Design the order of windows in overview mode is MRU. | 497 // With Material Design the order of windows in overview mode is MRU. |
| 499 if (ash::MaterialDesignController::IsOverviewMaterial() || | 498 if (MaterialDesignController::IsOverviewMaterial() || |
| 500 !SupportsMultipleDisplays()) { | 499 !SupportsMultipleDisplays()) { |
| 501 return; | 500 return; |
| 502 } | 501 } |
| 503 // Verify the same works on the second display | 502 // Verify the same works on the second display |
| 504 UpdateDisplay("400x400,400x400"); | 503 UpdateDisplay("400x400,400x400"); |
| 505 gfx::Rect left_bounds(400, 0, 200, 400); | 504 gfx::Rect left_bounds(400, 0, 200, 400); |
| 506 gfx::Rect right_bounds(600, 0, 200, 400); | 505 gfx::Rect right_bounds(600, 0, 200, 400); |
| 507 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds)); | 506 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds)); |
| 508 WmWindow* left_window_wm = WmWindowAura::Get(left_window.get()); | 507 WmWindow* left_window_wm = WmWindowAura::Get(left_window.get()); |
| 509 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds)); | 508 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds)); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 539 | 538 |
| 540 // Before Material Design the initial ordering is not defined, but should | 539 // Before Material Design the initial ordering is not defined, but should |
| 541 // remain consistent the next time overview is started. | 540 // remain consistent the next time overview is started. |
| 542 // With Material Design the order of windows in overview mode is MRU. | 541 // With Material Design the order of windows in overview mode is MRU. |
| 543 wm::GetWindowState(window1.get())->Activate(); | 542 wm::GetWindowState(window1.get())->Activate(); |
| 544 ToggleOverview(); | 543 ToggleOverview(); |
| 545 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); | 544 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); |
| 546 int initial_order[3] = {overview1[0]->GetWindow()->GetShellWindowId(), | 545 int initial_order[3] = {overview1[0]->GetWindow()->GetShellWindowId(), |
| 547 overview1[1]->GetWindow()->GetShellWindowId(), | 546 overview1[1]->GetWindow()->GetShellWindowId(), |
| 548 overview1[2]->GetWindow()->GetShellWindowId()}; | 547 overview1[2]->GetWindow()->GetShellWindowId()}; |
| 549 if (ash::MaterialDesignController::IsOverviewMaterial()) { | 548 if (MaterialDesignController::IsOverviewMaterial()) { |
| 550 // With Material Design the order should be MRU. | 549 // With Material Design the order should be MRU. |
| 551 EXPECT_EQ(1, overview1[0]->GetWindow()->GetShellWindowId()); | 550 EXPECT_EQ(1, overview1[0]->GetWindow()->GetShellWindowId()); |
| 552 EXPECT_EQ(3, overview1[1]->GetWindow()->GetShellWindowId()); | 551 EXPECT_EQ(3, overview1[1]->GetWindow()->GetShellWindowId()); |
| 553 EXPECT_EQ(2, overview1[2]->GetWindow()->GetShellWindowId()); | 552 EXPECT_EQ(2, overview1[2]->GetWindow()->GetShellWindowId()); |
| 554 } | 553 } |
| 555 ToggleOverview(); | 554 ToggleOverview(); |
| 556 | 555 |
| 557 // Activate the second window. | 556 // Activate the second window. |
| 558 wm::GetWindowState(window2.get())->Activate(); | 557 wm::GetWindowState(window2.get())->Activate(); |
| 559 ToggleOverview(); | 558 ToggleOverview(); |
| 560 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); | 559 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); |
| 561 | 560 |
| 562 if (ash::MaterialDesignController::IsOverviewMaterial()) { | 561 if (MaterialDesignController::IsOverviewMaterial()) { |
| 563 // With Material Design the order should be MRU. | 562 // With Material Design the order should be MRU. |
| 564 EXPECT_EQ(2, overview2[0]->GetWindow()->GetShellWindowId()); | 563 EXPECT_EQ(2, overview2[0]->GetWindow()->GetShellWindowId()); |
| 565 EXPECT_EQ(1, overview2[1]->GetWindow()->GetShellWindowId()); | 564 EXPECT_EQ(1, overview2[1]->GetWindow()->GetShellWindowId()); |
| 566 EXPECT_EQ(3, overview2[2]->GetWindow()->GetShellWindowId()); | 565 EXPECT_EQ(3, overview2[2]->GetWindow()->GetShellWindowId()); |
| 567 } else { | 566 } else { |
| 568 // Before Material Design the order should be the same as the first time. | 567 // Before Material Design the order should be the same as the first time. |
| 569 EXPECT_EQ(initial_order[0], overview2[0]->GetWindow()->GetShellWindowId()); | 568 EXPECT_EQ(initial_order[0], overview2[0]->GetWindow()->GetShellWindowId()); |
| 570 EXPECT_EQ(initial_order[1], overview2[1]->GetWindow()->GetShellWindowId()); | 569 EXPECT_EQ(initial_order[1], overview2[1]->GetWindow()->GetShellWindowId()); |
| 571 EXPECT_EQ(initial_order[2], overview2[2]->GetWindow()->GetShellWindowId()); | 570 EXPECT_EQ(initial_order[2], overview2[2]->GetWindow()->GetShellWindowId()); |
| 572 } | 571 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 923 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | 922 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); |
| 924 } | 923 } |
| 925 | 924 |
| 926 // Tests that the shelf dimming state is removed while in overview and restored | 925 // Tests that the shelf dimming state is removed while in overview and restored |
| 927 // on exiting overview. | 926 // on exiting overview. |
| 928 TEST_P(WindowSelectorTest, OverviewUndimsShelf) { | 927 TEST_P(WindowSelectorTest, OverviewUndimsShelf) { |
| 929 gfx::Rect bounds(0, 0, 400, 400); | 928 gfx::Rect bounds(0, 0, 400, 400); |
| 930 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 929 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 931 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 930 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
| 932 window_state->Maximize(); | 931 window_state->Maximize(); |
| 933 ash::ShelfWidget* shelf = | 932 ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf_widget(); |
| 934 Shell::GetPrimaryRootWindowController()->shelf_widget(); | |
| 935 EXPECT_TRUE(shelf->GetDimsShelf()); | 933 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 936 ToggleOverview(); | 934 ToggleOverview(); |
| 937 EXPECT_FALSE(shelf->GetDimsShelf()); | 935 EXPECT_FALSE(shelf->GetDimsShelf()); |
| 938 ToggleOverview(); | 936 ToggleOverview(); |
| 939 EXPECT_TRUE(shelf->GetDimsShelf()); | 937 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 940 } | 938 } |
| 941 | 939 |
| 942 // Tests that entering overview when a fullscreen window is active in maximized | 940 // Tests that entering overview when a fullscreen window is active in maximized |
| 943 // mode correctly applies the transformations to the window and correctly | 941 // mode correctly applies the transformations to the window and correctly |
| 944 // updates the window bounds on exiting overview mode: http://crbug.com/401664. | 942 // updates the window bounds on exiting overview mode: http://crbug.com/401664. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 } | 1266 } |
| 1269 | 1267 |
| 1270 // Tests starting overview during a drag and drop tracking operation. | 1268 // Tests starting overview during a drag and drop tracking operation. |
| 1271 // TODO(flackr): Fix memory corruption crash when running locally (not failing | 1269 // TODO(flackr): Fix memory corruption crash when running locally (not failing |
| 1272 // on bots). See http://crbug.com/342528. | 1270 // on bots). See http://crbug.com/342528. |
| 1273 TEST_P(WindowSelectorTest, DISABLED_DragDropInProgress) { | 1271 TEST_P(WindowSelectorTest, DISABLED_DragDropInProgress) { |
| 1274 bool drag_canceled_by_test = false; | 1272 bool drag_canceled_by_test = false; |
| 1275 gfx::Rect bounds(0, 0, 400, 400); | 1273 gfx::Rect bounds(0, 0, 400, 400); |
| 1276 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); | 1274 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 1277 test::ShellTestApi shell_test_api(Shell::GetInstance()); | 1275 test::ShellTestApi shell_test_api(Shell::GetInstance()); |
| 1278 ash::DragDropController* drag_drop_controller = | 1276 DragDropController* drag_drop_controller = |
| 1279 shell_test_api.drag_drop_controller(); | 1277 shell_test_api.drag_drop_controller(); |
| 1280 ui::OSExchangeData data; | 1278 ui::OSExchangeData data; |
| 1281 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1279 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1282 FROM_HERE, | 1280 FROM_HERE, |
| 1283 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); | 1281 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); |
| 1284 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1282 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1285 FROM_HERE, | 1283 FROM_HERE, |
| 1286 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); | 1284 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); |
| 1287 data.SetString(base::UTF8ToUTF16("I am being dragged")); | 1285 data.SetString(base::UTF8ToUTF16("I am being dragged")); |
| 1288 drag_drop_controller->StartDragAndDrop( | 1286 drag_drop_controller->StartDragAndDrop( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1309 EXPECT_EQ(label->GetText(), window_title); | 1307 EXPECT_EQ(label->GetText(), window_title); |
| 1310 | 1308 |
| 1311 // Update the window title and check that the label is updated, too. | 1309 // Update the window title and check that the label is updated, too. |
| 1312 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); | 1310 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); |
| 1313 window->SetTitle(updated_title); | 1311 window->SetTitle(updated_title); |
| 1314 EXPECT_EQ(label->GetText(), updated_title); | 1312 EXPECT_EQ(label->GetText(), updated_title); |
| 1315 | 1313 |
| 1316 // Labels are located based on target_bounds, not the actual window item | 1314 // Labels are located based on target_bounds, not the actual window item |
| 1317 // bounds. | 1315 // bounds. |
| 1318 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen(); | 1316 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen(); |
| 1319 if (ash::MaterialDesignController::IsOverviewMaterial()) | 1317 if (MaterialDesignController::IsOverviewMaterial()) |
| 1320 label_bounds.Inset(kWindowMarginMD, kWindowMarginMD); | 1318 label_bounds.Inset(kWindowMarginMD, kWindowMarginMD); |
| 1321 EXPECT_EQ(window_item->target_bounds(), label_bounds); | 1319 EXPECT_EQ(window_item->target_bounds(), label_bounds); |
| 1322 } | 1320 } |
| 1323 | 1321 |
| 1324 // Tests that overview updates the window positions if the display orientation | 1322 // Tests that overview updates the window positions if the display orientation |
| 1325 // changes. | 1323 // changes. |
| 1326 TEST_P(WindowSelectorTest, DisplayOrientationChanged) { | 1324 TEST_P(WindowSelectorTest, DisplayOrientationChanged) { |
| 1327 if (!SupportsHostWindowResize()) | 1325 if (!SupportsHostWindowResize()) |
| 1328 return; | 1326 return; |
| 1329 | 1327 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1417 }; | 1415 }; |
| 1418 | 1416 |
| 1419 for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) { | 1417 for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) { |
| 1420 ToggleOverview(); | 1418 ToggleOverview(); |
| 1421 const std::vector<WindowSelectorItem*>& overview_windows = | 1419 const std::vector<WindowSelectorItem*>& overview_windows = |
| 1422 GetWindowItemsForRoot(0); | 1420 GetWindowItemsForRoot(0); |
| 1423 for (size_t i = 0; i < test_windows + 1; i++) { | 1421 for (size_t i = 0; i < test_windows + 1; i++) { |
| 1424 SendKey(arrow_keys[key_index]); | 1422 SendKey(arrow_keys[key_index]); |
| 1425 // TODO(flackr): Add a more readable error message by constructing a | 1423 // TODO(flackr): Add a more readable error message by constructing a |
| 1426 // string from the window IDs. | 1424 // string from the window IDs. |
| 1427 const int index = ash::MaterialDesignController::IsOverviewMaterial() | 1425 const int index = MaterialDesignController::IsOverviewMaterial() |
| 1428 ? index_path_for_direction_MD[key_index][i] | 1426 ? index_path_for_direction_MD[key_index][i] |
| 1429 : index_path_for_direction[key_index][i]; | 1427 : index_path_for_direction[key_index][i]; |
| 1430 EXPECT_EQ(GetSelectedWindow()->id(), | 1428 EXPECT_EQ(GetSelectedWindow()->id(), |
| 1431 overview_windows[index - 1]->GetWindow()->GetShellWindowId()); | 1429 overview_windows[index - 1]->GetWindow()->GetShellWindowId()); |
| 1432 } | 1430 } |
| 1433 ToggleOverview(); | 1431 ToggleOverview(); |
| 1434 } | 1432 } |
| 1435 } | 1433 } |
| 1436 | 1434 |
| 1437 // Tests basic selection across multiple monitors. | 1435 // Tests basic selection across multiple monitors. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1800 // when inset and header height are specified. | 1798 // when inset and header height are specified. |
| 1801 TEST_P(WindowSelectorTest, TransformedRectIsCenteredWithInset) { | 1799 TEST_P(WindowSelectorTest, TransformedRectIsCenteredWithInset) { |
| 1802 gfx::Rect rect(50, 50, 400, 200); | 1800 gfx::Rect rect(50, 50, 400, 200); |
| 1803 gfx::Rect bounds(100, 100, 50, 50); | 1801 gfx::Rect bounds(100, 100, 50, 50); |
| 1804 const int inset = 20; | 1802 const int inset = 20; |
| 1805 const int header_height = 10; | 1803 const int header_height = 10; |
| 1806 const float scale = GetItemScale(rect, bounds, inset, header_height); | 1804 const float scale = GetItemScale(rect, bounds, inset, header_height); |
| 1807 gfx::Rect transformed_rect = | 1805 gfx::Rect transformed_rect = |
| 1808 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( | 1806 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( |
| 1809 rect, bounds, inset, header_height); | 1807 rect, bounds, inset, header_height); |
| 1810 if (ash::MaterialDesignController::IsOverviewMaterial()) { | 1808 if (MaterialDesignController::IsOverviewMaterial()) { |
| 1811 // With Material Design the |rect| width does not fit and therefore it gets | 1809 // With Material Design the |rect| width does not fit and therefore it gets |
| 1812 // centered outside |bounds| starting before |bounds.x()| and ending after | 1810 // centered outside |bounds| starting before |bounds.x()| and ending after |
| 1813 // |bounds.right()|. | 1811 // |bounds.right()|. |
| 1814 EXPECT_LE(transformed_rect.x(), bounds.x()); | 1812 EXPECT_LE(transformed_rect.x(), bounds.x()); |
| 1815 EXPECT_GE(transformed_rect.right(), bounds.right()); | 1813 EXPECT_GE(transformed_rect.right(), bounds.right()); |
| 1816 } else { | 1814 } else { |
| 1817 EXPECT_GE(transformed_rect.x(), bounds.x()); | 1815 EXPECT_GE(transformed_rect.x(), bounds.x()); |
| 1818 EXPECT_LE(transformed_rect.right(), bounds.right()); | 1816 EXPECT_LE(transformed_rect.right(), bounds.right()); |
| 1819 } | 1817 } |
| 1820 EXPECT_GE( | 1818 EXPECT_GE( |
| 1821 transformed_rect.y() + gfx::ToCeiledInt(scale * inset) - header_height, | 1819 transformed_rect.y() + gfx::ToCeiledInt(scale * inset) - header_height, |
| 1822 bounds.y()); | 1820 bounds.y()); |
| 1823 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); | 1821 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); |
| 1824 EXPECT_NEAR(transformed_rect.x() - bounds.x(), | 1822 EXPECT_NEAR(transformed_rect.x() - bounds.x(), |
| 1825 bounds.right() - transformed_rect.right(), 1); | 1823 bounds.right() - transformed_rect.right(), 1); |
| 1826 EXPECT_NEAR( | 1824 EXPECT_NEAR( |
| 1827 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), | 1825 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), |
| 1828 bounds.bottom() - transformed_rect.bottom(), 1); | 1826 bounds.bottom() - transformed_rect.bottom(), 1); |
| 1829 } | 1827 } |
| 1830 | 1828 |
| 1831 } // namespace ash | 1829 } // namespace ash |
| OLD | NEW |