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..008a8d8c1504e8dc134ef70197e3f891ca77f334 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 initialX, int initialY) { |
|
ananta
2015/12/16 20:47:54
Please rename these to hotspot_x or something on t
Bret
2015/12/16 22:27:51
Done.
|
| + gfx::Display display; |
| + display.set_device_scale_factor(scaleFactor); |
| + |
| + WebCursor::CursorInfo info; |
| + info.type = WebCursorInfo::TypeCustom; |
| + info.hotspot = gfx::Point(initialX, initialY); |
| + |
| + 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 * initialX), windowsIconInfo.xHotspot); |
| + EXPECT_EQ(static_cast<int>(scaleFactor * initialY), windowsIconInfo.yHotspot); |
| +} |
| + |
| +TEST(WebCursorTest, WindowsCursorScaledAtHiDpi) { |
| + ScaleCursor(2.0f, 4, 6); |
| + ScaleCursor(1.5f, 2, 8); |
| + ScaleCursor(1.25f, 3, 7); |
| +} |
| +#endif |
| + |
| } // namespace content |