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

Side by Side Diff: content/test/test_web_contents_factory.cc

Issue 962393002: Add TestWebContentsFactory to content/public/test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Scott's Created 5 years, 9 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 | « content/public/test/test_web_contents_factory.h ('k') | ui/aura/env.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "content/public/test/test_web_contents_factory.h"
6
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"
11
12 #if defined(USE_AURA)
13 #include "ui/aura/env.h"
14 #endif
15
16 namespace content {
17
18 TestWebContentsFactory::TestWebContentsFactory()
19 : rvh_enabler_(new content::RenderViewHostTestEnabler()),
20 tear_down_aura_(false) {
21 #if defined(USE_AURA)
22 if (aura::Env::GetInstanceDontCreate() == nullptr) {
23 aura::Env::CreateInstance(true);
24 tear_down_aura_ = true;
25 }
26 #endif
27 }
28
29 TestWebContentsFactory::~TestWebContentsFactory() {
30 // We explicitly clear the vector to force destruction of any created web
31 // contents so that we can properly handle their cleanup (running posted
32 // tasks, etc).
33 web_contents_.clear();
34 // Let any posted tasks for web contents deletion run.
35 base::RunLoop().RunUntilIdle();
36 rvh_enabler_.reset();
37 // Let any posted tasks for RenderProcess/ViewHost deletion run.
38 base::RunLoop().RunUntilIdle();
39 #if defined(USE_AURA)
40 if (tear_down_aura_)
41 aura::Env::DeleteInstance();
42 #endif
43 }
44
45 WebContents* TestWebContentsFactory::CreateWebContents(
46 BrowserContext* context) {
47 web_contents_.push_back(
48 WebContentsTester::CreateTestWebContents(context, nullptr));
49 DCHECK(web_contents_.back());
50 return web_contents_.back();
51 }
52
53 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_web_contents_factory.h ('k') | ui/aura/env.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698