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

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

Issue 1908913002: Revert of mus: Fix event transformation in client code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « ui/events/event.cc ('k') | ui/views/mus/window_tree_host_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/events/event_utils.h" 15 #include "ui/events/event_utils.h"
16 #include "ui/events/keycodes/dom/dom_code.h" 16 #include "ui/events/keycodes/dom/dom_code.h"
17 #include "ui/events/keycodes/dom/keycode_converter.h" 17 #include "ui/events/keycodes/dom/keycode_converter.h"
18 #include "ui/events/test/events_test_utils.h" 18 #include "ui/events/test/events_test_utils.h"
19 #include "ui/gfx/transform.h"
20 19
21 #if defined(USE_X11) 20 #if defined(USE_X11)
22 #include <X11/Xlib.h> 21 #include <X11/Xlib.h>
23 #include "ui/events/test/events_test_utils_x11.h" 22 #include "ui/events/test/events_test_utils_x11.h"
24 #include "ui/gfx/x/x11_types.h" // nogncheck 23 #include "ui/gfx/x/x11_types.h" // nogncheck
25 #endif 24 #endif
26 25
27 namespace ui { 26 namespace ui {
28 27
29 TEST(EventTest, NoNativeEvent) { 28 TEST(EventTest, NoNativeEvent) {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 418
420 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam }; 419 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam };
421 KeyEvent key(native_event); 420 KeyEvent key(native_event);
422 421
423 // KeyEvent converts from the native keycode (scan code) to the code. 422 // KeyEvent converts from the native keycode (scan code) to the code.
424 EXPECT_EQ(kCodeForHome, key.GetCodeString()); 423 EXPECT_EQ(kCodeForHome, key.GetCodeString());
425 } 424 }
426 #endif // OS_WIN 425 #endif // OS_WIN
427 } 426 }
428 427
429 TEST(EventTest, LocatedEventTransform) {
430 const gfx::Point root_location(10, 20);
431 const gfx::Point location(0, 14);
432 MouseEvent mouseev(ET_MOUSE_MOVED, location, root_location,
433 EventTimeForNow(), EF_NONE, EF_NONE);
434 gfx::Transform transform;
435 transform.Scale(0.5, 0.5);
436 mouseev.UpdateForRootTransform(transform);
437 EXPECT_EQ(gfx::Point(5, 10).ToString(),
438 mouseev.root_location().ToString());
439 EXPECT_EQ(gfx::Point(0, 7).ToString(),
440 mouseev.location().ToString());
441 }
442
443 namespace { 428 namespace {
444 #if defined(USE_X11) 429 #if defined(USE_X11)
445 void SetKeyEventTimestamp(XEvent* event, long time) { 430 void SetKeyEventTimestamp(XEvent* event, long time) {
446 event->xkey.time = time; 431 event->xkey.time = time;
447 } 432 }
448 433
449 void AdvanceKeyEventTimestamp(XEvent* event) { 434 void AdvanceKeyEventTimestamp(XEvent* event) {
450 event->xkey.time++; 435 event->xkey.time++;
451 } 436 }
452 437
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 876
892 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type()); 877 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type());
893 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id()); 878 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id());
894 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details()); 879 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details());
895 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location()); 880 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location());
896 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location()); 881 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location());
897 } 882 }
898 } 883 }
899 884
900 } // namespace ui 885 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.cc ('k') | ui/views/mus/window_tree_host_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698