| 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 "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "ui/base/cursor/cursor_util.h" | 13 #include "ui/base/cursor/cursor_util.h" |
| 14 #include "ui/display/display.h" |
| 14 | 15 |
| 15 namespace ui { | 16 namespace ui { |
| 16 | 17 |
| 17 TEST(CursorLoaderX11Test, ScaleAndRotate) { | 18 TEST(CursorLoaderX11Test, ScaleAndRotate) { |
| 18 SkBitmap bitmap; | 19 SkBitmap bitmap; |
| 19 bitmap.allocN32Pixels(10, 5); | 20 bitmap.allocN32Pixels(10, 5); |
| 20 bitmap.eraseColor(SK_ColorBLACK); | 21 bitmap.eraseColor(SK_ColorBLACK); |
| 21 | 22 |
| 22 gfx::Point hotpoint(3,4); | 23 gfx::Point hotpoint(3,4); |
| 23 | 24 |
| 24 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, | 25 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, display::Display::ROTATE_0, |
| 25 gfx::Display::ROTATE_0, | 26 &bitmap, &hotpoint); |
| 26 &bitmap, | |
| 27 &hotpoint); | |
| 28 EXPECT_EQ(10, bitmap.width()); | 27 EXPECT_EQ(10, bitmap.width()); |
| 29 EXPECT_EQ(5, bitmap.height()); | 28 EXPECT_EQ(5, bitmap.height()); |
| 30 EXPECT_EQ("3,4", hotpoint.ToString()); | 29 EXPECT_EQ("3,4", hotpoint.ToString()); |
| 31 | 30 |
| 32 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, | 31 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, display::Display::ROTATE_90, |
| 33 gfx::Display::ROTATE_90, | 32 &bitmap, &hotpoint); |
| 34 &bitmap, | |
| 35 &hotpoint); | |
| 36 | 33 |
| 37 EXPECT_EQ(5, bitmap.width()); | 34 EXPECT_EQ(5, bitmap.width()); |
| 38 EXPECT_EQ(10, bitmap.height()); | 35 EXPECT_EQ(10, bitmap.height()); |
| 39 EXPECT_EQ("1,3", hotpoint.ToString()); | 36 EXPECT_EQ("1,3", hotpoint.ToString()); |
| 40 | 37 |
| 41 ScaleAndRotateCursorBitmapAndHotpoint(2.0f, | 38 ScaleAndRotateCursorBitmapAndHotpoint(2.0f, display::Display::ROTATE_180, |
| 42 gfx::Display::ROTATE_180, | 39 &bitmap, &hotpoint); |
| 43 &bitmap, | |
| 44 &hotpoint); | |
| 45 EXPECT_EQ(10, bitmap.width()); | 40 EXPECT_EQ(10, bitmap.width()); |
| 46 EXPECT_EQ(20, bitmap.height()); | 41 EXPECT_EQ(20, bitmap.height()); |
| 47 EXPECT_EQ("8,14", hotpoint.ToString()); | 42 EXPECT_EQ("8,14", hotpoint.ToString()); |
| 48 | 43 |
| 49 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, | 44 ScaleAndRotateCursorBitmapAndHotpoint(1.0f, display::Display::ROTATE_270, |
| 50 gfx::Display::ROTATE_270, | 45 &bitmap, &hotpoint); |
| 51 &bitmap, | |
| 52 &hotpoint); | |
| 53 EXPECT_EQ(20, bitmap.width()); | 46 EXPECT_EQ(20, bitmap.width()); |
| 54 EXPECT_EQ(10, bitmap.height()); | 47 EXPECT_EQ(10, bitmap.height()); |
| 55 EXPECT_EQ("14,2", hotpoint.ToString()); | 48 EXPECT_EQ("14,2", hotpoint.ToString()); |
| 56 } | 49 } |
| 57 | 50 |
| 58 } // namespace ui | 51 } // namespace ui |
| OLD | NEW |