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 "ui/wm/core/nested_accelerator_controller.h" | 5 #include "ui/wm/core/nested_accelerator_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/event_types.h" | 8 #include "base/event_types.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 class MockNestedAcceleratorDelegate : public NestedAcceleratorDelegate { | 100 class MockNestedAcceleratorDelegate : public NestedAcceleratorDelegate { |
101 public: | 101 public: |
102 MockNestedAcceleratorDelegate() | 102 MockNestedAcceleratorDelegate() |
103 : accelerator_manager_(new ui::AcceleratorManager) {} | 103 : accelerator_manager_(new ui::AcceleratorManager) {} |
104 ~MockNestedAcceleratorDelegate() override {} | 104 ~MockNestedAcceleratorDelegate() override {} |
105 | 105 |
106 // NestedAcceleratorDelegate: | 106 // NestedAcceleratorDelegate: |
107 Result ProcessAccelerator(const ui::Accelerator& accelerator) override { | 107 Result ProcessAccelerator(const ui::Accelerator& accelerator) override { |
108 return accelerator_manager_->Process(accelerator) ? | 108 return accelerator_manager_->ProcessAccelerator(accelerator) |
109 RESULT_PROCESSED : RESULT_NOT_PROCESSED; | 109 ? RESULT_PROCESSED |
| 110 : RESULT_NOT_PROCESSED; |
110 } | 111 } |
111 | 112 |
112 void Register(const ui::Accelerator& accelerator, | 113 void Register(const ui::Accelerator& accelerator, |
113 ui::AcceleratorTarget* target) { | 114 ui::AcceleratorTarget* target) { |
114 accelerator_manager_->Register( | 115 accelerator_manager_->Register( |
115 accelerator, ui::AcceleratorManager::kNormalPriority, target); | 116 accelerator, ui::AcceleratorManager::kNormalPriority, target); |
116 } | 117 } |
117 | 118 |
118 private: | 119 private: |
119 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 120 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 &inner_dispatcher); | 198 &inner_dispatcher); |
198 aura::client::DispatcherRunLoop run_loop( | 199 aura::client::DispatcherRunLoop run_loop( |
199 aura::client::GetDispatcherClient(root_window()), NULL); | 200 aura::client::GetDispatcherClient(root_window()), NULL); |
200 run_loop.Run(); | 201 run_loop.Run(); |
201 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 202 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
202 EXPECT_EQ(1, target.accelerator_pressed_count()); | 203 EXPECT_EQ(1, target.accelerator_pressed_count()); |
203 } | 204 } |
204 | 205 |
205 } // namespace test | 206 } // namespace test |
206 } // namespace wm | 207 } // namespace wm |
OLD | NEW |