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