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

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 393953012: Eager Gesture Recognition on Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests. Created 6 years, 5 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 | Annotate | Revision Log
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 virtual ~QueueTouchEventDelegate() { 343 virtual ~QueueTouchEventDelegate() {
344 while(!queue_.empty()) { 344 while(!queue_.empty()) {
345 delete queue_.front(); 345 delete queue_.front();
346 queue_.pop(); 346 queue_.pop();
347 } 347 }
348 } 348 }
349 349
350 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { 350 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
351 if (queue_events_) { 351 if (queue_events_) {
352 if (event->IsTouchEvent())
353 dispatcher_->OnForwardingTouchEvent(event, window_);
354
352 queue_.push(new ui::TouchEvent(*event, window_, window_)); 355 queue_.push(new ui::TouchEvent(*event, window_, window_));
353 event->StopPropagation(); 356 event->StopPropagation();
354 } 357 }
355 } 358 }
356 359
357 void ReceivedAck() { 360 void ReceivedAck() {
358 ReceivedAckImpl(false); 361 ReceivedAckImpl(false);
359 } 362 }
360 363
361 void ReceivedAckPreventDefaulted() { 364 void ReceivedAckPreventDefaulted() {
(...skipping 4057 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 kTouchId, 4422 kTouchId,
4420 ui::EventTimeForNow()); 4423 ui::EventTimeForNow());
4421 DispatchEventUsingWindowDispatcher(&press1); 4424 DispatchEventUsingWindowDispatcher(&press1);
4422 EXPECT_TRUE(window != NULL); 4425 EXPECT_TRUE(window != NULL);
4423 4426
4424 // Wait until the timer runs out. 4427 // Wait until the timer runs out.
4425 delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 4428 delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
4426 EXPECT_EQ(NULL, window); 4429 EXPECT_EQ(NULL, window);
4427 } 4430 }
4428 4431
4432 TEST_P(GestureRecognizerTest, EagerGestureDetection) {
4433 if (!UsingUnifiedGR())
4434 return;
4435
4436 scoped_ptr<QueueTouchEventDelegate> delegate(
4437 new QueueTouchEventDelegate(host()->dispatcher()));
4438 TimedEvents tes;
4439 const int kTouchId = 2;
4440 gfx::Rect bounds(100, 200, 100, 100);
4441 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4442 delegate.get(), -1234, bounds, root_window()));
4443 delegate->set_window(window.get());
4444
4445 delegate->Reset();
4446 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
4447 kTouchId, tes.Now());
4448 DispatchEventUsingWindowDispatcher(&press);
4449 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
4450 kTouchId, tes.LeapForward(50));
4451 DispatchEventUsingWindowDispatcher(&release);
4452
4453 delegate->Reset();
4454 delegate->ReceivedAck();
4455 EXPECT_TRUE(delegate->tap_down());
4456
4457 delegate->Reset();
4458 base::MessageLoop::current()->PostDelayedTask(
4459 FROM_HERE,
4460 base::MessageLoop::QuitClosure(),
4461 base::TimeDelta::FromSecondsD(
4462 ui::GestureConfiguration::long_press_time_in_seconds() * 1.1));
4463 base::MessageLoop::current()->Run();
4464
4465 delegate->ReceivedAck();
4466 EXPECT_TRUE(delegate->tap());
4467 EXPECT_FALSE(delegate->long_press());
4468 }
4469
4429 INSTANTIATE_TEST_CASE_P(GestureRecognizer, 4470 INSTANTIATE_TEST_CASE_P(GestureRecognizer,
4430 GestureRecognizerTest, 4471 GestureRecognizerTest,
4431 ::testing::Bool()); 4472 ::testing::Bool());
4432 4473
4433 } // namespace test 4474 } // namespace test
4434 } // namespace aura 4475 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698