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

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: 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
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::HasInstanceForTesting()) {
23 aura::Env::CreateInstance(true);
24 tear_down_aura_ = true;
25 }
26 #endif
27 }
28
29 TestWebContentsFactory::~TestWebContentsFactory() {
30 web_contents_.clear();
sky 2015/02/28 17:30:45 Document why you need to explicitly clear here.
Devlin 2015/03/02 17:27:12 Done.
31 // Let any posted tasks for web contents deletion run.
32 base::RunLoop().RunUntilIdle();
33 rvh_enabler_.reset();
34 // Let any posted tasks for RenderProcess/ViewHost deletion run.
35 base::RunLoop().RunUntilIdle();
36 #if defined(USE_AURA)
37 if (tear_down_aura_)
38 aura::Env::DeleteInstance();
39 #endif
40 }
41
42 WebContents* TestWebContentsFactory::CreateWebContents(
43 BrowserContext* context) {
44 web_contents_.push_back(
45 WebContentsTester::CreateTestWebContents(context, nullptr));
46 DCHECK(web_contents_.back());
47 return web_contents_.back();
48 }
49
50 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698