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

Side by Side Diff: ui/events/gestures/gesture_provider_aura_unittest.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates Created 4 years, 7 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 "ui/events/gestures/gesture_provider_aura.h" 5 #include "ui/events/gestures/gesture_provider_aura.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 20 matching lines...) Expand all
31 31
32 GestureProviderAura* provider() { return provider_.get(); } 32 GestureProviderAura* provider() { return provider_.get(); }
33 33
34 private: 34 private:
35 std::unique_ptr<GestureConsumer> consumer_; 35 std::unique_ptr<GestureConsumer> consumer_;
36 std::unique_ptr<GestureProviderAura> provider_; 36 std::unique_ptr<GestureProviderAura> provider_;
37 base::MessageLoopForUI message_loop_; 37 base::MessageLoopForUI message_loop_;
38 }; 38 };
39 39
40 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) { 40 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) {
41 base::TimeDelta time = ui::EventTimeForNow(); 41 base::TimeTicks time = ui::EventTimeForNow();
42 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time); 42 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time);
43 EXPECT_TRUE(provider()->OnTouchEvent(&press1)); 43 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
44 44
45 time += base::TimeDelta::FromMilliseconds(10); 45 time += base::TimeDelta::FromMilliseconds(10);
46 TouchEvent press2(ET_TOUCH_PRESSED, gfx::Point(30, 40), 0, time); 46 TouchEvent press2(ET_TOUCH_PRESSED, gfx::Point(30, 40), 0, time);
47 // TODO(tdresser): this redundant press with same id should be 47 // TODO(tdresser): this redundant press with same id should be
48 // ignored; however, there is at least one case where we need to 48 // ignored; however, there is at least one case where we need to
49 // allow a touch press from a currently used touch id. See 49 // allow a touch press from a currently used touch id. See
50 // crbug.com/373125 for details. 50 // crbug.com/373125 for details.
51 EXPECT_TRUE(provider()->OnTouchEvent(&press2)); 51 EXPECT_TRUE(provider()->OnTouchEvent(&press2));
52 } 52 }
53 53
54 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) { 54 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) {
55 base::TimeDelta time = ui::EventTimeForNow(); 55 base::TimeTicks time = ui::EventTimeForNow();
56 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time); 56 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time);
57 EXPECT_TRUE(provider()->OnTouchEvent(&press1)); 57 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
58 58
59 time += base::TimeDelta::FromMilliseconds(10); 59 time += base::TimeDelta::FromMilliseconds(10);
60 TouchEvent release1(ET_TOUCH_RELEASED, gfx::Point(30, 40), 0, time); 60 TouchEvent release1(ET_TOUCH_RELEASED, gfx::Point(30, 40), 0, time);
61 EXPECT_TRUE(provider()->OnTouchEvent(&release1)); 61 EXPECT_TRUE(provider()->OnTouchEvent(&release1));
62 62
63 time += base::TimeDelta::FromMilliseconds(10); 63 time += base::TimeDelta::FromMilliseconds(10);
64 TouchEvent release2(ET_TOUCH_RELEASED, gfx::Point(30, 45), 0, time); 64 TouchEvent release2(ET_TOUCH_RELEASED, gfx::Point(30, 45), 0, time);
65 EXPECT_FALSE(provider()->OnTouchEvent(&release1)); 65 EXPECT_FALSE(provider()->OnTouchEvent(&release1));
66 66
67 time += base::TimeDelta::FromMilliseconds(10); 67 time += base::TimeDelta::FromMilliseconds(10);
68 TouchEvent move1(ET_TOUCH_MOVED, gfx::Point(70, 75), 0, time); 68 TouchEvent move1(ET_TOUCH_MOVED, gfx::Point(70, 75), 0, time);
69 EXPECT_FALSE(provider()->OnTouchEvent(&move1)); 69 EXPECT_FALSE(provider()->OnTouchEvent(&move1));
70 } 70 }
71 71
72 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) { 72 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) {
73 const float kRadiusX = 20.f; 73 const float kRadiusX = 20.f;
74 const float kRadiusY = 30.f; 74 const float kRadiusY = 30.f;
75 const float kAngle = 0.321f; 75 const float kAngle = 0.321f;
76 const float kForce = 40.f; 76 const float kForce = 40.f;
77 const int kTouchId0 = 5; 77 const int kTouchId0 = 5;
78 const int kTouchId1 = 3; 78 const int kTouchId1 = 3;
79 79
80 base::TimeDelta time = ui::EventTimeForNow(); 80 base::TimeTicks time = ui::EventTimeForNow();
81 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::Point(9, 10), kTouchId0, time); 81 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::Point(9, 10), kTouchId0, time);
82 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1)); 82 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1));
83 83
84 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::Point(40, 40), kTouchId1, time); 84 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::Point(40, 40), kTouchId1, time);
85 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1)); 85 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1));
86 86
87 time += base::TimeDelta::FromMilliseconds(10); 87 time += base::TimeDelta::FromMilliseconds(10);
88 TouchEvent move0_1(ET_TOUCH_MOVED, gfx::Point(10, 10), 0, kTouchId0, time, 88 TouchEvent move0_1(ET_TOUCH_MOVED, gfx::Point(10, 10), 0, kTouchId0, time,
89 kRadiusX, kRadiusY, kAngle, kForce); 89 kRadiusX, kRadiusY, kAngle, kForce);
90 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1)); 90 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1));
(...skipping 24 matching lines...) Expand all
115 time += base::TimeDelta::FromMilliseconds(10); 115 time += base::TimeDelta::FromMilliseconds(10);
116 TouchEvent move0_4(ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId0, time, kRadiusX, 116 TouchEvent move0_4(ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId0, time, kRadiusX,
117 kRadiusY + 1, kAngle, kForce); 117 kRadiusY + 1, kAngle, kForce);
118 move0_4.set_location_f(gfx::PointF(70, 75.1f)); 118 move0_4.set_location_f(gfx::PointF(70, 75.1f));
119 move0_4.set_root_location_f(gfx::PointF(70, 75.1f)); 119 move0_4.set_root_location_f(gfx::PointF(70, 75.1f));
120 } 120 }
121 121
122 // TODO(jdduke): Test whether event marked as scroll trigger. 122 // TODO(jdduke): Test whether event marked as scroll trigger.
123 123
124 } // namespace ui 124 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698