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 "ash/keyboard_overlay/keyboard_overlay_view.h" | 5 #include "ash/keyboard_overlay/keyboard_overlay_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/accelerators/accelerator_table.h" | 9 #include "ash/accelerators/accelerator_table.h" |
10 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" | 10 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 Shell::GetInstance()->delegate()->GetActiveBrowserContext(), | 30 Shell::GetInstance()->delegate()->GetActiveBrowserContext(), |
31 &delegate, | 31 &delegate, |
32 new ui::test::TestWebContentsHandler); | 32 new ui::test::TestWebContentsHandler); |
33 for (size_t i = 0; i < kAcceleratorDataLength; ++i) { | 33 for (size_t i = 0; i < kAcceleratorDataLength; ++i) { |
34 if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY) | 34 if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY) |
35 continue; | 35 continue; |
36 const AcceleratorData& open_key_data = kAcceleratorData[i]; | 36 const AcceleratorData& open_key_data = kAcceleratorData[i]; |
37 ui::KeyEvent open_key(open_key_data.trigger_on_press ? | 37 ui::KeyEvent open_key(open_key_data.trigger_on_press ? |
38 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, | 38 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, |
39 open_key_data.keycode, | 39 open_key_data.keycode, |
40 open_key_data.modifiers, | 40 open_key_data.modifiers); |
41 false); | |
42 EXPECT_TRUE(view.IsCancelingKeyEvent(&open_key)); | 41 EXPECT_TRUE(view.IsCancelingKeyEvent(&open_key)); |
43 } | 42 } |
44 } | 43 } |
45 | 44 |
46 // Verifies that there are no redunduant keys in the canceling keys. | 45 // Verifies that there are no redunduant keys in the canceling keys. |
47 TEST_F(KeyboardOverlayViewTest, NoRedundantCancelingKeys) { | 46 TEST_F(KeyboardOverlayViewTest, NoRedundantCancelingKeys) { |
48 std::vector<KeyboardOverlayView::KeyEventData> open_keys; | 47 std::vector<KeyboardOverlayView::KeyEventData> open_keys; |
49 for (size_t i = 0; i < kAcceleratorDataLength; ++i) { | 48 for (size_t i = 0; i < kAcceleratorDataLength; ++i) { |
50 if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY) | 49 if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY) |
51 continue; | 50 continue; |
(...skipping 17 matching lines...) Expand all Loading... |
69 | 68 |
70 // Other canceling keys should be same as opening keys. | 69 // Other canceling keys should be same as opening keys. |
71 EXPECT_EQ(open_keys.size(), canceling_keys.size()); | 70 EXPECT_EQ(open_keys.size(), canceling_keys.size()); |
72 for (size_t i = 0; i < canceling_keys.size(); ++i) { | 71 for (size_t i = 0; i < canceling_keys.size(); ++i) { |
73 EXPECT_NE(std::find(open_keys.begin(), open_keys.end(), canceling_keys[i]), | 72 EXPECT_NE(std::find(open_keys.begin(), open_keys.end(), canceling_keys[i]), |
74 open_keys.end()); | 73 open_keys.end()); |
75 } | 74 } |
76 } | 75 } |
77 | 76 |
78 } // namespace ash | 77 } // namespace ash |
OLD | NEW |