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

Unified Diff: content/test/content_test_launcher.cc

Issue 10803026: Get content_browsertest working. I've added a simple test for now, and will convert the tests in sr… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Index: content/test/content_test_launcher.cc
===================================================================
--- content/test/content_test_launcher.cc (revision 147044)
+++ content/test/content_test_launcher.cc (working copy)
@@ -12,13 +12,79 @@
#include "base/test/test_suite.h"
#include "content/public/app/content_main.h"
#include "content/public/common/content_switches.h"
+#include "content/public/test/content_test_suite_base.h"
+#include "content/shell/shell_content_browser_client.h"
+#include "content/shell/shell_content_client.h"
#include "content/shell/shell_main_delegate.h"
+#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
#include "content/public/app/startup_helper_win.h"
#include "sandbox/src/sandbox_types.h"
+#include "ui/base/win/scoped_ole_initializer.h"
#endif // defined(OS_WIN)
+namespace content {
+
+class ContentShellTestSuiteInitializer
+ : public testing::EmptyTestEventListener {
+ public:
+ ContentShellTestSuiteInitializer() {
+ }
+
+ virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
+ DCHECK(!GetContentClient());
+ content_client_.reset(new ShellContentClient);
+ browser_content_client_.reset(new ShellContentBrowserClient());
+ content_client_->set_browser_for_testing(browser_content_client_.get());
+ SetContentClient(content_client_.get());
+ }
+
+ virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
+ DCHECK_EQ(content_client_.get(), GetContentClient());
+ browser_content_client_.reset();
+ content_client_.reset();
+ SetContentClient(NULL);
+ }
+
+ private:
+ scoped_ptr<ShellContentClient> content_client_;
+ scoped_ptr<ShellContentBrowserClient> browser_content_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentShellTestSuiteInitializer);
+};
+
+class ContentBrowserTestSuite : public ContentTestSuiteBase {
+ public:
+ ContentBrowserTestSuite(int argc, char** argv)
+ : ContentTestSuiteBase(argc, argv) {
+ }
+ virtual ~ContentBrowserTestSuite() {
+ }
+
+ protected:
+ virtual void Initialize() OVERRIDE {
+ ContentTestSuiteBase::Initialize();
+
+ testing::TestEventListeners& listeners =
+ testing::UnitTest::GetInstance()->listeners();
+ listeners.Append(new ContentShellTestSuiteInitializer);
+ }
+ virtual void Shutdown() OVERRIDE {
+ base::TestSuite::Shutdown();
+ }
+
+ virtual ContentClient* CreateClientForInitialization() OVERRIDE {
+ return new ShellContentClient();
+ }
+
+#if defined(OS_WIN)
+ ui::ScopedOleInitializer ole_initializer_;
+#endif
+};
sky 2012/07/18 23:23:35 DISALLOW_...
jam 2012/07/18 23:44:06 Done.
+
+} // namespace content
+
class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate {
public:
ContentTestLauncherDelegate() {
@@ -47,7 +113,7 @@
}
virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
- return base::TestSuite(argc, argv).Run();
+ return content::ContentBrowserTestSuite(argc, argv).Run();
}
virtual bool AdjustChildProcessCommandLine(

Powered by Google App Engine
This is Rietveld 408576698