Index: chrome/browser/ui/views/harmony/layout_delegate_unittest.cc |
diff --git a/chrome/browser/ui/views/harmony/layout_delegate_unittest.cc b/chrome/browser/ui/views/harmony/layout_delegate_unittest.cc |
index 89306aac3b2576ba3c3dd3b7d82170cf00053438..7f58e6c5669e8005a704f1427ffa85eb1151f263 100644 |
--- a/chrome/browser/ui/views/harmony/layout_delegate_unittest.cc |
+++ b/chrome/browser/ui/views/harmony/layout_delegate_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/base/default_style.h" |
#include "ui/base/resource/resource_bundle.h" |
+#include "ui/base/test/material_design_controller_test_api.h" |
#include "ui/gfx/font_list.h" |
#include "ui/views/style/typography.h" |
#include "ui/views/style/typography_provider.h" |
@@ -229,3 +230,41 @@ TEST(LayoutDelegateTest, FontSizeRelativeToBase) { |
GetFont(CONTEXT_DEPRECATED_SMALL, kStyle).GetFontSize()); |
#endif |
} |
+ |
+// Ensure that line height is overridden under Harmony for the standard set of |
Peter Kasting
2017/04/04 00:47:58
Nit: If there's a way to word comments/test names
tapted
2017/04/04 06:23:00
Done.
|
+// styles. This varies by platform and test machine configuration. Generally, |
+// for a particular platform configuration, there should be a consistent |
+// increase in line height when compared to the height of a given font. |
+TEST(LayoutDelegateTest, HarmonyLineHeight) { |
+ constexpr int kStyle = views::style::STYLE_PRIMARY; |
+ |
+ // Only Harmony overrides the default line spacing. |
+ ui::test::MaterialDesignControllerTestAPI md_test_api( |
+ ui::MaterialDesignController::MATERIAL_NORMAL); |
+ md_test_api.SetSecondaryUiMaterial(true); |
+ |
+ ChromeViewsDelegate views_delegate; |
+ |
+ const struct { |
Peter Kasting
2017/04/04 00:47:58
Nit: Can this be constexpr?
tapted
2017/04/04 06:23:00
Done.
|
+ int context; |
+ int min; |
+ int max; |
+ } kExpectedIncreases[] = {{CONTEXT_HEADLINE, 4, 8}, |
+ {views::style::CONTEXT_DIALOG_TITLE, 2, 4}, |
+ {CONTEXT_BODY_TEXT_LARGE, 3, 4}, |
+ {CONTEXT_BODY_TEXT_SMALL, 5, 5}}; |
+ |
+ int i = 0; |
+ for (const auto& increase : kExpectedIncreases) { |
+ SCOPED_TRACE(testing::Message() << "Testing index: " << i++); |
Peter Kasting
2017/04/04 00:47:58
Nit: If we're going to have a counting index anywa
tapted
2017/04/04 06:23:00
Done.
|
+ const gfx::FontList& font = views::style::GetFont(increase.context, kStyle); |
+ int line_spacing = views::style::GetLineHeight(increase.context, kStyle); |
+ EXPECT_GE(increase.max, line_spacing - font.GetHeight()); |
+ EXPECT_LE(increase.min, line_spacing - font.GetHeight()); |
+ } |
+ |
+ // Buttons should specify zero line height (i.e. use the font's height) so |
+ // buttons have flexibility to configure their own spacing. |
+ EXPECT_EQ(0, |
+ views::style::GetLineHeight(views::style::CONTEXT_BUTTON, kStyle)); |
+} |