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

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

Issue 2617733002: Hide docked windows behind a flag (Closed)
Patch Set: Fix tests failed because of DCHECK Created 3 years, 11 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
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/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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 ToggleOverview(); 539 ToggleOverview();
540 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); 540 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0));
541 541
542 // The order should be MRU. 542 // The order should be MRU.
543 EXPECT_EQ(2, overview2[0]->GetWindow()->GetShellWindowId()); 543 EXPECT_EQ(2, overview2[0]->GetWindow()->GetShellWindowId());
544 EXPECT_EQ(1, overview2[1]->GetWindow()->GetShellWindowId()); 544 EXPECT_EQ(1, overview2[1]->GetWindow()->GetShellWindowId());
545 EXPECT_EQ(3, overview2[2]->GetWindow()->GetShellWindowId()); 545 EXPECT_EQ(3, overview2[2]->GetWindow()->GetShellWindowId());
546 ToggleOverview(); 546 ToggleOverview();
547 } 547 }
548 548
549 // Test class used for tests that need docked windows enabled.
550 class EnabledDockedWindowsWindowSelectorTest : public WindowSelectorTest {
551 public:
552 EnabledDockedWindowsWindowSelectorTest() = default;
553 ~EnabledDockedWindowsWindowSelectorTest() override = default;
554
555 void SetUp() override {
556 base::CommandLine::ForCurrentProcess()->AppendSwitch(
557 ash::switches::kAshEnableDockedWindows);
558 WindowSelectorTest::SetUp();
559 }
560
561 private:
562 DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsWindowSelectorTest);
563 };
564
549 // Tests entering overview mode with docked windows 565 // Tests entering overview mode with docked windows
550 TEST_F(WindowSelectorTest, BasicWithDocked) { 566 TEST_F(EnabledDockedWindowsWindowSelectorTest, BasicWithDocked) {
551 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 567 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
552 gfx::Rect bounds(300, 0, 200, 200); 568 gfx::Rect bounds(300, 0, 200, 200);
553 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 569 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
554 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 570 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
555 std::unique_ptr<aura::Window> docked1(CreateWindow(bounds)); 571 std::unique_ptr<aura::Window> docked1(CreateWindow(bounds));
556 std::unique_ptr<aura::Window> docked2(CreateWindow(bounds)); 572 std::unique_ptr<aura::Window> docked2(CreateWindow(bounds));
557 573
558 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 574 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
559 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event); 575 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event);
560 576
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 ->GetDisplayNearestWindow(docked1.get()) 630 ->GetDisplayNearestWindow(docked1.get())
615 .work_area(); 631 .work_area();
616 expected_work_area_bounds = container_bounds.size(); 632 expected_work_area_bounds = container_bounds.size();
617 expected_work_area_bounds.Enlarge(-manager->docked_bounds().width(), 633 expected_work_area_bounds.Enlarge(-manager->docked_bounds().width(),
618 -shelf->GetWindowBoundsInScreen().height()); 634 -shelf->GetWindowBoundsInScreen().height());
619 EXPECT_EQ(expected_work_area_bounds.ToString(), work_area.size().ToString()); 635 EXPECT_EQ(expected_work_area_bounds.ToString(), work_area.size().ToString());
620 } 636 }
621 637
622 // Tests that selecting a docked window updates docked layout pushing another 638 // Tests that selecting a docked window updates docked layout pushing another
623 // window to get docked-minimized. 639 // window to get docked-minimized.
624 TEST_F(WindowSelectorTest, ActivateDockedWindow) { 640 TEST_F(EnabledDockedWindowsWindowSelectorTest, ActivateDockedWindow) {
625 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 641 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
626 gfx::Rect bounds(300, 0, 200, 200); 642 gfx::Rect bounds(300, 0, 200, 200);
627 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 643 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
628 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 644 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
629 645
630 aura::test::TestWindowDelegate delegate; 646 aura::test::TestWindowDelegate delegate;
631 delegate.set_minimum_size(gfx::Size(200, 500)); 647 delegate.set_minimum_size(gfx::Size(200, 500));
632 std::unique_ptr<aura::Window> docked_window1( 648 std::unique_ptr<aura::Window> docked_window1(
633 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 649 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
634 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight); 650 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 696
681 // |docked_window1| is docked-minimized and hidden. 697 // |docked_window1| is docked-minimized and hidden.
682 EXPECT_FALSE(docked_window1->IsVisible()); 698 EXPECT_FALSE(docked_window1->IsVisible());
683 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); 699 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType());
684 // |docked_window2| is docked and visible. 700 // |docked_window2| is docked and visible.
685 EXPECT_TRUE(docked_window2->IsVisible()); 701 EXPECT_TRUE(docked_window2->IsVisible());
686 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 702 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
687 } 703 }
688 704
689 // Tests that clicking on the close button closes the docked window. 705 // Tests that clicking on the close button closes the docked window.
690 TEST_F(WindowSelectorTest, CloseDockedWindow) { 706 TEST_F(EnabledDockedWindowsWindowSelectorTest, CloseDockedWindow) {
691 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 707 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
692 gfx::Rect bounds(300, 0, 200, 200); 708 gfx::Rect bounds(300, 0, 200, 200);
693 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 709 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
694 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 710 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
695 711
696 aura::test::TestWindowDelegate delegate; 712 aura::test::TestWindowDelegate delegate;
697 delegate.set_minimum_size(gfx::Size(200, 500)); 713 delegate.set_minimum_size(gfx::Size(200, 500));
698 std::unique_ptr<aura::Window> docked_window1( 714 std::unique_ptr<aura::Window> docked_window1(
699 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 715 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
700 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight); 716 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 759
744 // Window bounds are still the same. 760 // Window bounds are still the same.
745 EXPECT_EQ(expected_bounds1.ToString(), docked_window1->bounds().ToString()); 761 EXPECT_EQ(expected_bounds1.ToString(), docked_window1->bounds().ToString());
746 762
747 // |docked_window1| returns to docked-minimized and hidden state. 763 // |docked_window1| returns to docked-minimized and hidden state.
748 EXPECT_FALSE(docked_window1->IsVisible()); 764 EXPECT_FALSE(docked_window1->IsVisible());
749 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); 765 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType());
750 } 766 }
751 767
752 // Tests that clicking on the close button closes the docked-minimized window. 768 // Tests that clicking on the close button closes the docked-minimized window.
753 TEST_F(WindowSelectorTest, CloseDockedMinimizedWindow) { 769 TEST_F(EnabledDockedWindowsWindowSelectorTest, CloseDockedMinimizedWindow) {
754 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 770 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
755 gfx::Rect bounds(300, 0, 200, 200); 771 gfx::Rect bounds(300, 0, 200, 200);
756 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 772 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
757 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 773 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
758 774
759 aura::test::TestWindowDelegate delegate; 775 aura::test::TestWindowDelegate delegate;
760 delegate.set_minimum_size(gfx::Size(200, 500)); 776 delegate.set_minimum_size(gfx::Size(200, 500));
761 std::unique_ptr<aura::Window> docked_window1( 777 std::unique_ptr<aura::Window> docked_window1(
762 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 778 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
763 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight); 779 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 2144 HTCAPTION, aura::client::WINDOW_MOVE_SOURCE_MOUSE));
2129 ASSERT_TRUE(resizer.get()); 2145 ASSERT_TRUE(resizer.get());
2130 gfx::Point location = resizer->GetInitialLocation(); 2146 gfx::Point location = resizer->GetInitialLocation();
2131 location.Offset(20, 20); 2147 location.Offset(20, 20);
2132 resizer->Drag(location, 0); 2148 resizer->Drag(location, 0);
2133 ToggleOverview(); 2149 ToggleOverview();
2134 resizer->RevertDrag(); 2150 resizer->RevertDrag();
2135 } 2151 }
2136 2152
2137 } // namespace ash 2153 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698