Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if defined(OS_WIN) | |
| 6 #include <windows.h> | |
| 7 #endif | |
| 8 | |
| 5 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 6 #include "content/common/cursors/webcursor.h" | 10 #include "content/common/cursors/webcursor.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 12 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 9 | 13 |
| 10 using blink::WebCursorInfo; | 14 using blink::WebCursorInfo; |
| 11 | 15 |
| 12 namespace content { | 16 namespace content { |
| 13 | 17 |
| 14 TEST(WebCursorTest, OKCursorSerialization) { | 18 TEST(WebCursorTest, OKCursorSerialization) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 custom_cursor_copy.GetCursorInfo(&cursor_info); | 254 custom_cursor_copy.GetCursorInfo(&cursor_info); |
| 251 { | 255 { |
| 252 SkAutoLockPixels lock(cursor_info.custom_image); | 256 SkAutoLockPixels lock(cursor_info.custom_image); |
| 253 EXPECT_EQ(kUnpremul_SkAlphaType, cursor_info.custom_image.alphaType()); | 257 EXPECT_EQ(kUnpremul_SkAlphaType, cursor_info.custom_image.alphaType()); |
| 254 EXPECT_EQ(testColor, | 258 EXPECT_EQ(testColor, |
| 255 SkPreMultiplyColor(*cursor_info.custom_image.getAddr32(0,0))); | 259 SkPreMultiplyColor(*cursor_info.custom_image.getAddr32(0,0))); |
| 256 } | 260 } |
| 257 #endif | 261 #endif |
| 258 } | 262 } |
| 259 | 263 |
| 264 #if defined(USE_AURA) | |
| 265 TEST(WebCursorTest, CursorScaleFactor) { | |
| 266 gfx::Display display; | |
| 267 display.set_device_scale_factor(80.2f); | |
| 268 | |
| 269 WebCursor::CursorInfo info; | |
| 270 info.image_scale_factor = 2.0f; | |
| 271 | |
| 272 WebCursor cursor; | |
| 273 cursor.InitFromCursorInfo(info); | |
| 274 cursor.SetDisplayInfo(display); | |
| 275 | |
| 276 EXPECT_EQ(40.1f, cursor.GetCursorScaleFactor()); | |
| 277 } | |
| 278 #endif | |
| 279 | |
| 280 #if defined(OS_WIN) | |
| 281 void ScaleCursor(float scaleFactor, int hotspotX, int hotspotY) { | |
| 282 gfx::Display display; | |
| 283 display.set_device_scale_factor(scaleFactor); | |
| 284 | |
| 285 WebCursor::CursorInfo info; | |
| 286 info.type = WebCursorInfo::TypeCustom; | |
| 287 info.hotspot = gfx::Point(hotspotX, hotspotY); | |
| 288 | |
| 289 info.custom_image = SkBitmap(); | |
| 290 info.custom_image.allocN32Pixels(10, 10); | |
| 291 | |
| 292 WebCursor cursor; | |
| 293 cursor.SetDisplayInfo(display); | |
| 294 cursor.InitFromCursorInfo(info); | |
| 295 | |
| 296 HCURSOR windowsCursorHandle = cursor.GetPlatformCursor(); | |
| 297 EXPECT_NE(nullptr, windowsCursorHandle); | |
| 298 ICONINFO windowsIconInfo; | |
| 299 EXPECT_TRUE(GetIconInfo(windowsCursorHandle, &windowsIconInfo)); | |
| 300 EXPECT_FALSE(windowsIconInfo.fIcon); | |
| 301 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
| |
| 302 EXPECT_EQ(static_cast<int>(scaleFactor * hotspotY), windowsIconInfo.yHotspot); | |
| 303 } | |
| 304 | |
| 305 TEST(WebCursorTest, WindowsCursorScaledAtHiDpi) { | |
| 306 ScaleCursor(2.0f, 4, 6); | |
| 307 ScaleCursor(1.5f, 2, 8); | |
| 308 ScaleCursor(1.25f, 3, 7); | |
| 309 } | |
| 310 #endif | |
| 311 | |
| 260 } // namespace content | 312 } // namespace content |
| OLD | NEW |