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

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

Issue 2551573002: [Touch emulator] Update cursor when device scale factor changes. (Closed)
Patch Set: nit Created 4 years 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/touch_emulator_unittest.cc
diff --git a/content/browser/renderer_host/input/touch_emulator_unittest.cc b/content/browser/renderer_host/input/touch_emulator_unittest.cc
index 3d53db1ff40584a816114b7772441c89334399e9..600badd5bcb77f3cb654baabda7f6935e6a660d3 100644
--- a/content/browser/renderer_host/input/touch_emulator_unittest.cc
+++ b/content/browser/renderer_host/input/touch_emulator_unittest.cc
@@ -77,7 +77,9 @@ class TouchEmulatorTest : public testing::Test,
}
}
- void SetCursor(const WebCursor& cursor) override {}
+ void SetCursor(const WebCursor& cursor) override {
+ cursor_ = cursor;
+ }
void ShowContextMenuAtPoint(const gfx::Point& point) override {}
@@ -241,6 +243,12 @@ class TouchEmulatorTest : public testing::Test,
void DisableSynchronousTouchAck() { ack_touches_synchronously_ = false; }
+ float GetCursorScaleFactor() {
+ WebCursor::CursorInfo info;
+ cursor_.GetCursorInfo(&info);
+ return info.image_scale_factor;
+ }
+
private:
std::unique_ptr<TouchEmulator> emulator_;
std::vector<WebInputEvent::Type> forwarded_events_;
@@ -253,6 +261,7 @@ class TouchEmulatorTest : public testing::Test,
int last_mouse_y_;
std::vector<WebTouchEvent> touch_events_to_ack_;
base::MessageLoopForUI message_loop_;
+ WebCursor cursor_;
};
@@ -569,4 +578,25 @@ TEST_F(TouchEmulatorTest, ConstructorWithHighDeviceScaleDoesNotCrash) {
TouchEmulator(this, 4.0f);
}
+TEST_F(TouchEmulatorTest, CursorScaleFactor) {
+ EXPECT_EQ(1.0f, GetCursorScaleFactor());
+ emulator()->SetDeviceScaleFactor(3.0f);
+ EXPECT_EQ(2.0f, GetCursorScaleFactor());
+ emulator()->SetDeviceScaleFactor(1.33f);
+ EXPECT_EQ(1.0f, GetCursorScaleFactor());
+ emulator()->Disable();
+ EXPECT_EQ(1.0f, GetCursorScaleFactor());
+ emulator()->SetDeviceScaleFactor(3.0f);
+ EXPECT_EQ(1.0f, GetCursorScaleFactor());
+ emulator()->Enable(ui::GestureProviderConfigType::GENERIC_MOBILE);
+ EXPECT_EQ(2.0f, GetCursorScaleFactor());
+ emulator()->SetDeviceScaleFactor(1.0f);
+ EXPECT_EQ(1.0f, GetCursorScaleFactor());
+
+ TouchEmulator another(this, 4.0f);
+ EXPECT_EQ(1.0f, GetCursorScaleFactor());
+ another.Enable(ui::GestureProviderConfigType::GENERIC_MOBILE);
+ EXPECT_EQ(2.0f, GetCursorScaleFactor());
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/touch_emulator.cc ('k') | content/browser/renderer_host/render_widget_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698