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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 gfx::Vector3dF lid(kAccelerometerVerticalHingeTestData[i * 6 + 3], | 438 gfx::Vector3dF lid(kAccelerometerVerticalHingeTestData[i * 6 + 3], |
439 kAccelerometerVerticalHingeTestData[i * 6 + 4], | 439 kAccelerometerVerticalHingeTestData[i * 6 + 4], |
440 kAccelerometerVerticalHingeTestData[i * 6 + 5]); | 440 kAccelerometerVerticalHingeTestData[i * 6 + 5]); |
441 TriggerBaseAndLidUpdate(base, lid); | 441 TriggerBaseAndLidUpdate(base, lid); |
442 // There are a lot of samples, so ASSERT rather than EXPECT to only generate | 442 // There are a lot of samples, so ASSERT rather than EXPECT to only generate |
443 // one failure rather than potentially hundreds. | 443 // one failure rather than potentially hundreds. |
444 ASSERT_TRUE(IsMaximizeModeStarted()); | 444 ASSERT_TRUE(IsMaximizeModeStarted()); |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 // Tests that CanEnterMaximizeMode returns false until a valid accelerometer | |
449 // event has been received, and that it returns true afterwards. | |
450 TEST_F(MaximizeModeControllerTest, | |
451 CanEnterMaximizeModeRequiresValidAccelerometerUpdate) { | |
452 // Should be false until an accelerometer event is sent. | |
453 ASSERT_FALSE(maximize_mode_controller()->CanEnterMaximizeMode()); | |
454 OpenLidToAngle(90.0f); | |
455 EXPECT_TRUE(maximize_mode_controller()->CanEnterMaximizeMode()); | |
456 } | |
457 | |
458 // Tests that when an accelerometer event is received which has no keyboard that | 448 // Tests that when an accelerometer event is received which has no keyboard that |
459 // we enter maximize mode. | 449 // we enter maximize mode. |
460 TEST_F(MaximizeModeControllerTest, | 450 TEST_F(MaximizeModeControllerTest, |
461 NoKeyboardAccelerometerTriggersMaximizeMode) { | 451 NoKeyboardAccelerometerTriggersMaximizeMode) { |
462 ASSERT_FALSE(IsMaximizeModeStarted()); | 452 ASSERT_FALSE(IsMaximizeModeStarted()); |
463 TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity)); | 453 TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity)); |
464 ASSERT_TRUE(IsMaximizeModeStarted()); | 454 ASSERT_TRUE(IsMaximizeModeStarted()); |
465 } | 455 } |
466 | 456 |
467 // Test if this case does not crash. See http://crbug.com/462806 | 457 // Test if this case does not crash. See http://crbug.com/462806 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 3], | 524 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 3], |
535 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 4], | 525 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 4], |
536 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 5]); | 526 kAccelerometerVerticalHingeUnstableAnglesTestData[i * 6 + 5]); |
537 TriggerBaseAndLidUpdate(base, lid); | 527 TriggerBaseAndLidUpdate(base, lid); |
538 // There are a lot of samples, so ASSERT rather than EXPECT to only generate | 528 // There are a lot of samples, so ASSERT rather than EXPECT to only generate |
539 // one failure rather than potentially hundreds. | 529 // one failure rather than potentially hundreds. |
540 ASSERT_TRUE(IsMaximizeModeStarted()); | 530 ASSERT_TRUE(IsMaximizeModeStarted()); |
541 } | 531 } |
542 } | 532 } |
543 | 533 |
544 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { | |
545 public: | |
546 MaximizeModeControllerSwitchesTest() {} | |
547 ~MaximizeModeControllerSwitchesTest() override {} | |
548 | |
549 void SetUp() override { | |
550 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
551 switches::kAshEnableTouchViewTesting); | |
552 MaximizeModeControllerTest::SetUp(); | |
553 } | |
554 | |
555 private: | |
556 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); | |
557 }; | |
558 | |
559 // Tests that when the command line switch for testing maximize mode is on, that | |
560 // accelerometer updates which would normally cause it to exit do not. | |
561 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { | |
562 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); | |
563 | |
564 // Would normally trigger an exit from maximize mode. | |
565 OpenLidToAngle(90.0f); | |
566 EXPECT_TRUE(IsMaximizeModeStarted()); | |
567 } | |
568 | |
569 } // namespace ash | 534 } // namespace ash |
OLD | NEW |