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

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

Issue 2765883004: Implement Harmony typography spec. (Closed)
Patch Set: test, nit comment Created 3 years, 9 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
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));
+}

Powered by Google App Engine
This is Rietveld 408576698