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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_browsertest.cc

Issue 2779713002: Add a test checking that compositor works in a reused renderer. (Closed)
Patch Set: Don't create a new shell. Created 3 years, 8 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 | « no previous file | content/test/data/page_with_animation.html » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/barrier_closure.h" 8 #include "base/barrier_closure.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "cc/paint/skia_paint_canvas.h" 18 #include "cc/paint/skia_paint_canvas.h"
18 #include "content/browser/gpu/compositor_util.h" 19 #include "content/browser/gpu/compositor_util.h"
19 #include "content/browser/gpu/gpu_data_manager_impl.h" 20 #include "content/browser/gpu/gpu_data_manager_impl.h"
20 #include "content/browser/renderer_host/dip_util.h" 21 #include "content/browser/renderer_host/dip_util.h"
21 #include "content/browser/renderer_host/render_widget_host_impl.h" 22 #include "content/browser/renderer_host/render_widget_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_host_view_base.h" 23 #include "content/browser/renderer_host/render_widget_host_view_base.h"
23 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber .h" 24 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber .h"
25 #include "content/common/frame_messages.h"
24 #include "content/public/browser/gpu_data_manager.h" 26 #include "content/public/browser/gpu_data_manager.h"
25 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "content/public/common/content_paths.h" 29 #include "content/public/common/content_paths.h"
28 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
29 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
30 #include "content/public/test/browser_test_utils.h" 32 #include "content/public/test/browser_test_utils.h"
31 #include "content/public/test/content_browser_test.h" 33 #include "content/public/test/content_browser_test.h"
32 #include "content/public/test/content_browser_test_utils.h" 34 #include "content/public/test/content_browser_test_utils.h"
35 #include "content/public/test/test_utils.h"
33 #include "content/shell/browser/shell.h" 36 #include "content/shell/browser/shell.h"
34 #include "media/base/video_frame.h" 37 #include "media/base/video_frame.h"
35 #include "media/renderers/skcanvas_video_renderer.h" 38 #include "media/renderers/skcanvas_video_renderer.h"
36 #include "net/base/filename_util.h" 39 #include "net/base/filename_util.h"
40 #include "net/dns/mock_host_resolver.h"
37 #include "third_party/skia/include/core/SkBitmap.h" 41 #include "third_party/skia/include/core/SkBitmap.h"
38 #include "third_party/skia/include/core/SkCanvas.h" 42 #include "third_party/skia/include/core/SkCanvas.h"
39 #include "ui/base/layout.h" 43 #include "ui/base/layout.h"
40 #include "ui/base/ui_base_switches.h" 44 #include "ui/base/ui_base_switches.h"
41 #include "ui/display/display_switches.h" 45 #include "ui/display/display_switches.h"
42 #include "ui/gfx/geometry/size_conversions.h" 46 #include "ui/gfx/geometry/size_conversions.h"
43 #include "ui/gl/gl_switches.h" 47 #include "ui/gl/gl_switches.h"
44 48
45 #if defined(OS_WIN) 49 #if defined(OS_WIN)
46 #include "base/win/windows_version.h" 50 #include "base/win/windows_version.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 run_loop.Run(); 199 run_loop.Run();
196 } 200 }
197 201
198 private: 202 private:
199 const gfx::Size frame_size_; 203 const gfx::Size frame_size_;
200 base::FilePath test_dir_; 204 base::FilePath test_dir_;
201 int callback_invoke_count_; 205 int callback_invoke_count_;
202 int frames_captured_; 206 int frames_captured_;
203 }; 207 };
204 208
209 // Helps to ensure that a navigation is committed after a compositor frame was
210 // submitted by the renderer, but before corresponding ACK is sent back.
211 class CommitBeforeSwapAckSentHelper : public WebContentsObserver {
212 public:
213 explicit CommitBeforeSwapAckSentHelper(WebContents* web_contents)
214 : WebContentsObserver(web_contents) {}
215
216 private:
217 void WaitForSwapCompositorFrame() {
218 base::MessageLoop::ScopedNestableTaskAllower allow(
219 base::MessageLoop::current());
220 FrameWatcher(web_contents()).WaitFrames(1);
221 }
222
223 bool OnMessageReceived(const IPC::Message& message,
224 RenderFrameHost* rfh) override {
225 IPC_BEGIN_MESSAGE_MAP(CommitBeforeSwapAckSentHelper, message)
226 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
227 WaitForSwapCompositorFrame())
228 IPC_END_MESSAGE_MAP()
229 return false;
230 }
231
232 DISALLOW_COPY_AND_ASSIGN(CommitBeforeSwapAckSentHelper);
233 };
234
235 using RenderWidgetHostViewBrowserTestBase = ContentBrowserTest;
236
237 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewBrowserTestBase,
238 CompositorWorksWhenReusingRenderer) {
239 host_resolver()->AddRule("*", "127.0.0.1");
240 ASSERT_TRUE(embedded_test_server()->Start());
241 auto* web_contents = shell()->web_contents();
242 // Load a page that draws new frames infinitely.
243 NavigateToURL(shell(),
244 embedded_test_server()->GetURL("/page_with_animation.html"));
245
246 // Open a new page in the same renderer to keep it alive.
247 WebContents::CreateParams new_contents_params(
248 web_contents->GetBrowserContext(), web_contents->GetSiteInstance());
249 std::unique_ptr<WebContents> new_web_contents(
250 WebContents::Create(new_contents_params));
251
252 new_web_contents->GetController().LoadURLWithParams(
253 NavigationController::LoadURLParams(GURL(url::kAboutBlankURL)));
254 EXPECT_TRUE(WaitForLoadStop(new_web_contents.get()));
255
256 // Start a cross-process navigation.
257 shell()->LoadURL(embedded_test_server()->GetURL("foo.com", "/title1.html"));
258
259 // When the navigation is about to commit, wait for the next frame to be
260 // submitted by the renderer before proceeding with page load.
261 {
262 CommitBeforeSwapAckSentHelper commit_helper(web_contents);
263 EXPECT_TRUE(WaitForLoadStop(web_contents));
264 EXPECT_NE(web_contents->GetRenderProcessHost(),
265 new_web_contents->GetRenderProcessHost());
266 }
267
268 // Go back and verify that the renderer continues to draw new frames.
269 shell()->GoBackOrForward(-1);
270 EXPECT_TRUE(WaitForLoadStop(web_contents));
271 EXPECT_EQ(web_contents->GetRenderProcessHost(),
272 new_web_contents->GetRenderProcessHost());
273 FrameWatcher(web_contents).WaitFrames(5);
274 }
275
205 enum CompositingMode { 276 enum CompositingMode {
206 GL_COMPOSITING, 277 GL_COMPOSITING,
207 SOFTWARE_COMPOSITING, 278 SOFTWARE_COMPOSITING,
208 }; 279 };
209 280
210 class CompositingRenderWidgetHostViewBrowserTest 281 class CompositingRenderWidgetHostViewBrowserTest
211 : public RenderWidgetHostViewBrowserTest, 282 : public RenderWidgetHostViewBrowserTest,
212 public testing::WithParamInterface<CompositingMode> { 283 public testing::WithParamInterface<CompositingMode> {
213 public: 284 public:
214 CompositingRenderWidgetHostViewBrowserTest() 285 CompositingRenderWidgetHostViewBrowserTest()
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 kTestCompositingModes); 1007 kTestCompositingModes);
937 INSTANTIATE_TEST_CASE_P( 1008 INSTANTIATE_TEST_CASE_P(
938 GLAndSoftwareCompositing, 1009 GLAndSoftwareCompositing,
939 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, 1010 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
940 kTestCompositingModes); 1011 kTestCompositingModes);
941 1012
942 #endif // !defined(OS_ANDROID) 1013 #endif // !defined(OS_ANDROID)
943 1014
944 } // namespace 1015 } // namespace
945 } // namespace content 1016 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/data/page_with_animation.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698