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

Unified Diff: Source/core/rendering/TextPainterTest.cpp

Issue 738863002: Move TextPainter to core/paint/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/TextPainter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/TextPainterTest.cpp
diff --git a/Source/core/rendering/TextPainterTest.cpp b/Source/core/rendering/TextPainterTest.cpp
deleted file mode 100644
index 02babfdee02f47a02460d59e3636718ad424faa9..0000000000000000000000000000000000000000
--- a/Source/core/rendering/TextPainterTest.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "core/rendering/TextPainter.h"
-
-#include "core/CSSPropertyNames.h"
-#include "core/CSSValueKeywords.h"
-#include "core/css/CSSPrimitiveValue.h"
-#include "core/frame/Settings.h"
-#include "core/rendering/RenderText.h"
-#include "core/rendering/RenderingTestHelper.h"
-#include "core/rendering/style/ShadowData.h"
-#include "core/rendering/style/ShadowList.h"
-#include <gtest/gtest.h>
-
-namespace blink {
-namespace {
-
-class TextPainterTest : public RenderingTest {
-public:
- TextPainterTest() : m_renderText(nullptr) { }
-
-protected:
- RenderText* renderText() { return m_renderText; }
-
-private:
- virtual void SetUp() override
- {
- RenderingTest::SetUp();
- setBodyInnerHTML("Hello world");
- m_renderText = toRenderText(document().body()->firstChild()->renderer());
- ASSERT_TRUE(m_renderText);
- ASSERT_EQ("Hello world", m_renderText->text());
- }
-
- RenderText* m_renderText;
-};
-
-TEST_F(TextPainterTest, TextPaintingStyle_Simple)
-{
- document().body()->setInlineStyleProperty(CSSPropertyColor, CSSValueBlue);
- document().view()->updateLayoutAndStyleIfNeededRecursive();
-
- TextPainter::Style textStyle = TextPainter::textPaintingStyle(
- *renderText(), renderText()->style(), false /* forceBlackText */, 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::CSS_PX);
- document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3px yellow");
- document().view()->updateLayoutAndStyleIfNeededRecursive();
-
- TextPainter::Style textStyle = TextPainter::textPaintingStyle(
- *renderText(), renderText()->style(), false /* forceBlackText */, 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());
-}
-
-TEST_F(TextPainterTest, TextPaintingStyle_ForceBlackText)
-{
- document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CSSValueRed);
- document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
- document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, CSSValueBlue);
- document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::CSS_PX);
- document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3px yellow");
- document().view()->updateLayoutAndStyleIfNeededRecursive();
-
- TextPainter::Style textStyle = TextPainter::textPaintingStyle(
- *renderText(), renderText()->style(), true /* forceBlackText */, 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().view()->updateLayoutAndStyleIfNeededRecursive();
-
- TextPainter::Style textStyle = TextPainter::textPaintingStyle(
- *renderText(), renderText()->style(), false /* forceBlackText */, 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);
-}
-
-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().view()->updateLayoutAndStyleIfNeededRecursive();
-
- TextPainter::Style textStyle = TextPainter::textPaintingStyle(
- *renderText(), renderText()->style(), false /* forceBlackText */, 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);
-}
-
-} // namespace
-} // namespace blink
« no previous file with comments | « Source/core/rendering/TextPainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698