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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
index 251885b7212fc2907158ccc625f6a02efdc56235..c321e1660ee32fd7c8e4aebee829e520f8999fbf 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
@@ -141,6 +141,12 @@ class MaximizeModeControllerTest : public test::AshTestBase {
TriggerBaseAndLidUpdate(base_vector, lid_vector);
}
+ void HoldDeviceVertical() {
+ gfx::Vector3dF base_vector(9.8f, 0.0f, 0.0f);
+ gfx::Vector3dF lid_vector(9.8f, 0.0f, 0.0f);
+ TriggerBaseAndLidUpdate(base_vector, lid_vector);
+ }
+
void OpenLid() {
maximize_mode_controller()->LidEventReceived(true /* open */,
maximize_mode_controller()->tick_clock_->NowTicks());
@@ -155,6 +161,11 @@ class MaximizeModeControllerTest : public test::AshTestBase {
return maximize_mode_controller()->WasLidOpenedRecently();
}
+ void SetTabletMode(bool on) {
+ maximize_mode_controller()->TabletModeEventReceived(
+ on, maximize_mode_controller()->tick_clock_->NowTicks());
+ }
+
bool AreEventsBlocked() {
return !!maximize_mode_controller()->event_blocker_.get();
}
@@ -266,6 +277,32 @@ TEST_F(MaximizeModeControllerTest, WasLidOpenedRecentlyOverTime) {
EXPECT_FALSE(WasLidOpenedRecently());
}
+TEST_F(MaximizeModeControllerTest, TabletModeTransition) {
+ OpenLidToAngle(90.0f);
+ EXPECT_FALSE(IsMaximizeModeStarted());
+
+ // Unstable reading. This should not trigger maximize mode.
+ HoldDeviceVertical();
+ EXPECT_FALSE(IsMaximizeModeStarted());
+
+ // When tablet mode switch is on it should force maximize mode even if the
+ // reading is not stable.
+ SetTabletMode(true);
+ EXPECT_TRUE(IsMaximizeModeStarted());
+
+ // After tablet mode switch is off it should stay in maximize mode if the
+ // reading is not stable.
+ SetTabletMode(false);
+ EXPECT_TRUE(IsMaximizeModeStarted());
+
+ // Should leave maximize mode when the lid angle is small enough.
+ OpenLidToAngle(90.0f);
+ EXPECT_FALSE(IsMaximizeModeStarted());
+
+ OpenLidToAngle(300.0f);
+ EXPECT_TRUE(IsMaximizeModeStarted());
+}
+
// Verify the maximize mode enter/exit thresholds for stable angles.
TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) {
ASSERT_FALSE(IsMaximizeModeStarted());

Powered by Google App Engine
This is Rietveld 408576698