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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
8 #include "ui/events/event_utils.h" | 8 #include "ui/events/event_utils.h" |
9 #include "ui/events/keycodes/dom4/keycode_converter.h" | 9 #include "ui/events/keycodes/dom4/keycode_converter.h" |
10 #include "ui/events/test/events_test_utils.h" | 10 #include "ui/events/test/events_test_utils.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 { | 257 { |
258 KeyEvent keyev(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN, false); | 258 KeyEvent keyev(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN, false); |
259 EXPECT_EQ(EF_ALT_DOWN, keyev.flags()); | 259 EXPECT_EQ(EF_ALT_DOWN, keyev.flags()); |
260 keyev.NormalizeFlags(); | 260 keyev.NormalizeFlags(); |
261 EXPECT_EQ(EF_NONE, keyev.flags()); | 261 EXPECT_EQ(EF_NONE, keyev.flags()); |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 TEST(EventTest, KeyEventCopy) { | 265 TEST(EventTest, KeyEventCopy) { |
266 KeyEvent key(ET_KEY_PRESSED, VKEY_A, EF_NONE, false); | 266 KeyEvent key(ET_KEY_PRESSED, VKEY_A, EF_NONE, false); |
267 scoped_ptr<KeyEvent> copied_key(key.Copy()); | 267 scoped_ptr<KeyEvent> copied_key(new KeyEvent(key)); |
268 EXPECT_EQ(copied_key->type(), key.type()); | 268 EXPECT_EQ(copied_key->type(), key.type()); |
269 EXPECT_EQ(copied_key->key_code(), key.key_code()); | 269 EXPECT_EQ(copied_key->key_code(), key.key_code()); |
270 } | 270 } |
271 | 271 |
272 TEST(EventTest, KeyEventCode) { | 272 TEST(EventTest, KeyEventCode) { |
273 KeycodeConverter* conv = KeycodeConverter::GetInstance(); | 273 KeycodeConverter* conv = KeycodeConverter::GetInstance(); |
274 | 274 |
275 const char kCodeForSpace[] = "Space"; | 275 const char kCodeForSpace[] = "Space"; |
276 const uint16 kNativeCodeSpace = conv->CodeToNativeKeycode(kCodeForSpace); | 276 const uint16 kNativeCodeSpace = conv->CodeToNativeKeycode(kCodeForSpace); |
277 ASSERT_NE(conv->InvalidNativeKeycode(), kNativeCodeSpace); | 277 ASSERT_NE(conv->InvalidNativeKeycode(), kNativeCodeSpace); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam }; | 325 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam }; |
326 KeyEvent key(native_event, false); | 326 KeyEvent key(native_event, false); |
327 | 327 |
328 // KeyEvent converts from the native keycode (scan code) to the code. | 328 // KeyEvent converts from the native keycode (scan code) to the code. |
329 EXPECT_EQ(kCodeForHome, key.code()); | 329 EXPECT_EQ(kCodeForHome, key.code()); |
330 } | 330 } |
331 #endif // OS_WIN | 331 #endif // OS_WIN |
332 } | 332 } |
333 | 333 |
334 } // namespace ui | 334 } // namespace ui |
OLD | NEW |