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

Side by Side Diff: third_party/WebKit/Source/web/PageOverlayTest.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Rebase Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "web/PageOverlay.h" 5 #include "web/PageOverlay.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "platform/graphics/Color.h" 8 #include "platform/graphics/Color.h"
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/paint/DrawingRecorder.h" 10 #include "platform/graphics/paint/DrawingRecorder.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 public: 102 public:
103 RuntimeFeatureChange(bool newValue) : m_oldValue(getter()) { 103 RuntimeFeatureChange(bool newValue) : m_oldValue(getter()) {
104 setter(newValue); 104 setter(newValue);
105 } 105 }
106 ~RuntimeFeatureChange() { setter(m_oldValue); } 106 ~RuntimeFeatureChange() { setter(m_oldValue); }
107 107
108 private: 108 private:
109 bool m_oldValue; 109 bool m_oldValue;
110 }; 110 };
111 111
112 class MockCanvas : public SkCanvas { 112 class MockCanvas : public PaintCanvas {
113 public: 113 public:
114 MockCanvas(int width, int height) : SkCanvas(width, height) {} 114 MockCanvas(int width, int height) : PaintCanvas(width, height) {}
115 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&)); 115 MOCK_METHOD2(onDrawRect, void(const SkRect&, const PaintFlags&));
116 }; 116 };
117 117
118 TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) { 118 TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) {
119 initialize(AcceleratedCompositing); 119 initialize(AcceleratedCompositing);
120 webViewImpl()->layerTreeView()->setViewportSize( 120 webViewImpl()->layerTreeView()->setViewportSize(
121 WebSize(viewportWidth, viewportHeight)); 121 WebSize(viewportWidth, viewportHeight));
122 122
123 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); 123 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay();
124 pageOverlay->update(); 124 pageOverlay->update();
125 webViewImpl()->updateAllLifecyclePhases(); 125 webViewImpl()->updateAllLifecyclePhases();
126 126
127 // Ideally, we would get results from the compositor that showed that this 127 // Ideally, we would get results from the compositor that showed that this
128 // page overlay actually winds up getting drawn on top of the rest. 128 // page overlay actually winds up getting drawn on top of the rest.
129 // For now, we just check that the GraphicsLayer will draw the right thing. 129 // For now, we just check that the GraphicsLayer will draw the right thing.
130 130
131 MockCanvas canvas(viewportWidth, viewportHeight); 131 MockCanvas canvas(viewportWidth, viewportHeight);
132 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0)); 132 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0));
133 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight), 133 EXPECT_CALL(canvas,
134 Property(&SkPaint::getColor, SK_ColorYELLOW))); 134 onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight),
135 Property(&PaintFlags::getColor, SK_ColorYELLOW)));
135 136
136 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer(); 137 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer();
137 WebRect rect(0, 0, viewportWidth, viewportHeight); 138 WebRect rect(0, 0, viewportWidth, viewportHeight);
138 139
139 // Paint the layer with a null canvas to get a display list, and then 140 // Paint the layer with a null canvas to get a display list, and then
140 // replay that onto the mock canvas for examination. 141 // replay that onto the mock canvas for examination.
141 IntRect intRect = rect; 142 IntRect intRect = rect;
142 graphicsLayer->paint(&intRect); 143 graphicsLayer->paint(&intRect);
143 144
144 PaintController& paintController = graphicsLayer->getPaintController(); 145 PaintController& paintController = graphicsLayer->getPaintController();
145 GraphicsContext graphicsContext(paintController); 146 GraphicsContext graphicsContext(paintController);
146 graphicsContext.beginRecording(intRect); 147 graphicsContext.beginRecording(intRect);
147 paintController.paintArtifact().replay(graphicsContext); 148 paintController.paintArtifact().replay(graphicsContext);
148 graphicsContext.endRecording()->playback(&canvas); 149 graphicsContext.endRecording()->playback(&canvas);
149 } 150 }
150 151
151 TEST_F(PageOverlayTest, PageOverlay_VisualRect) { 152 TEST_F(PageOverlayTest, PageOverlay_VisualRect) {
152 initialize(AcceleratedCompositing); 153 initialize(AcceleratedCompositing);
153 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); 154 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay();
154 pageOverlay->update(); 155 pageOverlay->update();
155 webViewImpl()->updateAllLifecyclePhases(); 156 webViewImpl()->updateAllLifecyclePhases();
156 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), 157 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight),
157 pageOverlay->visualRect()); 158 pageOverlay->visualRect());
158 } 159 }
159 160
160 } // namespace 161 } // namespace
161 } // namespace blink 162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698