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

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) {
Daniel Erat 2016/06/06 17:23:08 nit: rename this to SetTabletMode (toggling would
jcliang 2016/06/06 18:19:25 Done.
159 maximize_mode_controller()->TabletModeEventReceived(
160 on, maximize_mode_controller()->tick_clock_->NowTicks());
161 }
162
163 bool IsTabletModeOn() {
Daniel Erat 2016/06/06 17:23:08 i'd delete this method and the calls to it. checki
jcliang 2016/06/06 18:19:25 Done.
164 return maximize_mode_controller()->tablet_mode_switch_is_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(IsTabletModeOn());
280
281 OpenLidToAngle(90.0f);
282 EXPECT_FALSE(IsMaximizeModeStarted());
283
284 OpenLidToAngle(355.0f);
285 EXPECT_FALSE(IsMaximizeModeStarted());
Daniel Erat 2016/06/06 17:23:07 why didn't this trigger maximize mode? it is becau
jcliang 2016/06/06 18:19:25 I meant to trigger an unstable reading and make su
286
287 ToggleTabletMode(true);
288 EXPECT_TRUE(IsTabletModeOn());
289 EXPECT_TRUE(IsMaximizeModeStarted());
290
291 ToggleTabletMode(false);
292 EXPECT_FALSE(IsTabletModeOn());
293 EXPECT_TRUE(IsMaximizeModeStarted());
294
295 OpenLidToAngle(300.0f);
296 EXPECT_TRUE(IsMaximizeModeStarted());
297
298 OpenLidToAngle(90.0f);
299 EXPECT_FALSE(IsMaximizeModeStarted());
300 }
Daniel Erat 2016/06/06 17:23:07 can you open the lid to a large angle at the end o
jcliang 2016/06/06 18:19:25 Done.
301
269 // Verify the maximize mode enter/exit thresholds for stable angles. 302 // Verify the maximize mode enter/exit thresholds for stable angles.
270 TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) { 303 TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) {
271 ASSERT_FALSE(IsMaximizeModeStarted()); 304 ASSERT_FALSE(IsMaximizeModeStarted());
272 ASSERT_FALSE(WasLidOpenedRecently()); 305 ASSERT_FALSE(WasLidOpenedRecently());
273 306
274 OpenLidToAngle(180.0f); 307 OpenLidToAngle(180.0f);
275 EXPECT_FALSE(IsMaximizeModeStarted()); 308 EXPECT_FALSE(IsMaximizeModeStarted());
276 309
277 OpenLidToAngle(315.0f); 310 OpenLidToAngle(315.0f);
278 EXPECT_TRUE(IsMaximizeModeStarted()); 311 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. 525 // accelerometer updates which would normally cause it to exit do not.
493 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { 526 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
494 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); 527 maximize_mode_controller()->EnableMaximizeModeWindowManager(true);
495 528
496 // Would normally trigger an exit from maximize mode. 529 // Would normally trigger an exit from maximize mode.
497 OpenLidToAngle(90.0f); 530 OpenLidToAngle(90.0f);
498 EXPECT_TRUE(IsMaximizeModeStarted()); 531 EXPECT_TRUE(IsMaximizeModeStarted());
499 } 532 }
500 533
501 } // namespace ash 534 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698