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

Side by Side Diff: chrome/browser/ui/views/harmony/layout_delegate_unittest.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Fix warning which causes one of the bots to fail 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/views/chrome_views_delegate.h" 5 #include "chrome/browser/ui/views/harmony/chrome_layout_delegate.h"
6 #include "chrome/browser/ui/views/harmony/chrome_typography.h" 6 #include "chrome/browser/ui/views/harmony/chrome_typography.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/base/default_style.h" 8 #include "ui/base/default_style.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/font_list.h" 10 #include "ui/gfx/font_list.h"
11 #include "ui/views/style/typography.h" 11 #include "ui/views/style/typography.h"
12 #include "ui/views/style/typography_provider.h" 12 #include "ui/views/style/typography_provider.h"
13 13
14 #if defined(OS_MACOSX) 14 #if defined(OS_MACOSX)
15 #include "base/mac/mac_util.h" 15 #include "base/mac/mac_util.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 // Test that the default TypographyProvider correctly maps TextContexts relative 186 // Test that the default TypographyProvider correctly maps TextContexts relative
187 // to the "base" font in the manner that legacy toolkit-views code expects. This 187 // to the "base" font in the manner that legacy toolkit-views code expects. This
188 // reads the base font configuration at runtime, and only tests font sizes, so 188 // reads the base font configuration at runtime, and only tests font sizes, so
189 // should be robust against platform changes. 189 // should be robust against platform changes.
190 TEST(LayoutDelegateTest, FontSizeRelativeToBase) { 190 TEST(LayoutDelegateTest, FontSizeRelativeToBase) {
191 using views::style::GetFont; 191 using views::style::GetFont;
192 192
193 constexpr int kStyle = views::style::STYLE_PRIMARY; 193 constexpr int kStyle = views::style::STYLE_PRIMARY;
194 194
195 // Typography described in chrome_typography.h requires a ChromeViewsDelegate. 195 // Typography described in chrome_typography.h requires a
196 ChromeViewsDelegate views_delegate; 196 // ChromeLayoutDelegate.
197 ChromeLayoutDelegate layout_delegate;
197 198
198 // Legacy code measures everything relative to a default-constructed FontList. 199 // Legacy code measures everything relative to a default-constructed FontList.
199 // On Mac, subtract one since that is 13pt instead of 12pt. 200 // On Mac, subtract one since that is 13pt instead of 12pt.
200 #if defined(OS_MACOSX) 201 #if defined(OS_MACOSX)
201 const int twelve = gfx::FontList().GetFontSize() - 1; 202 const int twelve = gfx::FontList().GetFontSize() - 1;
202 #else 203 #else
203 const int twelve = gfx::FontList().GetFontSize(); 204 const int twelve = gfx::FontList().GetFontSize();
204 #endif 205 #endif
205 206
206 EXPECT_EQ(twelve, GetFont(CONTEXT_BODY_TEXT_SMALL, kStyle).GetFontSize()); 207 EXPECT_EQ(twelve, GetFont(CONTEXT_BODY_TEXT_SMALL, kStyle).GetFontSize());
(...skipping 15 matching lines...) Expand all
222 // E.g. Headline should give a 20pt font. 223 // E.g. Headline should give a 20pt font.
223 EXPECT_EQ(twelve + 8, GetFont(CONTEXT_HEADLINE, kStyle).GetFontSize()); 224 EXPECT_EQ(twelve + 8, GetFont(CONTEXT_HEADLINE, kStyle).GetFontSize());
224 // Titles should be 15pt. Etc. 225 // Titles should be 15pt. Etc.
225 EXPECT_EQ(twelve + 3, 226 EXPECT_EQ(twelve + 3,
226 GetFont(views::style::CONTEXT_DIALOG_TITLE, kStyle).GetFontSize()); 227 GetFont(views::style::CONTEXT_DIALOG_TITLE, kStyle).GetFontSize());
227 EXPECT_EQ(twelve + 1, GetFont(CONTEXT_BODY_TEXT_LARGE, kStyle).GetFontSize()); 228 EXPECT_EQ(twelve + 1, GetFont(CONTEXT_BODY_TEXT_LARGE, kStyle).GetFontSize());
228 EXPECT_EQ(twelve - 1, 229 EXPECT_EQ(twelve - 1,
229 GetFont(CONTEXT_DEPRECATED_SMALL, kStyle).GetFontSize()); 230 GetFont(CONTEXT_DEPRECATED_SMALL, kStyle).GetFontSize());
230 #endif 231 #endif
231 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698