| 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/common/cursors/webcursor.h" | 9 #include "content/common/cursors/webcursor.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SkAutoLockPixels lock(cursor_info.custom_image); | 260 SkAutoLockPixels lock(cursor_info.custom_image); |
| 261 EXPECT_EQ(kUnpremul_SkAlphaType, cursor_info.custom_image.alphaType()); | 261 EXPECT_EQ(kUnpremul_SkAlphaType, cursor_info.custom_image.alphaType()); |
| 262 EXPECT_EQ(testColor, | 262 EXPECT_EQ(testColor, |
| 263 SkPreMultiplyColor(*cursor_info.custom_image.getAddr32(0,0))); | 263 SkPreMultiplyColor(*cursor_info.custom_image.getAddr32(0,0))); |
| 264 } | 264 } |
| 265 #endif | 265 #endif |
| 266 } | 266 } |
| 267 | 267 |
| 268 #if defined(USE_AURA) | 268 #if defined(USE_AURA) |
| 269 TEST(WebCursorTest, CursorScaleFactor) { | 269 TEST(WebCursorTest, CursorScaleFactor) { |
| 270 gfx::Display display; | 270 display::Display display; |
| 271 display.set_device_scale_factor(80.2f); | 271 display.set_device_scale_factor(80.2f); |
| 272 | 272 |
| 273 WebCursor::CursorInfo info; | 273 WebCursor::CursorInfo info; |
| 274 info.image_scale_factor = 2.0f; | 274 info.image_scale_factor = 2.0f; |
| 275 | 275 |
| 276 WebCursor cursor; | 276 WebCursor cursor; |
| 277 cursor.InitFromCursorInfo(info); | 277 cursor.InitFromCursorInfo(info); |
| 278 cursor.SetDisplayInfo(display); | 278 cursor.SetDisplayInfo(display); |
| 279 | 279 |
| 280 EXPECT_EQ(40.1f, cursor.GetCursorScaleFactor()); | 280 EXPECT_EQ(40.1f, cursor.GetCursorScaleFactor()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 302 EXPECT_EQ(kUnpremul_SkAlphaType, image_copy.alphaType()); | 302 EXPECT_EQ(kUnpremul_SkAlphaType, image_copy.alphaType()); |
| 303 EXPECT_EQ(2, image_copy.width()); | 303 EXPECT_EQ(2, image_copy.width()); |
| 304 EXPECT_EQ(2, image_copy.height()); | 304 EXPECT_EQ(2, image_copy.height()); |
| 305 EXPECT_EQ(0, hotspot.x()); | 305 EXPECT_EQ(0, hotspot.x()); |
| 306 EXPECT_EQ(1, hotspot.y()); | 306 EXPECT_EQ(1, hotspot.y()); |
| 307 } | 307 } |
| 308 #endif | 308 #endif |
| 309 | 309 |
| 310 #if defined(OS_WIN) | 310 #if defined(OS_WIN) |
| 311 void ScaleCursor(float scaleFactor, int hotspotX, int hotspotY) { | 311 void ScaleCursor(float scaleFactor, int hotspotX, int hotspotY) { |
| 312 gfx::Display display; | 312 display::Display display; |
| 313 display.set_device_scale_factor(scaleFactor); | 313 display.set_device_scale_factor(scaleFactor); |
| 314 | 314 |
| 315 WebCursor::CursorInfo info; | 315 WebCursor::CursorInfo info; |
| 316 info.type = WebCursorInfo::TypeCustom; | 316 info.type = WebCursorInfo::TypeCustom; |
| 317 info.hotspot = gfx::Point(hotspotX, hotspotY); | 317 info.hotspot = gfx::Point(hotspotX, hotspotY); |
| 318 | 318 |
| 319 info.custom_image = SkBitmap(); | 319 info.custom_image = SkBitmap(); |
| 320 info.custom_image.allocN32Pixels(10, 10); | 320 info.custom_image.allocN32Pixels(10, 10); |
| 321 info.custom_image.eraseColor(0); | 321 info.custom_image.eraseColor(0); |
| 322 | 322 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 336 } | 336 } |
| 337 | 337 |
| 338 TEST(WebCursorTest, WindowsCursorScaledAtHiDpi) { | 338 TEST(WebCursorTest, WindowsCursorScaledAtHiDpi) { |
| 339 ScaleCursor(2.0f, 4, 6); | 339 ScaleCursor(2.0f, 4, 6); |
| 340 ScaleCursor(1.5f, 2, 8); | 340 ScaleCursor(1.5f, 2, 8); |
| 341 ScaleCursor(1.25f, 3, 7); | 341 ScaleCursor(1.25f, 3, 7); |
| 342 } | 342 } |
| 343 #endif | 343 #endif |
| 344 | 344 |
| 345 } // namespace content | 345 } // namespace content |
| OLD | NEW |