Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: ui/events/event_unittest.cc

Issue 841263005: Use DOM- rather than Windows-based key code for non-layout cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments (sadrul) Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/events/event.cc ('k') | ui/events/event_utils.h » ('j') | ui/keyboard/keyboard_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698