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

Unified Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 309823002: Pass ui::LatencyInfo correct with unified gesture detector on Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix int to unsigned int comparison. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/events/gestures/gesture_provider_aura.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/gestures/gesture_recognizer_unittest.cc
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index aab2898a3cb38efa182c63ea496d93bb1cc9674d..d2c150b5ee61b76b81a01e30d42f6ef859e26c56 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -138,6 +138,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
tap_count_ = 0;
scale_ = 0;
flags_ = 0;
+ latency_info_.Clear();
}
const std::vector<ui::EventType>& events() const { return events_; };
@@ -187,6 +188,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
const gfx::Rect& bounding_box() const { return bounding_box_; }
int tap_count() const { return tap_count_; }
int flags() const { return flags_; }
+ const ui::LatencyInfo& latency_info() const { return latency_info_; }
void WaitUntilReceivedGesture(ui::EventType type) {
wait_until_event_ = type;
@@ -198,6 +200,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
events_.push_back(gesture->type());
bounding_box_ = gesture->details().bounding_box();
flags_ = gesture->flags();
+ latency_info_ = *gesture->latency();
switch (gesture->type()) {
case ui::ET_GESTURE_TAP:
tap_location_ = gesture->location();
@@ -322,6 +325,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
gfx::Rect bounding_box_;
int tap_count_;
int flags_;
+ ui::LatencyInfo latency_info_;
ui::EventType wait_until_event_;
@@ -4270,6 +4274,63 @@ TEST_P(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
EXPECT_NE(default_flags, delegate->flags());
}
+// Test that latency info is passed through to the gesture event.
+TEST_P(GestureRecognizerTest, LatencyPassedFromTouchEvent) {
+ scoped_ptr<GestureEventConsumeDelegate> delegate(
+ new GestureEventConsumeDelegate());
+ TimedEvents tes;
+ const int kWindowWidth = 123;
+ const int kWindowHeight = 45;
+ const int kTouchId = 6;
+
+ const base::TimeTicks time_original = base::TimeTicks::FromInternalValue(100);
+ const base::TimeTicks time_ui = base::TimeTicks::FromInternalValue(200);
+ const base::TimeTicks time_acked = base::TimeTicks::FromInternalValue(300);
+
+ gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ delegate.get(), -1234, bounds, root_window()));
+
+ delegate->Reset();
+
+ ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
+ kTouchId, tes.Now());
+
+ // Ensure the only components around are the ones we add.
+ press1.latency()->Clear();
+
+ press1.latency()->AddLatencyNumberWithTimestamp(
+ ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, time_original, 1);
+
+ press1.latency()->AddLatencyNumberWithTimestamp(
+ ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0, time_ui, 1);
+
+ press1.latency()->AddLatencyNumberWithTimestamp(
+ ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0, time_acked, 1);
+
+ DispatchEventUsingWindowDispatcher(&press1);
+ EXPECT_TRUE(delegate->tap_down());
+
+ ui::LatencyInfo::LatencyComponent component;
+
+ EXPECT_EQ(3U, delegate->latency_info().latency_components.size());
+ ASSERT_TRUE(delegate->latency_info().FindLatency(
+ ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &component));
+ EXPECT_EQ(time_original, component.event_time);
+
+ ASSERT_TRUE(delegate->latency_info().FindLatency(
+ ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &component));
+ EXPECT_EQ(time_ui, component.event_time);
+
+ ASSERT_TRUE(delegate->latency_info().FindLatency(
+ ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, &component));
+ EXPECT_EQ(time_acked, component.event_time);
+
+ delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS);
+ EXPECT_TRUE(delegate->show_press());
+ EXPECT_EQ(0U, delegate->latency_info().latency_components.size());
+}
+
INSTANTIATE_TEST_CASE_P(GestureRecognizer,
GestureRecognizerTest,
::testing::Bool());
« no previous file with comments | « no previous file | ui/events/gestures/gesture_provider_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698