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

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 tests) 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 702
688 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 703 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
689 gfx::Rect bounds(300, 0, 200, 200); 704 gfx::Rect bounds(300, 0, 200, 200);
690 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 705 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
691 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 706 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
692 707
693 aura::test::TestWindowDelegate delegate; 708 aura::test::TestWindowDelegate delegate;
694 delegate.set_minimum_size(gfx::Size(200, 500)); 709 delegate.set_minimum_size(gfx::Size(200, 500));
695 std::unique_ptr<aura::Window> docked_window1( 710 std::unique_ptr<aura::Window> docked_window1(
696 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 711 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
712 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
697 std::unique_ptr<aura::Window> docked_window2( 713 std::unique_ptr<aura::Window> docked_window2(
698 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 714 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
715 docked_window2->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
699 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get()); 716 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get());
700 wm::WindowState* state2 = wm::GetWindowState(docked_window2.get()); 717 wm::WindowState* state2 = wm::GetWindowState(docked_window2.get());
701 718
702 // Dock the second window first, then the first window. 719 // Dock the second window first, then the first window.
703 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 720 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
704 state2->OnWMEvent(&dock_event); 721 state2->OnWMEvent(&dock_event);
705 state1->OnWMEvent(&dock_event); 722 state1->OnWMEvent(&dock_event);
706 723
707 // Both windows' restored bounds are same. 724 // Both windows' restored bounds are same.
708 const gfx::Rect expected_bounds = docked_window1->bounds(); 725 const gfx::Rect expected_bounds = docked_window1->bounds();
709 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString()); 726 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString());
710 727
711 // |docked_window1| is docked and visible. 728 // |docked_window1| is docked and visible.
712 EXPECT_TRUE(docked_window1->IsVisible()); 729 EXPECT_TRUE(docked_window1->IsVisible());
713 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 730 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
714 // |docked_window2| is docked-minimized and hidden. 731 // |docked_window2| is docked-minimized and hidden.
715 EXPECT_FALSE(docked_window2->IsVisible()); 732 EXPECT_FALSE(docked_window2->IsVisible());
716 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); 733 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType());
717 734
718 ToggleOverview(); 735 ToggleOverview();
719 736
720 // Activate |docked_window2| leaving the overview. 737 // Activate |docked_window2| leaving the overview.
721 const gfx::RectF rect = 738 const gfx::RectF rect =
722 GetTransformedBoundsInRootWindow(docked_window2.get()); 739 GetTransformedBoundsInRootWindow(docked_window2.get());
723 gfx::Point point(rect.top_right().x() - 50, rect.top_right().y() + 10); 740 gfx::Point point(rect.top_right().x() - 50, rect.top_right().y() + 50);
724 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), 741 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(),
725 point); 742 point);
726 event_generator.ClickLeftButton(); 743 event_generator.ClickLeftButton();
727 744
728 // Windows' bounds are still the same. 745 // Windows' bounds are still the same.
729 EXPECT_EQ(expected_bounds.ToString(), docked_window1->bounds().ToString()); 746 EXPECT_EQ(expected_bounds.ToString(), docked_window1->bounds().ToString());
730 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString()); 747 EXPECT_EQ(expected_bounds.ToString(), docked_window2->bounds().ToString());
731 748
732 // |docked_window1| is docked-minimized and hidden. 749 // |docked_window1| is docked-minimized and hidden.
733 EXPECT_FALSE(docked_window1->IsVisible()); 750 EXPECT_FALSE(docked_window1->IsVisible());
(...skipping 10 matching lines...) Expand all
744 761
745 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 762 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
746 gfx::Rect bounds(300, 0, 200, 200); 763 gfx::Rect bounds(300, 0, 200, 200);
747 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 764 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
748 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 765 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
749 766
750 aura::test::TestWindowDelegate delegate; 767 aura::test::TestWindowDelegate delegate;
751 delegate.set_minimum_size(gfx::Size(200, 500)); 768 delegate.set_minimum_size(gfx::Size(200, 500));
752 std::unique_ptr<aura::Window> docked_window1( 769 std::unique_ptr<aura::Window> docked_window1(
753 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 770 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
771 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
754 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds); 772 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds);
755 aura::Window* docked_window2 = docked2->GetNativeWindow(); 773 aura::Window* docked_window2 = docked2->GetNativeWindow();
756 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get()); 774 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get());
757 wm::WindowState* state2 = wm::GetWindowState(docked_window2); 775 wm::WindowState* state2 = wm::GetWindowState(docked_window2);
758 776
759 // Dock the first window first, then the second window. 777 // Dock the first window first, then the second window.
760 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 778 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
761 state1->OnWMEvent(&dock_event); 779 state1->OnWMEvent(&dock_event);
762 state2->OnWMEvent(&dock_event); 780 state2->OnWMEvent(&dock_event);
763 781
764 const gfx::Rect expected_bounds1 = docked_window1->bounds(); 782 const gfx::Rect expected_bounds1 = docked_window1->bounds();
765 783
766 // |docked_window1| is docked-minimized and hidden. 784 // |docked_window1| is docked-minimized and hidden.
767 EXPECT_FALSE(docked_window1->IsVisible()); 785 EXPECT_FALSE(docked_window1->IsVisible());
768 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); 786 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType());
769 // |docked_window2| is docked and visible. 787 // |docked_window2| is docked and visible.
770 EXPECT_TRUE(docked_window2->IsVisible()); 788 EXPECT_TRUE(docked_window2->IsVisible());
771 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 789 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
772 790
773 ToggleOverview(); 791 ToggleOverview();
774 792
775 // Close |docked_window2| (staying in overview). 793 // Close |docked_window2| (staying in overview).
776 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2); 794 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2);
777 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() - 5); 795 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5);
778 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), 796 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(),
779 point); 797 point);
780 // Both windows are visible while in overview. 798 // Both windows are visible while in overview.
781 EXPECT_TRUE(docked_window1->IsVisible()); 799 EXPECT_TRUE(docked_window1->IsVisible());
782 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 800 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
783 EXPECT_TRUE(docked_window2->IsVisible()); 801 EXPECT_TRUE(docked_window2->IsVisible());
784 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 802 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
785 803
786 event_generator.ClickLeftButton(); 804 event_generator.ClickLeftButton();
787 // |docked2| widget is closed. 805 // |docked2| widget is closed.
(...skipping 17 matching lines...) Expand all
805 823
806 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 824 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
807 gfx::Rect bounds(300, 0, 200, 200); 825 gfx::Rect bounds(300, 0, 200, 200);
808 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 826 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
809 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 827 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
810 828
811 aura::test::TestWindowDelegate delegate; 829 aura::test::TestWindowDelegate delegate;
812 delegate.set_minimum_size(gfx::Size(200, 500)); 830 delegate.set_minimum_size(gfx::Size(200, 500));
813 std::unique_ptr<aura::Window> docked_window1( 831 std::unique_ptr<aura::Window> docked_window1(
814 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 832 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
833 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
815 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds); 834 std::unique_ptr<views::Widget> docked2 = CreateWindowWidget(bounds);
816 aura::Window* docked_window2 = docked2->GetNativeWindow(); 835 aura::Window* docked_window2 = docked2->GetNativeWindow();
817 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get()); 836 wm::WindowState* state1 = wm::GetWindowState(docked_window1.get());
818 wm::WindowState* state2 = wm::GetWindowState(docked_window2); 837 wm::WindowState* state2 = wm::GetWindowState(docked_window2);
819 838
820 // Dock the second window first, then the first window. 839 // Dock the second window first, then the first window.
821 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 840 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
822 state2->OnWMEvent(&dock_event); 841 state2->OnWMEvent(&dock_event);
823 state1->OnWMEvent(&dock_event); 842 state1->OnWMEvent(&dock_event);
824 843
825 const gfx::Rect expected_bounds1 = docked_window1->bounds(); 844 const gfx::Rect expected_bounds1 = docked_window1->bounds();
826 845
827 // |docked_window1| is docked and visible. 846 // |docked_window1| is docked and visible.
828 EXPECT_TRUE(docked_window1->IsVisible()); 847 EXPECT_TRUE(docked_window1->IsVisible());
829 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 848 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
830 // |docked_window2| is docked-minimized and hidden. 849 // |docked_window2| is docked-minimized and hidden.
831 EXPECT_FALSE(docked_window2->IsVisible()); 850 EXPECT_FALSE(docked_window2->IsVisible());
832 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType()); 851 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state2->GetStateType());
833 852
834 ToggleOverview(); 853 ToggleOverview();
835 854
836 // Close |docked_window2| (staying in overview). 855 // Close |docked_window2| (staying in overview).
837 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2); 856 const gfx::RectF rect = GetTransformedBoundsInRootWindow(docked_window2);
838 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() - 5); 857 gfx::Point point(rect.top_right().x() - 5, rect.top_right().y() + 5);
839 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(), 858 ui::test::EventGenerator event_generator(docked_window2->GetRootWindow(),
840 point); 859 point);
841 // Both windows are visible while in overview. 860 // Both windows are visible while in overview.
842 EXPECT_TRUE(docked_window1->IsVisible()); 861 EXPECT_TRUE(docked_window1->IsVisible());
843 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 862 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
844 EXPECT_TRUE(docked_window2->IsVisible()); 863 EXPECT_TRUE(docked_window2->IsVisible());
845 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 864 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
846 865
847 event_generator.ClickLeftButton(); 866 event_generator.ClickLeftButton();
848 // |docked2| widget is closed. 867 // |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. 983 // recorded when overview mode exits as a result of closing its only window.
965 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { 984 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) {
966 base::UserActionTester user_action_tester; 985 base::UserActionTester user_action_tester;
967 std::unique_ptr<views::Widget> widget = 986 std::unique_ptr<views::Widget> widget =
968 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 987 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
969 988
970 ToggleOverview(); 989 ToggleOverview();
971 990
972 aura::Window* window = widget->GetNativeWindow(); 991 aura::Window* window = widget->GetNativeWindow();
973 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); 992 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
974 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); 993 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5);
975 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); 994 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
976 995
977 ASSERT_FALSE(widget->IsClosed()); 996 ASSERT_FALSE(widget->IsClosed());
978 event_generator.ClickLeftButton(); 997 event_generator.ClickLeftButton();
979 ASSERT_TRUE(widget->IsClosed()); 998 ASSERT_TRUE(widget->IsClosed());
980 EXPECT_EQ( 999 EXPECT_EQ(
981 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); 1000 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview));
982 } 1001 }
983 1002
984 // Tests that we do not crash and overview mode remains engaged if the desktop 1003 // 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 1098
1080 // Tests that clicking on the close button effectively closes the window. 1099 // Tests that clicking on the close button effectively closes the window.
1081 TEST_P(WindowSelectorTest, CloseButton) { 1100 TEST_P(WindowSelectorTest, CloseButton) {
1082 std::unique_ptr<views::Widget> widget = 1101 std::unique_ptr<views::Widget> widget =
1083 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 1102 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1084 1103
1085 ToggleOverview(); 1104 ToggleOverview();
1086 1105
1087 aura::Window* window = widget->GetNativeWindow(); 1106 aura::Window* window = widget->GetNativeWindow();
1088 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); 1107 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
1089 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); 1108 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5);
1090 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); 1109 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
1091 1110
1092 EXPECT_FALSE(widget->IsClosed()); 1111 EXPECT_FALSE(widget->IsClosed());
1093 event_generator.ClickLeftButton(); 1112 event_generator.ClickLeftButton();
1094 EXPECT_TRUE(widget->IsClosed()); 1113 EXPECT_TRUE(widget->IsClosed());
1095 } 1114 }
1096 1115
1097 // Tests that clicking on the close button on a secondary display effectively 1116 // Tests that clicking on the close button on a secondary display effectively
1098 // closes the window. 1117 // closes the window.
1099 TEST_P(WindowSelectorTest, CloseButtonOnMultipleDisplay) { 1118 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 1129 // 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 1130 // closed or not. We explicity create the widget so that the window can be
1112 // parented to a non-primary root window. 1131 // parented to a non-primary root window.
1113 std::unique_ptr<views::Widget> widget(new views::Widget); 1132 std::unique_ptr<views::Widget> widget(new views::Widget);
1114 views::Widget::InitParams params; 1133 views::Widget::InitParams params;
1115 params.bounds = gfx::Rect(650, 0, 400, 400); 1134 params.bounds = gfx::Rect(650, 0, 400, 400);
1116 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1135 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1117 params.parent = window1->parent(); 1136 params.parent = window1->parent();
1118 widget->Init(params); 1137 widget->Init(params);
1119 widget->Show(); 1138 widget->Show();
1139 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get());
1140 window->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET, kHeaderHeight);
1120 1141
1121 ASSERT_EQ(root_windows[1], window1->GetRootWindow()); 1142 ASSERT_EQ(root_windows[1], window1->GetRootWindow());
1122 1143
1123 ToggleOverview(); 1144 ToggleOverview();
1124 1145
1125 aura::Window* window2 = widget->GetNativeWindow(); 1146 aura::Window* window2 = widget->GetNativeWindow();
1126 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); 1147 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2);
1127 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); 1148 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5);
1128 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); 1149 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point);
1129 1150
1130 EXPECT_FALSE(widget->IsClosed()); 1151 EXPECT_FALSE(widget->IsClosed());
1131 event_generator.ClickLeftButton(); 1152 event_generator.ClickLeftButton();
1132 EXPECT_TRUE(widget->IsClosed()); 1153 EXPECT_TRUE(widget->IsClosed());
1133 } 1154 }
1134 1155
1135 // Tests entering overview mode with two windows and selecting one. 1156 // Tests entering overview mode with two windows and selecting one.
1136 TEST_P(WindowSelectorTest, FullscreenWindow) { 1157 TEST_P(WindowSelectorTest, FullscreenWindow) {
1137 gfx::Rect bounds(0, 0, 400, 400); 1158 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); 1278 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1258 ToggleOverview(); 1279 ToggleOverview();
1259 EXPECT_FALSE(window1->IsVisible()); 1280 EXPECT_FALSE(window1->IsVisible());
1260 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); 1281 EXPECT_FALSE(window1->layer()->GetTargetVisibility());
1261 } 1282 }
1262 } 1283 }
1263 1284
1264 // Tests that a bounds change during overview is corrected for. 1285 // Tests that a bounds change during overview is corrected for.
1265 TEST_P(WindowSelectorTest, BoundsChangeDuringOverview) { 1286 TEST_P(WindowSelectorTest, BoundsChangeDuringOverview) {
1266 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); 1287 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400)));
1288 // Use overview headers above the window in this test.
1289 window->SetProperty(aura::client::kTopViewInset, 0);
1267 ToggleOverview(); 1290 ToggleOverview();
1268 gfx::Rect overview_bounds = 1291 gfx::Rect overview_bounds =
1269 ToEnclosingRect(GetTransformedTargetBounds(window.get())); 1292 ToEnclosingRect(GetTransformedTargetBounds(window.get()));
1270 window->SetBounds(gfx::Rect(200, 0, 200, 200)); 1293 window->SetBounds(gfx::Rect(200, 0, 200, 200));
1271 gfx::Rect new_overview_bounds = 1294 gfx::Rect new_overview_bounds =
1272 ToEnclosingRect(GetTransformedTargetBounds(window.get())); 1295 ToEnclosingRect(GetTransformedTargetBounds(window.get()));
1273 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); 1296 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x());
1274 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); 1297 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y());
1275 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); 1298 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width());
1276 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); 1299 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height());
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 bounds.y()); 2142 bounds.y());
2120 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); 2143 EXPECT_LE(transformed_rect.bottom(), bounds.bottom());
2121 EXPECT_NEAR(transformed_rect.x() - bounds.x(), 2144 EXPECT_NEAR(transformed_rect.x() - bounds.x(),
2122 bounds.right() - transformed_rect.right(), 1); 2145 bounds.right() - transformed_rect.right(), 1);
2123 EXPECT_NEAR( 2146 EXPECT_NEAR(
2124 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), 2147 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(),
2125 bounds.bottom() - transformed_rect.bottom(), 1); 2148 bounds.bottom() - transformed_rect.bottom(), 1);
2126 } 2149 }
2127 2150
2128 } // namespace ash 2151 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698