OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 6 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
7 #include "chrome/browser/ui/views/harmony/chrome_typography.h" | 7 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/base/default_style.h" | 9 #include "ui/base/default_style.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 const gfx::FontList& font = views::style::GetFont(increase.context, kStyle); | 272 const gfx::FontList& font = views::style::GetFont(increase.context, kStyle); |
273 int line_spacing = views::style::GetLineHeight(increase.context, kStyle); | 273 int line_spacing = views::style::GetLineHeight(increase.context, kStyle); |
274 EXPECT_GE(increase.max, line_spacing - font.GetHeight()); | 274 EXPECT_GE(increase.max, line_spacing - font.GetHeight()); |
275 EXPECT_LE(increase.min, line_spacing - font.GetHeight()); | 275 EXPECT_LE(increase.min, line_spacing - font.GetHeight()); |
276 } | 276 } |
277 | 277 |
278 // Buttons should specify zero line height (i.e. use the font's height) so | 278 // Buttons should specify zero line height (i.e. use the font's height) so |
279 // buttons have flexibility to configure their own spacing. | 279 // buttons have flexibility to configure their own spacing. |
280 EXPECT_EQ(0, | 280 EXPECT_EQ(0, |
281 views::style::GetLineHeight(views::style::CONTEXT_BUTTON, kStyle)); | 281 views::style::GetLineHeight(views::style::CONTEXT_BUTTON, kStyle)); |
| 282 EXPECT_EQ( |
| 283 0, views::style::GetLineHeight(views::style::CONTEXT_BUTTON_MD, kStyle)); |
282 } | 284 } |
283 | 285 |
284 // Ensure that line heights reported in a default bot configuration match the | 286 // Ensure that line heights reported in a default bot configuration match the |
285 // Harmony spec. This test will only run if it detects that the current machine | 287 // Harmony spec. This test will only run if it detects that the current machine |
286 // has the default OS configuration. | 288 // has the default OS configuration. |
287 TEST(LayoutProviderTest, ExplicitTypographyLineHeight) { | 289 TEST(LayoutProviderTest, ExplicitTypographyLineHeight) { |
288 ui::test::MaterialDesignControllerTestAPI md_test_api( | 290 ui::test::MaterialDesignControllerTestAPI md_test_api( |
289 ui::MaterialDesignController::MATERIAL_NORMAL); | 291 ui::MaterialDesignController::MATERIAL_NORMAL); |
290 md_test_api.SetSecondaryUiMaterial(true); | 292 md_test_api.SetSecondaryUiMaterial(true); |
291 | 293 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 constexpr int kStyledLabelWidth = 200; // Enough to avoid wrapping. | 330 constexpr int kStyledLabelWidth = 200; // Enough to avoid wrapping. |
329 styled_label.SizeToFit(kStyledLabelWidth); | 331 styled_label.SizeToFit(kStyledLabelWidth); |
330 EXPECT_EQ(kBodyLineHeight, styled_label.height()); | 332 EXPECT_EQ(kBodyLineHeight, styled_label.height()); |
331 | 333 |
332 // Adding a link should not change the size. | 334 // Adding a link should not change the size. |
333 styled_label.AddStyleRange( | 335 styled_label.AddStyleRange( |
334 gfx::Range(0, 2), views::StyledLabel::RangeStyleInfo::CreateForLink()); | 336 gfx::Range(0, 2), views::StyledLabel::RangeStyleInfo::CreateForLink()); |
335 styled_label.SizeToFit(kStyledLabelWidth); | 337 styled_label.SizeToFit(kStyledLabelWidth); |
336 EXPECT_EQ(kBodyLineHeight, styled_label.height()); | 338 EXPECT_EQ(kBodyLineHeight, styled_label.height()); |
337 } | 339 } |
OLD | NEW |