| 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/common/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/common/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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 maximize_mode_controller()->TabletModeEventReceived( | 172 maximize_mode_controller()->TabletModeEventReceived( |
| 173 on ? chromeos::PowerManagerClient::TabletMode::ON | 173 on ? chromeos::PowerManagerClient::TabletMode::ON |
| 174 : chromeos::PowerManagerClient::TabletMode::OFF, | 174 : chromeos::PowerManagerClient::TabletMode::OFF, |
| 175 maximize_mode_controller()->tick_clock_->NowTicks()); | 175 maximize_mode_controller()->tick_clock_->NowTicks()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool AreEventsBlocked() { | 178 bool AreEventsBlocked() { |
| 179 return !!maximize_mode_controller()->event_blocker_.get(); | 179 return !!maximize_mode_controller()->event_blocker_.get(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 MaximizeModeController::ForceTabletMode forced_tablet_mode() { |
| 183 return maximize_mode_controller()->force_tablet_mode_; |
| 184 } |
| 185 |
| 182 base::UserActionTester* user_action_tester() { return &user_action_tester_; } | 186 base::UserActionTester* user_action_tester() { return &user_action_tester_; } |
| 183 | 187 |
| 184 private: | 188 private: |
| 185 base::SimpleTestTickClock* test_tick_clock_; | 189 base::SimpleTestTickClock* test_tick_clock_; |
| 186 | 190 |
| 187 // Tracks user action counts. | 191 // Tracks user action counts. |
| 188 base::UserActionTester user_action_tester_; | 192 base::UserActionTester user_action_tester_; |
| 189 | 193 |
| 190 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); | 194 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); |
| 191 }; | 195 }; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()); | 599 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()); |
| 596 power_manager_client->set_tablet_mode( | 600 power_manager_client->set_tablet_mode( |
| 597 chromeos::PowerManagerClient::TabletMode::ON); | 601 chromeos::PowerManagerClient::TabletMode::ON); |
| 598 MaximizeModeController controller; | 602 MaximizeModeController controller; |
| 599 EXPECT_FALSE(controller.IsMaximizeModeWindowManagerEnabled()); | 603 EXPECT_FALSE(controller.IsMaximizeModeWindowManagerEnabled()); |
| 600 // PowerManagerClient callback is a posted task. | 604 // PowerManagerClient callback is a posted task. |
| 601 base::RunLoop().RunUntilIdle(); | 605 base::RunLoop().RunUntilIdle(); |
| 602 EXPECT_TRUE(controller.IsMaximizeModeWindowManagerEnabled()); | 606 EXPECT_TRUE(controller.IsMaximizeModeWindowManagerEnabled()); |
| 603 } | 607 } |
| 604 | 608 |
| 609 // Verify when the force clamshell mode flag is turned on, opening the lid past |
| 610 // 180 degrees or setting tablet mode to true will no turn on maximize mode. |
| 611 TEST_F(MaximizeModeControllerTest, ForceClamshellModeTest) { |
| 612 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 613 switches::kAshForceTabletMode, switches::kAshForceTabletModeClamshell); |
| 614 maximize_mode_controller()->OnShellInitialized(); |
| 615 EXPECT_EQ(MaximizeModeController::ForceTabletMode::CLAMSHELL, |
| 616 forced_tablet_mode()); |
| 617 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 618 |
| 619 OpenLidToAngle(300.0f); |
| 620 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 621 EXPECT_FALSE(AreEventsBlocked()); |
| 622 |
| 623 SetTabletMode(true); |
| 624 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 625 EXPECT_FALSE(AreEventsBlocked()); |
| 626 } |
| 627 |
| 628 // Verify when the force touch view mode flag is turned on, maximize mode is on |
| 629 // intially, and opening the lid to less than 180 degress or setting tablet mode |
| 630 // to off will not turn off maximize mode. |
| 631 TEST_F(MaximizeModeControllerTest, ForceTouchViewModeTest) { |
| 632 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 633 switches::kAshForceTabletMode, switches::kAshForceTabletModeTouchView); |
| 634 maximize_mode_controller()->OnShellInitialized(); |
| 635 EXPECT_EQ(MaximizeModeController::ForceTabletMode::TOUCHVIEW, |
| 636 forced_tablet_mode()); |
| 637 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 638 EXPECT_TRUE(AreEventsBlocked()); |
| 639 |
| 640 OpenLidToAngle(30.0f); |
| 641 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 642 EXPECT_TRUE(AreEventsBlocked()); |
| 643 |
| 644 SetTabletMode(false); |
| 645 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 646 EXPECT_TRUE(AreEventsBlocked()); |
| 647 } |
| 648 |
| 605 } // namespace ash | 649 } // namespace ash |
| OLD | NEW |