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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc

Issue 2020553003: Hook up TABLET_MODE switch to maximize_mode_controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 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/wm/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 void CloseLid() { 149 void CloseLid() {
150 maximize_mode_controller()->LidEventReceived(false /* open */, 150 maximize_mode_controller()->LidEventReceived(false /* open */,
151 maximize_mode_controller()->tick_clock_->NowTicks()); 151 maximize_mode_controller()->tick_clock_->NowTicks());
152 } 152 }
153 153
154 bool WasLidOpenedRecently() { 154 bool WasLidOpenedRecently() {
155 return maximize_mode_controller()->WasLidOpenedRecently(); 155 return maximize_mode_controller()->WasLidOpenedRecently();
156 } 156 }
157 157
158 void ToggleTabletMode(const bool on) {
159 maximize_mode_controller()->TabletModeEventReceived(
160 on, maximize_mode_controller()->tick_clock_->NowTicks());
161 }
162
163 bool WasTabletModeOn() {
164 return maximize_mode_controller()->tablet_mode_switch_was_on_;
165 }
166
158 bool AreEventsBlocked() { 167 bool AreEventsBlocked() {
159 return !!maximize_mode_controller()->event_blocker_.get(); 168 return !!maximize_mode_controller()->event_blocker_.get();
160 } 169 }
161 170
162 base::UserActionTester* user_action_tester() { return &user_action_tester_; } 171 base::UserActionTester* user_action_tester() { return &user_action_tester_; }
163 172
164 private: 173 private:
165 base::SimpleTestTickClock* test_tick_clock_; 174 base::SimpleTestTickClock* test_tick_clock_;
166 175
167 // Tracks user action counts. 176 // Tracks user action counts.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 268
260 // 1 second after lid open. 269 // 1 second after lid open.
261 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); 270 AdvanceTickClock(base::TimeDelta::FromSeconds(1));
262 EXPECT_TRUE(WasLidOpenedRecently()); 271 EXPECT_TRUE(WasLidOpenedRecently());
263 272
264 // 3 seconds after lid open. 273 // 3 seconds after lid open.
265 AdvanceTickClock(base::TimeDelta::FromSeconds(2)); 274 AdvanceTickClock(base::TimeDelta::FromSeconds(2));
266 EXPECT_FALSE(WasLidOpenedRecently()); 275 EXPECT_FALSE(WasLidOpenedRecently());
267 } 276 }
268 277
278 TEST_F(MaximizeModeControllerTest, TabletModeTransition) {
279 ASSERT_FALSE(WasTabletModeOn());
280
281 OpenLidToAngle(90.0f);
282 EXPECT_FALSE(IsMaximizeModeStarted());
283
284 OpenLidToAngle(355.0f);
285 EXPECT_FALSE(IsMaximizeModeStarted());
286
287 ToggleTabletMode(true);
288 EXPECT_FALSE(WasTabletModeOn());
289 EXPECT_TRUE(IsMaximizeModeStarted());
290
291 ToggleTabletMode(false);
292 EXPECT_TRUE(WasTabletModeOn());
293 EXPECT_TRUE(IsMaximizeModeStarted());
294
295 OpenLidToAngle(300.0f);
296 EXPECT_TRUE(WasTabletModeOn());
297 EXPECT_TRUE(IsMaximizeModeStarted());
298
299 OpenLidToAngle(90.0f);
300 EXPECT_FALSE(WasTabletModeOn());
301 EXPECT_FALSE(IsMaximizeModeStarted());
302 }
303
269 // Verify the maximize mode enter/exit thresholds for stable angles. 304 // Verify the maximize mode enter/exit thresholds for stable angles.
270 TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) { 305 TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) {
271 ASSERT_FALSE(IsMaximizeModeStarted()); 306 ASSERT_FALSE(IsMaximizeModeStarted());
272 ASSERT_FALSE(WasLidOpenedRecently()); 307 ASSERT_FALSE(WasLidOpenedRecently());
273 308
274 OpenLidToAngle(180.0f); 309 OpenLidToAngle(180.0f);
275 EXPECT_FALSE(IsMaximizeModeStarted()); 310 EXPECT_FALSE(IsMaximizeModeStarted());
276 311
277 OpenLidToAngle(315.0f); 312 OpenLidToAngle(315.0f);
278 EXPECT_TRUE(IsMaximizeModeStarted()); 313 EXPECT_TRUE(IsMaximizeModeStarted());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // accelerometer updates which would normally cause it to exit do not. 527 // accelerometer updates which would normally cause it to exit do not.
493 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { 528 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
494 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); 529 maximize_mode_controller()->EnableMaximizeModeWindowManager(true);
495 530
496 // Would normally trigger an exit from maximize mode. 531 // Would normally trigger an exit from maximize mode.
497 OpenLidToAngle(90.0f); 532 OpenLidToAngle(90.0f);
498 EXPECT_TRUE(IsMaximizeModeStarted()); 533 EXPECT_TRUE(IsMaximizeModeStarted());
499 } 534 }
500 535
501 } // namespace ash 536 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698