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

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

Issue 2753163004: Remove ID from ui::PointerEvent's constructors (Closed)
Patch Set: Created 3 years, 9 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/events/mojo/event_struct_traits.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>
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 {ui::ET_POINTER_ENTERED, ui::ET_MOUSE_ENTERED, gfx::Point(), gfx::Point(), 971 {ui::ET_POINTER_ENTERED, ui::ET_MOUSE_ENTERED, gfx::Point(), gfx::Point(),
972 EF_MIDDLE_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON, 0}, 972 EF_MIDDLE_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON, 0},
973 {ui::ET_POINTER_EXITED, ui::ET_MOUSE_EXITED, gfx::Point(5, 1), 973 {ui::ET_POINTER_EXITED, ui::ET_MOUSE_EXITED, gfx::Point(5, 1),
974 gfx::Point(1, 5), EF_RIGHT_MOUSE_BUTTON, 0}, 974 gfx::Point(1, 5), EF_RIGHT_MOUSE_BUTTON, 0},
975 {ui::ET_POINTER_UP, ui::ET_MOUSE_RELEASED, gfx::Point(1000, 1000), 975 {ui::ET_POINTER_UP, ui::ET_MOUSE_RELEASED, gfx::Point(1000, 1000),
976 gfx::Point(14, 15), EF_MIDDLE_MOUSE_BUTTON, EF_MIDDLE_MOUSE_BUTTON}}; 976 gfx::Point(14, 15), EF_MIDDLE_MOUSE_BUTTON, EF_MIDDLE_MOUSE_BUTTON}};
977 977
978 for (size_t i = 0; i < arraysize(kTestData); i++) { 978 for (size_t i = 0; i < arraysize(kTestData); i++) {
979 ui::PointerEvent pointer_event( 979 ui::PointerEvent pointer_event(
980 kTestData[i].in_type, kTestData[i].location, kTestData[i].root_location, 980 kTestData[i].in_type, kTestData[i].location, kTestData[i].root_location,
981 kTestData[i].flags, 0, kTestData[i].changed_button_flags, 981 kTestData[i].flags, kTestData[i].changed_button_flags,
982 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE), 982 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0),
983 base::TimeTicks()); 983 base::TimeTicks());
984 ui::MouseEvent mouse_event(pointer_event); 984 ui::MouseEvent mouse_event(pointer_event);
985 985
986 EXPECT_EQ(kTestData[i].out_type, mouse_event.type()); 986 EXPECT_EQ(kTestData[i].out_type, mouse_event.type());
987 EXPECT_EQ(kTestData[i].location, mouse_event.location()); 987 EXPECT_EQ(kTestData[i].location, mouse_event.location());
988 EXPECT_EQ(kTestData[i].root_location, mouse_event.root_location()); 988 EXPECT_EQ(kTestData[i].root_location, mouse_event.root_location());
989 EXPECT_EQ(kTestData[i].flags, mouse_event.flags()); 989 EXPECT_EQ(kTestData[i].flags, mouse_event.flags());
990 EXPECT_EQ(kTestData[i].changed_button_flags, 990 EXPECT_EQ(kTestData[i].changed_button_flags,
991 mouse_event.changed_button_flags()); 991 mouse_event.changed_button_flags());
992 } 992 }
993 } 993 }
994 994
995 TEST(EventTest, PointerEventToTouchEventType) { 995 TEST(EventTest, PointerEventToTouchEventType) {
996 ui::EventType kTouchTypeMap[][2] = { 996 ui::EventType kTouchTypeMap[][2] = {
997 {ui::ET_POINTER_DOWN, ui::ET_TOUCH_PRESSED}, 997 {ui::ET_POINTER_DOWN, ui::ET_TOUCH_PRESSED},
998 {ui::ET_POINTER_MOVED, ui::ET_TOUCH_MOVED}, 998 {ui::ET_POINTER_MOVED, ui::ET_TOUCH_MOVED},
999 {ui::ET_POINTER_UP, ui::ET_TOUCH_RELEASED}, 999 {ui::ET_POINTER_UP, ui::ET_TOUCH_RELEASED},
1000 {ui::ET_POINTER_CANCELLED, ui::ET_TOUCH_CANCELLED}, 1000 {ui::ET_POINTER_CANCELLED, ui::ET_TOUCH_CANCELLED},
1001 }; 1001 };
1002 1002
1003 for (size_t i = 0; i < arraysize(kTouchTypeMap); i++) { 1003 for (size_t i = 0; i < arraysize(kTouchTypeMap); i++) {
1004 ui::PointerEvent pointer_event( 1004 ui::PointerEvent pointer_event(
1005 kTouchTypeMap[i][0], gfx::Point(), gfx::Point(), 0, 0, 0, 1005 kTouchTypeMap[i][0], gfx::Point(), gfx::Point(), 0, 0,
1006 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0), 1006 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0),
1007 base::TimeTicks()); 1007 base::TimeTicks());
1008 ui::TouchEvent touch_event(pointer_event); 1008 ui::TouchEvent touch_event(pointer_event);
1009 1009
1010 EXPECT_EQ(kTouchTypeMap[i][1], touch_event.type()); 1010 EXPECT_EQ(kTouchTypeMap[i][1], touch_event.type());
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 TEST(EventTest, PointerEventToTouchEventDetails) { 1014 TEST(EventTest, PointerEventToTouchEventDetails) {
1015 ui::PointerEvent pointer_event(ui::TouchEvent( 1015 ui::PointerEvent pointer_event(ui::TouchEvent(
1016 ui::ET_TOUCH_PRESSED, gfx::Point(12, 14), EventTimeForNow(), 1016 ui::ET_TOUCH_PRESSED, gfx::Point(12, 14), EventTimeForNow(),
1017 PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1017 PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
1018 /* pointer_id*/ 15, 1018 /* pointer_id*/ 15,
1019 /* radius_x */ 11.5, 1019 /* radius_x */ 11.5,
1020 /* radius_y */ 13.5, 1020 /* radius_y */ 13.5,
1021 /* force */ 0.5), 1021 /* force */ 0.5),
1022 0, 13.0)); 1022 0, 13.0));
1023 ui::TouchEvent touch_event(pointer_event); 1023 ui::TouchEvent touch_event(pointer_event);
1024 1024
1025 EXPECT_EQ(pointer_event.location(), touch_event.location()); 1025 EXPECT_EQ(pointer_event.location(), touch_event.location());
1026 EXPECT_EQ(pointer_event.flags(), touch_event.flags()); 1026 EXPECT_EQ(pointer_event.flags(), touch_event.flags());
1027 EXPECT_EQ(pointer_event.pointer_details().id, 1027 EXPECT_EQ(pointer_event.pointer_details().id,
1028 touch_event.pointer_details().id); 1028 touch_event.pointer_details().id);
1029 EXPECT_EQ(pointer_event.pointer_details(), touch_event.pointer_details()); 1029 EXPECT_EQ(pointer_event.pointer_details(), touch_event.pointer_details());
1030 EXPECT_EQ(pointer_event.time_stamp(), touch_event.time_stamp()); 1030 EXPECT_EQ(pointer_event.time_stamp(), touch_event.time_stamp());
1031 } 1031 }
1032 1032
1033 TEST(EventTest, PointerEventSourceEventTypeExistsInLatencyInfo) { 1033 TEST(EventTest, PointerEventSourceEventTypeExistsInLatencyInfo) {
1034 ui::PointerEvent wheel_poniter_event( 1034 ui::PointerEvent wheel_poniter_event(
1035 ui::ET_POINTER_WHEEL_CHANGED, gfx::Point(), gfx::Point(), 0, 0, 0, 1035 ui::ET_POINTER_WHEEL_CHANGED, gfx::Point(), gfx::Point(), 0, 0,
1036 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE), 1036 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0),
1037 ui::EventTimeForNow()); 1037 ui::EventTimeForNow());
1038 EXPECT_EQ(wheel_poniter_event.latency()->source_event_type(), 1038 EXPECT_EQ(wheel_poniter_event.latency()->source_event_type(),
1039 ui::SourceEventType::WHEEL); 1039 ui::SourceEventType::WHEEL);
1040 1040
1041 ui::PointerEvent touch_poniter_event( 1041 ui::PointerEvent touch_poniter_event(
1042 ui::ET_TOUCH_PRESSED, gfx::Point(), gfx::Point(), 0, 0, 0, 1042 ui::ET_TOUCH_PRESSED, gfx::Point(), gfx::Point(), 0, 0,
1043 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0), 1043 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0),
1044 ui::EventTimeForNow()); 1044 ui::EventTimeForNow());
1045 EXPECT_EQ(touch_poniter_event.latency()->source_event_type(), 1045 EXPECT_EQ(touch_poniter_event.latency()->source_event_type(),
1046 ui::SourceEventType::TOUCH); 1046 ui::SourceEventType::TOUCH);
1047 } 1047 }
1048 1048
1049 // Checks that Event.Latency.OS.TOUCH_PRESSED, TOUCH_MOVED, 1049 // Checks that Event.Latency.OS.TOUCH_PRESSED, TOUCH_MOVED,
1050 // and TOUCH_RELEASED histograms are computed properly. 1050 // and TOUCH_RELEASED histograms are computed properly.
1051 #if defined(USE_X11) 1051 #if defined(USE_X11)
1052 TEST(EventTest, EventLatencyOSTouchHistograms) { 1052 TEST(EventTest, EventLatencyOSTouchHistograms) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 XButtonEvent* button_event = &(native_event.xbutton); 1092 XButtonEvent* button_event = &(native_event.xbutton);
1093 button_event->type = ButtonPress; 1093 button_event->type = ButtonPress;
1094 button_event->button = 4; // A valid wheel button number between min and max. 1094 button_event->button = 4; // A valid wheel button number between min and max.
1095 MouseWheelEvent mouse_ev(&native_event); 1095 MouseWheelEvent mouse_ev(&native_event);
1096 1096
1097 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); 1097 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1);
1098 #endif 1098 #endif
1099 } 1099 }
1100 1100
1101 } // namespace ui 1101 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.cc ('k') | ui/events/mojo/event_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698