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

Unified 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 side-by-side diff with in-line comments
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')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/native_theme/native_theme_aura_unittest.cc
diff --git a/ui/native_theme/native_theme_aura_unittest.cc b/ui/native_theme/native_theme_aura_unittest.cc
index b5ded9d46cca2066b4ebb74a2be52e670c51ced9..c011e2ad6f306e638a150469b9426c817a341992 100644
--- a/ui/native_theme/native_theme_aura_unittest.cc
+++ b/ui/native_theme/native_theme_aura_unittest.cc
@@ -70,4 +70,71 @@ TEST(NativeThemeAuraTest, HorizontalArrows) {
SkPoint::Make(26, 88.5));
}
+TEST(NativeThemeAuraTest, ArrowForNonSquareButton) {
+ NativeThemeAura* theme = NativeThemeAura::instance();
+ SkPath path = theme->PathForArrow(gfx::Rect(90, 80, 42, 37),
+ NativeTheme::kScrollbarLeftArrow);
+ VerifyTriangle(path, SkPoint::Make(116, 89), SkPoint::Make(116, 109),
+ SkPoint::Make(105, 99));
+}
+
+TEST(NativeThemeAuraTest, BoundingRectSquare) {
+ NativeThemeAura* theme = NativeThemeAura::instance();
+ gfx::RectF bounding_rect =
+ theme->BoundingRectForArrow(gfx::Rect(42, 61, 21, 21));
+ EXPECT_EQ(48.f, bounding_rect.x());
+ EXPECT_EQ(67.f, bounding_rect.y());
+ EXPECT_EQ(9.f, bounding_rect.width());
+ EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
+}
+
+TEST(NativeThemeAuraTest, BoundingRectSlightlyRectangular) {
+ NativeThemeAura* theme = NativeThemeAura::instance();
+
+ // Stretched horzontally.
+ gfx::RectF bounding_rect =
+ theme->BoundingRectForArrow(gfx::Rect(42, 61, 25, 20));
+ EXPECT_EQ(49.f, bounding_rect.x());
+ EXPECT_EQ(66.f, bounding_rect.y());
+ EXPECT_EQ(11.f, bounding_rect.width());
+ EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
+
+ // Stretched vertically.
+ bounding_rect = theme->BoundingRectForArrow(gfx::Rect(42, 61, 14, 10));
+ EXPECT_EQ(46.f, bounding_rect.x());
+ EXPECT_EQ(63.f, bounding_rect.y());
+ EXPECT_EQ(6.f, bounding_rect.width());
+ EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
+}
+
+TEST(NativeThemeAuraTest, BoundingRectVeryRectangular) {
+ NativeThemeAura* theme = NativeThemeAura::instance();
+
+ // Stretched horzontally.
+ gfx::RectF bounding_rect =
+ theme->BoundingRectForArrow(gfx::Rect(42, 61, 30, 8));
+ EXPECT_EQ(53.f, bounding_rect.x());
+ EXPECT_EQ(61.f, bounding_rect.y());
+ EXPECT_EQ(8.f, bounding_rect.width());
+ EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
+
+ // Stretched vertically.
+ bounding_rect = theme->BoundingRectForArrow(gfx::Rect(42, 61, 6, 44));
+ EXPECT_EQ(42.f, bounding_rect.x());
+ EXPECT_EQ(80.f, bounding_rect.y());
+ EXPECT_EQ(6.f, bounding_rect.width());
+ EXPECT_EQ(bounding_rect.width(), bounding_rect.height());
+}
+
+TEST(NativeThemeAuraTest, BoundingRectSnappedToWholePixels) {
+ NativeThemeAura* theme = NativeThemeAura::instance();
+
+ gfx::RectF bounding_rect =
+ theme->BoundingRectForArrow(gfx::Rect(0, 0, 9, 10));
+ EXPECT_EQ(3.f, bounding_rect.x());
+
+ bounding_rect = theme->BoundingRectForArrow(gfx::Rect(0, 0, 10, 9));
+ EXPECT_EQ(3.f, bounding_rect.y());
+}
+
} // namespace ui
« 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