| Index: third_party/WebKit/Source/core/paint/TextPainterTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/TextPainterTest.cpp b/third_party/WebKit/Source/core/paint/TextPainterTest.cpp
|
| index cf65e5965b2b9420e11916dbeae7b59466983dd2..06e12ac279bedbed56bf66a1900cd858e9dd76c0 100644
|
| --- a/third_party/WebKit/Source/core/paint/TextPainterTest.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/TextPainterTest.cpp
|
| @@ -2,143 +2,26 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "core/paint/TextPainter.h"
|
| +#include "core/style/ComputedStyle.h"
|
|
|
| -#include "core/CSSPropertyNames.h"
|
| -#include "core/CSSValueKeywords.h"
|
| -#include "core/css/CSSPrimitiveValue.h"
|
| -#include "core/frame/Settings.h"
|
| -#include "core/layout/LayoutTestHelper.h"
|
| -#include "core/layout/api/LineLayoutText.h"
|
| -#include "core/paint/PaintInfo.h"
|
| -#include "core/style/ShadowData.h"
|
| -#include "core/style/ShadowList.h"
|
| -#include "platform/graphics/paint/PaintController.h"
|
| -#include "testing/gtest/include/gtest/gtest.h"
|
| -#include <memory>
|
| +#include <stdio.h>
|
| +#include <stdlib.h>
|
|
|
| -namespace blink {
|
| -namespace {
|
| +using namespace blink;
|
|
|
| -class TextPainterTest : public RenderingTest {
|
| -public:
|
| - TextPainterTest()
|
| - : m_layoutText(nullptr)
|
| - , m_paintController(PaintController::create())
|
| - , m_context(*m_paintController)
|
| - { }
|
| -
|
| -protected:
|
| - LineLayoutText getLineLayoutText() { return LineLayoutText(m_layoutText); }
|
| -
|
| - PaintInfo createPaintInfo(bool usesTextAsClip, bool isPrinting)
|
| - {
|
| - return PaintInfo(m_context, IntRect(), usesTextAsClip ? PaintPhaseTextClip : PaintPhaseSelfBlockBackgroundOnly, isPrinting ? GlobalPaintPrinting : GlobalPaintNormalPhase, 0);
|
| - }
|
| -
|
| -private:
|
| - void SetUp() override
|
| - {
|
| - RenderingTest::SetUp();
|
| - setBodyInnerHTML("Hello world");
|
| - m_layoutText = toLayoutText(document().body()->firstChild()->layoutObject());
|
| - ASSERT_TRUE(m_layoutText);
|
| - ASSERT_EQ("Hello world", m_layoutText->text());
|
| - }
|
| -
|
| - LayoutText* m_layoutText;
|
| - std::unique_ptr<PaintController> m_paintController;
|
| - GraphicsContext m_context;
|
| -};
|
| -
|
| -TEST_F(TextPainterTest, TextPaintingStyle_Simple)
|
| -{
|
| - document().body()->setInlineStyleProperty(CSSPropertyColor, CSSValueBlue);
|
| - document().view()->updateAllLifecyclePhases();
|
| -
|
| - TextPainter::Style textStyle = TextPainter::textPaintingStyle(
|
| - getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(false /* usesTextAsClip */, false /* isPrinting */));
|
| - EXPECT_EQ(Color(0, 0, 255), textStyle.fillColor);
|
| - EXPECT_EQ(Color(0, 0, 255), textStyle.strokeColor);
|
| - EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
|
| - EXPECT_EQ(0, textStyle.strokeWidth);
|
| - EXPECT_EQ(nullptr, textStyle.shadow);
|
| -}
|
| -
|
| -TEST_F(TextPainterTest, TextPaintingStyle_AllProperties)
|
| -{
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CSSValueRed);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, CSSValueBlue);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::UnitType::Pixels);
|
| - document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3px yellow");
|
| - document().view()->updateAllLifecyclePhases();
|
| -
|
| - TextPainter::Style textStyle = TextPainter::textPaintingStyle(
|
| - getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(false /* usesTextAsClip */, false /* isPrinting */));
|
| - EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor);
|
| - EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor);
|
| - EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
|
| - EXPECT_EQ(4, textStyle.strokeWidth);
|
| - ASSERT_NE(nullptr, textStyle.shadow);
|
| - EXPECT_EQ(1u, textStyle.shadow->shadows().size());
|
| - EXPECT_EQ(1, textStyle.shadow->shadows()[0].x());
|
| - EXPECT_EQ(2, textStyle.shadow->shadows()[0].y());
|
| - EXPECT_EQ(3, textStyle.shadow->shadows()[0].blur());
|
| - EXPECT_EQ(Color(255, 255, 0), textStyle.shadow->shadows()[0].color().getColor());
|
| -}
|
| -
|
| -TEST_F(TextPainterTest, TextPaintingStyle_UsesTextAsClip)
|
| -{
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CSSValueRed);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, CSSValueBlue);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::UnitType::Pixels);
|
| - document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3px yellow");
|
| - document().view()->updateAllLifecyclePhases();
|
| -
|
| - TextPainter::Style textStyle = TextPainter::textPaintingStyle(
|
| - getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(true /* usesTextAsClip */, false /* isPrinting */));
|
| - EXPECT_EQ(Color::black, textStyle.fillColor);
|
| - EXPECT_EQ(Color::black, textStyle.strokeColor);
|
| - EXPECT_EQ(Color::black, textStyle.emphasisMarkColor);
|
| - EXPECT_EQ(4, textStyle.strokeWidth);
|
| - EXPECT_EQ(nullptr, textStyle.shadow);
|
| -}
|
| -
|
| -TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_NoAdjustmentNeeded)
|
| -{
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CSSValueRed);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, CSSValueBlue);
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy);
|
| - document().settings()->setShouldPrintBackgrounds(false);
|
| - document().setPrinting(true);
|
| - document().view()->updateAllLifecyclePhases();
|
| -
|
| - TextPainter::Style textStyle = TextPainter::textPaintingStyle(
|
| - getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(false /* usesTextAsClip */, true /* isPrinting */));
|
| - EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor);
|
| - EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor);
|
| - EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
|
| +Color secretColor() {
|
| + return Color::black;
|
| }
|
|
|
| -TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened)
|
| -{
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, "rgb(255, 220, 220)");
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, "rgb(220, 255, 220)");
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, "rgb(220, 220, 255)");
|
| - document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy);
|
| - document().settings()->setShouldPrintBackgrounds(false);
|
| - document().setPrinting(true);
|
| - document().view()->updateAllLifecyclePhases();
|
| -
|
| - TextPainter::Style textStyle = TextPainter::textPaintingStyle(
|
| - getLineLayoutText(), getLineLayoutText().styleRef(), createPaintInfo(false /* usesTextAsClip */, true /* isPrinting */));
|
| - EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor);
|
| - EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor);
|
| - EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor);
|
| +int main(int argc, char* argv[]) {
|
| + ComputedStyle style1;
|
| + StyleColor color(0xffff0000);
|
| + style1.setVisitedLinkTextFillColor(color);
|
| + Color c = style1.colorIncludingFallback(CSSPropertyWebkitTextFillColor, false);
|
| + if (Color(255, 0, 0) != c) {
|
| + fprintf(stderr, "fail2\n");
|
| + exit(1);
|
| + } else {
|
| + fprintf(stderr, "pass2\n");
|
| + }
|
| }
|
| -
|
| -} // namespace
|
| -} // namespace blink
|
|
|