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

Side by Side Diff: Source/core/paint/TextPainterTest.cpp

Issue 1196223008: ViewPainter should skip background in print economy mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix unittests Created 5 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/paint/TextPainter.h" 6 #include "core/paint/TextPainter.h"
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/CSSValueKeywords.h" 9 #include "core/CSSValueKeywords.h"
10 #include "core/css/CSSPrimitiveValue.h" 10 #include "core/css/CSSPrimitiveValue.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 EXPECT_EQ(nullptr, textStyle.shadow); 93 EXPECT_EQ(nullptr, textStyle.shadow);
94 } 94 }
95 95
96 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_NoAdjustmentNee ded) 96 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_NoAdjustmentNee ded)
97 { 97 {
98 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CS SValueRed); 98 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CS SValueRed);
99 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime); 99 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
100 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , CSSValueBlue); 100 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , CSSValueBlue);
101 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy); 101 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy);
102 document().settings()->setShouldPrintBackgrounds(false); 102 document().settings()->setShouldPrintBackgrounds(false);
103 document().setPrinting(true);
103 document().view()->updateLayoutAndStyleForPainting(); 104 document().view()->updateLayoutAndStyleForPainting();
104 105
105 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 106 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
106 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */); 107 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */);
107 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor); 108 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor);
108 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor); 109 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor);
109 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor); 110 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
110 } 111 }
111 112
112 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened) 113 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened)
113 { 114 {
114 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, "r gb(255, 220, 220)"); 115 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, "r gb(255, 220, 220)");
115 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, "rgb(220, 255, 220)"); 116 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, "rgb(220, 255, 220)");
116 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , "rgb(220, 220, 255)"); 117 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , "rgb(220, 220, 255)");
117 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy); 118 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy);
118 document().settings()->setShouldPrintBackgrounds(false); 119 document().settings()->setShouldPrintBackgrounds(false);
120 document().setPrinting(true);
119 document().view()->updateLayoutAndStyleForPainting(); 121 document().view()->updateLayoutAndStyleForPainting();
120 122
121 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 123 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
122 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */); 124 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */);
123 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor); 125 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor);
124 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor); 126 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor);
125 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor); 127 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor);
126 } 128 }
127 129
128 } // namespace 130 } // namespace
129 } // namespace blink 131 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698