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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kDomCodeForSpace, EF_NONE); | 360 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kDomCodeForSpace, EF_NONE); |
361 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); | 361 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
362 } | 362 } |
363 { | 363 { |
364 // Regardless the KeyEvent.key_code (VKEY_RETURN), code should be | 364 // Regardless the KeyEvent.key_code (VKEY_RETURN), code should be |
365 // the specified value. | 365 // the specified value. |
366 KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kDomCodeForSpace, EF_NONE); | 366 KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kDomCodeForSpace, EF_NONE); |
367 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); | 367 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
368 } | 368 } |
369 { | 369 { |
370 // If the synthetic event is initialized without code, it returns | 370 // If the synthetic event is initialized without code, the code is |
371 // an empty string. | 371 // determined from the KeyboardCode assuming a US keyboard layout. |
372 // TODO(komatsu): Fill a fallback value assuming the US keyboard layout. | |
373 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE); | 372 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE); |
374 EXPECT_TRUE(key.GetCodeString().empty()); | 373 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
375 } | 374 } |
376 #if defined(USE_X11) | 375 #if defined(USE_X11) |
377 { | 376 { |
378 // KeyEvent converts from the native keycode (XKB) to the code. | 377 // KeyEvent converts from the native keycode (XKB) to the code. |
379 ScopedXI2Event xevent; | 378 ScopedXI2Event xevent; |
380 xevent.InitKeyEvent(ET_KEY_PRESSED, VKEY_SPACE, kNativeCodeSpace); | 379 xevent.InitKeyEvent(ET_KEY_PRESSED, VKEY_SPACE, kNativeCodeSpace); |
381 KeyEvent key(xevent); | 380 KeyEvent key(xevent); |
382 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); | 381 EXPECT_EQ(kCodeForSpace, key.GetCodeString()); |
383 } | 382 } |
384 #endif // USE_X11 | 383 #endif // USE_X11 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 598 |
600 { | 599 { |
601 const float angle_too_big = 400; | 600 const float angle_too_big = 400; |
602 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 601 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, |
603 radius_x, radius_y, angle_too_big, 0); | 602 radius_x, radius_y, angle_too_big, 0); |
604 EXPECT_FLOAT_EQ(400 - 360, event.rotation_angle()); | 603 EXPECT_FLOAT_EQ(400 - 360, event.rotation_angle()); |
605 } | 604 } |
606 } | 605 } |
607 | 606 |
608 } // namespace ui | 607 } // namespace ui |
OLD | NEW |