Commit 01924fbe authored by tdresser@chromium.org's avatar tdresser@chromium.org

Pass ui::LatencyInfo correct with unified gesture detector on Aura.

BUG=379812
TEST=GestureRecognizerTest.LatencyPassedFromTouchEvent

Review URL: https://codereview.chromium.org/309823002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274602 0039d316-1c4b-4281-b951-d872f2087c98
parent 772618e0
...@@ -138,6 +138,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { ...@@ -138,6 +138,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
tap_count_ = 0; tap_count_ = 0;
scale_ = 0; scale_ = 0;
flags_ = 0; flags_ = 0;
latency_info_.Clear();
} }
const std::vector<ui::EventType>& events() const { return events_; }; const std::vector<ui::EventType>& events() const { return events_; };
...@@ -187,6 +188,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { ...@@ -187,6 +188,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
const gfx::Rect& bounding_box() const { return bounding_box_; } const gfx::Rect& bounding_box() const { return bounding_box_; }
int tap_count() const { return tap_count_; } int tap_count() const { return tap_count_; }
int flags() const { return flags_; } int flags() const { return flags_; }
const ui::LatencyInfo& latency_info() const { return latency_info_; }
void WaitUntilReceivedGesture(ui::EventType type) { void WaitUntilReceivedGesture(ui::EventType type) {
wait_until_event_ = type; wait_until_event_ = type;
...@@ -198,6 +200,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { ...@@ -198,6 +200,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
events_.push_back(gesture->type()); events_.push_back(gesture->type());
bounding_box_ = gesture->details().bounding_box(); bounding_box_ = gesture->details().bounding_box();
flags_ = gesture->flags(); flags_ = gesture->flags();
latency_info_ = *gesture->latency();
switch (gesture->type()) { switch (gesture->type()) {
case ui::ET_GESTURE_TAP: case ui::ET_GESTURE_TAP:
tap_location_ = gesture->location(); tap_location_ = gesture->location();
...@@ -322,6 +325,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { ...@@ -322,6 +325,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
gfx::Rect bounding_box_; gfx::Rect bounding_box_;
int tap_count_; int tap_count_;
int flags_; int flags_;
ui::LatencyInfo latency_info_;
ui::EventType wait_until_event_; ui::EventType wait_until_event_;
...@@ -4270,6 +4274,63 @@ TEST_P(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) { ...@@ -4270,6 +4274,63 @@ TEST_P(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
EXPECT_NE(default_flags, delegate->flags()); 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, INSTANTIATE_TEST_CASE_P(GestureRecognizer,
GestureRecognizerTest, GestureRecognizerTest,
::testing::Bool()); ::testing::Bool());
......
...@@ -23,7 +23,6 @@ GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) ...@@ -23,7 +23,6 @@ GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client)
GestureProviderAura::~GestureProviderAura() {} GestureProviderAura::~GestureProviderAura() {}
bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) {
last_touch_event_flags_ = event.flags();
bool pointer_id_is_active = false; bool pointer_id_is_active = false;
for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) { for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) {
if (event.touch_id() != pointer_state_.GetPointerId(i)) if (event.touch_id() != pointer_state_.GetPointerId(i))
...@@ -42,6 +41,8 @@ bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { ...@@ -42,6 +41,8 @@ bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) {
return false; return false;
} }
last_touch_event_flags_ = event.flags();
last_touch_event_latency_info_ = *event.latency();
pointer_state_.OnTouch(event); pointer_state_.OnTouch(event);
bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
...@@ -54,6 +55,7 @@ void GestureProviderAura::OnTouchEventAck(bool event_consumed) { ...@@ -54,6 +55,7 @@ void GestureProviderAura::OnTouchEventAck(bool event_consumed) {
DCHECK(!handling_event_); DCHECK(!handling_event_);
base::AutoReset<bool> handling_event(&handling_event_, true); base::AutoReset<bool> handling_event(&handling_event_, true);
filtered_gesture_provider_.OnTouchEventAck(event_consumed); filtered_gesture_provider_.OnTouchEventAck(event_consumed);
last_touch_event_latency_info_.Clear();
} }
void GestureProviderAura::OnGestureEvent( void GestureProviderAura::OnGestureEvent(
...@@ -87,6 +89,19 @@ void GestureProviderAura::OnGestureEvent( ...@@ -87,6 +89,19 @@ void GestureProviderAura::OnGestureEvent(
// be cleaned up. See crbug.com/366707. // be cleaned up. See crbug.com/366707.
1 << gesture.motion_event_id)); 1 << gesture.motion_event_id));
ui::LatencyInfo* gesture_latency = event->latency();
gesture_latency->CopyLatencyFrom(
last_touch_event_latency_info_,
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
gesture_latency->CopyLatencyFrom(
last_touch_event_latency_info_,
ui::INPUT_EVENT_LATENCY_UI_COMPONENT);
gesture_latency->CopyLatencyFrom(
last_touch_event_latency_info_,
ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT);
if (!handling_event_) { if (!handling_event_) {
// Dispatching event caused by timer. // Dispatching event caused by timer.
client_->OnGestureEvent(event.get()); client_->OnGestureEvent(event.get());
......
...@@ -47,6 +47,7 @@ class EVENTS_EXPORT GestureProviderAura : public GestureProviderClient { ...@@ -47,6 +47,7 @@ class EVENTS_EXPORT GestureProviderAura : public GestureProviderClient {
FilteredGestureProvider filtered_gesture_provider_; FilteredGestureProvider filtered_gesture_provider_;
int last_touch_event_flags_; int last_touch_event_flags_;
ui::LatencyInfo last_touch_event_latency_info_;
bool handling_event_; bool handling_event_;
ScopedVector<GestureEvent> pending_gestures_; ScopedVector<GestureEvent> pending_gestures_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment