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

Side by Side Diff: third_party/WebKit/Source/core/paint/LayoutObjectDrawingRecorderTest.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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
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 "core/paint/LayoutObjectDrawingRecorder.h" 5 #include "core/paint/LayoutObjectDrawingRecorder.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/PaintControllerPaintTest.h" 9 #include "core/paint/PaintControllerPaintTest.h"
10 #include "core/paint/PaintLayer.h" 10 #include "core/paint/PaintLayer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 IntRect rect(0, 0, 10, 10); 44 IntRect rect(0, 0, 10, 10);
45 context.drawRect(rect); 45 context.drawRect(rect);
46 } 46 }
47 47
48 TEST_F(LayoutObjectDrawingRecorderTest, Nothing) { 48 TEST_F(LayoutObjectDrawingRecorderTest, Nothing) {
49 rootPaintController().invalidateAll(); 49 rootPaintController().invalidateAll();
50 GraphicsContext context(rootPaintController()); 50 GraphicsContext context(rootPaintController());
51 LayoutRect bound = layoutView().viewRect(); 51 LayoutRect bound = layoutView().viewRect();
52 drawNothing(context, layoutView(), PaintPhaseForeground, bound); 52 drawNothing(context, layoutView(), PaintPhaseForeground, bound);
53 rootPaintController().commitNewDisplayItems(); 53 rootPaintController().commitNewDisplayItems();
54 EXPECT_DISPLAY_LIST( 54 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 1,
55 rootPaintController().getDisplayItemList(), 1, 55 TestDisplayItem(layoutView(),
56 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType( 56 DisplayItem::paintPhaseToDrawingType(
57 PaintPhaseForeground))); 57 PaintPhaseForeground)));
58 EXPECT_FALSE(static_cast<const DrawingDisplayItem&>( 58 EXPECT_FALSE(static_cast<const DrawingDisplayItem&>(
59 rootPaintController().getDisplayItemList()[0]) 59 rootPaintController().getDisplayItemList()[0])
60 .GetPaintRecord()); 60 .GetPaintRecord());
61 } 61 }
62 62
63 TEST_F(LayoutObjectDrawingRecorderTest, Rect) { 63 TEST_F(LayoutObjectDrawingRecorderTest, Rect) {
64 rootPaintController().invalidateAll(); 64 rootPaintController().invalidateAll();
65 GraphicsContext context(rootPaintController()); 65 GraphicsContext context(rootPaintController());
66 LayoutRect bound = layoutView().viewRect(); 66 LayoutRect bound = layoutView().viewRect();
67 drawRect(context, layoutView(), PaintPhaseForeground, bound); 67 drawRect(context, layoutView(), PaintPhaseForeground, bound);
68 rootPaintController().commitNewDisplayItems(); 68 rootPaintController().commitNewDisplayItems();
69 EXPECT_DISPLAY_LIST( 69 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 1,
70 rootPaintController().getDisplayItemList(), 1, 70 TestDisplayItem(layoutView(),
71 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType( 71 DisplayItem::paintPhaseToDrawingType(
72 PaintPhaseForeground))); 72 PaintPhaseForeground)));
73 } 73 }
74 74
75 TEST_F(LayoutObjectDrawingRecorderTest, Cached) { 75 TEST_F(LayoutObjectDrawingRecorderTest, Cached) {
76 rootPaintController().invalidateAll(); 76 rootPaintController().invalidateAll();
77 GraphicsContext context(rootPaintController()); 77 GraphicsContext context(rootPaintController());
78 LayoutRect bound = layoutView().viewRect(); 78 LayoutRect bound = layoutView().viewRect();
79 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackgroundOnly, bound); 79 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackgroundOnly, bound);
80 drawRect(context, layoutView(), PaintPhaseForeground, bound); 80 drawRect(context, layoutView(), PaintPhaseForeground, bound);
81 rootPaintController().commitNewDisplayItems(); 81 rootPaintController().commitNewDisplayItems();
82 82
83 EXPECT_DISPLAY_LIST( 83 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2,
84 rootPaintController().getDisplayItemList(), 2, 84 TestDisplayItem(layoutView(),
85 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType( 85 DisplayItem::paintPhaseToDrawingType(
86 PaintPhaseSelfBlockBackgroundOnly)), 86 PaintPhaseSelfBlockBackgroundOnly)),
87 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType( 87 TestDisplayItem(layoutView(),
88 PaintPhaseForeground))); 88 DisplayItem::paintPhaseToDrawingType(
89 PaintPhaseForeground)));
89 90
90 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackgroundOnly, bound); 91 drawNothing(context, layoutView(), PaintPhaseSelfBlockBackgroundOnly, bound);
91 drawRect(context, layoutView(), PaintPhaseForeground, bound); 92 drawRect(context, layoutView(), PaintPhaseForeground, bound);
92 93
93 EXPECT_EQ(2, numCachedNewItems()); 94 EXPECT_EQ(2, numCachedNewItems());
94 95
95 rootPaintController().commitNewDisplayItems(); 96 rootPaintController().commitNewDisplayItems();
96 97
97 EXPECT_DISPLAY_LIST( 98 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 2,
98 rootPaintController().getDisplayItemList(), 2, 99 TestDisplayItem(layoutView(),
99 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType( 100 DisplayItem::paintPhaseToDrawingType(
100 PaintPhaseSelfBlockBackgroundOnly)), 101 PaintPhaseSelfBlockBackgroundOnly)),
101 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType( 102 TestDisplayItem(layoutView(),
102 PaintPhaseForeground))); 103 DisplayItem::paintPhaseToDrawingType(
104 PaintPhaseForeground)));
103 } 105 }
104 106
105 template <typename T> 107 template <typename T>
106 FloatRect drawAndGetCullRect(PaintController& controller, 108 FloatRect drawAndGetCullRect(PaintController& controller,
107 const LayoutObject& layoutObject, 109 const LayoutObject& layoutObject,
108 const T& bounds) { 110 const T& bounds) {
109 controller.invalidateAll(); 111 controller.invalidateAll();
110 { 112 {
111 // Draw some things which will produce a non-null picture. 113 // Draw some things which will produce a non-null picture.
112 GraphicsContext context(controller); 114 GraphicsContext context(controller);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Ensure the new paint offset can be used. 183 // Ensure the new paint offset can be used.
182 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground)); 184 EXPECT_TRUE(LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutView(), PaintPhaseForeground));
183 rootPaintController().commitNewDisplayItems(); 185 rootPaintController().commitNewDisplayItems();
184 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 1, 186 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 1,
185 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 187 TestDisplayItem(layoutView(), DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)));
186 } 188 }
187 #endif 189 #endif
188 190
189 } // namespace 191 } // namespace
190 } // namespace blink 192 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698