OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/system/overview/overview_button_tray.h" | 5 #include "ash/system/overview/overview_button_tray.h" |
6 | 6 |
7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
8 #include "ash/common/login_status.h" | 8 #include "ash/common/login_status.h" |
9 #include "ash/common/shelf/shelf_types.h" | 9 #include "ash/common/shelf/shelf_types.h" |
10 #include "ash/common/wm/overview/window_selector_controller.h" | 10 #include "ash/common/wm/overview/window_selector_controller.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ui/events/gestures/gesture_types.h" | 30 #include "ui/events/gestures/gesture_types.h" |
31 #include "ui/views/controls/image_view.h" | 31 #include "ui/views/controls/image_view.h" |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 const char kTrayOverview[] = "Tray_Overview"; | 37 const char kTrayOverview[] = "Tray_Overview"; |
38 | 38 |
39 OverviewButtonTray* GetTray() { | 39 OverviewButtonTray* GetTray() { |
40 return StatusAreaWidgetTestHelper::GetStatusAreaWidget()-> | 40 return StatusAreaWidgetTestHelper::GetStatusAreaWidget() |
41 overview_button_tray(); | 41 ->overview_button_tray(); |
42 } | 42 } |
43 | 43 |
44 OverviewButtonTray* GetSecondaryTray() { | 44 OverviewButtonTray* GetSecondaryTray() { |
45 return StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()-> | 45 return StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget() |
46 overview_button_tray(); | 46 ->overview_button_tray(); |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 class OverviewButtonTrayTest : public test::AshTestBase { | 51 class OverviewButtonTrayTest : public test::AshTestBase { |
52 public: | 52 public: |
53 OverviewButtonTrayTest() {} | 53 OverviewButtonTrayTest() {} |
54 ~OverviewButtonTrayTest() override {} | 54 ~OverviewButtonTrayTest() override {} |
55 | 55 |
56 void SetUp() override; | 56 void SetUp() override; |
(...skipping 23 matching lines...) Expand all Loading... |
80 // Ensures that creation doesn't cause any crashes and adds the image icon. | 80 // Ensures that creation doesn't cause any crashes and adds the image icon. |
81 TEST_F(OverviewButtonTrayTest, BasicConstruction) { | 81 TEST_F(OverviewButtonTrayTest, BasicConstruction) { |
82 EXPECT_TRUE(GetImageView(GetTray()) != NULL); | 82 EXPECT_TRUE(GetImageView(GetTray()) != NULL); |
83 } | 83 } |
84 | 84 |
85 // Test that maximize mode toggle changes visibility. | 85 // Test that maximize mode toggle changes visibility. |
86 // OverviewButtonTray should only be visible when MaximizeMode is enabled. | 86 // OverviewButtonTray should only be visible when MaximizeMode is enabled. |
87 // By default the system should not have MaximizeMode enabled. | 87 // By default the system should not have MaximizeMode enabled. |
88 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { | 88 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { |
89 ASSERT_FALSE(GetTray()->visible()); | 89 ASSERT_FALSE(GetTray()->visible()); |
90 Shell::GetInstance()->maximize_mode_controller()-> | 90 Shell::GetInstance() |
91 EnableMaximizeModeWindowManager(true); | 91 ->maximize_mode_controller() |
| 92 ->EnableMaximizeModeWindowManager(true); |
92 EXPECT_TRUE(GetTray()->visible()); | 93 EXPECT_TRUE(GetTray()->visible()); |
93 | 94 |
94 Shell::GetInstance()->maximize_mode_controller()-> | 95 Shell::GetInstance() |
95 EnableMaximizeModeWindowManager(false); | 96 ->maximize_mode_controller() |
| 97 ->EnableMaximizeModeWindowManager(false); |
96 EXPECT_FALSE(GetTray()->visible()); | 98 EXPECT_FALSE(GetTray()->visible()); |
97 } | 99 } |
98 | 100 |
99 // Tests that activating this control brings up window selection mode. | 101 // Tests that activating this control brings up window selection mode. |
100 TEST_F(OverviewButtonTrayTest, PerformAction) { | 102 TEST_F(OverviewButtonTrayTest, PerformAction) { |
101 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 103 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
102 | 104 |
103 // Overview Mode only works when there is a window | 105 // Overview Mode only works when there is a window |
104 std::unique_ptr<aura::Window> window( | 106 std::unique_ptr<aura::Window> window( |
105 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 107 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Tests that a second OverviewButtonTray has been created, and only shows | 142 // Tests that a second OverviewButtonTray has been created, and only shows |
141 // when MaximizeMode has been enabled, when we are using multiple displays. | 143 // when MaximizeMode has been enabled, when we are using multiple displays. |
142 // By default the DisplayManger is in extended mode. | 144 // By default the DisplayManger is in extended mode. |
143 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { | 145 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { |
144 if (!SupportsMultipleDisplays()) | 146 if (!SupportsMultipleDisplays()) |
145 return; | 147 return; |
146 | 148 |
147 UpdateDisplay("400x400,200x200"); | 149 UpdateDisplay("400x400,200x200"); |
148 EXPECT_FALSE(GetTray()->visible()); | 150 EXPECT_FALSE(GetTray()->visible()); |
149 EXPECT_FALSE(GetSecondaryTray()->visible()); | 151 EXPECT_FALSE(GetSecondaryTray()->visible()); |
150 Shell::GetInstance()->maximize_mode_controller()-> | 152 Shell::GetInstance() |
151 EnableMaximizeModeWindowManager(true); | 153 ->maximize_mode_controller() |
| 154 ->EnableMaximizeModeWindowManager(true); |
152 EXPECT_TRUE(GetTray()->visible()); | 155 EXPECT_TRUE(GetTray()->visible()); |
153 EXPECT_TRUE(GetSecondaryTray()->visible()); | 156 EXPECT_TRUE(GetSecondaryTray()->visible()); |
154 Shell::GetInstance()->maximize_mode_controller()-> | 157 Shell::GetInstance() |
155 EnableMaximizeModeWindowManager(false); | 158 ->maximize_mode_controller() |
| 159 ->EnableMaximizeModeWindowManager(false); |
156 } | 160 } |
157 | 161 |
158 // Tests if Maximize Mode is enabled before a secondary display is attached | 162 // Tests if Maximize Mode is enabled before a secondary display is attached |
159 // that the second OverviewButtonTray should be created in a visible state. | 163 // that the second OverviewButtonTray should be created in a visible state. |
160 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { | 164 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { |
161 if (!SupportsMultipleDisplays()) | 165 if (!SupportsMultipleDisplays()) |
162 return; | 166 return; |
163 | 167 |
164 Shell::GetInstance()->maximize_mode_controller()-> | 168 Shell::GetInstance() |
165 EnableMaximizeModeWindowManager(true); | 169 ->maximize_mode_controller() |
| 170 ->EnableMaximizeModeWindowManager(true); |
166 UpdateDisplay("400x400,200x200"); | 171 UpdateDisplay("400x400,200x200"); |
167 EXPECT_TRUE(GetSecondaryTray()->visible()); | 172 EXPECT_TRUE(GetSecondaryTray()->visible()); |
168 Shell::GetInstance()->maximize_mode_controller()-> | 173 Shell::GetInstance() |
169 EnableMaximizeModeWindowManager(false); | 174 ->maximize_mode_controller() |
| 175 ->EnableMaximizeModeWindowManager(false); |
170 } | 176 } |
171 | 177 |
172 // Tests that the tray loses visibility when a user logs out, and that it | 178 // Tests that the tray loses visibility when a user logs out, and that it |
173 // regains visibility when a user logs back in. | 179 // regains visibility when a user logs back in. |
174 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { | 180 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { |
175 Shell::GetInstance()->maximize_mode_controller()-> | 181 Shell::GetInstance() |
176 EnableMaximizeModeWindowManager(true); | 182 ->maximize_mode_controller() |
| 183 ->EnableMaximizeModeWindowManager(true); |
177 SetUserLoggedIn(false); | 184 SetUserLoggedIn(false); |
178 Shell::GetInstance()->UpdateAfterLoginStatusChange( | 185 Shell::GetInstance()->UpdateAfterLoginStatusChange( |
179 LoginStatus::NOT_LOGGED_IN); | 186 LoginStatus::NOT_LOGGED_IN); |
180 EXPECT_FALSE(GetTray()->visible()); | 187 EXPECT_FALSE(GetTray()->visible()); |
181 SetUserLoggedIn(true); | 188 SetUserLoggedIn(true); |
182 SetSessionStarted(true); | 189 SetSessionStarted(true); |
183 Shell::GetInstance()->UpdateAfterLoginStatusChange(LoginStatus::USER); | 190 Shell::GetInstance()->UpdateAfterLoginStatusChange(LoginStatus::USER); |
184 EXPECT_TRUE(GetTray()->visible()); | 191 EXPECT_TRUE(GetTray()->visible()); |
185 SetUserAddingScreenRunning(true); | 192 SetUserAddingScreenRunning(true); |
186 NotifySessionStateChanged(); | 193 NotifySessionStateChanged(); |
187 EXPECT_FALSE(GetTray()->visible()); | 194 EXPECT_FALSE(GetTray()->visible()); |
188 SetUserAddingScreenRunning(false); | 195 SetUserAddingScreenRunning(false); |
189 NotifySessionStateChanged(); | 196 NotifySessionStateChanged(); |
190 EXPECT_TRUE(GetTray()->visible()); | 197 EXPECT_TRUE(GetTray()->visible()); |
191 Shell::GetInstance()->maximize_mode_controller()-> | 198 Shell::GetInstance() |
192 EnableMaximizeModeWindowManager(false); | 199 ->maximize_mode_controller() |
| 200 ->EnableMaximizeModeWindowManager(false); |
193 } | 201 } |
194 | 202 |
195 // Tests that the tray only renders as active while selection is ongoing. Any | 203 // Tests that the tray only renders as active while selection is ongoing. Any |
196 // dismissal of overview mode clears the active state. | 204 // dismissal of overview mode clears the active state. |
197 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 205 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
198 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 206 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
199 ASSERT_FALSE(GetTray()->draw_background_as_active()); | 207 ASSERT_FALSE(GetTray()->draw_background_as_active()); |
200 | 208 |
201 // Overview Mode only works when there is a window | 209 // Overview Mode only works when there is a window |
202 std::unique_ptr<aura::Window> window( | 210 std::unique_ptr<aura::Window> window( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 ->maximize_mode_controller() | 270 ->maximize_mode_controller() |
263 ->EnableMaximizeModeWindowManager(true); | 271 ->EnableMaximizeModeWindowManager(true); |
264 EXPECT_TRUE(GetTray()->visible()); | 272 EXPECT_TRUE(GetTray()->visible()); |
265 Shell::GetInstance() | 273 Shell::GetInstance() |
266 ->maximize_mode_controller() | 274 ->maximize_mode_controller() |
267 ->EnableMaximizeModeWindowManager(false); | 275 ->EnableMaximizeModeWindowManager(false); |
268 EXPECT_FALSE(GetTray()->visible()); | 276 EXPECT_FALSE(GetTray()->visible()); |
269 } | 277 } |
270 | 278 |
271 } // namespace ash | 279 } // namespace ash |
OLD | NEW |