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

Side by Side Diff: ui/events/gesture_detection/motion_event_generic_unittest.cc

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/events/event_constants.h" 6 #include "ui/events/event_constants.h"
7 #include "ui/events/gesture_detection/motion_event_generic.h" 7 #include "ui/events/gesture_detection/motion_event_generic.h"
8 #include "ui/events/test/motion_event_test_utils.h" 8 #include "ui/events/test/motion_event_test_utils.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 TEST(MotionEventGenericTest, Basic) { 12 TEST(MotionEventGenericTest, Basic) {
13 base::TimeTicks event_time = base::TimeTicks::Now(); 13 base::TimeTicks event_time = base::TimeTicks::Now();
14 MotionEventGeneric event( 14 MotionEventGeneric event(
15 MotionEvent::ACTION_DOWN, event_time, PointerProperties()); 15 MotionEvent::ACTION_DOWN, event_time, PointerProperties());
16 EXPECT_EQ(1U, event.GetPointerCount()); 16 EXPECT_EQ(1U, event.GetPointerCount());
17 EXPECT_EQ(0U, event.GetHistorySize()); 17 EXPECT_EQ(0U, event.GetHistorySize());
18 EXPECT_EQ(event_time, event.GetEventTime()); 18 EXPECT_EQ(event_time, event.GetEventTime());
19 19
20 event.PushPointer(PointerProperties(8.3f, 4.7f, 0.9f)); 20 event.PushPointer(PointerProperties(8.3f, 4.7f, 0.9f));
21 ASSERT_EQ(2U, event.GetPointerCount()); 21 ASSERT_EQ(2U, event.GetPointerCount());
22 EXPECT_EQ(8.3f, event.GetX(1)); 22 EXPECT_EQ(8.3f, event.GetX(1));
23 EXPECT_EQ(4.7f, event.GetY(1)); 23 EXPECT_EQ(4.7f, event.GetY(1));
24 24
25 event.PushPointer(PointerProperties(2.3f, -3.7f, 5.8f)); 25 event.PushPointer(PointerProperties(2.3f, -3.7f, 5.8f));
26 ASSERT_EQ(3U, event.GetPointerCount()); 26 ASSERT_EQ(3U, event.GetPointerCount());
27 EXPECT_EQ(2.3f, event.GetX(2)); 27 EXPECT_EQ(2.3f, event.GetX(2));
28 EXPECT_EQ(-3.7f, event.GetY(2)); 28 EXPECT_EQ(-3.7f, event.GetY(2));
29 29
30 event.set_id(1);
tdresser 2015/04/16 17:33:34 Shouldn't we still be able to verify that the poin
lanwei 2015/04/20 19:58:59 Done.
31 EXPECT_EQ(1, event.GetId());
32
33 event.set_action(MotionEvent::ACTION_POINTER_DOWN); 30 event.set_action(MotionEvent::ACTION_POINTER_DOWN);
34 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); 31 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction());
35 32
36 event_time += base::TimeDelta::FromMilliseconds(5); 33 event_time += base::TimeDelta::FromMilliseconds(5);
37 event.set_event_time(event_time); 34 event.set_event_time(event_time);
38 EXPECT_EQ(event_time, event.GetEventTime()); 35 EXPECT_EQ(event_time, event.GetEventTime());
39 36
40 event.set_button_state(MotionEvent::BUTTON_PRIMARY); 37 event.set_button_state(MotionEvent::BUTTON_PRIMARY);
41 EXPECT_EQ(MotionEvent::BUTTON_PRIMARY, event.GetButtonState()); 38 EXPECT_EQ(MotionEvent::BUTTON_PRIMARY, event.GetButtonState());
42 39
(...skipping 28 matching lines...) Expand all
71 EXPECT_EQ(2.f, event.GetHistoricalTouchMajor(1, 0)); 68 EXPECT_EQ(2.f, event.GetHistoricalTouchMajor(1, 0));
72 EXPECT_EQ(4.8f, event.GetHistoricalX(2, 0)); 69 EXPECT_EQ(4.8f, event.GetHistoricalX(2, 0));
73 EXPECT_EQ(9.6f, event.GetHistoricalY(2, 0)); 70 EXPECT_EQ(9.6f, event.GetHistoricalY(2, 0));
74 EXPECT_EQ(3.f, event.GetHistoricalTouchMajor(2, 0)); 71 EXPECT_EQ(3.f, event.GetHistoricalTouchMajor(2, 0));
75 } 72 }
76 73
77 TEST(MotionEventGenericTest, Clone) { 74 TEST(MotionEventGenericTest, Clone) {
78 MotionEventGeneric event(MotionEvent::ACTION_DOWN, 75 MotionEventGeneric event(MotionEvent::ACTION_DOWN,
79 base::TimeTicks::Now(), 76 base::TimeTicks::Now(),
80 PointerProperties(8.3f, 4.7f, 2.f)); 77 PointerProperties(8.3f, 4.7f, 2.f));
81 event.set_id(1);
82 event.set_button_state(MotionEvent::BUTTON_PRIMARY); 78 event.set_button_state(MotionEvent::BUTTON_PRIMARY);
83 79
84 scoped_ptr<MotionEvent> clone = event.Clone(); 80 scoped_ptr<MotionEvent> clone = event.Clone();
85 ASSERT_TRUE(clone); 81 ASSERT_TRUE(clone);
86 EXPECT_EQ(test::ToString(event), test::ToString(*clone)); 82 EXPECT_EQ(test::ToString(event), test::ToString(*clone));
87 } 83 }
88 84
89 TEST(MotionEventGenericTest, CloneWithHistory) { 85 TEST(MotionEventGenericTest, CloneWithHistory) {
90 base::TimeTicks event_time = base::TimeTicks::Now(); 86 base::TimeTicks event_time = base::TimeTicks::Now();
91 base::TimeTicks historical_event_time = 87 base::TimeTicks historical_event_time =
(...skipping 11 matching lines...) Expand all
103 99
104 scoped_ptr<MotionEvent> clone = event.Clone(); 100 scoped_ptr<MotionEvent> clone = event.Clone();
105 ASSERT_TRUE(clone); 101 ASSERT_TRUE(clone);
106 EXPECT_EQ(test::ToString(event), test::ToString(*clone)); 102 EXPECT_EQ(test::ToString(event), test::ToString(*clone));
107 } 103 }
108 104
109 TEST(MotionEventGenericTest, Cancel) { 105 TEST(MotionEventGenericTest, Cancel) {
110 MotionEventGeneric event(MotionEvent::ACTION_UP, 106 MotionEventGeneric event(MotionEvent::ACTION_UP,
111 base::TimeTicks::Now(), 107 base::TimeTicks::Now(),
112 PointerProperties(8.7f, 4.3f, 1.f)); 108 PointerProperties(8.7f, 4.3f, 1.f));
113 event.set_id(2);
114 event.set_button_state(MotionEvent::BUTTON_SECONDARY); 109 event.set_button_state(MotionEvent::BUTTON_SECONDARY);
115 110
116 scoped_ptr<MotionEvent> cancel = event.Cancel(); 111 scoped_ptr<MotionEvent> cancel = event.Cancel();
117 event.set_action(MotionEvent::ACTION_CANCEL); 112 event.set_action(MotionEvent::ACTION_CANCEL);
118 ASSERT_TRUE(cancel); 113 ASSERT_TRUE(cancel);
119 EXPECT_EQ(test::ToString(event), test::ToString(*cancel)); 114 EXPECT_EQ(test::ToString(event), test::ToString(*cancel));
120 } 115 }
121 116
122 TEST(MotionEventGenericTest, FindPointerIndexOfId) { 117 TEST(MotionEventGenericTest, FindPointerIndexOfId) {
123 base::TimeTicks event_time = base::TimeTicks::Now(); 118 base::TimeTicks event_time = base::TimeTicks::Now();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 ASSERT_EQ(2U, event.GetHistorySize()); 208 ASSERT_EQ(2U, event.GetHistorySize());
214 ASSERT_EQ(2U, event.GetPointerCount()); 209 ASSERT_EQ(2U, event.GetPointerCount());
215 210
216 // Do a basic smoke exercise of event stringification to ensure things don't 211 // Do a basic smoke exercise of event stringification to ensure things don't
217 // explode in the process. 212 // explode in the process.
218 std::string event_string = test::ToString(event); 213 std::string event_string = test::ToString(event);
219 EXPECT_FALSE(event_string.empty()); 214 EXPECT_FALSE(event_string.empty());
220 } 215 }
221 216
222 } // namespace ui 217 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698