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

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

Issue 2860673002: Change all test cases to use WebViewBase instead of WebViewImpl. (Closed)
Patch Set: Address code review comments. Created 3 years, 7 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 <memory> 7 #include <memory>
8 #include "core/exported/WebViewBase.h" 8 #include "core/exported/WebViewBase.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "platform/graphics/Color.h" 10 #include "platform/graphics/Color.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 protected: 69 protected:
70 enum CompositingMode { kAcceleratedCompositing, kUnacceleratedCompositing }; 70 enum CompositingMode { kAcceleratedCompositing, kUnacceleratedCompositing };
71 71
72 void Initialize(CompositingMode compositing_mode) { 72 void Initialize(CompositingMode compositing_mode) {
73 helper_.Initialize( 73 helper_.Initialize(
74 false /* enableJavascript */, nullptr /* webFrameClient */, 74 false /* enableJavascript */, nullptr /* webFrameClient */,
75 nullptr /* webViewClient */, nullptr /* webWidgetClient */, 75 nullptr /* webViewClient */, nullptr /* webWidgetClient */,
76 compositing_mode == kAcceleratedCompositing 76 compositing_mode == kAcceleratedCompositing
77 ? EnableAcceleratedCompositing 77 ? EnableAcceleratedCompositing
78 : DisableAcceleratedCompositing); 78 : DisableAcceleratedCompositing);
79 GetWebViewImpl()->Resize(WebSize(kViewportWidth, kViewportHeight)); 79 GetWebView()->Resize(WebSize(kViewportWidth, kViewportHeight));
80 GetWebViewImpl()->UpdateAllLifecyclePhases(); 80 GetWebView()->UpdateAllLifecyclePhases();
81 ASSERT_EQ(compositing_mode == kAcceleratedCompositing, 81 ASSERT_EQ(compositing_mode == kAcceleratedCompositing,
82 GetWebViewImpl()->IsAcceleratedCompositingActive()); 82 GetWebView()->IsAcceleratedCompositingActive());
83 } 83 }
84 84
85 WebViewImpl* GetWebViewImpl() const { return helper_.WebView(); } 85 WebViewBase* GetWebView() const { return helper_.WebView(); }
86 86
87 std::unique_ptr<PageOverlay> CreateSolidYellowOverlay() { 87 std::unique_ptr<PageOverlay> CreateSolidYellowOverlay() {
88 return PageOverlay::Create( 88 return PageOverlay::Create(
89 GetWebViewImpl()->MainFrameImpl(), 89 GetWebView()->MainFrameImpl(),
90 WTF::MakeUnique<SolidColorOverlay>(SK_ColorYELLOW)); 90 WTF::MakeUnique<SolidColorOverlay>(SK_ColorYELLOW));
91 } 91 }
92 92
93 template <typename OverlayType> 93 template <typename OverlayType>
94 void RunPageOverlayTestWithAcceleratedCompositing(); 94 void RunPageOverlayTestWithAcceleratedCompositing();
95 95
96 private: 96 private:
97 FrameTestHelpers::WebViewHelper helper_; 97 FrameTestHelpers::WebViewHelper helper_;
98 }; 98 };
99 99
(...skipping 10 matching lines...) Expand all
110 }; 110 };
111 111
112 class MockCanvas : public SkCanvas { 112 class MockCanvas : public SkCanvas {
113 public: 113 public:
114 MockCanvas(int width, int height) : SkCanvas(width, height) {} 114 MockCanvas(int width, int height) : SkCanvas(width, height) {}
115 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&)); 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(kAcceleratedCompositing); 119 Initialize(kAcceleratedCompositing);
120 GetWebViewImpl()->LayerTreeView()->SetViewportSize( 120 GetWebView()->LayerTreeView()->SetViewportSize(
121 WebSize(kViewportWidth, kViewportHeight)); 121 WebSize(kViewportWidth, kViewportHeight));
122 122
123 std::unique_ptr<PageOverlay> page_overlay = CreateSolidYellowOverlay(); 123 std::unique_ptr<PageOverlay> page_overlay = CreateSolidYellowOverlay();
124 page_overlay->Update(); 124 page_overlay->Update();
125 GetWebViewImpl()->UpdateAllLifecyclePhases(); 125 GetWebView()->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(kViewportWidth, kViewportHeight); 131 MockCanvas canvas(kViewportWidth, kViewportHeight);
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(kViewportWidth, kViewportHeight), 134 onDrawRect(SkRect::MakeWH(kViewportWidth, kViewportHeight),
135 Property(&SkPaint::getColor, SK_ColorYELLOW))); 135 Property(&SkPaint::getColor, SK_ColorYELLOW)));
(...skipping 10 matching lines...) Expand all
146 GraphicsContext graphics_context(paint_controller); 146 GraphicsContext graphics_context(paint_controller);
147 graphics_context.BeginRecording(int_rect); 147 graphics_context.BeginRecording(int_rect);
148 paint_controller.GetPaintArtifact().Replay(int_rect, graphics_context); 148 paint_controller.GetPaintArtifact().Replay(int_rect, graphics_context);
149 graphics_context.EndRecording()->playback(&canvas); 149 graphics_context.EndRecording()->playback(&canvas);
150 } 150 }
151 151
152 TEST_F(PageOverlayTest, PageOverlay_VisualRect) { 152 TEST_F(PageOverlayTest, PageOverlay_VisualRect) {
153 Initialize(kAcceleratedCompositing); 153 Initialize(kAcceleratedCompositing);
154 std::unique_ptr<PageOverlay> page_overlay = CreateSolidYellowOverlay(); 154 std::unique_ptr<PageOverlay> page_overlay = CreateSolidYellowOverlay();
155 page_overlay->Update(); 155 page_overlay->Update();
156 GetWebViewImpl()->UpdateAllLifecyclePhases(); 156 GetWebView()->UpdateAllLifecyclePhases();
157 EXPECT_EQ(LayoutRect(0, 0, kViewportWidth, kViewportHeight), 157 EXPECT_EQ(LayoutRect(0, 0, kViewportWidth, kViewportHeight),
158 page_overlay->VisualRect()); 158 page_overlay->VisualRect());
159 } 159 }
160 160
161 } // namespace 161 } // namespace
162 } // namespace blink 162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698