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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc

Issue 1408213002: Add hooks for flushing input from BeginFrame dispatch on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build for real Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture.h"
9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 base::Unretained(this))); 484 base::Unretained(this)));
485 } 485 }
486 486
487 void FlushInputUntilComplete() { 487 void FlushInputUntilComplete() {
488 while (target_->flush_requested()) { 488 while (target_->flush_requested()) {
489 while (target_->flush_requested()) { 489 while (target_->flush_requested()) {
490 target_->ClearFlushRequest(); 490 target_->ClearFlushRequest();
491 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); 491 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
492 controller_->Flush(time_); 492 controller_->Flush(time_);
493 } 493 }
494 controller_->OnDidFlushInput(); 494 controller_->OnDidFlushAllInput();
495 } 495 }
496 } 496 }
497 497
498 void OnSyntheticGestureCompleted(SyntheticGesture::Result result) { 498 void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {
499 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING); 499 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING);
500 if (result == SyntheticGesture::GESTURE_FINISHED) 500 if (result == SyntheticGesture::GESTURE_FINISHED)
501 num_success_++; 501 num_success_++;
502 else 502 else
503 num_failure_++; 503 num_failure_++;
504 } 504 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 QueueSyntheticGesture(gesture_2.Pass()); 618 QueueSyntheticGesture(gesture_2.Pass());
619 FlushInputUntilComplete(); 619 FlushInputUntilComplete();
620 620
621 EXPECT_TRUE(finished_1); 621 EXPECT_TRUE(finished_1);
622 EXPECT_TRUE(finished_2); 622 EXPECT_TRUE(finished_2);
623 623
624 EXPECT_EQ(2, num_success_); 624 EXPECT_EQ(2, num_success_);
625 EXPECT_EQ(0, num_failure_); 625 EXPECT_EQ(0, num_failure_);
626 } 626 }
627 627
628 TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) { 628 TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushAllInput) {
629 CreateControllerAndTarget<MockSyntheticGestureTarget>(); 629 CreateControllerAndTarget<MockSyntheticGestureTarget>();
630 630
631 bool finished_1, finished_2; 631 bool finished_1, finished_2;
632 scoped_ptr<MockSyntheticGesture> gesture_1( 632 scoped_ptr<MockSyntheticGesture> gesture_1(
633 new MockSyntheticGesture(&finished_1, 2)); 633 new MockSyntheticGesture(&finished_1, 2));
634 scoped_ptr<MockSyntheticGesture> gesture_2( 634 scoped_ptr<MockSyntheticGesture> gesture_2(
635 new MockSyntheticGesture(&finished_2, 4)); 635 new MockSyntheticGesture(&finished_2, 4));
636 636
637 QueueSyntheticGesture(gesture_1.Pass()); 637 QueueSyntheticGesture(gesture_1.Pass());
638 QueueSyntheticGesture(gesture_2.Pass()); 638 QueueSyntheticGesture(gesture_2.Pass());
639 639
640 while (target_->flush_requested()) { 640 while (target_->flush_requested()) {
641 target_->ClearFlushRequest(); 641 target_->ClearFlushRequest();
642 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); 642 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
643 controller_->Flush(time_); 643 controller_->Flush(time_);
644 } 644 }
645 EXPECT_EQ(0, num_success_); 645 EXPECT_EQ(0, num_success_);
646 controller_->OnDidFlushInput(); 646 controller_->OnDidFlushAllInput();
647 EXPECT_EQ(1, num_success_); 647 EXPECT_EQ(1, num_success_);
648 648
649 while (target_->flush_requested()) { 649 while (target_->flush_requested()) {
650 target_->ClearFlushRequest(); 650 target_->ClearFlushRequest();
651 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); 651 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
652 controller_->Flush(time_); 652 controller_->Flush(time_);
653 } 653 }
654 EXPECT_EQ(1, num_success_); 654 EXPECT_EQ(1, num_success_);
655 controller_->OnDidFlushInput(); 655 controller_->OnDidFlushAllInput();
656 EXPECT_EQ(2, num_success_); 656 EXPECT_EQ(2, num_success_);
657 } 657 }
658 658
659 gfx::Vector2d AddTouchSlopToVector(const gfx::Vector2dF& vector, 659 gfx::Vector2d AddTouchSlopToVector(const gfx::Vector2dF& vector,
660 SyntheticGestureTarget* target) { 660 SyntheticGestureTarget* target) {
661 const int kTouchSlop = target->GetTouchSlopInDips(); 661 const int kTouchSlop = target->GetTouchSlopInDips();
662 662
663 int x = vector.x(); 663 int x = vector.x();
664 if (x > 0) 664 if (x > 0)
665 x += kTouchSlop; 665 x += kTouchSlop;
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 EXPECT_TRUE(tap_target->GestureFinished()); 1416 EXPECT_TRUE(tap_target->GestureFinished());
1417 EXPECT_EQ(tap_target->position(), params.position); 1417 EXPECT_EQ(tap_target->position(), params.position);
1418 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 1418 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
1419 EXPECT_GE(GetTotalTime(), 1419 EXPECT_GE(GetTotalTime(),
1420 base::TimeDelta::FromMilliseconds(params.duration_ms)); 1420 base::TimeDelta::FromMilliseconds(params.duration_ms));
1421 } 1421 }
1422 1422
1423 } // namespace 1423 } // namespace
1424 1424
1425 } // namespace content 1425 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698