OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "ui/base/event.h" |
10 #include "ui/views/controls/button/text_button.h" | 11 #include "ui/views/controls/button/text_button.h" |
11 #include "ui/views/focus/accelerator_handler.h" | 12 #include "ui/views/focus/accelerator_handler.h" |
12 #include "ui/views/focus/focus_manager_test.h" | 13 #include "ui/views/focus/focus_manager_test.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 class MessageTrackingView : public View { | 20 class MessageTrackingView : public View { |
(...skipping 13 matching lines...) Expand all Loading... |
33 | 34 |
34 const std::vector<ui::KeyboardCode>& keys_released() const { | 35 const std::vector<ui::KeyboardCode>& keys_released() const { |
35 return keys_released_; | 36 return keys_released_; |
36 } | 37 } |
37 | 38 |
38 bool accelerator_pressed() const { | 39 bool accelerator_pressed() const { |
39 return accelerator_pressed_; | 40 return accelerator_pressed_; |
40 } | 41 } |
41 | 42 |
42 // Overridden from View: | 43 // Overridden from View: |
43 virtual bool OnKeyPressed(const KeyEvent& e) OVERRIDE { | 44 virtual bool OnKeyPressed(const ui::KeyEvent& e) OVERRIDE { |
44 keys_pressed_.push_back(e.key_code()); | 45 keys_pressed_.push_back(e.key_code()); |
45 return true; | 46 return true; |
46 } | 47 } |
47 virtual bool OnKeyReleased(const KeyEvent& e) OVERRIDE { | 48 virtual bool OnKeyReleased(const ui::KeyEvent& e) OVERRIDE { |
48 keys_released_.push_back(e.key_code()); | 49 keys_released_.push_back(e.key_code()); |
49 return true; | 50 return true; |
50 } | 51 } |
51 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE { | 52 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE { |
52 accelerator_pressed_ = true; | 53 accelerator_pressed_ = true; |
53 return true; | 54 return true; |
54 } | 55 } |
55 | 56 |
56 private: | 57 private: |
57 bool accelerator_pressed_; | 58 bool accelerator_pressed_; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 PostKeyUp(ui::VKEY_0); | 273 PostKeyUp(ui::VKEY_0); |
273 run_loop.reset(new base::RunLoop(&accelerator_handler)); | 274 run_loop.reset(new base::RunLoop(&accelerator_handler)); |
274 run_loop->RunUntilIdle(); | 275 run_loop->RunUntilIdle(); |
275 EXPECT_TRUE(mtv->keys_pressed().empty()); | 276 EXPECT_TRUE(mtv->keys_pressed().empty()); |
276 EXPECT_TRUE(mtv->keys_released().empty()); | 277 EXPECT_TRUE(mtv->keys_released().empty()); |
277 EXPECT_TRUE(mtv->accelerator_pressed()); | 278 EXPECT_TRUE(mtv->accelerator_pressed()); |
278 mtv->Reset(); | 279 mtv->Reset(); |
279 } | 280 } |
280 | 281 |
281 } // namespace views | 282 } // namespace views |
OLD | NEW |