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

Unified 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, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_web_contents_factory.h
diff --git a/content/public/test/test_web_contents_factory.h b/content/public/test/test_web_contents_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..8b48f9ef2e446a1971f11fcb8038cee897fde462
--- /dev/null
+++ b/content/public/test/test_web_contents_factory.h
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
+#define CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_vector.h"
+
+namespace content {
+class BrowserContext;
+class RenderViewHostTestEnabler;
+class WebContents;
+
+// A helper class to create test web contents (tabs) for unit tests, without
+// inheriting from RenderViewTestHarness. Can create web contents, and will
+// clean up after itself upon destruction. Owns all created web contents.
+// A few notes:
+// - Works well allocated on the stack, because it should be destroyed before
+// associated browser context.
+// - Doesn't play nice with web contents created any other way (because of
+// the implementation of RenderViewHostTestEnabler). But if you are creating
+// web contents already, what do you need this for? ;)
+// TODO(devlin): The API is currently a bit sparse; there may need to be methods
+// to, e.g., delete/close a web contents, access existing web contents, etc.
+// These can be added as-needed.
+class TestWebContentsFactory {
+ public:
+ TestWebContentsFactory();
+ ~TestWebContentsFactory();
+
+ // Creates a new WebContents with the given |context|, and returns it.
+ // Ownership remains with the TestWebContentsFactory.
+ WebContents* CreateWebContents(BrowserContext* context);
+
+ private:
+ // The test factory (and friends) for creating test web contents.
+ scoped_ptr<RenderViewHostTestEnabler> rvh_enabler_;
+
+ // The vector of web contents that this class created.
+ ScopedVector<WebContents> web_contents_;
+
+ // True if the factory initialized aura (and should thus tear it down).
+ bool tear_down_aura_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWebContentsFactory);
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
« 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