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

Side by Side Diff: content/public/test/test_web_contents_factory.h

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/content_tests.gypi ('k') | content/test/test_web_contents_factory.cc » ('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 #ifndef CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
6 #define CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_vector.h"
10
11 namespace content {
12 class BrowserContext;
13 class RenderViewHostTestEnabler;
14 class WebContents;
15
16 // A helper class to create test web contents (tabs) for unit tests, without
17 // inheriting from RenderViewTestHarness. Can create web contents, and will
18 // clean up after itself upon destruction. Owns all created web contents.
19 // A few notes:
20 // - Works well allocated on the stack, because it should be destroyed before
21 // associated browser context.
22 // - Doesn't play nice with web contents created any other way (because of
23 // the implementation of RenderViewHostTestEnabler). But if you are creating
24 // web contents already, what do you need this for? ;)
25 // TODO(devlin): The API is currently a bit sparse; there may need to be methods
26 // to, e.g., delete/close a web contents, access existing web contents, etc.
27 // These can be added as-needed.
28 class TestWebContentsFactory {
29 public:
30 TestWebContentsFactory();
31 ~TestWebContentsFactory();
32
33 // Creates a new WebContents with the given |context|, and returns it.
34 // Ownership remains with the TestWebContentsFactory.
35 WebContents* CreateWebContents(BrowserContext* context);
36
37 private:
38 // The test factory (and friends) for creating test web contents.
39 scoped_ptr<RenderViewHostTestEnabler> rvh_enabler_;
40
41 // The vector of web contents that this class created.
42 ScopedVector<WebContents> web_contents_;
43
44 // True if the factory initialized aura (and should thus tear it down).
45 bool tear_down_aura_;
46
47 DISALLOW_COPY_AND_ASSIGN(TestWebContentsFactory);
48 };
49
50 } // namespace content
51
52 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/test/test_web_contents_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698