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

Side by Side 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 unified diff | Download patch
OLDNEW
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
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 TEST(WebCursorTest, WindowsCursorScaledAtHiDpi) {
282 gfx::Display display;
283 display.set_device_scale_factor(2.0f);
ananta 2015/12/15 23:28:17 It would be good to add more test cases like 1.25/
Bret 2015/12/16 19:03:59 Done.
284
285 WebCursor::CursorInfo info;
286 info.type = WebCursorInfo::TypeCustom;
287 info.hotspot = gfx::Point(4, 6);
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(8, windowsIconInfo.xHotspot);
302 EXPECT_EQ(12, windowsIconInfo.yHotspot);
303 }
304 #endif
305
260 } // namespace content 306 } // namespace content
OLDNEW
« content/common/cursors/webcursor_aurawin.cc ('K') | « content/common/cursors/webcursor_aurax11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698