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 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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
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"
11 #include "platform/graphics/paint/PaintController.h" 11 #include "platform/graphics/paint/PaintController.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 #include "public/platform/WebCanvas.h" 13 #include "public/platform/WebCanvas.h"
14 #include "public/platform/WebThread.h" 14 #include "public/platform/WebThread.h"
15 #include "public/web/WebSettings.h" 15 #include "public/web/WebSettings.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
20 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
21 #include "third_party/skia/include/core/SkPaint.h" 21 #include "third_party/skia/include/core/SkPaint.h"
22 #include "web/WebLocalFrameImpl.h" 22 #include "web/WebLocalFrameImpl.h"
23 #include "web/WebViewImpl.h" 23 #include "web/WebViewImpl.h"
24 #include "web/tests/FrameTestHelpers.h" 24 #include "web/tests/FrameTestHelpers.h"
25 #include <memory>
25 26
26 using testing::_; 27 using testing::_;
27 using testing::AtLeast; 28 using testing::AtLeast;
28 using testing::Property; 29 using testing::Property;
29 30
30 namespace blink { 31 namespace blink {
31 namespace { 32 namespace {
32 33
33 static const int viewportWidth = 800; 34 static const int viewportWidth = 800;
34 static const int viewportHeight = 600; 35 static const int viewportHeight = 600;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 m_helper.initialize( 73 m_helper.initialize(
73 false /* enableJavascript */, nullptr /* webFrameClient */, nullptr /* webViewClient */, nullptr /* webWidgetClient */, 74 false /* enableJavascript */, nullptr /* webFrameClient */, nullptr /* webViewClient */, nullptr /* webWidgetClient */,
74 compositingMode == AcceleratedCompositing ? enableAcceleratedComposi ting : disableAcceleratedCompositing); 75 compositingMode == AcceleratedCompositing ? enableAcceleratedComposi ting : disableAcceleratedCompositing);
75 webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); 76 webViewImpl()->resize(WebSize(viewportWidth, viewportHeight));
76 webViewImpl()->updateAllLifecyclePhases(); 77 webViewImpl()->updateAllLifecyclePhases();
77 ASSERT_EQ(compositingMode == AcceleratedCompositing, webViewImpl()->isAc celeratedCompositingActive()); 78 ASSERT_EQ(compositingMode == AcceleratedCompositing, webViewImpl()->isAc celeratedCompositingActive());
78 } 79 }
79 80
80 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); } 81 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); }
81 82
82 PassOwnPtr<PageOverlay> createSolidYellowOverlay() 83 std::unique_ptr<PageOverlay> createSolidYellowOverlay()
83 { 84 {
84 return PageOverlay::create(webViewImpl(), new SolidColorOverlay(SK_Color YELLOW)); 85 return PageOverlay::create(webViewImpl(), new SolidColorOverlay(SK_Color YELLOW));
85 } 86 }
86 87
87 template <typename OverlayType> 88 template <typename OverlayType>
88 void runPageOverlayTestWithAcceleratedCompositing(); 89 void runPageOverlayTestWithAcceleratedCompositing();
89 90
90 private: 91 private:
91 FrameTestHelpers::WebViewHelper m_helper; 92 FrameTestHelpers::WebViewHelper m_helper;
92 }; 93 };
(...skipping 11 matching lines...) Expand all
104 public: 105 public:
105 MockCanvas(int width, int height) : SkCanvas(width, height) { } 106 MockCanvas(int width, int height) : SkCanvas(width, height) { }
106 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&)); 107 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&));
107 }; 108 };
108 109
109 TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) 110 TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing)
110 { 111 {
111 initialize(AcceleratedCompositing); 112 initialize(AcceleratedCompositing);
112 webViewImpl()->layerTreeView()->setViewportSize(WebSize(viewportWidth, viewp ortHeight)); 113 webViewImpl()->layerTreeView()->setViewportSize(WebSize(viewportWidth, viewp ortHeight));
113 114
114 OwnPtr<PageOverlay> pageOverlay = createSolidYellowOverlay(); 115 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay();
115 pageOverlay->update(); 116 pageOverlay->update();
116 webViewImpl()->updateAllLifecyclePhases(); 117 webViewImpl()->updateAllLifecyclePhases();
117 118
118 // Ideally, we would get results from the compositor that showed that this 119 // Ideally, we would get results from the compositor that showed that this
119 // page overlay actually winds up getting drawn on top of the rest. 120 // page overlay actually winds up getting drawn on top of the rest.
120 // For now, we just check that the GraphicsLayer will draw the right thing. 121 // For now, we just check that the GraphicsLayer will draw the right thing.
121 122
122 MockCanvas canvas(viewportWidth, viewportHeight); 123 MockCanvas canvas(viewportWidth, viewportHeight);
123 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0)); 124 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0));
124 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight) , Property(&SkPaint::getColor, SK_ColorYELLOW))); 125 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight) , Property(&SkPaint::getColor, SK_ColorYELLOW)));
125 126
126 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer(); 127 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer();
127 WebRect rect(0, 0, viewportWidth, viewportHeight); 128 WebRect rect(0, 0, viewportWidth, viewportHeight);
128 129
129 // Paint the layer with a null canvas to get a display list, and then 130 // Paint the layer with a null canvas to get a display list, and then
130 // replay that onto the mock canvas for examination. 131 // replay that onto the mock canvas for examination.
131 IntRect intRect = rect; 132 IntRect intRect = rect;
132 graphicsLayer->paint(&intRect); 133 graphicsLayer->paint(&intRect);
133 134
134 PaintController& paintController = graphicsLayer->getPaintController(); 135 PaintController& paintController = graphicsLayer->getPaintController();
135 GraphicsContext graphicsContext(paintController); 136 GraphicsContext graphicsContext(paintController);
136 graphicsContext.beginRecording(intRect); 137 graphicsContext.beginRecording(intRect);
137 paintController.paintArtifact().replay(graphicsContext); 138 paintController.paintArtifact().replay(graphicsContext);
138 graphicsContext.endRecording()->playback(&canvas); 139 graphicsContext.endRecording()->playback(&canvas);
139 } 140 }
140 141
141 TEST_F(PageOverlayTest, PageOverlay_VisualRect) 142 TEST_F(PageOverlayTest, PageOverlay_VisualRect)
142 { 143 {
143 initialize(AcceleratedCompositing); 144 initialize(AcceleratedCompositing);
144 OwnPtr<PageOverlay> pageOverlay = createSolidYellowOverlay(); 145 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay();
145 pageOverlay->update(); 146 pageOverlay->update();
146 webViewImpl()->updateAllLifecyclePhases(); 147 webViewImpl()->updateAllLifecyclePhases();
147 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), pageOverlay->visu alRect()); 148 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), pageOverlay->visu alRect());
148 } 149 }
149 150
150 } // namespace 151 } // namespace
151 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/PageOverlay.cpp ('k') | third_party/WebKit/Source/web/PageWidgetDelegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698