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

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

Issue 2329433003: Revert of [ash-md] Fades overview header in and out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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"
11 #include "ash/common/ash_switches.h" 11 #include "ash/common/ash_switches.h"
12 #include "ash/common/material_design/material_design_controller.h" 12 #include "ash/common/material_design/material_design_controller.h"
13 #include "ash/common/shelf/shelf_widget.h" 13 #include "ash/common/shelf/shelf_widget.h"
14 #include "ash/common/shelf/wm_shelf.h" 14 #include "ash/common/shelf/wm_shelf.h"
15 #include "ash/common/shell_window_ids.h" 15 #include "ash/common/shell_window_ids.h"
16 #include "ash/common/system/tray/system_tray.h" 16 #include "ash/common/system/tray/system_tray.h"
17 #include "ash/common/test/material_design_controller_test_api.h" 17 #include "ash/common/test/material_design_controller_test_api.h"
18 #include "ash/common/wm/dock/docked_window_layout_manager.h" 18 #include "ash/common/wm/dock/docked_window_layout_manager.h"
19 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 19 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
20 #include "ash/common/wm/mru_window_tracker.h" 20 #include "ash/common/wm/mru_window_tracker.h"
21 #include "ash/common/wm/overview/scoped_transform_overview_window.h" 21 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
22 #include "ash/common/wm/overview/window_grid.h" 22 #include "ash/common/wm/overview/window_grid.h"
23 #include "ash/common/wm/overview/window_selector.h" 23 #include "ash/common/wm/overview/window_selector.h"
24 #include "ash/common/wm/overview/window_selector_controller.h" 24 #include "ash/common/wm/overview/window_selector_controller.h"
25 #include "ash/common/wm/overview/window_selector_item.h" 25 #include "ash/common/wm/overview/window_selector_item.h"
26 #include "ash/common/wm/panels/panel_layout_manager.h" 26 #include "ash/common/wm/panels/panel_layout_manager.h"
27 #include "ash/common/wm/window_state.h" 27 #include "ash/common/wm/window_state.h"
28 #include "ash/common/wm/wm_event.h" 28 #include "ash/common/wm/wm_event.h"
29 #include "ash/common/wm_lookup.h"
30 #include "ash/common/wm_shell.h" 29 #include "ash/common/wm_shell.h"
31 #include "ash/common/wm_window_property.h"
32 #include "ash/display/display_manager.h" 30 #include "ash/display/display_manager.h"
33 #include "ash/drag_drop/drag_drop_controller.h" 31 #include "ash/drag_drop/drag_drop_controller.h"
34 #include "ash/root_window_controller.h" 32 #include "ash/root_window_controller.h"
35 #include "ash/screen_util.h" 33 #include "ash/screen_util.h"
36 #include "ash/shell.h" 34 #include "ash/shell.h"
37 #include "ash/test/ash_test_base.h" 35 #include "ash/test/ash_test_base.h"
38 #include "ash/test/display_manager_test_api.h" 36 #include "ash/test/display_manager_test_api.h"
39 #include "ash/test/shelf_view_test_api.h" 37 #include "ash/test/shelf_view_test_api.h"
40 #include "ash/test/shell_test_api.h" 38 #include "ash/test/shell_test_api.h"
41 #include "ash/test/test_shelf_delegate.h" 39 #include "ash/test/test_shelf_delegate.h"
(...skipping 30 matching lines...) Expand all
72 #include "ui/wm/core/window_util.h" 70 #include "ui/wm/core/window_util.h"
73 #include "ui/wm/public/activation_delegate.h" 71 #include "ui/wm/public/activation_delegate.h"
74 72
75 namespace ash { 73 namespace ash {
76 namespace { 74 namespace {
77 75
78 // With Material Design the label covers selector item windows with a padding 76 // With Material Design the label covers selector item windows with a padding
79 // in order to prevent them from receiving user input events while in overview. 77 // in order to prevent them from receiving user input events while in overview.
80 static const int kWindowMarginMD = 5; 78 static const int kWindowMarginMD = 5;
81 79
82 // With Material Design the overview mode header overlaps original window
83 // header. This value is used to set top inset property on the windows.
84 static const int kHeaderHeight = 32;
85
86 const char kActiveWindowChangedFromOverview[] = 80 const char kActiveWindowChangedFromOverview[] =
87 "WindowSelector_ActiveWindowChanged"; 81 "WindowSelector_ActiveWindowChanged";
88 82
89 class NonActivatableActivationDelegate 83 class NonActivatableActivationDelegate
90 : public aura::client::ActivationDelegate { 84 : public aura::client::ActivationDelegate {
91 public: 85 public:
92 bool ShouldActivate() const override { return false; } 86 bool ShouldActivate() const override { return false; }
93 }; 87 };
94 88
95 void CancelDrag(DragDropController* controller, bool* canceled) { 89 void CancelDrag(DragDropController* controller, bool* canceled) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 121 }
128 ASSERT_TRUE(test::TestShelfDelegate::instance()); 122 ASSERT_TRUE(test::TestShelfDelegate::instance());
129 123
130 shelf_view_test_.reset(new test::ShelfViewTestAPI( 124 shelf_view_test_.reset(new test::ShelfViewTestAPI(
131 GetPrimaryShelf()->GetShelfViewForTesting())); 125 GetPrimaryShelf()->GetShelfViewForTesting()));
132 shelf_view_test_->SetAnimationDuration(1); 126 shelf_view_test_->SetAnimationDuration(1);
133 ScopedTransformOverviewWindow::SetImmediateCloseForTests(); 127 ScopedTransformOverviewWindow::SetImmediateCloseForTests();
134 } 128 }
135 129
136 aura::Window* CreateWindow(const gfx::Rect& bounds) { 130 aura::Window* CreateWindow(const gfx::Rect& bounds) {
137 aura::Window* window = 131 return CreateTestWindowInShellWithDelegate(&delegate_, -1, bounds);
138 CreateTestWindowInShellWithDelegate(&delegate_, -1, bounds);
139 window->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
140 return window;
141 } 132 }
142 133
143 aura::Window* CreateWindowWithId(const gfx::Rect& bounds, int id) { 134 aura::Window* CreateWindowWithId(const gfx::Rect& bounds, int id) {
144 aura::Window* window = 135 return CreateTestWindowInShellWithDelegate(&delegate_, id, bounds);
145 CreateTestWindowInShellWithDelegate(&delegate_, id, bounds);
146 window->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
147 return window;
148 } 136 }
149 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) { 137 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) {
150 aura::Window* window = CreateWindow(bounds); 138 aura::Window* window = CreateWindow(bounds);
151 aura::client::SetActivationDelegate(window, 139 aura::client::SetActivationDelegate(window,
152 &non_activatable_activation_delegate_); 140 &non_activatable_activation_delegate_);
153 EXPECT_FALSE(wm::CanActivateWindow(window)); 141 EXPECT_FALSE(wm::CanActivateWindow(window));
154 return window; 142 return window;
155 } 143 }
156 144
157 // Creates a Widget containing a Window with the given |bounds|. This should 145 // Creates a Widget containing a Window with the given |bounds|. This should
158 // be used when the test requires a Widget. For example any test that will 146 // be used when the test requires a Widget. For example any test that will
159 // cause a window to be closed via 147 // cause a window to be closed via
160 // views::Widget::GetWidgetForNativeView(window)->Close(). 148 // views::Widget::GetWidgetForNativeView(window)->Close().
161 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { 149 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) {
162 std::unique_ptr<views::Widget> widget(new views::Widget); 150 std::unique_ptr<views::Widget> widget(new views::Widget);
163 views::Widget::InitParams params; 151 views::Widget::InitParams params;
164 params.bounds = bounds; 152 params.bounds = bounds;
165 params.type = views::Widget::InitParams::TYPE_WINDOW; 153 params.type = views::Widget::InitParams::TYPE_WINDOW;
166 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 154 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
167 widget->Init(params); 155 widget->Init(params);
168 widget->Show(); 156 widget->Show();
169 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get());
170 window->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET, kHeaderHeight);
171 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow()); 157 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow());
172 return widget; 158 return widget;
173 } 159 }
174 160
175 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { 161 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) {
176 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 162 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
177 nullptr, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); 163 nullptr, ui::wm::WINDOW_TYPE_PANEL, 0, bounds);
178 window->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
179 test::TestShelfDelegate::instance()->AddShelfItem(window); 164 test::TestShelfDelegate::instance()->AddShelfItem(window);
180 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 165 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
181 return window; 166 return window;
182 } 167 }
183 168
184 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) { 169 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) {
185 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1); 170 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1);
186 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2); 171 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2);
187 return window1_bounds.Intersects(window2_bounds); 172 return window1_bounds.Intersects(window2_bounds);
188 } 173 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 407
423 // Tests that there are no crashes when there is not enough screen space 408 // Tests that there are no crashes when there is not enough screen space
424 // available to show all of the windows. 409 // available to show all of the windows.
425 TEST_P(WindowSelectorTest, SmallDisplay) { 410 TEST_P(WindowSelectorTest, SmallDisplay) {
426 UpdateDisplay("3x1"); 411 UpdateDisplay("3x1");
427 gfx::Rect bounds(0, 0, 1, 1); 412 gfx::Rect bounds(0, 0, 1, 1);
428 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 413 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
429 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 414 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
430 std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); 415 std::unique_ptr<aura::Window> window3(CreateWindow(bounds));
431 std::unique_ptr<aura::Window> window4(CreateWindow(bounds)); 416 std::unique_ptr<aura::Window> window4(CreateWindow(bounds));
432 window1->SetProperty(aura::client::kTopViewInset, 0);
433 window2->SetProperty(aura::client::kTopViewInset, 0);
434 window3->SetProperty(aura::client::kTopViewInset, 0);
435 window4->SetProperty(aura::client::kTopViewInset, 0);
436 ToggleOverview(); 417 ToggleOverview();
437 } 418 }
438 419
439 // Tests entering overview mode with two windows and selecting one by clicking. 420 // Tests entering overview mode with two windows and selecting one by clicking.
440 TEST_P(WindowSelectorTest, Basic) { 421 TEST_P(WindowSelectorTest, Basic) {
441 gfx::Rect bounds(0, 0, 400, 400); 422 gfx::Rect bounds(0, 0, 400, 400);
442 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 423 aura::Window* root_window = Shell::GetPrimaryRootWindow();
443 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 424 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
444 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 425 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
445 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 426 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 687
707 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 688 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
708 gfx::Rect bounds(300, 0, 200, 200); 689 gfx::Rect bounds(300, 0, 200, 200);
709 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 690 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
710 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 691 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
711 692
712 aura::test::TestWindowDelegate delegate; 693 aura::test::TestWindowDelegate delegate;
713 delegate.set_minimum_size(gfx::Size(200, 500)); 694 delegate.set_minimum_size(gfx::Size(200, 500));
714 std::unique_ptr<aura::Window> docked_window1( 695 std::unique_ptr<aura::Window> docked_window1(
715 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 696 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
716 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
717 std::unique_ptr<aura::Window> docked_window2( 697 std::unique_ptr<aura::Window> docked_window2(
718 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 698 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
719 docked_window2->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
720 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get()); 699 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get());
721 wm::WindowState* state2 = wm::GetWindowState(docked_window2.get()); 700 wm::WindowState* state2 = wm::GetWindowState(docked_window2.get());
722 701
723 // Dock the second window first, then the first window. 702 // Dock the second window first, then the first window.
724 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 703 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
725 state2->OnWMEvent(&dock_event); 704 state2->OnWMEvent(&dock_event);
726 state1->OnWMEvent(&dock_event); 705 state1->OnWMEvent(&dock_event);
727 706
728 // Both windows' restored bounds are same. 707 // Both windows' restored bounds are same.
729 const gfx::Rect expected_bounds = docked_window1->bounds(); 708 const gfx::Rect expected_bounds = docked_window1->bounds();
730 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString()); 709 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString());
731 710
732 // |docked_window1| is docked and visible. 711 // |docked_window1| is docked and visible.
733 EXPECT_TRUE(docked_window1->IsVisible()); 712 EXPECT_TRUE(docked_window1->IsVisible());
734 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 713 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
735 // |docked_window2| is docked-minimized and hidden. 714 // |docked_window2| is docked-minimized and hidden.
736 EXPECT_FALSE(docked_window2->IsVisible()); 715 EXPECT_FALSE(docked_window2->IsVisible());
737 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); 716 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType());
738 717
739 ToggleOverview(); 718 ToggleOverview();
740 719
741 // Activate |docked_window2| leaving the overview. 720 // Activate |docked_window2| leaving the overview.
742 const gfx::RectF rect = 721 const gfx::RectF rect =
743 GetTransformedBoundsInRootWindow(docked_window2.get()); 722 GetTransformedBoundsInRootWindow(docked_window2.get());
744 gfx::Point point(rect.top_right().x() - 50, rect.top_right().y() + 50); 723 gfx::Point point(rect.top_right().x() - 50, rect.top_right().y() + 10);
745 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), 724 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(),
746 point); 725 point);
747 event_generator.ClickLeftButton(); 726 event_generator.ClickLeftButton();
748 727
749 // Windows' bounds are still the same. 728 // Windows' bounds are still the same.
750 EXPECT_EQ(expected_bounds.ToString(), docked_window1->bounds().ToString()); 729 EXPECT_EQ(expected_bounds.ToString(), docked_window1->bounds().ToString());
751 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString()); 730 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString());
752 731
753 // |docked_window1| is docked-minimized and hidden. 732 // |docked_window1| is docked-minimized and hidden.
754 EXPECT_FALSE(docked_window1->IsVisible()); 733 EXPECT_FALSE(docked_window1->IsVisible());
(...skipping 10 matching lines...) Expand all
765 744
766 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 745 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
767 gfx::Rect bounds(300, 0, 200, 200); 746 gfx::Rect bounds(300, 0, 200, 200);
768 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 747 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
769 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 748 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
770 749
771 aura::test::TestWindowDelegate delegate; 750 aura::test::TestWindowDelegate delegate;
772 delegate.set_minimum_size(gfx::Size(200, 500)); 751 delegate.set_minimum_size(gfx::Size(200, 500));
773 std::unique_ptr<aura::Window> docked_window1( 752 std::unique_ptr<aura::Window> docked_window1(
774 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 753 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
775 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
776 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds); 754 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds);
777 aura::Window* docked_window2 = docked2->GetNativeWindow(); 755 aura::Window* docked_window2 = docked2->GetNativeWindow();
778 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get()); 756 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get());
779 wm::WindowState* state2 = wm::GetWindowState(docked_window2); 757 wm::WindowState* state2 = wm::GetWindowState(docked_window2);
780 758
781 // Dock the first window first, then the second window. 759 // Dock the first window first, then the second window.
782 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 760 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
783 state1->OnWMEvent(&dock_event); 761 state1->OnWMEvent(&dock_event);
784 state2->OnWMEvent(&dock_event); 762 state2->OnWMEvent(&dock_event);
785 763
786 const gfx::Rect expected_bounds1 = docked_window1->bounds(); 764 const gfx::Rect expected_bounds1 = docked_window1->bounds();
787 765
788 // |docked_window1| is docked-minimized and hidden. 766 // |docked_window1| is docked-minimized and hidden.
789 EXPECT_FALSE(docked_window1->IsVisible()); 767 EXPECT_FALSE(docked_window1->IsVisible());
790 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); 768 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType());
791 // |docked_window2| is docked and visible. 769 // |docked_window2| is docked and visible.
792 EXPECT_TRUE(docked_window2->IsVisible()); 770 EXPECT_TRUE(docked_window2->IsVisible());
793 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 771 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
794 772
795 ToggleOverview(); 773 ToggleOverview();
796 774
797 // Close |docked_window2| (staying in overview). 775 // Close |docked_window2| (staying in overview).
798 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2); 776 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2);
799 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5); 777 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() - 5);
800 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), 778 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(),
801 point); 779 point);
802 // Both windows are visible while in overview. 780 // Both windows are visible while in overview.
803 EXPECT_TRUE(docked_window1->IsVisible()); 781 EXPECT_TRUE(docked_window1->IsVisible());
804 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 782 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
805 EXPECT_TRUE(docked_window2->IsVisible()); 783 EXPECT_TRUE(docked_window2->IsVisible());
806 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 784 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
807 785
808 event_generator.ClickLeftButton(); 786 event_generator.ClickLeftButton();
809 // |docked2| widget is closed. 787 // |docked2| widget is closed.
(...skipping 17 matching lines...) Expand all
827 805
828 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 806 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
829 gfx::Rect bounds(300, 0, 200, 200); 807 gfx::Rect bounds(300, 0, 200, 200);
830 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 808 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
831 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 809 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
832 810
833 aura::test::TestWindowDelegate delegate; 811 aura::test::TestWindowDelegate delegate;
834 delegate.set_minimum_size(gfx::Size(200, 500)); 812 delegate.set_minimum_size(gfx::Size(200, 500));
835 std::unique_ptr<aura::Window> docked_window1( 813 std::unique_ptr<aura::Window> docked_window1(
836 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 814 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
837 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
838 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds); 815 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds);
839 aura::Window* docked_window2 = docked2->GetNativeWindow(); 816 aura::Window* docked_window2 = docked2->GetNativeWindow();
840 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get()); 817 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get());
841 wm::WindowState* state2 = wm::GetWindowState(docked_window2); 818 wm::WindowState* state2 = wm::GetWindowState(docked_window2);
842 819
843 // Dock the second window first, then the first window. 820 // Dock the second window first, then the first window.
844 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 821 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
845 state2->OnWMEvent(&dock_event); 822 state2->OnWMEvent(&dock_event);
846 state1->OnWMEvent(&dock_event); 823 state1->OnWMEvent(&dock_event);
847 824
848 const gfx::Rect expected_bounds1 = docked_window1->bounds(); 825 const gfx::Rect expected_bounds1 = docked_window1->bounds();
849 826
850 // |docked_window1| is docked and visible. 827 // |docked_window1| is docked and visible.
851 EXPECT_TRUE(docked_window1->IsVisible()); 828 EXPECT_TRUE(docked_window1->IsVisible());
852 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 829 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
853 // |docked_window2| is docked-minimized and hidden. 830 // |docked_window2| is docked-minimized and hidden.
854 EXPECT_FALSE(docked_window2->IsVisible()); 831 EXPECT_FALSE(docked_window2->IsVisible());
855 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); 832 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType());
856 833
857 ToggleOverview(); 834 ToggleOverview();
858 835
859 // Close |docked_window2| (staying in overview). 836 // Close |docked_window2| (staying in overview).
860 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2); 837 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2);
861 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5); 838 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() - 5);
862 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), 839 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(),
863 point); 840 point);
864 // Both windows are visible while in overview. 841 // Both windows are visible while in overview.
865 EXPECT_TRUE(docked_window1->IsVisible()); 842 EXPECT_TRUE(docked_window1->IsVisible());
866 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 843 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
867 EXPECT_TRUE(docked_window2->IsVisible()); 844 EXPECT_TRUE(docked_window2->IsVisible());
868 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 845 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
869 846
870 event_generator.ClickLeftButton(); 847 event_generator.ClickLeftButton();
871 // |docked2| widget is closed. 848 // |docked2| widget is closed.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 // recorded when overview mode exits as a result of closing its only window. 964 // recorded when overview mode exits as a result of closing its only window.
988 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { 965 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) {
989 base::UserActionTester user_action_tester; 966 base::UserActionTester user_action_tester;
990 std::unique_ptr<views::Widget> widget = 967 std::unique_ptr<views::Widget> widget =
991 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 968 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
992 969
993 ToggleOverview(); 970 ToggleOverview();
994 971
995 aura::Window* window = widget->GetNativeWindow(); 972 aura::Window* window = widget->GetNativeWindow();
996 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); 973 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
997 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); 974 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1);
998 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); 975 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
999 976
1000 ASSERT_FALSE(widget->IsClosed()); 977 ASSERT_FALSE(widget->IsClosed());
1001 event_generator.ClickLeftButton(); 978 event_generator.ClickLeftButton();
1002 ASSERT_TRUE(widget->IsClosed()); 979 ASSERT_TRUE(widget->IsClosed());
1003 EXPECT_EQ( 980 EXPECT_EQ(
1004 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); 981 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview));
1005 } 982 }
1006 983
1007 // Tests that we do not crash and overview mode remains engaged if the desktop 984 // Tests that we do not crash and overview mode remains engaged if the desktop
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1079
1103 // Tests that clicking on the close button effectively closes the window. 1080 // Tests that clicking on the close button effectively closes the window.
1104 TEST_P(WindowSelectorTest, CloseButton) { 1081 TEST_P(WindowSelectorTest, CloseButton) {
1105 std::unique_ptr<views::Widget> widget = 1082 std::unique_ptr<views::Widget> widget =
1106 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 1083 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1107 1084
1108 ToggleOverview(); 1085 ToggleOverview();
1109 1086
1110 aura::Window* window = widget->GetNativeWindow(); 1087 aura::Window* window = widget->GetNativeWindow();
1111 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); 1088 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
1112 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); 1089 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1);
1113 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); 1090 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
1114 1091
1115 EXPECT_FALSE(widget->IsClosed()); 1092 EXPECT_FALSE(widget->IsClosed());
1116 event_generator.ClickLeftButton(); 1093 event_generator.ClickLeftButton();
1117 EXPECT_TRUE(widget->IsClosed()); 1094 EXPECT_TRUE(widget->IsClosed());
1118 } 1095 }
1119 1096
1120 // Tests that clicking on the close button on a secondary display effectively 1097 // Tests that clicking on the close button on a secondary display effectively
1121 // closes the window. 1098 // closes the window.
1122 TEST_P(WindowSelectorTest, CloseButtonOnMultipleDisplay) { 1099 TEST_P(WindowSelectorTest, CloseButtonOnMultipleDisplay) {
(...skipping 10 matching lines...) Expand all
1133 // via the widget. We also use the widget to determine if the window has been 1110 // via the widget. We also use the widget to determine if the window has been
1134 // closed or not. We explicity create the widget so that the window can be 1111 // closed or not. We explicity create the widget so that the window can be
1135 // parented to a non-primary root window. 1112 // parented to a non-primary root window.
1136 std::unique_ptr<views::Widget> widget(new views::Widget); 1113 std::unique_ptr<views::Widget> widget(new views::Widget);
1137 views::Widget::InitParams params; 1114 views::Widget::InitParams params;
1138 params.bounds = gfx::Rect(650, 0, 400, 400); 1115 params.bounds = gfx::Rect(650, 0, 400, 400);
1139 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1116 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1140 params.parent = window1->parent(); 1117 params.parent = window1->parent();
1141 widget->Init(params); 1118 widget->Init(params);
1142 widget->Show(); 1119 widget->Show();
1143 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get());
1144 window->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET, kHeaderHeight);
1145 1120
1146 ASSERT_EQ(root_windows[1], window1->GetRootWindow()); 1121 ASSERT_EQ(root_windows[1], window1->GetRootWindow());
1147 1122
1148 ToggleOverview(); 1123 ToggleOverview();
1149 1124
1150 aura::Window* window2 = widget->GetNativeWindow(); 1125 aura::Window* window2 = widget->GetNativeWindow();
1151 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); 1126 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2);
1152 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); 1127 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1);
1153 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); 1128 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point);
1154 1129
1155 EXPECT_FALSE(widget->IsClosed()); 1130 EXPECT_FALSE(widget->IsClosed());
1156 event_generator.ClickLeftButton(); 1131 event_generator.ClickLeftButton();
1157 EXPECT_TRUE(widget->IsClosed()); 1132 EXPECT_TRUE(widget->IsClosed());
1158 } 1133 }
1159 1134
1160 // Tests entering overview mode with two windows and selecting one. 1135 // Tests entering overview mode with two windows and selecting one.
1161 TEST_P(WindowSelectorTest, FullscreenWindow) { 1136 TEST_P(WindowSelectorTest, FullscreenWindow) {
1162 gfx::Rect bounds(0, 0, 400, 400); 1137 gfx::Rect bounds(0, 0, 400, 400);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1257 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1283 ToggleOverview(); 1258 ToggleOverview();
1284 EXPECT_FALSE(window1->IsVisible()); 1259 EXPECT_FALSE(window1->IsVisible());
1285 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); 1260 EXPECT_FALSE(window1->layer()->GetTargetVisibility());
1286 } 1261 }
1287 } 1262 }
1288 1263
1289 // Tests that a bounds change during overview is corrected for. 1264 // Tests that a bounds change during overview is corrected for.
1290 TEST_P(WindowSelectorTest, BoundsChangeDuringOverview) { 1265 TEST_P(WindowSelectorTest, BoundsChangeDuringOverview) {
1291 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); 1266 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400)));
1292 // Use overview headers above the window in this test.
1293 window->SetProperty(aura::client::kTopViewInset, 0);
1294 ToggleOverview(); 1267 ToggleOverview();
1295 gfx::Rect overview_bounds = 1268 gfx::Rect overview_bounds =
1296 ToEnclosingRect(GetTransformedTargetBounds(window.get())); 1269 ToEnclosingRect(GetTransformedTargetBounds(window.get()));
1297 window->SetBounds(gfx::Rect(200, 0, 200, 200)); 1270 window->SetBounds(gfx::Rect(200, 0, 200, 200));
1298 gfx::Rect new_overview_bounds = 1271 gfx::Rect new_overview_bounds =
1299 ToEnclosingRect(GetTransformedTargetBounds(window.get())); 1272 ToEnclosingRect(GetTransformedTargetBounds(window.get()));
1300 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); 1273 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x());
1301 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); 1274 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y());
1302 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); 1275 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width());
1303 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); 1276 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height());
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 bounds.y()); 2119 bounds.y());
2147 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); 2120 EXPECT_LE(transformed_rect.bottom(), bounds.bottom());
2148 EXPECT_NEAR(transformed_rect.x() - bounds.x(), 2121 EXPECT_NEAR(transformed_rect.x() - bounds.x(),
2149 bounds.right() - transformed_rect.right(), 1); 2122 bounds.right() - transformed_rect.right(), 1);
2150 EXPECT_NEAR( 2123 EXPECT_NEAR(
2151 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), 2124 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(),
2152 bounds.bottom() - transformed_rect.bottom(), 1); 2125 bounds.bottom() - transformed_rect.bottom(), 1);
2153 } 2126 }
2154 2127
2155 } // namespace ash 2128 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/scoped_overview_animation_settings_aura.cc ('k') | ash/wm/panels/panel_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698