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

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

Issue 2886263002: input: Dispatch synthesized events at regular intervals. (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
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3ebe91678954095f4d0d8cd90f58a201218bcfde..4483b3631c98f8fd5f22ace9d1bf2e260b55a4c2 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
@@ -11,6 +11,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/test/scoped_task_environment.h"
#include "base/time/time.h"
#include "content/browser/renderer_host/input/synthetic_gesture.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
@@ -675,6 +676,8 @@ class DummySyntheticGestureControllerDelegate
DISALLOW_COPY_AND_ASSIGN(DummySyntheticGestureControllerDelegate);
};
+} // namespace
+
class SyntheticGestureControllerTestBase {
public:
SyntheticGestureControllerTestBase() {}
@@ -697,9 +700,15 @@ class SyntheticGestureControllerTestBase {
}
void FlushInputUntilComplete() {
+ // Start and stop the timer explicitly here, since the test does not need to
+ // wait for begin-frame to start the timer.
+ controller_->dispatch_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(1),
+ base::Bind(&base::DoNothing));
do
time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
while (controller_->DispatchNextEvent(time_));
+ controller_->dispatch_timer_.Stop();
}
void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {
@@ -712,6 +721,7 @@ class SyntheticGestureControllerTestBase {
base::TimeDelta GetTotalTime() const { return time_ - start_time_; }
+ base::test::ScopedTaskEnvironment env_;
MockSyntheticGestureTarget* target_;
DummySyntheticGestureControllerDelegate delegate_;
std::unique_ptr<SyntheticGestureController> controller_;
@@ -845,9 +855,7 @@ TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) {
QueueSyntheticGesture(std::move(gesture_1));
QueueSyntheticGesture(std::move(gesture_2));
- do {
- time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
- } while (controller_->DispatchNextEvent(time_));
+ FlushInputUntilComplete();
EXPECT_EQ(2, num_success_);
}
@@ -1761,6 +1769,4 @@ TEST_F(SyntheticGestureControllerTest, PointerMouseAction) {
pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1));
}
-} // namespace
-
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698