OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/base/cursor/cursor_loader_x11.h" | 5 #include "ui/base/cursor/cursor_loader_x11.h" |
6 | 6 |
7 #undef None | 7 #undef None |
8 #undef Bool | 8 #undef Bool |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "grit/ui_resources.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/base/cursor/cursor_util.h" | 14 #include "ui/base/cursor/cursor_util.h" |
| 15 #include "ui/gfx/geometry/point.h" |
14 | 16 |
15 namespace ui { | 17 namespace ui { |
16 | 18 |
17 TEST(CursorLoaderX11Test, ScaleAndRotate) { | 19 TEST(CursorLoaderX11Test, ScaleAndRotateCursorBitmapAndHotpoint) { |
18 SkBitmap bitmap; | 20 SkBitmap bitmap; |
19 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 5); | 21 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 5); |
20 bitmap.allocPixels(); | 22 bitmap.allocPixels(); |
21 bitmap.eraseColor(SK_ColorBLACK); | 23 bitmap.eraseColor(SK_ColorBLACK); |
22 | 24 |
23 gfx::Point hotpoint(3,4); | 25 gfx::Point hotpoint(3,4); |
24 | 26 |
25 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, | 27 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, |
26 gfx::Display::ROTATE_0, | 28 gfx::Display::ROTATE_0, |
27 &bitmap, | 29 &bitmap, |
(...skipping 21 matching lines...) Expand all Loading... |
49 | 51 |
50 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, | 52 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, |
51 gfx::Display::ROTATE_270, | 53 gfx::Display::ROTATE_270, |
52 &bitmap, | 54 &bitmap, |
53 &hotpoint); | 55 &hotpoint); |
54 EXPECT_EQ(20, bitmap.width()); | 56 EXPECT_EQ(20, bitmap.width()); |
55 EXPECT_EQ(10, bitmap.height()); | 57 EXPECT_EQ(10, bitmap.height()); |
56 EXPECT_EQ("14,2", hotpoint.ToString()); | 58 EXPECT_EQ("14,2", hotpoint.ToString()); |
57 } | 59 } |
58 | 60 |
| 61 TEST(CursorLoaderX11Test, Scale) { |
| 62 const int kCursorId = 1; |
| 63 test::ResetXCursorCache(); |
| 64 CursorLoaderX11 loader; |
| 65 loader.set_scale(1.0f); |
| 66 |
| 67 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 68 const XcursorImage* image = |
| 69 test::GetCachedXcursorImage(loader.GetCursorForTest(kCursorId)); |
| 70 int height = image->height; |
| 71 int width = image->width; |
| 72 loader.UnloadAll(); |
| 73 |
| 74 // Load 2x cursor and make sure its size is 2x of the 1x cusor. |
| 75 loader.set_scale(2.0f); |
| 76 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 77 image = test::GetCachedXcursorImage(loader.GetCursorForTest(kCursorId)); |
| 78 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
| 79 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
| 80 |
| 81 test::ResetXCursorCache(); |
| 82 } |
| 83 |
59 } // namespace ui | 84 } // namespace ui |
OLD | NEW |