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

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

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