| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 169 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| 170 nullptr, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); | 170 nullptr, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); |
| 171 window->SetProperty(aura::client::kTopViewInset, kHeaderHeight); | 171 window->SetProperty(aura::client::kTopViewInset, kHeaderHeight); |
| 172 test::TestShelfDelegate::instance()->AddShelfItem( | 172 test::TestShelfDelegate::instance()->AddShelfItem( |
| 173 WmWindowAura::Get(window)); | 173 WmWindowAura::Get(window)); |
| 174 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 174 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 175 return window; | 175 return window; |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) { | 178 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) { |
| 179 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1); | 179 gfx::Rect window1_bounds = GetTransformedTargetBounds(window1); |
| 180 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2); | 180 gfx::Rect window2_bounds = GetTransformedTargetBounds(window2); |
| 181 return window1_bounds.Intersects(window2_bounds); | 181 return window1_bounds.Intersects(window2_bounds); |
| 182 } | 182 } |
| 183 | 183 |
| 184 WindowSelectorController* window_selector_controller() { | 184 WindowSelectorController* window_selector_controller() { |
| 185 return WmShell::Get()->window_selector_controller(); | 185 return WmShell::Get()->window_selector_controller(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 WindowSelector* window_selector() { | 188 WindowSelector* window_selector() { |
| 189 return window_selector_controller()->window_selector_.get(); | 189 return window_selector_controller()->window_selector_.get(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void ToggleOverview() { window_selector_controller()->ToggleOverview(); } | 192 void ToggleOverview() { window_selector_controller()->ToggleOverview(); } |
| 193 | 193 |
| 194 gfx::RectF GetTransformedBounds(aura::Window* window) { | 194 aura::Window* GetOverviewWindowForMinimizedState(int index, |
| 195 aura::Window* window) { |
| 196 WindowSelectorItem* selector = GetWindowItemForWindow(index, window); |
| 197 return WmWindowAura::GetAuraWindow( |
| 198 selector->GetOverviewWindowForMinimizedStateForTest()); |
| 199 } |
| 200 |
| 201 gfx::Rect GetTransformedBounds(aura::Window* window) { |
| 195 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( | 202 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( |
| 196 window->parent(), window->layer()->bounds())); | 203 window->parent(), window->layer()->bounds())); |
| 197 gfx::Transform transform(gfx::TransformAboutPivot( | 204 gfx::Transform transform(gfx::TransformAboutPivot( |
| 198 gfx::ToFlooredPoint(bounds.origin()), window->layer()->transform())); | 205 gfx::ToFlooredPoint(bounds.origin()), window->layer()->transform())); |
| 199 transform.TransformRect(&bounds); | 206 transform.TransformRect(&bounds); |
| 200 return bounds; | 207 return gfx::ToEnclosingRect(bounds); |
| 201 } | 208 } |
| 202 | 209 |
| 203 gfx::RectF GetTransformedTargetBounds(aura::Window* window) { | 210 gfx::Rect GetTransformedTargetBounds(aura::Window* window) { |
| 204 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( | 211 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( |
| 205 window->parent(), window->layer()->GetTargetBounds())); | 212 window->parent(), window->layer()->GetTargetBounds())); |
| 206 gfx::Transform transform( | 213 gfx::Transform transform( |
| 207 gfx::TransformAboutPivot(gfx::ToFlooredPoint(bounds.origin()), | 214 gfx::TransformAboutPivot(gfx::ToFlooredPoint(bounds.origin()), |
| 208 window->layer()->GetTargetTransform())); | 215 window->layer()->GetTargetTransform())); |
| 209 transform.TransformRect(&bounds); | 216 transform.TransformRect(&bounds); |
| 210 return bounds; | 217 return gfx::ToEnclosingRect(bounds); |
| 211 } | 218 } |
| 212 | 219 |
| 213 gfx::RectF GetTransformedBoundsInRootWindow(aura::Window* window) { | 220 gfx::Rect GetTransformedBoundsInRootWindow(aura::Window* window) { |
| 214 gfx::RectF bounds = gfx::RectF(gfx::SizeF(window->bounds().size())); | 221 gfx::RectF bounds = gfx::RectF(gfx::SizeF(window->bounds().size())); |
| 215 aura::Window* root = window->GetRootWindow(); | 222 aura::Window* root = window->GetRootWindow(); |
| 216 CHECK(window->layer()); | 223 CHECK(window->layer()); |
| 217 CHECK(root->layer()); | 224 CHECK(root->layer()); |
| 218 gfx::Transform transform; | 225 gfx::Transform transform; |
| 219 if (!window->layer()->GetTargetTransformRelativeTo(root->layer(), | 226 if (!window->layer()->GetTargetTransformRelativeTo(root->layer(), |
| 220 &transform)) { | 227 &transform)) { |
| 221 return gfx::RectF(); | 228 return gfx::Rect(); |
| 222 } | 229 } |
| 223 transform.TransformRect(&bounds); | 230 transform.TransformRect(&bounds); |
| 224 return bounds; | 231 return gfx::ToEnclosingRect(bounds); |
| 225 } | 232 } |
| 226 | 233 |
| 227 void ClickWindow(aura::Window* window) { | 234 void ClickWindow(aura::Window* window) { |
| 228 ui::test::EventGenerator event_generator(window->GetRootWindow(), window); | 235 ui::test::EventGenerator event_generator(window->GetRootWindow(), window); |
| 229 event_generator.ClickLeftButton(); | 236 event_generator.ClickLeftButton(); |
| 230 } | 237 } |
| 231 | 238 |
| 232 void SendKey(ui::KeyboardCode key) { | 239 void SendKey(ui::KeyboardCode key) { |
| 233 ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow()); | 240 ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow()); |
| 234 event_generator.PressKey(key, 0); | 241 event_generator.PressKey(key, 0); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 329 |
| 323 // Tests that a window is contained within a given WindowSelectorItem, and | 330 // Tests that a window is contained within a given WindowSelectorItem, and |
| 324 // that both the window and its matching close button are within the same | 331 // that both the window and its matching close button are within the same |
| 325 // screen. | 332 // screen. |
| 326 void IsWindowAndCloseButtonInScreen(aura::Window* window, | 333 void IsWindowAndCloseButtonInScreen(aura::Window* window, |
| 327 WindowSelectorItem* window_item) { | 334 WindowSelectorItem* window_item) { |
| 328 aura::Window* root_window = | 335 aura::Window* root_window = |
| 329 WmWindowAura::GetAuraWindow(window_item->root_window()); | 336 WmWindowAura::GetAuraWindow(window_item->root_window()); |
| 330 EXPECT_TRUE(window_item->Contains(WmWindowAura::Get(window))); | 337 EXPECT_TRUE(window_item->Contains(WmWindowAura::Get(window))); |
| 331 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains( | 338 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains( |
| 332 ToEnclosingRect(GetTransformedTargetBounds(window)))); | 339 GetTransformedTargetBounds(window))); |
| 333 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains( | 340 EXPECT_TRUE( |
| 334 ToEnclosingRect(GetTransformedTargetBounds( | 341 root_window->GetBoundsInScreen().Contains(GetTransformedTargetBounds( |
| 335 GetCloseButton(window_item)->GetNativeView())))); | 342 GetCloseButton(window_item)->GetNativeView()))); |
| 336 } | 343 } |
| 337 | 344 |
| 338 void FilterItems(const base::StringPiece& pattern) { | 345 void FilterItems(const base::StringPiece& pattern) { |
| 339 window_selector()->ContentsChanged(nullptr, base::UTF8ToUTF16(pattern)); | 346 window_selector()->ContentsChanged(nullptr, base::UTF8ToUTF16(pattern)); |
| 340 } | 347 } |
| 341 | 348 |
| 342 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } | 349 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } |
| 343 | 350 |
| 344 views::Widget* text_filter_widget() { | 351 views::Widget* text_filter_widget() { |
| 345 return window_selector()->text_filter_widget_.get(); | 352 return window_selector()->text_filter_widget_.get(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 // Clicking window 1 should activate it. | 454 // Clicking window 1 should activate it. |
| 448 ClickWindow(window1.get()); | 455 ClickWindow(window1.get()); |
| 449 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 456 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 450 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 457 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 451 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 458 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 452 | 459 |
| 453 // Cursor should have been unlocked. | 460 // Cursor should have been unlocked. |
| 454 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); | 461 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); |
| 455 } | 462 } |
| 456 | 463 |
| 464 // Tests activating minimized window. |
| 465 TEST_F(WindowSelectorTest, ActivateMinimized) { |
| 466 gfx::Rect bounds(0, 0, 400, 400); |
| 467 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 468 |
| 469 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 470 wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE); |
| 471 window_state->OnWMEvent(&minimize_event); |
| 472 EXPECT_FALSE(window->IsVisible()); |
| 473 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED, |
| 474 wm::GetWindowState(window.get())->GetStateType()); |
| 475 |
| 476 ToggleOverview(); |
| 477 |
| 478 EXPECT_FALSE(window->IsVisible()); |
| 479 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED, |
| 480 wm::GetWindowState(window.get())->GetStateType()); |
| 481 aura::Window* window_for_minimized_window = |
| 482 GetOverviewWindowForMinimizedState(0, window.get()); |
| 483 EXPECT_TRUE(window_for_minimized_window); |
| 484 |
| 485 const gfx::Point point = |
| 486 GetTransformedBoundsInRootWindow(window_for_minimized_window) |
| 487 .CenterPoint(); |
| 488 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); |
| 489 event_generator.ClickLeftButton(); |
| 490 |
| 491 EXPECT_FALSE(IsSelecting()); |
| 492 |
| 493 EXPECT_TRUE(window->IsVisible()); |
| 494 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, |
| 495 wm::GetWindowState(window.get())->GetStateType()); |
| 496 } |
| 497 |
| 457 // Tests that entering overview mode with an App-list active properly focuses | 498 // Tests that entering overview mode with an App-list active properly focuses |
| 458 // and activates the overview text filter window. | 499 // and activates the overview text filter window. |
| 459 TEST_F(WindowSelectorTest, TextFilterActive) { | 500 TEST_F(WindowSelectorTest, TextFilterActive) { |
| 460 gfx::Rect bounds(0, 0, 400, 400); | 501 gfx::Rect bounds(0, 0, 400, 400); |
| 461 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 502 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 462 wm::ActivateWindow(window1.get()); | 503 wm::ActivateWindow(window1.get()); |
| 463 | 504 |
| 464 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 505 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 465 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 506 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 466 | 507 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 577 |
| 537 ToggleOverview(); | 578 ToggleOverview(); |
| 538 | 579 |
| 539 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); | 580 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); |
| 540 | 581 |
| 541 gfx::Rect container_bounds = docked1->parent()->bounds(); | 582 gfx::Rect container_bounds = docked1->parent()->bounds(); |
| 542 ShelfWidget* shelf = GetPrimaryShelf()->shelf_widget(); | 583 ShelfWidget* shelf = GetPrimaryShelf()->shelf_widget(); |
| 543 DockedWindowLayoutManager* manager = | 584 DockedWindowLayoutManager* manager = |
| 544 DockedWindowLayoutManager::Get(WmWindowAura::Get(docked1.get())); | 585 DockedWindowLayoutManager::Get(WmWindowAura::Get(docked1.get())); |
| 545 | 586 |
| 546 // Docked windows get shown and transformed. | 587 // Minimized docked windows stays invisible. |
| 547 EXPECT_TRUE(docked2->IsVisible()); | 588 EXPECT_FALSE(docked2->IsVisible()); |
| 589 EXPECT_TRUE(GetOverviewWindowForMinimizedState(0, docked2.get())); |
| 548 | 590 |
| 549 // Docked area shrinks. | 591 // Docked area shrinks. |
| 550 EXPECT_EQ(0, manager->docked_bounds().width()); | 592 EXPECT_EQ(0, manager->docked_bounds().width()); |
| 551 | 593 |
| 552 // Work area takes the whole screen minus the shelf. | 594 // Work area takes the whole screen minus the shelf. |
| 553 gfx::Rect work_area = display::Screen::GetScreen() | 595 gfx::Rect work_area = display::Screen::GetScreen() |
| 554 ->GetDisplayNearestWindow(docked1.get()) | 596 ->GetDisplayNearestWindow(docked1.get()) |
| 555 .work_area(); | 597 .work_area(); |
| 556 gfx::Size expected_work_area_bounds(container_bounds.size()); | 598 gfx::Size expected_work_area_bounds(container_bounds.size()); |
| 557 expected_work_area_bounds.Enlarge(0, | 599 expected_work_area_bounds.Enlarge(0, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 648 |
| 607 // |docked_window1| is docked and visible. | 649 // |docked_window1| is docked and visible. |
| 608 EXPECT_TRUE(docked_window1->IsVisible()); | 650 EXPECT_TRUE(docked_window1->IsVisible()); |
| 609 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); | 651 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); |
| 610 // |docked_window2| is docked-minimized and hidden. | 652 // |docked_window2| is docked-minimized and hidden. |
| 611 EXPECT_FALSE(docked_window2->IsVisible()); | 653 EXPECT_FALSE(docked_window2->IsVisible()); |
| 612 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); | 654 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); |
| 613 | 655 |
| 614 ToggleOverview(); | 656 ToggleOverview(); |
| 615 | 657 |
| 658 // Minimized should stay minimized. |
| 659 EXPECT_FALSE(docked_window2->IsVisible()); |
| 660 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); |
| 661 |
| 662 aura::Window* window_for_minimized_docked_window2 = |
| 663 GetOverviewWindowForMinimizedState(0, docked_window2.get()); |
| 664 ASSERT_TRUE(window_for_minimized_docked_window2); |
| 665 |
| 616 // Activate |docked_window2| leaving the overview. | 666 // Activate |docked_window2| leaving the overview. |
| 617 const gfx::RectF rect = | 667 const gfx::Rect rect = |
| 618 GetTransformedBoundsInRootWindow(docked_window2.get()); | 668 GetTransformedBoundsInRootWindow(window_for_minimized_docked_window2); |
| 619 gfx::Point point(rect.top_right().x() - 50, rect.top_right().y() + 50); | 669 gfx::Point point(rect.top_right().x() - 50, rect.top_right().y() + 50); |
| 620 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), | 670 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), |
| 621 point); | 671 point); |
| 622 event_generator.ClickLeftButton(); | 672 event_generator.ClickLeftButton(); |
| 623 | 673 |
| 674 EXPECT_FALSE(IsSelecting()); |
| 675 |
| 624 // Windows' bounds are still the same. | 676 // Windows' bounds are still the same. |
| 625 EXPECT_EQ(expected_bounds.ToString(), docked_window1->bounds().ToString()); | 677 EXPECT_EQ(expected_bounds.ToString(), docked_window1->bounds().ToString()); |
| 626 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString()); | 678 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString()); |
| 627 | 679 |
| 628 // |docked_window1| is docked-minimized and hidden. | 680 // |docked_window1| is docked-minimized and hidden. |
| 629 EXPECT_FALSE(docked_window1->IsVisible()); | 681 EXPECT_FALSE(docked_window1->IsVisible()); |
| 630 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); | 682 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); |
| 631 // |docked_window2| is docked and visible. | 683 // |docked_window2| is docked and visible. |
| 632 EXPECT_TRUE(docked_window2->IsVisible()); | 684 EXPECT_TRUE(docked_window2->IsVisible()); |
| 633 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); | 685 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 660 // |docked_window1| is docked-minimized and hidden. | 712 // |docked_window1| is docked-minimized and hidden. |
| 661 EXPECT_FALSE(docked_window1->IsVisible()); | 713 EXPECT_FALSE(docked_window1->IsVisible()); |
| 662 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); | 714 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); |
| 663 // |docked_window2| is docked and visible. | 715 // |docked_window2| is docked and visible. |
| 664 EXPECT_TRUE(docked_window2->IsVisible()); | 716 EXPECT_TRUE(docked_window2->IsVisible()); |
| 665 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); | 717 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); |
| 666 | 718 |
| 667 ToggleOverview(); | 719 ToggleOverview(); |
| 668 | 720 |
| 669 // Close |docked_window2| (staying in overview). | 721 // Close |docked_window2| (staying in overview). |
| 670 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2); | 722 const gfx::Rect rect = GetTransformedBoundsInRootWindow(docked_window2); |
| 671 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5); | 723 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5); |
| 672 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), | 724 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), |
| 673 point); | 725 point); |
| 674 // Both windows are visible while in overview. | 726 |
| 675 EXPECT_TRUE(docked_window1->IsVisible()); | 727 // Minimized window stays invisible and in the minimized state while in |
| 676 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); | 728 // overview. |
| 729 EXPECT_FALSE(docked_window1->IsVisible()); |
| 730 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); |
| 677 EXPECT_TRUE(docked_window2->IsVisible()); | 731 EXPECT_TRUE(docked_window2->IsVisible()); |
| 678 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); | 732 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); |
| 679 | 733 |
| 734 EXPECT_TRUE(GetOverviewWindowForMinimizedState(0, docked_window1.get())); |
| 735 |
| 680 event_generator.ClickLeftButton(); | 736 event_generator.ClickLeftButton(); |
| 681 // |docked2| widget is closed. | 737 // |docked2| widget is closed. |
| 682 EXPECT_TRUE(docked2->IsClosed()); | 738 EXPECT_TRUE(docked2->IsClosed()); |
| 683 | 739 |
| 684 // Exit overview. | 740 // Exit overview. |
| 685 ToggleOverview(); | 741 ToggleOverview(); |
| 686 | 742 |
| 687 // Window bounds are still the same. | 743 // Window bounds are still the same. |
| 688 EXPECT_EQ(expected_bounds1.ToString(), docked_window1->bounds().ToString()); | 744 EXPECT_EQ(expected_bounds1.ToString(), docked_window1->bounds().ToString()); |
| 689 | 745 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 718 | 774 |
| 719 // |docked_window1| is docked and visible. | 775 // |docked_window1| is docked and visible. |
| 720 EXPECT_TRUE(docked_window1->IsVisible()); | 776 EXPECT_TRUE(docked_window1->IsVisible()); |
| 721 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); | 777 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); |
| 722 // |docked_window2| is docked-minimized and hidden. | 778 // |docked_window2| is docked-minimized and hidden. |
| 723 EXPECT_FALSE(docked_window2->IsVisible()); | 779 EXPECT_FALSE(docked_window2->IsVisible()); |
| 724 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); | 780 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); |
| 725 | 781 |
| 726 ToggleOverview(); | 782 ToggleOverview(); |
| 727 | 783 |
| 728 // Close |docked_window2| (staying in overview). | |
| 729 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2); | |
| 730 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5); | |
| 731 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), | |
| 732 point); | |
| 733 // Both windows are visible while in overview. | 784 // Both windows are visible while in overview. |
| 734 EXPECT_TRUE(docked_window1->IsVisible()); | 785 EXPECT_TRUE(docked_window1->IsVisible()); |
| 735 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); | 786 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); |
| 736 EXPECT_TRUE(docked_window2->IsVisible()); | 787 EXPECT_FALSE(docked_window2->IsVisible()); |
| 737 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); | 788 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); |
| 738 | 789 |
| 790 // Close |docked_window2| (staying in overview). |
| 791 aura::Window* window_for_minimized_docked_window2 = |
| 792 GetOverviewWindowForMinimizedState(0, docked_window2); |
| 793 ASSERT_TRUE(window_for_minimized_docked_window2); |
| 794 const gfx::Rect rect = |
| 795 GetTransformedBoundsInRootWindow(window_for_minimized_docked_window2); |
| 796 gfx::Point point(rect.top_right().x() - 10, rect.top_right().y() - 10); |
| 797 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), |
| 798 point); |
| 739 event_generator.ClickLeftButton(); | 799 event_generator.ClickLeftButton(); |
| 740 // |docked2| widget is closed. | 800 // |docked2| widget is closed. |
| 741 EXPECT_TRUE(docked2->IsClosed()); | 801 EXPECT_TRUE(docked2->IsClosed()); |
| 742 | 802 |
| 743 // Exit overview. | 803 // Exit overview. |
| 744 ToggleOverview(); | 804 ToggleOverview(); |
| 745 | 805 |
| 746 // Window bounds are still the same. | 806 // Window bounds are still the same. |
| 747 EXPECT_EQ(expected_bounds1.ToString(), | 807 EXPECT_EQ(expected_bounds1.ToString(), |
| 748 docked_window1->GetTargetBounds().ToString()); | 808 docked_window1->GetTargetBounds().ToString()); |
| 749 | 809 |
| 750 // |docked_window1| returns to docked and visible state. | 810 // |docked_window1| returns to docked and visible state. |
| 751 EXPECT_TRUE(docked_window1->IsVisible()); | 811 EXPECT_TRUE(docked_window1->IsVisible()); |
| 752 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); | 812 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); |
| 753 } | 813 } |
| 754 | 814 |
| 755 // Tests selecting a window by tapping on it. | 815 // Tests selecting a window by tapping on it. |
| 756 TEST_F(WindowSelectorTest, BasicGesture) { | 816 TEST_F(WindowSelectorTest, BasicGesture) { |
| 757 gfx::Rect bounds(0, 0, 400, 400); | 817 gfx::Rect bounds(0, 0, 400, 400); |
| 758 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 818 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 759 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 819 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 760 wm::ActivateWindow(window1.get()); | 820 wm::ActivateWindow(window1.get()); |
| 761 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 821 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 762 ToggleOverview(); | 822 ToggleOverview(); |
| 763 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); | 823 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); |
| 764 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 824 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 765 window2.get()); | 825 window2.get()); |
| 766 generator.GestureTapAt( | 826 generator.GestureTapAt( |
| 767 gfx::ToEnclosingRect(GetTransformedTargetBounds(window2.get())) | 827 GetTransformedTargetBounds(window2.get()).CenterPoint()); |
| 768 .CenterPoint()); | |
| 769 EXPECT_EQ(window2.get(), GetFocusedWindow()); | 828 EXPECT_EQ(window2.get(), GetFocusedWindow()); |
| 770 } | 829 } |
| 771 | 830 |
| 772 // Tests that the user action WindowSelector_ActiveWindowChanged is | 831 // Tests that the user action WindowSelector_ActiveWindowChanged is |
| 773 // recorded when the mouse/touchscreen/keyboard are used to select a window | 832 // recorded when the mouse/touchscreen/keyboard are used to select a window |
| 774 // in overview mode which is different from the previously-active window. | 833 // in overview mode which is different from the previously-active window. |
| 775 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { | 834 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { |
| 776 base::UserActionTester user_action_tester; | 835 base::UserActionTester user_action_tester; |
| 777 gfx::Rect bounds(0, 0, 400, 400); | 836 gfx::Rect bounds(0, 0, 400, 400); |
| 778 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 837 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 779 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 838 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 780 | 839 |
| 781 // Tap on |window2| to activate it and exit overview. | 840 // Tap on |window2| to activate it and exit overview. |
| 782 wm::ActivateWindow(window1.get()); | 841 wm::ActivateWindow(window1.get()); |
| 783 ToggleOverview(); | 842 ToggleOverview(); |
| 784 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 843 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 785 window2.get()); | 844 window2.get()); |
| 786 generator.GestureTapAt( | 845 generator.GestureTapAt( |
| 787 gfx::ToEnclosingRect(GetTransformedTargetBounds(window2.get())) | 846 GetTransformedTargetBounds(window2.get()).CenterPoint()); |
| 788 .CenterPoint()); | |
| 789 EXPECT_EQ( | 847 EXPECT_EQ( |
| 790 1, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 848 1, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 791 | 849 |
| 792 // Click on |window2| to activate it and exit overview. | 850 // Click on |window2| to activate it and exit overview. |
| 793 wm::ActivateWindow(window1.get()); | 851 wm::ActivateWindow(window1.get()); |
| 794 ToggleOverview(); | 852 ToggleOverview(); |
| 795 ClickWindow(window2.get()); | 853 ClickWindow(window2.get()); |
| 796 EXPECT_EQ( | 854 EXPECT_EQ( |
| 797 2, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 855 2, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 798 | 856 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 817 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 875 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 818 | 876 |
| 819 // Set |window1| to be initially active. | 877 // Set |window1| to be initially active. |
| 820 wm::ActivateWindow(window1.get()); | 878 wm::ActivateWindow(window1.get()); |
| 821 ToggleOverview(); | 879 ToggleOverview(); |
| 822 | 880 |
| 823 // Tap on |window1| to exit overview. | 881 // Tap on |window1| to exit overview. |
| 824 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 882 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 825 window1.get()); | 883 window1.get()); |
| 826 generator.GestureTapAt( | 884 generator.GestureTapAt( |
| 827 gfx::ToEnclosingRect(GetTransformedTargetBounds(window1.get())) | 885 GetTransformedTargetBounds(window1.get()).CenterPoint()); |
| 828 .CenterPoint()); | |
| 829 EXPECT_EQ( | 886 EXPECT_EQ( |
| 830 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 887 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 831 | 888 |
| 832 // |window1| remains active. Click on it to exit overview. | 889 // |window1| remains active. Click on it to exit overview. |
| 833 ASSERT_EQ(window1.get(), GetFocusedWindow()); | 890 ASSERT_EQ(window1.get(), GetFocusedWindow()); |
| 834 ToggleOverview(); | 891 ToggleOverview(); |
| 835 ClickWindow(window1.get()); | 892 ClickWindow(window1.get()); |
| 836 EXPECT_EQ( | 893 EXPECT_EQ( |
| 837 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 894 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 838 | 895 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 855 // Tests that the user action WindowSelector_ActiveWindowChanged is not | 912 // Tests that the user action WindowSelector_ActiveWindowChanged is not |
| 856 // recorded when overview mode exits as a result of closing its only window. | 913 // recorded when overview mode exits as a result of closing its only window. |
| 857 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { | 914 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { |
| 858 base::UserActionTester user_action_tester; | 915 base::UserActionTester user_action_tester; |
| 859 std::unique_ptr<views::Widget> widget = | 916 std::unique_ptr<views::Widget> widget = |
| 860 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); | 917 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); |
| 861 | 918 |
| 862 ToggleOverview(); | 919 ToggleOverview(); |
| 863 | 920 |
| 864 aura::Window* window = widget->GetNativeWindow(); | 921 aura::Window* window = widget->GetNativeWindow(); |
| 865 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); | 922 gfx::Rect bounds = GetTransformedBoundsInRootWindow(window); |
| 866 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); | 923 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); |
| 867 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); | 924 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); |
| 868 | 925 |
| 869 ASSERT_FALSE(widget->IsClosed()); | 926 ASSERT_FALSE(widget->IsClosed()); |
| 870 event_generator.ClickLeftButton(); | 927 event_generator.ClickLeftButton(); |
| 871 ASSERT_TRUE(widget->IsClosed()); | 928 ASSERT_TRUE(widget->IsClosed()); |
| 872 EXPECT_EQ( | 929 EXPECT_EQ( |
| 873 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 930 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 874 } | 931 } |
| 875 | 932 |
| 876 // Tests that we do not crash and overview mode remains engaged if the desktop | 933 // Tests that we do not crash and overview mode remains engaged if the desktop |
| 877 // is tapped while a finger is already down over a window. | 934 // is tapped while a finger is already down over a window. |
| 878 TEST_F(WindowSelectorTest, NoCrashWithDesktopTap) { | 935 TEST_F(WindowSelectorTest, NoCrashWithDesktopTap) { |
| 879 std::unique_ptr<aura::Window> window( | 936 std::unique_ptr<aura::Window> window( |
| 880 CreateWindow(gfx::Rect(200, 300, 250, 450))); | 937 CreateWindow(gfx::Rect(200, 300, 250, 450))); |
| 881 | 938 |
| 882 ToggleOverview(); | 939 ToggleOverview(); |
| 883 | 940 |
| 884 gfx::Rect bounds = | 941 gfx::Rect bounds = GetTransformedBoundsInRootWindow(window.get()); |
| 885 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window.get())); | |
| 886 ui::test::EventGenerator event_generator(window->GetRootWindow(), | 942 ui::test::EventGenerator event_generator(window->GetRootWindow(), |
| 887 bounds.CenterPoint()); | 943 bounds.CenterPoint()); |
| 888 | 944 |
| 889 // Press down on the window. | 945 // Press down on the window. |
| 890 const int kTouchId = 19; | 946 const int kTouchId = 19; |
| 891 event_generator.PressTouchId(kTouchId); | 947 event_generator.PressTouchId(kTouchId); |
| 892 | 948 |
| 893 // Tap on the desktop, which should not cause a crash. Overview mode should | 949 // Tap on the desktop, which should not cause a crash. Overview mode should |
| 894 // be disengaged. | 950 // be disengaged. |
| 895 event_generator.GestureTapAt(gfx::Point(0, 0)); | 951 event_generator.GestureTapAt(gfx::Point(0, 0)); |
| 896 EXPECT_FALSE(IsSelecting()); | 952 EXPECT_FALSE(IsSelecting()); |
| 897 | 953 |
| 898 event_generator.ReleaseTouchId(kTouchId); | 954 event_generator.ReleaseTouchId(kTouchId); |
| 899 } | 955 } |
| 900 | 956 |
| 901 // Tests that we do not crash and a window is selected when appropriate when | 957 // Tests that we do not crash and a window is selected when appropriate when |
| 902 // we click on a window during touch. | 958 // we click on a window during touch. |
| 903 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) { | 959 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) { |
| 904 gfx::Rect bounds(0, 0, 400, 400); | 960 gfx::Rect bounds(0, 0, 400, 400); |
| 905 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 961 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 906 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 962 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 907 wm::ActivateWindow(window2.get()); | 963 wm::ActivateWindow(window2.get()); |
| 908 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 964 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 909 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 965 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 910 | 966 |
| 911 ToggleOverview(); | 967 ToggleOverview(); |
| 912 | 968 |
| 913 gfx::Rect window1_bounds = | 969 gfx::Rect window1_bounds = GetTransformedBoundsInRootWindow(window1.get()); |
| 914 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get())); | |
| 915 ui::test::EventGenerator event_generator(window1->GetRootWindow(), | 970 ui::test::EventGenerator event_generator(window1->GetRootWindow(), |
| 916 window1_bounds.CenterPoint()); | 971 window1_bounds.CenterPoint()); |
| 917 | 972 |
| 918 // Clicking on |window2| while touching on |window1| should not cause a | 973 // Clicking on |window2| while touching on |window1| should not cause a |
| 919 // crash, overview mode should be disengaged and |window2| should be active. | 974 // crash, overview mode should be disengaged and |window2| should be active. |
| 920 const int kTouchId = 19; | 975 const int kTouchId = 19; |
| 921 event_generator.PressTouchId(kTouchId); | 976 event_generator.PressTouchId(kTouchId); |
| 922 event_generator.MoveMouseToCenterOf(window2.get()); | 977 event_generator.MoveMouseToCenterOf(window2.get()); |
| 923 event_generator.ClickLeftButton(); | 978 event_generator.ClickLeftButton(); |
| 924 EXPECT_FALSE(IsSelecting()); | 979 EXPECT_FALSE(IsSelecting()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 953 ui::EventTarget* root_target = root_window; | 1008 ui::EventTarget* root_target = root_window; |
| 954 ui::EventTargeter* targeter = root_target->GetEventTargeter(); | 1009 ui::EventTargeter* targeter = root_target->GetEventTargeter(); |
| 955 | 1010 |
| 956 // The event should target the window because we are still not in overview | 1011 // The event should target the window because we are still not in overview |
| 957 // mode. | 1012 // mode. |
| 958 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &event1)); | 1013 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &event1)); |
| 959 | 1014 |
| 960 ToggleOverview(); | 1015 ToggleOverview(); |
| 961 | 1016 |
| 962 // The bounds have changed, take that into account. | 1017 // The bounds have changed, take that into account. |
| 963 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window.get()); | 1018 gfx::Rect bounds = GetTransformedBoundsInRootWindow(window.get()); |
| 964 gfx::Point point2(bounds.x() + 10, bounds.y() + 10); | 1019 gfx::Point point2(bounds.x() + 10, bounds.y() + 10); |
| 965 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, | 1020 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, |
| 966 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 1021 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 967 | 1022 |
| 968 // Now the transparent window should be intercepting this event. | 1023 // Now the transparent window should be intercepting this event. |
| 969 EXPECT_NE(window.get(), targeter->FindTargetForEvent(root_target, &event2)); | 1024 EXPECT_NE(window.get(), targeter->FindTargetForEvent(root_target, &event2)); |
| 970 } | 1025 } |
| 971 | 1026 |
| 972 // Tests that clicking on the close button effectively closes the window. | 1027 // Tests that clicking on the close button effectively closes the window. |
| 973 TEST_F(WindowSelectorTest, CloseButton) { | 1028 TEST_F(WindowSelectorTest, CloseButton) { |
| 974 std::unique_ptr<views::Widget> widget = | 1029 std::unique_ptr<views::Widget> widget = |
| 975 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); | 1030 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); |
| 976 | 1031 |
| 1032 std::unique_ptr<views::Widget> minimized_widget = |
| 1033 CreateWindowWidget(gfx::Rect(400, 0, 400, 400)); |
| 1034 minimized_widget->Minimize(); |
| 1035 |
| 977 ToggleOverview(); | 1036 ToggleOverview(); |
| 978 | 1037 |
| 979 aura::Window* window = widget->GetNativeWindow(); | 1038 aura::Window* window = widget->GetNativeWindow(); |
| 980 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); | 1039 gfx::Rect bounds = GetTransformedBoundsInRootWindow(window); |
| 981 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); | 1040 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); |
| 982 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); | 1041 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); |
| 983 | 1042 |
| 984 EXPECT_FALSE(widget->IsClosed()); | 1043 EXPECT_FALSE(widget->IsClosed()); |
| 985 event_generator.ClickLeftButton(); | 1044 event_generator.ClickLeftButton(); |
| 986 EXPECT_TRUE(widget->IsClosed()); | 1045 EXPECT_TRUE(widget->IsClosed()); |
| 1046 |
| 1047 EXPECT_TRUE(IsSelecting()); |
| 1048 |
| 1049 aura::Window* window_for_minimized_window = |
| 1050 GetOverviewWindowForMinimizedState(0, |
| 1051 minimized_widget->GetNativeWindow()); |
| 1052 ASSERT_TRUE(window_for_minimized_window); |
| 1053 const gfx::Rect rect = |
| 1054 GetTransformedBoundsInRootWindow(window_for_minimized_window); |
| 1055 |
| 1056 event_generator.MoveMouseTo( |
| 1057 gfx::Point(rect.top_right().x() - 10, rect.top_right().y() - 10)); |
| 1058 |
| 1059 EXPECT_FALSE(minimized_widget->IsClosed()); |
| 1060 event_generator.ClickLeftButton(); |
| 1061 EXPECT_TRUE(minimized_widget->IsClosed()); |
| 1062 |
| 1063 // All minimized windows are closed, so it should exit overview mode. |
| 1064 RunAllPendingInMessageLoop(); |
| 1065 EXPECT_FALSE(IsSelecting()); |
| 1066 } |
| 1067 |
| 1068 // Tests minimizing/unminimizing in overview mode. |
| 1069 TEST_F(WindowSelectorTest, MinimizeUnminimizei) { |
| 1070 std::unique_ptr<views::Widget> widget = |
| 1071 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); |
| 1072 aura::Window* window = widget->GetNativeWindow(); |
| 1073 |
| 1074 ToggleOverview(); |
| 1075 |
| 1076 EXPECT_FALSE(GetOverviewWindowForMinimizedState(0, window)); |
| 1077 widget->Minimize(); |
| 1078 EXPECT_TRUE(widget->IsMinimized()); |
| 1079 EXPECT_TRUE(IsSelecting()); |
| 1080 |
| 1081 EXPECT_TRUE(GetOverviewWindowForMinimizedState(0, window)); |
| 1082 |
| 1083 widget->Restore(); |
| 1084 EXPECT_FALSE(widget->IsMinimized()); |
| 1085 |
| 1086 EXPECT_FALSE(GetOverviewWindowForMinimizedState(0, window)); |
| 1087 EXPECT_TRUE(IsSelecting()); |
| 987 } | 1088 } |
| 988 | 1089 |
| 989 // Tests that clicking on the close button on a secondary display effectively | 1090 // Tests that clicking on the close button on a secondary display effectively |
| 990 // closes the window. | 1091 // closes the window. |
| 991 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { | 1092 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { |
| 992 if (!SupportsMultipleDisplays()) | 1093 if (!SupportsMultipleDisplays()) |
| 993 return; | 1094 return; |
| 994 | 1095 |
| 995 UpdateDisplay("600x400,600x400"); | 1096 UpdateDisplay("600x400,600x400"); |
| 996 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1097 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1010 widget->Init(params); | 1111 widget->Init(params); |
| 1011 widget->Show(); | 1112 widget->Show(); |
| 1012 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 1113 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
| 1013 window->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET, kHeaderHeight); | 1114 window->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET, kHeaderHeight); |
| 1014 | 1115 |
| 1015 ASSERT_EQ(root_windows[1], window1->GetRootWindow()); | 1116 ASSERT_EQ(root_windows[1], window1->GetRootWindow()); |
| 1016 | 1117 |
| 1017 ToggleOverview(); | 1118 ToggleOverview(); |
| 1018 | 1119 |
| 1019 aura::Window* window2 = widget->GetNativeWindow(); | 1120 aura::Window* window2 = widget->GetNativeWindow(); |
| 1020 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); | 1121 gfx::Rect bounds = GetTransformedBoundsInRootWindow(window2); |
| 1021 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); | 1122 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); |
| 1022 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); | 1123 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); |
| 1023 | 1124 |
| 1024 EXPECT_FALSE(widget->IsClosed()); | 1125 EXPECT_FALSE(widget->IsClosed()); |
| 1025 event_generator.ClickLeftButton(); | 1126 event_generator.ClickLeftButton(); |
| 1026 EXPECT_TRUE(widget->IsClosed()); | 1127 EXPECT_TRUE(widget->IsClosed()); |
| 1027 } | 1128 } |
| 1028 | 1129 |
| 1029 // Tests entering overview mode with two windows and selecting one. | 1130 // Tests entering overview mode with two windows and selecting one. |
| 1030 TEST_F(WindowSelectorTest, FullscreenWindow) { | 1131 TEST_F(WindowSelectorTest, FullscreenWindow) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 } | 1286 } |
| 1186 } | 1287 } |
| 1187 } | 1288 } |
| 1188 | 1289 |
| 1189 // Tests that a bounds change during overview is corrected for. | 1290 // Tests that a bounds change during overview is corrected for. |
| 1190 TEST_F(WindowSelectorTest, BoundsChangeDuringOverview) { | 1291 TEST_F(WindowSelectorTest, BoundsChangeDuringOverview) { |
| 1191 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); | 1292 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); |
| 1192 // Use overview headers above the window in this test. | 1293 // Use overview headers above the window in this test. |
| 1193 window->SetProperty(aura::client::kTopViewInset, 0); | 1294 window->SetProperty(aura::client::kTopViewInset, 0); |
| 1194 ToggleOverview(); | 1295 ToggleOverview(); |
| 1195 gfx::Rect overview_bounds = | 1296 gfx::Rect overview_bounds = GetTransformedTargetBounds(window.get()); |
| 1196 ToEnclosingRect(GetTransformedTargetBounds(window.get())); | |
| 1197 window->SetBounds(gfx::Rect(200, 0, 200, 200)); | 1297 window->SetBounds(gfx::Rect(200, 0, 200, 200)); |
| 1198 gfx::Rect new_overview_bounds = | 1298 gfx::Rect new_overview_bounds = GetTransformedTargetBounds(window.get()); |
| 1199 ToEnclosingRect(GetTransformedTargetBounds(window.get())); | |
| 1200 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); | 1299 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); |
| 1201 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); | 1300 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); |
| 1202 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); | 1301 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); |
| 1203 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); | 1302 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); |
| 1204 ToggleOverview(); | 1303 ToggleOverview(); |
| 1205 } | 1304 } |
| 1206 | 1305 |
| 1207 // Tests that a newly created window aborts overview. | 1306 // Tests that a newly created window aborts overview. |
| 1208 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) { | 1307 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) { |
| 1209 gfx::Rect bounds(0, 0, 400, 400); | 1308 gfx::Rect bounds(0, 0, 400, 400); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 window1.reset(); | 1361 window1.reset(); |
| 1263 window2.reset(); | 1362 window2.reset(); |
| 1264 EXPECT_FALSE(IsSelecting()); | 1363 EXPECT_FALSE(IsSelecting()); |
| 1265 } | 1364 } |
| 1266 | 1365 |
| 1267 // Tests that entering overview mode restores a window to its original | 1366 // Tests that entering overview mode restores a window to its original |
| 1268 // target location. | 1367 // target location. |
| 1269 TEST_F(WindowSelectorTest, QuickReentryRestoresInitialTransform) { | 1368 TEST_F(WindowSelectorTest, QuickReentryRestoresInitialTransform) { |
| 1270 gfx::Rect bounds(0, 0, 400, 400); | 1369 gfx::Rect bounds(0, 0, 400, 400); |
| 1271 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); | 1370 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 1272 gfx::Rect initial_bounds = | 1371 gfx::Rect initial_bounds = GetTransformedBounds(window.get()); |
| 1273 ToEnclosingRect(GetTransformedBounds(window.get())); | |
| 1274 ToggleOverview(); | 1372 ToggleOverview(); |
| 1275 // Quickly exit and reenter overview mode. The window should still be | 1373 // Quickly exit and reenter overview mode. The window should still be |
| 1276 // animating when we reenter. We cannot short circuit animations for this but | 1374 // animating when we reenter. We cannot short circuit animations for this but |
| 1277 // we also don't have to wait for them to complete. | 1375 // we also don't have to wait for them to complete. |
| 1278 { | 1376 { |
| 1279 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 1377 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 1280 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1378 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 1281 ToggleOverview(); | 1379 ToggleOverview(); |
| 1282 ToggleOverview(); | 1380 ToggleOverview(); |
| 1283 } | 1381 } |
| 1284 EXPECT_NE(initial_bounds, | 1382 EXPECT_NE(initial_bounds, GetTransformedTargetBounds(window.get())); |
| 1285 ToEnclosingRect(GetTransformedTargetBounds(window.get()))); | |
| 1286 ToggleOverview(); | 1383 ToggleOverview(); |
| 1287 EXPECT_FALSE(IsSelecting()); | 1384 EXPECT_FALSE(IsSelecting()); |
| 1288 EXPECT_EQ(initial_bounds, | 1385 EXPECT_EQ(initial_bounds, GetTransformedTargetBounds(window.get())); |
| 1289 ToEnclosingRect(GetTransformedTargetBounds(window.get()))); | |
| 1290 } | 1386 } |
| 1291 | 1387 |
| 1292 // Tests that windows with modal child windows are transformed with the modal | 1388 // Tests that windows with modal child windows are transformed with the modal |
| 1293 // child even though not activatable themselves. | 1389 // child even though not activatable themselves. |
| 1294 TEST_F(WindowSelectorTest, ModalChild) { | 1390 TEST_F(WindowSelectorTest, ModalChild) { |
| 1295 gfx::Rect bounds(0, 0, 400, 400); | 1391 gfx::Rect bounds(0, 0, 400, 400); |
| 1296 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 1392 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1297 std::unique_ptr<aura::Window> child1(CreateWindow(bounds)); | 1393 std::unique_ptr<aura::Window> child1(CreateWindow(bounds)); |
| 1298 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | 1394 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 1299 ::wm::AddTransientChild(window1.get(), child1.get()); | 1395 ::wm::AddTransientChild(window1.get(), child1.get()); |
| 1300 EXPECT_EQ(window1->parent(), child1->parent()); | 1396 EXPECT_EQ(window1->parent(), child1->parent()); |
| 1301 ToggleOverview(); | 1397 ToggleOverview(); |
| 1302 EXPECT_TRUE(window1->IsVisible()); | 1398 EXPECT_TRUE(window1->IsVisible()); |
| 1303 EXPECT_TRUE(child1->IsVisible()); | 1399 EXPECT_TRUE(child1->IsVisible()); |
| 1304 EXPECT_EQ(ToEnclosingRect(GetTransformedTargetBounds(child1.get())), | 1400 EXPECT_EQ(GetTransformedTargetBounds(child1.get()), |
| 1305 ToEnclosingRect(GetTransformedTargetBounds(window1.get()))); | 1401 GetTransformedTargetBounds(window1.get())); |
| 1306 ToggleOverview(); | 1402 ToggleOverview(); |
| 1307 } | 1403 } |
| 1308 | 1404 |
| 1309 // Tests that clicking a modal window's parent activates the modal window in | 1405 // Tests that clicking a modal window's parent activates the modal window in |
| 1310 // overview. | 1406 // overview. |
| 1311 TEST_F(WindowSelectorTest, ClickModalWindowParent) { | 1407 TEST_F(WindowSelectorTest, ClickModalWindowParent) { |
| 1312 std::unique_ptr<aura::Window> window1( | 1408 std::unique_ptr<aura::Window> window1( |
| 1313 CreateWindow(gfx::Rect(0, 0, 180, 180))); | 1409 CreateWindow(gfx::Rect(0, 0, 180, 180))); |
| 1314 std::unique_ptr<aura::Window> child1( | 1410 std::unique_ptr<aura::Window> child1( |
| 1315 CreateWindow(gfx::Rect(200, 0, 180, 180))); | 1411 CreateWindow(gfx::Rect(200, 0, 180, 180))); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); | 1593 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); |
| 1498 gfx::Rect window_bounds(0, 0, 150, 150); | 1594 gfx::Rect window_bounds(0, 0, 150, 150); |
| 1499 ScopedVector<aura::Window> windows; | 1595 ScopedVector<aura::Window> windows; |
| 1500 for (int i = 0; i < 3; i++) { | 1596 for (int i = 0; i < 3; i++) { |
| 1501 windows.push_back(CreateWindow(window_bounds)); | 1597 windows.push_back(CreateWindow(window_bounds)); |
| 1502 } | 1598 } |
| 1503 | 1599 |
| 1504 ToggleOverview(); | 1600 ToggleOverview(); |
| 1505 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); | 1601 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); |
| 1506 iter != windows.end(); ++iter) { | 1602 iter != windows.end(); ++iter) { |
| 1507 EXPECT_TRUE(root_window->bounds().Contains( | 1603 EXPECT_TRUE( |
| 1508 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); | 1604 root_window->bounds().Contains(GetTransformedTargetBounds(*iter))); |
| 1509 } | 1605 } |
| 1510 | 1606 |
| 1511 // Rotate the display, windows should be repositioned to be within the screen | 1607 // Rotate the display, windows should be repositioned to be within the screen |
| 1512 // bounds. | 1608 // bounds. |
| 1513 UpdateDisplay("600x200/r"); | 1609 UpdateDisplay("600x200/r"); |
| 1514 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString()); | 1610 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString()); |
| 1515 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); | 1611 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); |
| 1516 iter != windows.end(); ++iter) { | 1612 iter != windows.end(); ++iter) { |
| 1517 EXPECT_TRUE(root_window->bounds().Contains( | 1613 EXPECT_TRUE( |
| 1518 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); | 1614 root_window->bounds().Contains(GetTransformedTargetBounds(*iter))); |
| 1519 } | 1615 } |
| 1520 } | 1616 } |
| 1521 | 1617 |
| 1522 // Tests traversing some windows in overview mode with the tab key. | 1618 // Tests traversing some windows in overview mode with the tab key. |
| 1523 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) { | 1619 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) { |
| 1524 gfx::Rect bounds(0, 0, 100, 100); | 1620 gfx::Rect bounds(0, 0, 100, 100); |
| 1525 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 1621 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1526 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 1622 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1527 ToggleOverview(); | 1623 ToggleOverview(); |
| 1528 | 1624 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); | 2125 HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
| 2030 ASSERT_TRUE(resizer.get()); | 2126 ASSERT_TRUE(resizer.get()); |
| 2031 gfx::Point location = resizer->GetInitialLocation(); | 2127 gfx::Point location = resizer->GetInitialLocation(); |
| 2032 location.Offset(20, 20); | 2128 location.Offset(20, 20); |
| 2033 resizer->Drag(location, 0); | 2129 resizer->Drag(location, 0); |
| 2034 ToggleOverview(); | 2130 ToggleOverview(); |
| 2035 resizer->RevertDrag(); | 2131 resizer->RevertDrag(); |
| 2036 } | 2132 } |
| 2037 | 2133 |
| 2038 } // namespace ash | 2134 } // namespace ash |
| OLD | NEW |