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

Side by Side Diff: Source/core/css/resolver/FontBuilderTest.cpp

Issue 975933002: Return reference from styleEngine() accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « Source/core/css/StyleSheetList.cpp ('k') | Source/core/css/resolver/ScopedStyleResolver.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/css/resolver/FontBuilder.h" 6 #include "core/css/resolver/FontBuilder.h"
7 7
8 #include "core/css/CSSFontSelector.h" 8 #include "core/css/CSSFontSelector.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/StyleEngine.h" 10 #include "core/dom/StyleEngine.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 class FontBuilderInitTest : public FontBuilderTest, public ::testing::Test { }; 49 class FontBuilderInitTest : public FontBuilderTest, public ::testing::Test { };
50 class FontBuilderAdditiveTest : public FontBuilderTest, public ::testing::TestWi thParam<FunctionPair> { }; 50 class FontBuilderAdditiveTest : public FontBuilderTest, public ::testing::TestWi thParam<FunctionPair> { };
51 51
52 TEST_F(FontBuilderInitTest, InitialFontSizeNotScaled) 52 TEST_F(FontBuilderInitTest, InitialFontSizeNotScaled)
53 { 53 {
54 RefPtr<LayoutStyle> initial = LayoutStyle::create(); 54 RefPtr<LayoutStyle> initial = LayoutStyle::create();
55 55
56 FontBuilder builder(document()); 56 FontBuilder builder(document());
57 builder.setInitial(1.0f); // FIXME: Remove unused param. 57 builder.setInitial(1.0f); // FIXME: Remove unused param.
58 builder.createFont(document().styleEngine()->fontSelector(), *initial); 58 builder.createFont(document().styleEngine().fontSelector(), *initial);
59 59
60 EXPECT_EQ(16.0f, initial->fontDescription().computedSize()); 60 EXPECT_EQ(16.0f, initial->fontDescription().computedSize());
61 } 61 }
62 62
63 TEST_F(FontBuilderInitTest, NotDirty) 63 TEST_F(FontBuilderInitTest, NotDirty)
64 { 64 {
65 FontBuilder builder(document()); 65 FontBuilder builder(document());
66 ASSERT_FALSE(builder.fontDirty()); 66 ASSERT_FALSE(builder.fontDirty());
67 } 67 }
68 68
69 // This test verifies that when you are setting some field F via FontBuilder, 69 // This test verifies that when you are setting some field F via FontBuilder,
70 // only F is actually modified on the incoming LayoutStyle::fontDescription. 70 // only F is actually modified on the incoming LayoutStyle::fontDescription.
71 TEST_P(FontBuilderAdditiveTest, OnlySetValueIsModified) 71 TEST_P(FontBuilderAdditiveTest, OnlySetValueIsModified)
72 { 72 {
73 FunctionPair funcs = GetParam(); 73 FunctionPair funcs = GetParam();
74 74
75 FontDescription parentDescription; 75 FontDescription parentDescription;
76 funcs.setBaseValue(parentDescription); 76 funcs.setBaseValue(parentDescription);
77 77
78 RefPtr<LayoutStyle> style = LayoutStyle::create(); 78 RefPtr<LayoutStyle> style = LayoutStyle::create();
79 style->setFontDescription(parentDescription); 79 style->setFontDescription(parentDescription);
80 80
81 FontBuilder fontBuilder(document()); 81 FontBuilder fontBuilder(document());
82 funcs.setValue(fontBuilder); 82 funcs.setValue(fontBuilder);
83 fontBuilder.createFont(document().styleEngine()->fontSelector(), *style); 83 fontBuilder.createFont(document().styleEngine().fontSelector(), *style);
84 84
85 FontDescription outputDescription = style->fontDescription(); 85 FontDescription outputDescription = style->fontDescription();
86 86
87 // FontBuilder should have overwritten our base value set in the parent, 87 // FontBuilder should have overwritten our base value set in the parent,
88 // hence the descriptions should not be equal. 88 // hence the descriptions should not be equal.
89 ASSERT_NE(parentDescription, outputDescription); 89 ASSERT_NE(parentDescription, outputDescription);
90 90
91 // Overwrite the value set by FontBuilder with the base value, directly 91 // Overwrite the value set by FontBuilder with the base value, directly
92 // on outputDescription. 92 // on outputDescription.
93 funcs.setBaseValue(outputDescription); 93 funcs.setBaseValue(outputDescription);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 FunctionPair(fontStyleBase, fontStyleValue), 157 FunctionPair(fontStyleBase, fontStyleValue),
158 FunctionPair(fontVariantBase, fontVariantValue), 158 FunctionPair(fontVariantBase, fontVariantValue),
159 FunctionPair(fontVariantLigaturesBase, fontVariantLigaturesValue), 159 FunctionPair(fontVariantLigaturesBase, fontVariantLigaturesValue),
160 FunctionPair(fontTextRenderingBase, fontTextRenderingValue), 160 FunctionPair(fontTextRenderingBase, fontTextRenderingValue),
161 FunctionPair(fontKerningBase, fontKerningValue), 161 FunctionPair(fontKerningBase, fontKerningValue),
162 FunctionPair(fontFontSmoothingBase, fontFontSmoothingValue), 162 FunctionPair(fontFontSmoothingBase, fontFontSmoothingValue),
163 FunctionPair(fontSizeBase, fontSizeValue), 163 FunctionPair(fontSizeBase, fontSizeValue),
164 FunctionPair(fontScriptBase, fontScriptValue))); 164 FunctionPair(fontScriptBase, fontScriptValue)));
165 165
166 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/StyleSheetList.cpp ('k') | Source/core/css/resolver/ScopedStyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698