- add sources.
[platform/framework/web/crosswalk.git] / src / ui / base / cursor / cursor_loader_x11_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "ui/base/cursor/cursor_loader_x11.h"
6
7 #undef None
8 #undef Bool
9
10 #include "base/logging.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13
14 namespace ui {
15
16 TEST(CursorLoaderX11Test, ScaleAndRotate) {
17   SkBitmap bitmap;
18   bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 5);
19   bitmap.allocPixels();
20
21   gfx::Point hotpoint(3,4);
22
23   ScaleAndRotateCursorBitmapAndHotpoint(1.0f,
24                                         gfx::Display::ROTATE_0,
25                                         &bitmap,
26                                         &hotpoint);
27   EXPECT_EQ(10, bitmap.width());
28   EXPECT_EQ(5, bitmap.height());
29   EXPECT_EQ("3,4", hotpoint.ToString());
30
31   ScaleAndRotateCursorBitmapAndHotpoint(1.0f,
32                                         gfx::Display::ROTATE_90,
33                                         &bitmap,
34                                         &hotpoint);
35
36   EXPECT_EQ(5, bitmap.width());
37   EXPECT_EQ(10, bitmap.height());
38   EXPECT_EQ("1,3", hotpoint.ToString());
39
40   ScaleAndRotateCursorBitmapAndHotpoint(2.0f,
41                                         gfx::Display::ROTATE_180,
42                                         &bitmap,
43                                         &hotpoint);
44   EXPECT_EQ(10, bitmap.width());
45   EXPECT_EQ(20, bitmap.height());
46   EXPECT_EQ("8,14", hotpoint.ToString());
47
48   ScaleAndRotateCursorBitmapAndHotpoint(1.0f,
49                                         gfx::Display::ROTATE_270,
50                                         &bitmap,
51                                         &hotpoint);
52   EXPECT_EQ(20, bitmap.width());
53   EXPECT_EQ(10, bitmap.height());
54   EXPECT_EQ("14,2", hotpoint.ToString());
55 }
56
57 }  // namespace ui