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

Unified Diff: chrome/browser/ui/views/harmony/layout_delegate_unittest.cc

Issue 2765883004: Implement Harmony typography spec. (Closed)
Patch Set: respond to comments Created 3 years, 8 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 | « chrome/browser/ui/views/harmony/harmony_typography_provider.cc ('k') | ui/gfx/platform_font.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a265ae7d353b08051af86cb5b58c5d0724c13249 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,42 @@ TEST(LayoutDelegateTest, FontSizeRelativeToBase) {
GetFont(CONTEXT_DEPRECATED_SMALL, kStyle).GetFontSize());
#endif
}
+
+// Ensure that line height can be overridden by Chrome's TypographyProvider for
+// for the standard set of 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, TypographyLineHeight) {
+ constexpr int kStyle = views::style::STYLE_PRIMARY;
+
+ // Only MD overrides the default line spacing.
+ ui::test::MaterialDesignControllerTestAPI md_test_api(
+ ui::MaterialDesignController::MATERIAL_NORMAL);
+ md_test_api.SetSecondaryUiMaterial(true);
+
+ ChromeViewsDelegate views_delegate;
+
+ constexpr struct {
+ 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}};
+
+ for (size_t i = 0; i < arraysize(kExpectedIncreases); ++i) {
+ SCOPED_TRACE(testing::Message() << "Testing index: " << i);
+ const auto& increase = kExpectedIncreases[i];
+ 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));
+}
« no previous file with comments | « chrome/browser/ui/views/harmony/harmony_typography_provider.cc ('k') | ui/gfx/platform_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698