Roll src/third_party/WebKit 29324ab:10b2b4a (svn 202547:202548)
[chromium-blink-merge.git] / content / test / test_web_contents_factory.cc
blob0cbbbe83f94447a2f4e413a039751e4a0d1e23ec
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
3 // found in the LICENSE file.
5 #include "content/public/test/test_web_contents_factory.h"
7 #include "base/run_loop.h"
8 #include "content/public/browser/web_contents.h"
9 #include "content/public/test/test_renderer_host.h"
10 #include "content/public/test/web_contents_tester.h"
12 namespace content {
14 TestWebContentsFactory::TestWebContentsFactory()
15 : rvh_enabler_(new content::RenderViewHostTestEnabler()) {
18 TestWebContentsFactory::~TestWebContentsFactory() {
19 // We explicitly clear the vector to force destruction of any created web
20 // contents so that we can properly handle their cleanup (running posted
21 // tasks, etc).
22 web_contents_.clear();
23 // Let any posted tasks for web contents deletion run.
24 base::RunLoop().RunUntilIdle();
25 rvh_enabler_.reset();
26 // Let any posted tasks for RenderProcess/ViewHost deletion run.
27 base::RunLoop().RunUntilIdle();
30 WebContents* TestWebContentsFactory::CreateWebContents(
31 BrowserContext* context) {
32 web_contents_.push_back(
33 WebContentsTester::CreateTestWebContents(context, nullptr));
34 DCHECK(web_contents_.back());
35 return web_contents_.back();
38 } // namespace content