OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "ui/base/event.h" |
8 #include "ui/views/events/event.h" | 9 #include "ui/views/events/event.h" |
9 | 10 |
10 // Bug 99129. | 11 // Bug 99129. |
11 #if defined(USE_AURA) | 12 #if defined(USE_AURA) |
12 #define MAYBE_KeyEvent FAILS_KeyEvent | 13 #define MAYBE_KeyEvent FAILS_KeyEvent |
13 #define MAYBE_KeyEventDirectUnicode FAILS_KeyEventDirectUnicode | 14 #define MAYBE_KeyEventDirectUnicode FAILS_KeyEventDirectUnicode |
14 #else | 15 #else |
15 #define MAYBE_KeyEvent KeyEvent | 16 #define MAYBE_KeyEvent KeyEvent |
16 #define MAYBE_KeyEventDirectUnicode KeyEventDirectUnicode | 17 #define MAYBE_KeyEventDirectUnicode KeyEventDirectUnicode |
17 #endif | 18 #endif |
18 | 19 |
| 20 // TODO(beng): move to src/ui/base/event_unittest.cc: |
| 21 |
19 namespace views { | 22 namespace views { |
20 | 23 |
21 class EventTest : public testing::Test { | 24 class EventTest : public testing::Test { |
22 public: | 25 public: |
23 EventTest() { | 26 EventTest() { |
24 } | 27 } |
25 | 28 |
26 private: | 29 private: |
27 DISALLOW_COPY_AND_ASSIGN(EventTest); | 30 DISALLOW_COPY_AND_ASSIGN(EventTest); |
28 }; | 31 }; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 { ui::VKEY_OEM_PLUS, ui::EF_SHIFT_DOWN, '+', '+' }, | 100 { ui::VKEY_OEM_PLUS, ui::EF_SHIFT_DOWN, '+', '+' }, |
98 { ui::VKEY_OEM_COMMA, ui::EF_CONTROL_DOWN, '\0', ',' }, | 101 { ui::VKEY_OEM_COMMA, ui::EF_CONTROL_DOWN, '\0', ',' }, |
99 { ui::VKEY_OEM_COMMA, ui::EF_SHIFT_DOWN, '<', '<' }, | 102 { ui::VKEY_OEM_COMMA, ui::EF_SHIFT_DOWN, '<', '<' }, |
100 { ui::VKEY_OEM_PERIOD, ui::EF_CONTROL_DOWN, '\0', '.' }, | 103 { ui::VKEY_OEM_PERIOD, ui::EF_CONTROL_DOWN, '\0', '.' }, |
101 { ui::VKEY_OEM_PERIOD, ui::EF_SHIFT_DOWN, '>', '>' }, | 104 { ui::VKEY_OEM_PERIOD, ui::EF_SHIFT_DOWN, '>', '>' }, |
102 { ui::VKEY_OEM_3, ui::EF_CONTROL_DOWN, '\0', '`' }, | 105 { ui::VKEY_OEM_3, ui::EF_CONTROL_DOWN, '\0', '`' }, |
103 { ui::VKEY_OEM_3, ui::EF_SHIFT_DOWN, '~', '~' }, | 106 { ui::VKEY_OEM_3, ui::EF_SHIFT_DOWN, '~', '~' }, |
104 }; | 107 }; |
105 | 108 |
106 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestData); ++i) { | 109 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestData); ++i) { |
107 KeyEvent key(ui::ET_KEY_PRESSED, kTestData[i].key_code, kTestData[i].flags); | 110 ui::KeyEvent key( |
| 111 ui::ET_KEY_PRESSED, kTestData[i].key_code, kTestData[i].flags); |
108 EXPECT_EQ(kTestData[i].character, key.GetCharacter()) | 112 EXPECT_EQ(kTestData[i].character, key.GetCharacter()) |
109 << " Index:" << i << " key_code:" << kTestData[i].key_code; | 113 << " Index:" << i << " key_code:" << kTestData[i].key_code; |
110 EXPECT_EQ(kTestData[i].unmodified_character, key.GetUnmodifiedCharacter()) | 114 EXPECT_EQ(kTestData[i].unmodified_character, key.GetUnmodifiedCharacter()) |
111 << " Index:" << i << " key_code:" << kTestData[i].key_code; | 115 << " Index:" << i << " key_code:" << kTestData[i].key_code; |
112 } | 116 } |
113 } | 117 } |
114 | 118 |
115 TEST_F(EventTest, MAYBE_KeyEventDirectUnicode) { | 119 TEST_F(EventTest, MAYBE_KeyEventDirectUnicode) { |
116 KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, ui::EF_SHIFT_DOWN); | 120 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, ui::EF_SHIFT_DOWN); |
117 key.set_character(0x1234U); | 121 key.set_character(0x1234U); |
118 key.set_unmodified_character(0x4321U); | 122 key.set_unmodified_character(0x4321U); |
119 EXPECT_EQ(0x1234U, key.GetCharacter()); | 123 EXPECT_EQ(0x1234U, key.GetCharacter()); |
120 EXPECT_EQ(0x4321U, key.GetUnmodifiedCharacter()); | 124 EXPECT_EQ(0x4321U, key.GetUnmodifiedCharacter()); |
121 KeyEvent key2(ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_CONTROL_DOWN); | 125 ui::KeyEvent key2(ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_CONTROL_DOWN); |
122 key2.set_character(0x4321U); | 126 key2.set_character(0x4321U); |
123 key2.set_unmodified_character(0x1234U); | 127 key2.set_unmodified_character(0x1234U); |
124 EXPECT_EQ(0x4321U, key2.GetCharacter()); | 128 EXPECT_EQ(0x4321U, key2.GetCharacter()); |
125 EXPECT_EQ(0x1234U, key2.GetUnmodifiedCharacter()); | 129 EXPECT_EQ(0x1234U, key2.GetUnmodifiedCharacter()); |
126 } | 130 } |
127 | 131 |
128 } // namespace views | 132 } // namespace views |
OLD | NEW |