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 #ifndef CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
6 #define CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_vector.h"
13 class RenderViewHostTestEnabler
;
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.
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
{
30 TestWebContentsFactory();
31 ~TestWebContentsFactory();
33 // Creates a new WebContents with the given |context|, and returns it.
34 // Ownership remains with the TestWebContentsFactory.
35 WebContents
* CreateWebContents(BrowserContext
* context
);
38 // The test factory (and friends) for creating test web contents.
39 scoped_ptr
<RenderViewHostTestEnabler
> rvh_enabler_
;
41 // The vector of web contents that this class created.
42 ScopedVector
<WebContents
> web_contents_
;
44 // True if the factory initialized aura (and should thus tear it down).
47 DISALLOW_COPY_AND_ASSIGN(TestWebContentsFactory
);
50 } // namespace content
52 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_