Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: ui/native_theme/native_theme_aura_unittest.cc

Issue 2009733002: Draw nicer arrows when the scrollbar buttons are not square. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor edits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/native_theme/native_theme_base.h » ('j') | ui/native_theme/native_theme_base.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/native_theme/native_theme_aura.h" 5 #include "ui/native_theme/native_theme_aura.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/native_theme/native_theme.h" 10 #include "ui/native_theme/native_theme.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 VerifyTriangle(path, SkPoint::Make(58, 76), SkPoint::Make(58, 85), 63 VerifyTriangle(path, SkPoint::Make(58, 76), SkPoint::Make(58, 85),
64 SkPoint::Make(63, 80.5)); 64 SkPoint::Make(63, 80.5));
65 65
66 // Left arrow is just a flipped right arrow. 66 // Left arrow is just a flipped right arrow.
67 path = theme->PathForArrow(gfx::Rect(20, 80, 17, 17), 67 path = theme->PathForArrow(gfx::Rect(20, 80, 17, 17),
68 NativeTheme::kScrollbarLeftArrow); 68 NativeTheme::kScrollbarLeftArrow);
69 VerifyTriangle(path, SkPoint::Make(30, 85), SkPoint::Make(30, 92), 69 VerifyTriangle(path, SkPoint::Make(30, 85), SkPoint::Make(30, 92),
70 SkPoint::Make(26, 88.5)); 70 SkPoint::Make(26, 88.5));
71 } 71 }
72 72
73 TEST(NativeThemeAuraTest, ArrowForNonSquareButton) {
74 NativeThemeAura* theme = NativeThemeAura::instance();
75 SkPath path = theme->PathForArrow(gfx::Rect(90, 80, 42, 37),
76 NativeTheme::kScrollbarLeftArrow);
77 VerifyTriangle(path, SkPoint::Make(116, 89), SkPoint::Make(116, 109),
78 SkPoint::Make(105, 99));
79 }
80
81 TEST(NativeThemeAuraTest, BoundingRectSquare) {
82 NativeThemeAura* theme = NativeThemeAura::instance();
83 gfx::RectF bounding_rect =
84 theme->BoundingRectForArrow(gfx::Rect(42, 61, 21, 21));
85 EXPECT_EQ(48.f, bounding_rect.x());
86 EXPECT_EQ(67.f, bounding_rect.y());
87 EXPECT_EQ(9.f, bounding_rect.width());
88 EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
89 }
90
91 TEST(NativeThemeAuraTest, BoundingRectSlightlyRectangular) {
92 NativeThemeAura* theme = NativeThemeAura::instance();
93
94 // Stretched horzontally.
95 gfx::RectF bounding_rect =
96 theme->BoundingRectForArrow(gfx::Rect(42, 61, 25, 20));
97 EXPECT_EQ(49.f, bounding_rect.x());
98 EXPECT_EQ(66.f, bounding_rect.y());
99 EXPECT_EQ(11.f, bounding_rect.width());
100 EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
101
102 // Stretched vertically.
103 bounding_rect = theme->BoundingRectForArrow(gfx::Rect(42, 61, 14, 10));
104 EXPECT_EQ(46.f, bounding_rect.x());
105 EXPECT_EQ(63.f, bounding_rect.y());
106 EXPECT_EQ(6.f, bounding_rect.width());
107 EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
108 }
109
110 TEST(NativeThemeAuraTest, BoundingRectVeryRectangular) {
111 NativeThemeAura* theme = NativeThemeAura::instance();
112
113 // Stretched horzontally.
114 gfx::RectF bounding_rect =
115 theme->BoundingRectForArrow(gfx::Rect(42, 61, 30, 8));
116 EXPECT_EQ(53.f, bounding_rect.x());
117 EXPECT_EQ(61.f, bounding_rect.y());
118 EXPECT_EQ(8.f, bounding_rect.width());
119 EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
120
121 // Stretched vertically.
122 bounding_rect = theme->BoundingRectForArrow(gfx::Rect(42, 61, 6, 44));
123 EXPECT_EQ(42.f, bounding_rect.x());
124 EXPECT_EQ(80.f, bounding_rect.y());
125 EXPECT_EQ(6.f, bounding_rect.width());
126 EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
127 }
128
129 TEST(NativeThemeAuraTest, BoundingRectSnappedToWholePixels) {
130 NativeThemeAura* theme = NativeThemeAura::instance();
131
132 gfx::RectF bounding_rect =
133 theme->BoundingRectForArrow(gfx::Rect(0, 0, 9, 10));
134 EXPECT_EQ(3.f, bounding_rect.x());
135
136 bounding_rect = theme->BoundingRectForArrow(gfx::Rect(0, 0, 10, 9));
137 EXPECT_EQ(3.f, bounding_rect.y());
138 }
139
73 } // namespace ui 140 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/native_theme/native_theme_base.h » ('j') | ui/native_theme/native_theme_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698