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

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

Issue 62443007: Replace old with new synthetic gesture framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: opt_mouse_move_event_x/y -> opt_start_x/y Created 7 years, 1 month 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_new_unittest.cc b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
similarity index 86%
rename from content/browser/renderer_host/input/synthetic_gesture_controller_new_unittest.cc
rename to content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
index 1d367f20a6710dbb3faccbae90c46a0d191f9fa5..03965693cc93847787589c5f4b2ec3e7b334cd82 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_controller_new_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
@@ -4,11 +4,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
-#include "content/browser/renderer_host/input/synthetic_gesture_controller_new.h"
-#include "content/browser/renderer_host/input/synthetic_gesture_new.h"
+#include "content/browser/renderer_host/input/synthetic_gesture.h"
+#include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
-#include "content/browser/renderer_host/input/synthetic_pinch_gesture_new.h"
-#include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture_new.h"
+#include "content/browser/renderer_host/input/synthetic_pinch_gesture.h"
+#include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/common/input/input_event.h"
@@ -25,7 +25,7 @@ namespace {
const int kFlushInputRateInMs = 16;
-class MockSyntheticGesture : public SyntheticGestureNew {
+class MockSyntheticGesture : public SyntheticGesture {
public:
MockSyntheticGesture(bool* finished, int num_steps)
: finished_(finished),
@@ -40,14 +40,14 @@ class MockSyntheticGesture : public SyntheticGestureNew {
step_count_++;
if (step_count_ == num_steps_) {
*finished_ = true;
- return SyntheticGestureNew::GESTURE_FINISHED;
+ return SyntheticGesture::GESTURE_FINISHED;
} else if (step_count_ > num_steps_) {
*finished_ = true;
// Return arbitrary failure.
- return SyntheticGestureNew::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED;
- } else {
- return SyntheticGestureNew::GESTURE_RUNNING;
+ return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED;
}
+
+ return SyntheticGesture::GESTURE_RUNNING;
}
protected:
@@ -68,9 +68,9 @@ class MockSyntheticGestureTarget : public SyntheticGestureTarget {
virtual void DispatchInputEventToPlatform(const InputEvent& event) OVERRIDE {}
virtual void OnSyntheticGestureCompleted(
- SyntheticGestureNew::Result result) OVERRIDE {
- DCHECK_NE(result, SyntheticGestureNew::GESTURE_RUNNING);
- if (result == SyntheticGestureNew::GESTURE_FINISHED)
+ SyntheticGesture::Result result) OVERRIDE {
+ DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING);
+ if (result == SyntheticGesture::GESTURE_FINISHED)
num_success_++;
else
num_failure_++;
@@ -110,10 +110,10 @@ class MockSyntheticSmoothScrollMouseTarget : public MockSyntheticGestureTarget {
virtual void DispatchInputEventToPlatform(const InputEvent& event) OVERRIDE {
const blink::WebInputEvent* web_event = event.web_event.get();
- DCHECK_EQ(web_event->type, blink::WebInputEvent::MouseWheel);
+ ASSERT_EQ(web_event->type, blink::WebInputEvent::MouseWheel);
const blink::WebMouseWheelEvent* mouse_wheel_event =
static_cast<const blink::WebMouseWheelEvent*>(web_event);
- DCHECK_EQ(mouse_wheel_event->deltaX, 0);
+ ASSERT_EQ(mouse_wheel_event->deltaX, 0);
scroll_distance_ -= mouse_wheel_event->deltaY;
}
@@ -223,6 +223,7 @@ class MockSyntheticPinchTouchTarget : public MockSyntheticGestureTarget {
return last_pointer_distance < current_pointer_distance ? ZOOM_IN
: ZOOM_OUT;
}
+
float total_num_pixels_covered_;
float last_pointer_distance_;
ZoomDirection zoom_direction_;
@@ -231,17 +232,17 @@ class MockSyntheticPinchTouchTarget : public MockSyntheticGestureTarget {
bool started_;
};
-class SyntheticGestureControllerNewTest : public testing::Test {
+class SyntheticGestureControllerTest : public testing::Test {
public:
- SyntheticGestureControllerNewTest() {}
- virtual ~SyntheticGestureControllerNewTest() {}
+ SyntheticGestureControllerTest() {}
+ virtual ~SyntheticGestureControllerTest() {}
protected:
template<typename MockGestureTarget>
void CreateControllerAndTarget() {
target_ = new MockGestureTarget();
- controller_.reset(new SyntheticGestureControllerNew(
+ controller_.reset(new SyntheticGestureController(
scoped_ptr<SyntheticGestureTarget>(target_)));
}
@@ -264,17 +265,17 @@ class SyntheticGestureControllerNewTest : public testing::Test {
}
MockSyntheticGestureTarget* target_;
- scoped_ptr<SyntheticGestureControllerNew> controller_;
+ scoped_ptr<SyntheticGestureController> controller_;
base::TimeTicks time_;
};
-TEST_F(SyntheticGestureControllerNewTest, SingleGesture) {
+TEST_F(SyntheticGestureControllerTest, SingleGesture) {
CreateControllerAndTarget<MockSyntheticGestureTarget>();
bool finished;
scoped_ptr<MockSyntheticGesture> gesture(
new MockSyntheticGesture(&finished, 3));
- controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>());
+ controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_TRUE(finished);
@@ -282,13 +283,13 @@ TEST_F(SyntheticGestureControllerNewTest, SingleGesture) {
EXPECT_EQ(0, target_->num_failure());
}
-TEST_F(SyntheticGestureControllerNewTest, GestureFailed) {
+TEST_F(SyntheticGestureControllerTest, GestureFailed) {
CreateControllerAndTarget<MockSyntheticGestureTarget>();
bool finished;
scoped_ptr<MockSyntheticGesture> gesture(
new MockSyntheticGesture(&finished, 0));
- controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>());
+ controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_TRUE(finished);
@@ -296,7 +297,7 @@ TEST_F(SyntheticGestureControllerNewTest, GestureFailed) {
EXPECT_EQ(0, target_->num_success());
}
-TEST_F(SyntheticGestureControllerNewTest, SuccessiveGestures) {
+TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) {
CreateControllerAndTarget<MockSyntheticGestureTarget>();
bool finished_1, finished_2;
@@ -306,7 +307,7 @@ TEST_F(SyntheticGestureControllerNewTest, SuccessiveGestures) {
new MockSyntheticGesture(&finished_2, 4));
// Queue first gesture and wait for it to finish
- controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGestureNew>());
+ controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_TRUE(finished_1);
@@ -314,7 +315,7 @@ TEST_F(SyntheticGestureControllerNewTest, SuccessiveGestures) {
EXPECT_EQ(0, target_->num_failure());
// Queue second gesture.
- controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGestureNew>());
+ controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_TRUE(finished_2);
@@ -322,7 +323,7 @@ TEST_F(SyntheticGestureControllerNewTest, SuccessiveGestures) {
EXPECT_EQ(0, target_->num_failure());
}
-TEST_F(SyntheticGestureControllerNewTest, TwoGesturesInFlight) {
+TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) {
CreateControllerAndTarget<MockSyntheticGestureTarget>();
bool finished_1, finished_2;
@@ -331,8 +332,8 @@ TEST_F(SyntheticGestureControllerNewTest, TwoGesturesInFlight) {
scoped_ptr<MockSyntheticGesture> gesture_2(
new MockSyntheticGesture(&finished_2, 4));
- controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGestureNew>());
- controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGestureNew>());
+ controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>());
+ controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_TRUE(finished_1);
@@ -342,16 +343,16 @@ TEST_F(SyntheticGestureControllerNewTest, TwoGesturesInFlight) {
EXPECT_EQ(0, target_->num_failure());
}
-TEST_F(SyntheticGestureControllerNewTest, SmoothScrollGestureTouch) {
+TEST_F(SyntheticGestureControllerTest, SmoothScrollGestureTouch) {
CreateControllerAndTarget<MockSyntheticSmoothScrollTouchTarget>();
SyntheticSmoothScrollGestureParams params;
params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
params.distance = 100;
- scoped_ptr<SyntheticSmoothScrollGestureNew> gesture(
- new SyntheticSmoothScrollGestureNew(params));
- controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>());
+ scoped_ptr<SyntheticSmoothScrollGesture> gesture(
+ new SyntheticSmoothScrollGesture(params));
+ controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_EQ(1, target_->num_success());
@@ -360,16 +361,16 @@ TEST_F(SyntheticGestureControllerNewTest, SmoothScrollGestureTouch) {
target_)->scroll_distance());
}
-TEST_F(SyntheticGestureControllerNewTest, SmoothScrollGestureMouse) {
+TEST_F(SyntheticGestureControllerTest, SmoothScrollGestureMouse) {
CreateControllerAndTarget<MockSyntheticSmoothScrollMouseTarget>();
SyntheticSmoothScrollGestureParams params;
params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
params.distance = -100;
- scoped_ptr<SyntheticSmoothScrollGestureNew> gesture(
- new SyntheticSmoothScrollGestureNew(params));
- controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>());
+ scoped_ptr<SyntheticSmoothScrollGesture> gesture(
+ new SyntheticSmoothScrollGesture(params));
+ controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_EQ(1, target_->num_success());
@@ -378,7 +379,7 @@ TEST_F(SyntheticGestureControllerNewTest, SmoothScrollGestureMouse) {
target_)->scroll_distance());
}
-TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomIn) {
+TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomIn) {
CreateControllerAndTarget<MockSyntheticPinchTouchTarget>();
SyntheticPinchGestureParams params;
@@ -386,9 +387,9 @@ TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomIn) {
params.zoom_in = true;
params.total_num_pixels_covered = 100;
- scoped_ptr<SyntheticPinchGestureNew> gesture(
- new SyntheticPinchGestureNew(params));
- controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>());
+ scoped_ptr<SyntheticPinchGesture> gesture(
+ new SyntheticPinchGesture(params));
+ controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_EQ(1, target_->num_success());
@@ -402,7 +403,7 @@ TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomIn) {
->total_num_pixels_covered());
}
-TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomOut) {
+TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomOut) {
CreateControllerAndTarget<MockSyntheticPinchTouchTarget>();
SyntheticPinchGestureParams params;
@@ -410,9 +411,9 @@ TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomOut) {
params.zoom_in = false;
params.total_num_pixels_covered = 100;
- scoped_ptr<SyntheticPinchGestureNew> gesture(
- new SyntheticPinchGestureNew(params));
- controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>());
+ scoped_ptr<SyntheticPinchGesture> gesture(
+ new SyntheticPinchGesture(params));
+ controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>());
FlushInputUntilComplete();
EXPECT_EQ(1, target_->num_success());

Powered by Google App Engine
This is Rietveld 408576698