| 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 "athena/input/input_manager_impl.h" | 5 #include "athena/input/input_manager_impl.h" |
| 6 | 6 |
| 7 #include "athena/input/public/accelerator_manager.h" | 7 #include "athena/input/public/accelerator_manager.h" |
| 8 #include "athena/test/base/athena_test_base.h" | 8 #include "athena/test/base/athena_test_base.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "ui/events/test/event_generator.h" | 10 #include "ui/events/test/event_generator.h" |
| 11 | 11 |
| 12 namespace athena { | 12 namespace athena { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class TestPowerButtonObserver : public PowerButtonObserver { | 15 class TestPowerButtonObserver : public PowerButtonObserver { |
| 16 public: | 16 public: |
| 17 TestPowerButtonObserver() : count_(0), state_(RELEASED) { | 17 TestPowerButtonObserver() : count_(0), state_(RELEASED) { |
| 18 InputManager::Get()->AddPowerButtonObserver(this); | 18 InputManager::Get()->AddPowerButtonObserver(this); |
| 19 } | 19 } |
| 20 virtual ~TestPowerButtonObserver() { | 20 ~TestPowerButtonObserver() override { |
| 21 InputManager::Get()->RemovePowerButtonObserver(this); | 21 InputManager::Get()->RemovePowerButtonObserver(this); |
| 22 } | 22 } |
| 23 | 23 |
| 24 int count() const { return count_; } | 24 int count() const { return count_; } |
| 25 State state() const { return state_; } | 25 State state() const { return state_; } |
| 26 | 26 |
| 27 bool WaitForLongPress() { | 27 bool WaitForLongPress() { |
| 28 run_loop_.Run(); | 28 run_loop_.Run(); |
| 29 return state_ == LONG_PRESSED; | 29 return state_ == LONG_PRESSED; |
| 30 } | 30 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 EXPECT_TRUE(observer.WaitForLongPress()); | 98 EXPECT_TRUE(observer.WaitForLongPress()); |
| 99 EXPECT_EQ(4, observer.count()); | 99 EXPECT_EQ(4, observer.count()); |
| 100 EXPECT_EQ(PowerButtonObserver::LONG_PRESSED, observer.state()); | 100 EXPECT_EQ(PowerButtonObserver::LONG_PRESSED, observer.state()); |
| 101 | 101 |
| 102 generator.ReleaseKey(ui::VKEY_P, ui::EF_ALT_DOWN); | 102 generator.ReleaseKey(ui::VKEY_P, ui::EF_ALT_DOWN); |
| 103 EXPECT_EQ(5, observer.count()); | 103 EXPECT_EQ(5, observer.count()); |
| 104 EXPECT_EQ(PowerButtonObserver::RELEASED, observer.state()); | 104 EXPECT_EQ(PowerButtonObserver::RELEASED, observer.state()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace athena | 107 } // namespace athena |
| OLD | NEW |