| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/test/test_launcher.h" | 5 #include "content/public/test/test_launcher.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/test/test_suite.h" | 11 #include "base/test/test_suite.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/test/content_test_suite_base.h" | 13 #include "content/public/test/content_test_suite_base.h" |
| 14 #include "content/shell/shell_content_browser_client.h" | 14 #include "content/shell/shell_content_browser_client.h" |
| 15 #include "content/shell/shell_content_client.h" | 15 #include "content/shell/shell_content_client.h" |
| 16 #include "content/shell/shell_main_delegate.h" | 16 #include "content/shell/shell_main_delegate.h" |
| 17 #include "content/shell/shell_switches.h" | 17 #include "content/shell/shell_switches.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 #if defined(OS_ANDROID) |
| 21 #include "base/message_loop.h" |
| 22 #include "base/message_pump_android.h" |
| 23 #endif |
| 24 |
| 20 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 21 #include "content/public/app/startup_helper_win.h" | 26 #include "content/public/app/startup_helper_win.h" |
| 22 #include "sandbox/win/src/sandbox_types.h" | 27 #include "sandbox/win/src/sandbox_types.h" |
| 23 #endif // defined(OS_WIN) | 28 #endif // defined(OS_WIN) |
| 24 | 29 |
| 25 namespace content { | 30 namespace content { |
| 26 | 31 |
| 27 class ContentShellTestSuiteInitializer | 32 class ContentShellTestSuiteInitializer |
| 28 : public testing::EmptyTestEventListener { | 33 : public testing::EmptyTestEventListener { |
| 29 public: | 34 public: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 45 SetContentClient(NULL); | 50 SetContentClient(NULL); |
| 46 } | 51 } |
| 47 | 52 |
| 48 private: | 53 private: |
| 49 scoped_ptr<ShellContentClient> content_client_; | 54 scoped_ptr<ShellContentClient> content_client_; |
| 50 scoped_ptr<ShellContentBrowserClient> browser_content_client_; | 55 scoped_ptr<ShellContentBrowserClient> browser_content_client_; |
| 51 | 56 |
| 52 DISALLOW_COPY_AND_ASSIGN(ContentShellTestSuiteInitializer); | 57 DISALLOW_COPY_AND_ASSIGN(ContentShellTestSuiteInitializer); |
| 53 }; | 58 }; |
| 54 | 59 |
| 60 #if defined(OS_ANDROID) |
| 61 base::MessagePump* CreateMessagePumpForUI() { |
| 62 return new base::MessagePumpForUI(); |
| 63 }; |
| 64 #endif |
| 65 |
| 55 class ContentBrowserTestSuite : public ContentTestSuiteBase { | 66 class ContentBrowserTestSuite : public ContentTestSuiteBase { |
| 56 public: | 67 public: |
| 57 ContentBrowserTestSuite(int argc, char** argv) | 68 ContentBrowserTestSuite(int argc, char** argv) |
| 58 : ContentTestSuiteBase(argc, argv) { | 69 : ContentTestSuiteBase(argc, argv) { |
| 59 } | 70 } |
| 60 virtual ~ContentBrowserTestSuite() { | 71 virtual ~ContentBrowserTestSuite() { |
| 61 } | 72 } |
| 62 | 73 |
| 63 protected: | 74 protected: |
| 64 virtual void Initialize() OVERRIDE { | 75 virtual void Initialize() OVERRIDE { |
| 76 |
| 77 #if defined(OS_ANDROID) |
| 78 // This needs to be done before base::TestSuite::Initialize() is called, |
| 79 // as it also tries to set MessagePumpForUIFactory. |
| 80 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUI)) |
| 81 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; |
| 82 #endif |
| 83 |
| 65 ContentTestSuiteBase::Initialize(); | 84 ContentTestSuiteBase::Initialize(); |
| 66 | 85 |
| 67 testing::TestEventListeners& listeners = | 86 testing::TestEventListeners& listeners = |
| 68 testing::UnitTest::GetInstance()->listeners(); | 87 testing::UnitTest::GetInstance()->listeners(); |
| 69 listeners.Append(new ContentShellTestSuiteInitializer); | 88 listeners.Append(new ContentShellTestSuiteInitializer); |
| 70 } | 89 } |
| 71 virtual void Shutdown() OVERRIDE { | 90 virtual void Shutdown() OVERRIDE { |
| 72 base::TestSuite::Shutdown(); | 91 base::TestSuite::Shutdown(); |
| 73 } | 92 } |
| 74 | 93 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 private: | 127 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); | 128 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); |
| 110 }; | 129 }; |
| 111 | 130 |
| 112 } // namespace content | 131 } // namespace content |
| 113 | 132 |
| 114 int main(int argc, char** argv) { | 133 int main(int argc, char** argv) { |
| 115 content::ContentTestLauncherDelegate launcher_delegate; | 134 content::ContentTestLauncherDelegate launcher_delegate; |
| 116 return LaunchTests(&launcher_delegate, argc, argv); | 135 return LaunchTests(&launcher_delegate, argc, argv); |
| 117 } | 136 } |
| OLD | NEW |