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

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

Issue 2633233002: Add the pointer type of pen to the synthetic WebMousEvent (Closed)
Patch Set: pen type Created 3 years, 11 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_pointer_action_unittest.cc
diff --git a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
index 46df157fc18487cf56c076f2bd7ca209aa1902d8..1b98d3c3cc007d9f785c4504cd13ab43eafc0aeb 100644
--- a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
@@ -171,7 +171,7 @@ class MockSyntheticPointerTouchActionTarget
class MockSyntheticPointerMouseActionTarget
: public MockSyntheticPointerActionTarget {
public:
- MockSyntheticPointerMouseActionTarget() {}
+ MockSyntheticPointerMouseActionTarget() : click_count_(0) {}
~MockSyntheticPointerMouseActionTarget() override {}
void DispatchInputEventToPlatform(const WebInputEvent& event) override {
@@ -179,13 +179,22 @@ class MockSyntheticPointerMouseActionTarget
const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
type_ = mouse_event.type();
position_ = gfx::PointF(mouse_event.x, mouse_event.y);
- clickCount_ = mouse_event.clickCount;
+ click_count_ = mouse_event.clickCount;
button_ = mouse_event.button;
}
testing::AssertionResult SyntheticMouseActionDispatchedCorrectly(
const SyntheticPointerActionParams& param,
- int click_count) {
+ int click_count,
+ SyntheticGestureParams::GestureSourceType source_type =
+ SyntheticGestureParams::MOUSE_INPUT) {
+ if (GetDefaultSyntheticGestureSourceType() != source_type) {
+ return testing::AssertionFailure()
+ << "Pointer source type was "
+ << int(GetDefaultSyntheticGestureSourceType()) << ", expected "
+ << int(source_type) << ".";
+ }
+
if (type_ != ToWebMouseEventType(param.pointer_action_type())) {
return testing::AssertionFailure()
<< "Pointer type was " << WebInputEvent::GetName(type_)
@@ -193,19 +202,19 @@ class MockSyntheticPointerMouseActionTarget
param.pointer_action_type())) << ".";
}
- if (clickCount_ != click_count) {
+ if (click_count_ != click_count) {
return testing::AssertionFailure() << "Pointer click count was "
- << clickCount_ << ", expected "
+ << click_count_ << ", expected "
<< click_count << ".";
}
- if (clickCount_ == 1 && button_ != WebMouseEvent::Button::Left) {
+ if (click_count_ == 1 && button_ != WebMouseEvent::Button::Left) {
return testing::AssertionFailure()
<< "Pointer button was " << (int)button_ << ", expected "
<< (int)WebMouseEvent::Button::Left << ".";
}
- if (clickCount_ == 0 && button_ != WebMouseEvent::Button::NoButton) {
+ if (click_count_ == 0 && button_ != WebMouseEvent::Button::NoButton) {
return testing::AssertionFailure()
<< "Pointer button was " << (int)button_ << ", expected "
<< (int)WebMouseEvent::Button::NoButton << ".";
@@ -230,10 +239,22 @@ class MockSyntheticPointerMouseActionTarget
private:
gfx::PointF position_;
- int clickCount_;
+ int click_count_;
WebMouseEvent::Button button_;
};
+class MockSyntheticPointerPenActionTarget
+ : public MockSyntheticPointerMouseActionTarget {
+ public:
+ MockSyntheticPointerPenActionTarget() {}
+ ~MockSyntheticPointerPenActionTarget() override {}
+
+ SyntheticGestureParams::GestureSourceType
+ GetDefaultSyntheticGestureSourceType() const override {
+ return SyntheticGestureParams::PEN_INPUT;
+ }
+};
+
class SyntheticPointerActionTest : public testing::Test {
public:
SyntheticPointerActionTest() {
@@ -557,6 +578,48 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
EXPECT_EQ(2, num_failure_);
}
+TEST_F(SyntheticPointerActionTest, PointerPenAction) {
+ CreateSyntheticPointerActionTarget<MockSyntheticPointerPenActionTarget>();
+
+ // Send a pen move.
+ SyntheticPointerActionParams param1 = SyntheticPointerActionParams(
+ SyntheticPointerActionParams::PointerActionType::MOVE);
+ param1.set_position(gfx::PointF(189, 62));
+ params_.PushPointerActionParams(param1);
+
+ // Send a pen down.
+ SyntheticPointerActionParams param2 = SyntheticPointerActionParams(
+ SyntheticPointerActionParams::PointerActionType::PRESS);
+ param2.set_position(gfx::PointF(189, 62));
+ params_.PushPointerActionParams(param2);
+
+ // Send a pen up.
+ SyntheticPointerActionParams param3 = SyntheticPointerActionParams(
+ SyntheticPointerActionParams::PointerActionType::RELEASE);
+ params_.PushPointerActionParams(param3);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+
+ ForwardSyntheticPointerAction();
+ MockSyntheticPointerPenActionTarget* pointer_pen_target =
+ static_cast<MockSyntheticPointerPenActionTarget*>(target_.get());
+ EXPECT_EQ(1, num_success_);
+ EXPECT_EQ(0, num_failure_);
+ EXPECT_TRUE(pointer_pen_target->SyntheticMouseActionDispatchedCorrectly(
+ param1, 0, SyntheticGestureParams::PEN_INPUT));
+
+ ForwardSyntheticPointerAction();
+ EXPECT_EQ(2, num_success_);
+ EXPECT_EQ(0, num_failure_);
+ EXPECT_TRUE(pointer_pen_target->SyntheticMouseActionDispatchedCorrectly(
+ param2, 1, SyntheticGestureParams::PEN_INPUT));
+
+ ForwardSyntheticPointerAction();
+ EXPECT_EQ(3, num_success_);
+ EXPECT_EQ(0, num_failure_);
+ EXPECT_TRUE(pointer_pen_target->SyntheticMouseActionDispatchedCorrectly(
+ param3, 1, SyntheticGestureParams::PEN_INPUT));
+}
+
} // namespace
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698