| 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 "core/paint/TextPainter.h" | 5 #include "core/paint/TextPainter.h" |
| 6 | 6 |
| 7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
| 8 #include "core/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
| 9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| 11 #include "core/layout/LayoutTestHelper.h" | 11 #include "core/layout/LayoutTestHelper.h" |
| 12 #include "core/layout/api/LineLayoutText.h" | 12 #include "core/layout/api/LineLayoutText.h" |
| 13 #include "core/paint/PaintInfo.h" | 13 #include "core/paint/PaintInfo.h" |
| 14 #include "core/style/ShadowData.h" | 14 #include "core/style/ShadowData.h" |
| 15 #include "core/style/ShadowList.h" | 15 #include "core/style/ShadowList.h" |
| 16 #include "platform/graphics/paint/PaintController.h" | 16 #include "platform/graphics/paint/PaintController.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include <memory> | |
| 19 | 18 |
| 20 namespace blink { | 19 namespace blink { |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 class TextPainterTest : public RenderingTest { | 22 class TextPainterTest : public RenderingTest { |
| 24 public: | 23 public: |
| 25 TextPainterTest() | 24 TextPainterTest() |
| 26 : m_layoutText(nullptr) | 25 : m_layoutText(nullptr) |
| 27 , m_paintController(PaintController::create()) | 26 , m_paintController(PaintController::create()) |
| 28 , m_context(*m_paintController) | 27 , m_context(*m_paintController) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 void SetUp() override | 39 void SetUp() override |
| 41 { | 40 { |
| 42 RenderingTest::SetUp(); | 41 RenderingTest::SetUp(); |
| 43 setBodyInnerHTML("Hello world"); | 42 setBodyInnerHTML("Hello world"); |
| 44 m_layoutText = toLayoutText(document().body()->firstChild()->layoutObjec
t()); | 43 m_layoutText = toLayoutText(document().body()->firstChild()->layoutObjec
t()); |
| 45 ASSERT_TRUE(m_layoutText); | 44 ASSERT_TRUE(m_layoutText); |
| 46 ASSERT_EQ("Hello world", m_layoutText->text()); | 45 ASSERT_EQ("Hello world", m_layoutText->text()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 LayoutText* m_layoutText; | 48 LayoutText* m_layoutText; |
| 50 std::unique_ptr<PaintController> m_paintController; | 49 OwnPtr<PaintController> m_paintController; |
| 51 GraphicsContext m_context; | 50 GraphicsContext m_context; |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 TEST_F(TextPainterTest, TextPaintingStyle_Simple) | 53 TEST_F(TextPainterTest, TextPaintingStyle_Simple) |
| 55 { | 54 { |
| 56 document().body()->setInlineStyleProperty(CSSPropertyColor, CSSValueBlue); | 55 document().body()->setInlineStyleProperty(CSSPropertyColor, CSSValueBlue); |
| 57 document().view()->updateAllLifecyclePhases(); | 56 document().view()->updateAllLifecyclePhases(); |
| 58 | 57 |
| 59 TextPainter::Style textStyle = TextPainter::textPaintingStyle( | 58 TextPainter::Style textStyle = TextPainter::textPaintingStyle( |
| 60 getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(fal
se /* usesTextAsClip */, false /* isPrinting */)); | 59 getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(fal
se /* usesTextAsClip */, false /* isPrinting */)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 134 |
| 136 TextPainter::Style textStyle = TextPainter::textPaintingStyle( | 135 TextPainter::Style textStyle = TextPainter::textPaintingStyle( |
| 137 getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(fal
se /* usesTextAsClip */, true /* isPrinting */)); | 136 getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(fal
se /* usesTextAsClip */, true /* isPrinting */)); |
| 138 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor); | 137 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor); |
| 139 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor); | 138 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor); |
| 140 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor); | 139 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor); |
| 141 } | 140 } |
| 142 | 141 |
| 143 } // namespace | 142 } // namespace |
| 144 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |