| OLD | NEW |
| 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" |
| 11 #include "core/frame/Settings.h" | 11 #include "core/frame/Settings.h" |
| 12 #include "core/layout/style/LayoutStyle.h" | 12 #include "core/layout/style/ComputedStyle.h" |
| 13 #include "core/testing/DummyPageHolder.h" | 13 #include "core/testing/DummyPageHolder.h" |
| 14 #include "platform/text/LocaleToScriptMapping.h" | 14 #include "platform/text/LocaleToScriptMapping.h" |
| 15 | 15 |
| 16 #include <gtest/gtest.h> | 16 #include <gtest/gtest.h> |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class FontBuilderTest { | 20 class FontBuilderTest { |
| 21 public: | 21 public: |
| 22 FontBuilderTest() | 22 FontBuilderTest() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 DescriptionFunc setBaseValue; | 45 DescriptionFunc setBaseValue; |
| 46 BuilderFunc setValue; | 46 BuilderFunc setValue; |
| 47 }; | 47 }; |
| 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<ComputedStyle> initial = ComputedStyle::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 ComputedStyle::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<ComputedStyle> style = ComputedStyle::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. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |