Chromium Code Reviews| 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 |