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

Unified Diff: content/common/cursors/webcursor_unittest.cc

Issue 1525263004: hidpi support for custom cursors in windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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
« no previous file with comments | « content/common/cursors/webcursor_aurax11.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/cursors/webcursor_unittest.cc
diff --git a/content/common/cursors/webcursor_unittest.cc b/content/common/cursors/webcursor_unittest.cc
index 25c236a459994d134a57bf138789b735838ac03b..1835423eed8399cbcb8e3e45ef8ad3018feb0145 100644
--- a/content/common/cursors/webcursor_unittest.cc
+++ b/content/common/cursors/webcursor_unittest.cc
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
#include "base/pickle.h"
#include "content/common/cursors/webcursor.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -257,4 +261,52 @@ TEST(WebCursorTest, AlphaConversion) {
#endif
}
+#if defined(USE_AURA)
+TEST(WebCursorTest, CursorScaleFactor) {
+ gfx::Display display;
+ display.set_device_scale_factor(80.2f);
+
+ WebCursor::CursorInfo info;
+ info.image_scale_factor = 2.0f;
+
+ WebCursor cursor;
+ cursor.InitFromCursorInfo(info);
+ cursor.SetDisplayInfo(display);
+
+ EXPECT_EQ(40.1f, cursor.GetCursorScaleFactor());
+}
+#endif
+
+#if defined(OS_WIN)
+void ScaleCursor(float scaleFactor, int hotspotX, int hotspotY) {
+ gfx::Display display;
+ display.set_device_scale_factor(scaleFactor);
+
+ WebCursor::CursorInfo info;
+ info.type = WebCursorInfo::TypeCustom;
+ info.hotspot = gfx::Point(hotspotX, hotspotY);
+
+ info.custom_image = SkBitmap();
+ info.custom_image.allocN32Pixels(10, 10);
+
+ WebCursor cursor;
+ cursor.SetDisplayInfo(display);
+ cursor.InitFromCursorInfo(info);
+
+ HCURSOR windowsCursorHandle = cursor.GetPlatformCursor();
+ EXPECT_NE(nullptr, windowsCursorHandle);
+ ICONINFO windowsIconInfo;
+ EXPECT_TRUE(GetIconInfo(windowsCursorHandle, &windowsIconInfo));
+ EXPECT_FALSE(windowsIconInfo.fIcon);
+ EXPECT_EQ(static_cast<int>(scaleFactor * hotspotX), windowsIconInfo.xHotspot);
Nico 2015/12/17 12:04:16 Does this intentionally not round? For the third c
+ EXPECT_EQ(static_cast<int>(scaleFactor * hotspotY), windowsIconInfo.yHotspot);
+}
+
+TEST(WebCursorTest, WindowsCursorScaledAtHiDpi) {
+ ScaleCursor(2.0f, 4, 6);
+ ScaleCursor(1.5f, 2, 8);
+ ScaleCursor(1.25f, 3, 7);
+}
+#endif
+
} // namespace content
« no previous file with comments | « content/common/cursors/webcursor_aurax11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698