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

Unified Diff: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc

Issue 2856423002: input: Change how synthesized events are dispatched in telemetry tests. (Closed)
Patch Set: . Created 3 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
Index: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
index 4aa4ada768374d2f19a973aa13ff4d0824656afc..95d4ee1c377b8c49c1a915196e7c40b7e9f980d0 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
@@ -135,8 +135,6 @@ class MockSyntheticGestureTarget : public SyntheticGestureTarget {
// SyntheticGestureTarget:
void DispatchInputEventToPlatform(const WebInputEvent& event) override {}
- void SetNeedsFlush() override { flush_requested_ = true; }
-
SyntheticGestureParams::GestureSourceType
GetDefaultSyntheticGestureSourceType() const override {
return SyntheticGestureParams::TOUCH_INPUT;
@@ -671,8 +669,9 @@ class SyntheticGestureControllerTestBase {
template<typename MockGestureTarget>
void CreateControllerAndTarget() {
target_ = new MockGestureTarget();
- controller_.reset(new SyntheticGestureController(
- std::unique_ptr<SyntheticGestureTarget>(target_)));
+ controller_ = base::MakeUnique<SyntheticGestureController>(
+ std::unique_ptr<SyntheticGestureTarget>(target_),
+ base::Bind([](base::OnceClosure callback) {}));
}
void QueueSyntheticGesture(std::unique_ptr<SyntheticGesture> gesture) {
@@ -684,14 +683,9 @@ class SyntheticGestureControllerTestBase {
}
void FlushInputUntilComplete() {
- while (target_->flush_requested()) {
- while (target_->flush_requested()) {
- target_->ClearFlushRequest();
- time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
- controller_->Flush(time_);
- }
- controller_->OnDidFlushInput();
- }
+ do
+ time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
+ while (controller_->DispatchNextEvent(time_));
}
void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {
@@ -836,22 +830,9 @@ TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) {
QueueSyntheticGesture(std::move(gesture_1));
QueueSyntheticGesture(std::move(gesture_2));
- while (target_->flush_requested()) {
- target_->ClearFlushRequest();
- time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
- controller_->Flush(time_);
- }
- EXPECT_EQ(0, num_success_);
- controller_->OnDidFlushInput();
- EXPECT_EQ(1, num_success_);
-
- while (target_->flush_requested()) {
- target_->ClearFlushRequest();
+ do {
time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
- controller_->Flush(time_);
- }
- EXPECT_EQ(1, num_success_);
- controller_->OnDidFlushInput();
+ } while (controller_->DispatchNextEvent(time_));
EXPECT_EQ(2, num_success_);
}

Powered by Google App Engine
This is Rietveld 408576698