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/dom3/dom_code.h" | 9 #include "ui/events/keycodes/dom3/dom_code.h" |
10 #include "ui/events/keycodes/dom4/keycode_converter.h" | 10 #include "ui/events/keycodes/dom4/keycode_converter.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kDomCodeForSpace, EF_NONE); | 344 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kDomCodeForSpace, EF_NONE); |
345 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); | 345 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
346 } | 346 } |
347 { | 347 { |
348 // Regardless the KeyEvent.key_code (VKEY_RETURN), code should be | 348 // Regardless the KeyEvent.key_code (VKEY_RETURN), code should be |
349 // the specified value. | 349 // the specified value. |
350 KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kDomCodeForSpace, EF_NONE); | 350 KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kDomCodeForSpace, EF_NONE); |
351 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); | 351 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
352 } | 352 } |
353 { | 353 { |
354 // If the synthetic event is initialized without code, it returns | 354 // If the synthetic event is initialized without code, the code is |
355 // an empty string. | 355 // determined from the KeyboardCode assuming a US keyboard layout. |
356 // TODO(komatsu): Fill a fallback value assuming the US keyboard layout. | |
357 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE); | 356 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE); |
358 EXPECT_TRUE(key.GetCodeString().empty()); | 357 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
359 } | 358 } |
360 #if defined(USE_X11) | 359 #if defined(USE_X11) |
361 { | 360 { |
362 // KeyEvent converts from the native keycode (XKB) to the code. | 361 // KeyEvent converts from the native keycode (XKB) to the code. |
363 ScopedXI2Event xevent; | 362 ScopedXI2Event xevent; |
364 xevent.InitKeyEvent(ET_KEY_PRESSED, VKEY_SPACE, kNativeCodeSpace); | 363 xevent.InitKeyEvent(ET_KEY_PRESSED, VKEY_SPACE, kNativeCodeSpace); |
365 KeyEvent key(xevent); | 364 KeyEvent key(xevent); |
366 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); | 365 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
367 } | 366 } |
368 #endif // USE_X11 | 367 #endif // USE_X11 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 DCHECK_EQ(non_zero_length1, event1.radius_x()); | 507 DCHECK_EQ(non_zero_length1, event1.radius_x()); |
509 DCHECK_EQ(non_zero_length1, event1.radius_y()); | 508 DCHECK_EQ(non_zero_length1, event1.radius_y()); |
510 | 509 |
511 TouchEvent event2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 510 TouchEvent event2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, |
512 0, non_zero_length2, 0, 0); | 511 0, non_zero_length2, 0, 0); |
513 DCHECK_EQ(non_zero_length2, event2.radius_x()); | 512 DCHECK_EQ(non_zero_length2, event2.radius_x()); |
514 DCHECK_EQ(non_zero_length2, event2.radius_y()); | 513 DCHECK_EQ(non_zero_length2, event2.radius_y()); |
515 } | 514 } |
516 | 515 |
517 } // namespace ui | 516 } // namespace ui |
OLD | NEW |