OLD | NEW |
---|---|
(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. | |
sky
2015/02/28 17:30:45
Even though you say it in the class descriptions I
Devlin
2015/03/02 17:27:12
Done.
| |
34 WebContents* CreateWebContents(BrowserContext* context); | |
35 | |
36 private: | |
37 // The test factory (and friends) for creating test web contents. | |
38 scoped_ptr<RenderViewHostTestEnabler> rvh_enabler_; | |
39 | |
40 // The vector of web contents that this class created. | |
41 ScopedVector<WebContents> web_contents_; | |
42 | |
43 // True if the factory initialized aura (and should thus tear it down). | |
44 bool tear_down_aura_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(TestWebContentsFactory); | |
47 }; | |
48 | |
49 } // namespace content | |
50 | |
51 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_ | |
OLD | NEW |