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

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

Issue 2715793002: Change mock canvases to paint into SkCanvas (Closed)
Patch Set: Fix deps 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
« no previous file with comments | « third_party/WebKit/Source/core/page/PrintContextTest.cpp ('k') | ui/views/BUILD.gn » ('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 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 PaintCanvas { 112 class MockCanvas : public SkCanvas {
113 public: 113 public:
114 MockCanvas(int width, int height) : PaintCanvas(width, height) {} 114 MockCanvas(int width, int height) : SkCanvas(width, height) {}
115 MOCK_METHOD2(onDrawRect, void(const SkRect&, const PaintFlags&)); 115 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&));
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, 133 EXPECT_CALL(canvas,
134 onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight), 134 onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight),
135 Property(&PaintFlags::getColor, SK_ColorYELLOW))); 135 Property(&SkPaint::getColor, SK_ColorYELLOW)));
136 136
137 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer(); 137 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer();
138 WebRect rect(0, 0, viewportWidth, viewportHeight); 138 WebRect rect(0, 0, viewportWidth, viewportHeight);
139 139
140 // 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
141 // replay that onto the mock canvas for examination. 141 // replay that onto the mock canvas for examination.
142 IntRect intRect = rect; 142 IntRect intRect = rect;
143 graphicsLayer->paint(&intRect); 143 graphicsLayer->paint(&intRect);
144 144
145 PaintController& paintController = graphicsLayer->getPaintController(); 145 PaintController& paintController = graphicsLayer->getPaintController();
146 GraphicsContext graphicsContext(paintController); 146 GraphicsContext graphicsContext(paintController);
147 graphicsContext.beginRecording(intRect); 147 graphicsContext.beginRecording(intRect);
148 paintController.paintArtifact().replay(graphicsContext); 148 paintController.paintArtifact().replay(graphicsContext);
149 graphicsContext.endRecording()->playback(&canvas); 149 graphicsContext.endRecording()->playback(&canvas);
150 } 150 }
151 151
152 TEST_F(PageOverlayTest, PageOverlay_VisualRect) { 152 TEST_F(PageOverlayTest, PageOverlay_VisualRect) {
153 initialize(AcceleratedCompositing); 153 initialize(AcceleratedCompositing);
154 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); 154 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay();
155 pageOverlay->update(); 155 pageOverlay->update();
156 webViewImpl()->updateAllLifecyclePhases(); 156 webViewImpl()->updateAllLifecyclePhases();
157 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), 157 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight),
158 pageOverlay->visualRect()); 158 pageOverlay->visualRect());
159 } 159 }
160 160
161 } // namespace 161 } // namespace
162 } // namespace blink 162 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/PrintContextTest.cpp ('k') | ui/views/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698