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/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 Loading... |
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 bool AreEventsBlocked() { |
| 159 return !!maximize_mode_controller()->event_blocker_.get(); |
| 160 } |
| 161 |
158 base::UserActionTester* user_action_tester() { return &user_action_tester_; } | 162 base::UserActionTester* user_action_tester() { return &user_action_tester_; } |
159 | 163 |
160 private: | 164 private: |
161 base::SimpleTestTickClock* test_tick_clock_; | 165 base::SimpleTestTickClock* test_tick_clock_; |
162 | 166 |
163 // Tracks user action counts. | 167 // Tracks user action counts. |
164 base::UserActionTester user_action_tester_; | 168 base::UserActionTester user_action_tester_; |
165 | 169 |
166 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); | 170 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); |
167 }; | 171 }; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // while disabled we do not re-enter maximize mode. | 451 // while disabled we do not re-enter maximize mode. |
448 TEST_F(MaximizeModeControllerTest, NoMaximizeModeWithDisabledInternalDisplay) { | 452 TEST_F(MaximizeModeControllerTest, NoMaximizeModeWithDisabledInternalDisplay) { |
449 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 453 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
450 UpdateDisplay("200x200, 200x200"); | 454 UpdateDisplay("200x200, 200x200"); |
451 const int64_t internal_display_id = | 455 const int64_t internal_display_id = |
452 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 456 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
453 ASSERT_FALSE(IsMaximizeModeStarted()); | 457 ASSERT_FALSE(IsMaximizeModeStarted()); |
454 | 458 |
455 OpenLidToAngle(270.0f); | 459 OpenLidToAngle(270.0f); |
456 EXPECT_TRUE(IsMaximizeModeStarted()); | 460 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 461 EXPECT_TRUE(AreEventsBlocked()); |
457 | 462 |
458 // Deactivate internal display to simulate Docked Mode. | 463 // Deactivate internal display to simulate Docked Mode. |
459 std::vector<DisplayInfo> secondary_only; | 464 std::vector<DisplayInfo> secondary_only; |
460 secondary_only.push_back( | 465 secondary_only.push_back( |
461 display_manager->GetDisplayInfo(display_manager->GetDisplayAt(1).id())); | 466 display_manager->GetDisplayInfo(display_manager->GetDisplayAt(1).id())); |
462 display_manager->OnNativeDisplaysChanged(secondary_only); | 467 display_manager->OnNativeDisplaysChanged(secondary_only); |
463 ASSERT_FALSE(display_manager->IsActiveDisplayId(internal_display_id)); | 468 ASSERT_FALSE(display_manager->IsActiveDisplayId(internal_display_id)); |
464 EXPECT_FALSE(IsMaximizeModeStarted()); | 469 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 470 EXPECT_FALSE(AreEventsBlocked()); |
465 | 471 |
466 OpenLidToAngle(270.0f); | 472 OpenLidToAngle(270.0f); |
467 EXPECT_FALSE(IsMaximizeModeStarted()); | 473 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 474 EXPECT_FALSE(AreEventsBlocked()); |
468 } | 475 } |
469 | 476 |
470 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { | 477 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { |
471 public: | 478 public: |
472 MaximizeModeControllerSwitchesTest() {} | 479 MaximizeModeControllerSwitchesTest() {} |
473 ~MaximizeModeControllerSwitchesTest() override {} | 480 ~MaximizeModeControllerSwitchesTest() override {} |
474 | 481 |
475 void SetUp() override { | 482 void SetUp() override { |
476 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 483 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
477 switches::kAshEnableTouchViewTesting); | 484 switches::kAshEnableTouchViewTesting); |
478 MaximizeModeControllerTest::SetUp(); | 485 MaximizeModeControllerTest::SetUp(); |
479 } | 486 } |
480 private: | 487 private: |
481 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); | 488 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); |
482 }; | 489 }; |
483 | 490 |
484 // Tests that when the command line switch for testing maximize mode is on, that | 491 // Tests that when the command line switch for testing maximize mode is on, that |
485 // accelerometer updates which would normally cause it to exit do not. | 492 // accelerometer updates which would normally cause it to exit do not. |
486 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { | 493 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { |
487 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); | 494 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); |
488 | 495 |
489 // Would normally trigger an exit from maximize mode. | 496 // Would normally trigger an exit from maximize mode. |
490 OpenLidToAngle(90.0f); | 497 OpenLidToAngle(90.0f); |
491 EXPECT_TRUE(IsMaximizeModeStarted()); | 498 EXPECT_TRUE(IsMaximizeModeStarted()); |
492 } | 499 } |
493 | 500 |
494 } // namespace ash | 501 } // namespace ash |
OLD | NEW |