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

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

Issue 1216543005: Revert of Add a FrameView lifecycle method that just updates layout, style and compositing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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
« no previous file with comments | « Source/core/paint/DisplayItemListPaintTest.cpp ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 ASSERT_TRUE(m_layoutText); 34 ASSERT_TRUE(m_layoutText);
35 ASSERT_EQ("Hello world", m_layoutText->text()); 35 ASSERT_EQ("Hello world", m_layoutText->text());
36 } 36 }
37 37
38 LayoutText* m_layoutText; 38 LayoutText* m_layoutText;
39 }; 39 };
40 40
41 TEST_F(TextPainterTest, TextPaintingStyle_Simple) 41 TEST_F(TextPainterTest, TextPaintingStyle_Simple)
42 { 42 {
43 document().body()->setInlineStyleProperty(CSSPropertyColor, CSSValueBlue); 43 document().body()->setInlineStyleProperty(CSSPropertyColor, CSSValueBlue);
44 document().view()->updateAllLifecyclePhases(); 44 document().view()->updateLayoutAndStyleForPainting();
45 45
46 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 46 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
47 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, fal se /* isPrinting */); 47 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, fal se /* isPrinting */);
48 EXPECT_EQ(Color(0, 0, 255), textStyle.fillColor); 48 EXPECT_EQ(Color(0, 0, 255), textStyle.fillColor);
49 EXPECT_EQ(Color(0, 0, 255), textStyle.strokeColor); 49 EXPECT_EQ(Color(0, 0, 255), textStyle.strokeColor);
50 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor); 50 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
51 EXPECT_EQ(0, textStyle.strokeWidth); 51 EXPECT_EQ(0, textStyle.strokeWidth);
52 EXPECT_EQ(nullptr, textStyle.shadow); 52 EXPECT_EQ(nullptr, textStyle.shadow);
53 } 53 }
54 54
55 TEST_F(TextPainterTest, TextPaintingStyle_AllProperties) 55 TEST_F(TextPainterTest, TextPaintingStyle_AllProperties)
56 { 56 {
57 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CS SValueRed); 57 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CS SValueRed);
58 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime); 58 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
59 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , CSSValueBlue); 59 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , CSSValueBlue);
60 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::CSS_PX); 60 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::CSS_PX);
61 document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3p x yellow"); 61 document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3p x yellow");
62 document().view()->updateAllLifecyclePhases(); 62 document().view()->updateLayoutAndStyleForPainting();
63 63
64 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 64 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
65 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, fal se /* isPrinting */); 65 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, fal se /* isPrinting */);
66 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor); 66 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor);
67 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor); 67 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor);
68 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor); 68 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
69 EXPECT_EQ(4, textStyle.strokeWidth); 69 EXPECT_EQ(4, textStyle.strokeWidth);
70 ASSERT_NE(nullptr, textStyle.shadow); 70 ASSERT_NE(nullptr, textStyle.shadow);
71 EXPECT_EQ(1u, textStyle.shadow->shadows().size()); 71 EXPECT_EQ(1u, textStyle.shadow->shadows().size());
72 EXPECT_EQ(1, textStyle.shadow->shadows()[0].x()); 72 EXPECT_EQ(1, textStyle.shadow->shadows()[0].x());
73 EXPECT_EQ(2, textStyle.shadow->shadows()[0].y()); 73 EXPECT_EQ(2, textStyle.shadow->shadows()[0].y());
74 EXPECT_EQ(3, textStyle.shadow->shadows()[0].blur()); 74 EXPECT_EQ(3, textStyle.shadow->shadows()[0].blur());
75 EXPECT_EQ(Color(255, 255, 0), textStyle.shadow->shadows()[0].color().color() ); 75 EXPECT_EQ(Color(255, 255, 0), textStyle.shadow->shadows()[0].color().color() );
76 } 76 }
77 77
78 TEST_F(TextPainterTest, TextPaintingStyle_ForceBlackText) 78 TEST_F(TextPainterTest, TextPaintingStyle_ForceBlackText)
79 { 79 {
80 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CS SValueRed); 80 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, CS SValueRed);
81 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime); 81 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, CSSValueLime);
82 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , CSSValueBlue); 82 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , CSSValueBlue);
83 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::CSS_PX); 83 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeWidth, 4, CSSPrimitiveValue::CSS_PX);
84 document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3p x yellow"); 84 document().body()->setInlineStyleProperty(CSSPropertyTextShadow, "1px 2px 3p x yellow");
85 document().view()->updateAllLifecyclePhases(); 85 document().view()->updateLayoutAndStyleForPainting();
86 86
87 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 87 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
88 *layoutText(), layoutText()->styleRef(), true /* forceBlackText */, fals e /* isPrinting */); 88 *layoutText(), layoutText()->styleRef(), true /* forceBlackText */, fals e /* isPrinting */);
89 EXPECT_EQ(Color::black, textStyle.fillColor); 89 EXPECT_EQ(Color::black, textStyle.fillColor);
90 EXPECT_EQ(Color::black, textStyle.strokeColor); 90 EXPECT_EQ(Color::black, textStyle.strokeColor);
91 EXPECT_EQ(Color::black, textStyle.emphasisMarkColor); 91 EXPECT_EQ(Color::black, textStyle.emphasisMarkColor);
92 EXPECT_EQ(4, textStyle.strokeWidth); 92 EXPECT_EQ(4, textStyle.strokeWidth);
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().setPrinting(true);
104 document().view()->updateAllLifecyclePhases(); 104 document().view()->updateLayoutAndStyleForPainting();
105 105
106 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 106 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
107 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */); 107 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */);
108 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor); 108 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor);
109 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor); 109 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor);
110 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor); 110 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor);
111 } 111 }
112 112
113 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened) 113 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened)
114 { 114 {
115 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, "r gb(255, 220, 220)"); 115 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, "r gb(255, 220, 220)");
116 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, "rgb(220, 255, 220)"); 116 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, "rgb(220, 255, 220)");
117 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , "rgb(220, 220, 255)"); 117 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor , "rgb(220, 220, 255)");
118 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy); 118 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, CSSValueEconomy);
119 document().settings()->setShouldPrintBackgrounds(false); 119 document().settings()->setShouldPrintBackgrounds(false);
120 document().setPrinting(true); 120 document().setPrinting(true);
121 document().view()->updateAllLifecyclePhases(); 121 document().view()->updateLayoutAndStyleForPainting();
122 122
123 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 123 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
124 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */); 124 *layoutText(), layoutText()->styleRef(), false /* forceBlackText */, tru e /* isPrinting */);
125 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor); 125 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor);
126 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor); 126 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor);
127 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor); 127 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor);
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 } // namespace blink 131 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/DisplayItemListPaintTest.cpp ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698