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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 555 |
557 { | 556 { |
558 const float angle_too_big = 400; | 557 const float angle_too_big = 400; |
559 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 558 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, |
560 radius_x, radius_y, angle_too_big, 0); | 559 radius_x, radius_y, angle_too_big, 0); |
561 EXPECT_FLOAT_EQ(400 - 360, event.rotation_angle()); | 560 EXPECT_FLOAT_EQ(400 - 360, event.rotation_angle()); |
562 } | 561 } |
563 } | 562 } |
564 | 563 |
565 } // namespace ui | 564 } // namespace ui |
OLD | NEW |