OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/native_theme/native_theme_aura.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/skia/include/core/SkPath.h" |
| 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/native_theme/native_theme.h" |
| 11 |
| 12 namespace ui { |
| 13 namespace { |
| 14 void VerifyPoint(SkPoint a, SkPoint b) { |
| 15 EXPECT_EQ(a.x(), b.x()); |
| 16 EXPECT_EQ(a.y(), b.y()); |
| 17 } |
| 18 |
| 19 void VerifyTriangle(SkPath actualPath, SkPoint p0, SkPoint p1, SkPoint p2) { |
| 20 EXPECT_EQ(3, actualPath.countPoints()); |
| 21 VerifyPoint(p0, actualPath.getPoint(0)); |
| 22 VerifyPoint(p1, actualPath.getPoint(1)); |
| 23 VerifyPoint(p2, actualPath.getPoint(2)); |
| 24 } |
| 25 } |
| 26 |
| 27 TEST(NativeThemeAuraTest, VerticalArrows) { |
| 28 NativeThemeAura* theme = NativeThemeAura::instance(); |
| 29 SkPath path; |
| 30 |
| 31 // Up arrow, sized for 1x. |
| 32 path = theme->PathForArrow(gfx::Rect(100, 200, 17, 17), |
| 33 NativeTheme::kScrollbarUpArrow); |
| 34 VerifyTriangle(path, SkPoint::Make(105, 211), SkPoint::Make(112, 211), |
| 35 SkPoint::Make(108.5, 207)); |
| 36 |
| 37 // 1.25x, should be larger. |
| 38 path = theme->PathForArrow(gfx::Rect(50, 70, 21, 21), |
| 39 NativeTheme::kScrollbarUpArrow); |
| 40 VerifyTriangle(path, SkPoint::Make(56, 84), SkPoint::Make(65, 84), |
| 41 SkPoint::Make(60.5, 79)); |
| 42 |
| 43 // Down arrow is just a flipped up arrow. |
| 44 path = theme->PathForArrow(gfx::Rect(20, 80, 17, 17), |
| 45 NativeTheme::kScrollbarDownArrow); |
| 46 VerifyTriangle(path, SkPoint::Make(25, 86), SkPoint::Make(32, 86), |
| 47 SkPoint::Make(28.5, 90)); |
| 48 } |
| 49 |
| 50 TEST(NativeThemeAuraTest, HorizontalArrows) { |
| 51 NativeThemeAura* theme = NativeThemeAura::instance(); |
| 52 SkPath path; |
| 53 |
| 54 // Right arrow, sized for 1x. |
| 55 path = theme->PathForArrow(gfx::Rect(100, 200, 17, 17), |
| 56 NativeTheme::kScrollbarRightArrow); |
| 57 VerifyTriangle(path, SkPoint::Make(107, 205), SkPoint::Make(107, 212), |
| 58 SkPoint::Make(111, 208.5)); |
| 59 |
| 60 // Button size for 1.25x, should be larger. |
| 61 path = theme->PathForArrow(gfx::Rect(50, 70, 21, 21), |
| 62 NativeTheme::kScrollbarRightArrow); |
| 63 VerifyTriangle(path, SkPoint::Make(58, 76), SkPoint::Make(58, 85), |
| 64 SkPoint::Make(63, 80.5)); |
| 65 |
| 66 // Left arrow is just a flipped right arrow. |
| 67 path = theme->PathForArrow(gfx::Rect(20, 80, 17, 17), |
| 68 NativeTheme::kScrollbarLeftArrow); |
| 69 VerifyTriangle(path, SkPoint::Make(30, 85), SkPoint::Make(30, 92), |
| 70 SkPoint::Make(26, 88.5)); |
| 71 } |
| 72 |
| 73 } // namespace ui |
OLD | NEW |