| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
| 10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "chrome/test/base/chrome_test_launcher.h" | 17 #include "chrome/test/base/chrome_test_launcher.h" |
| 18 #include "chrome/test/base/chrome_test_suite.h" | 18 #include "chrome/test/base/chrome_test_suite.h" |
| 19 #include "chrome/test/base/mojo_test_connector.h" | 19 #include "chrome/test/base/mojo_test_connector.h" |
| 20 #include "content/public/app/content_main.h" | |
| 21 #include "content/public/common/service_manager_connection.h" | 20 #include "content/public/common/service_manager_connection.h" |
| 22 #include "content/public/test/test_launcher.h" | 21 #include "content/public/test/test_launcher.h" |
| 23 #include "mash/package/mash_packaged_service.h" | 22 #include "mash/package/mash_packaged_service.h" |
| 24 #include "services/service_manager/public/cpp/connector.h" | 23 #include "services/service_manager/public/cpp/connector.h" |
| 25 #include "services/service_manager/public/cpp/service.h" | 24 #include "services/service_manager/public/cpp/service.h" |
| 26 #include "services/service_manager/public/cpp/service_context.h" | 25 #include "services/service_manager/public/cpp/service_context.h" |
| 27 #include "services/service_manager/public/cpp/service_runner.h" | 26 #include "services/service_manager/public/cpp/service_runner.h" |
| 28 #include "services/service_manager/public/cpp/standalone_service/standalone_serv
ice.h" | 27 #include "services/service_manager/public/cpp/standalone_service/standalone_serv
ice.h" |
| 29 #include "services/service_manager/runner/common/switches.h" | 28 #include "services/service_manager/runner/common/switches.h" |
| 30 #include "services/service_manager/runner/init.h" | 29 #include "services/service_manager/runner/init.h" |
| 31 #include "ui/aura/env.h" | |
| 32 | 30 |
| 33 namespace { | 31 namespace { |
| 34 | 32 |
| 35 void ConnectToDefaultApps(service_manager::Connector* connector) { | 33 void ConnectToDefaultApps(service_manager::Connector* connector) { |
| 36 connector->Connect("mash_session"); | 34 connector->Connect("mash_session"); |
| 37 } | 35 } |
| 38 | 36 |
| 39 class MashTestSuite : public ChromeTestSuite { | 37 class MashTestSuite : public ChromeTestSuite { |
| 40 public: | 38 public: |
| 41 MashTestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {} | 39 MashTestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 72 content::kSingleProcessTestsFlag)); | 70 content::kSingleProcessTestsFlag)); |
| 73 DCHECK(test_suite_); | 71 DCHECK(test_suite_); |
| 74 test_suite_->SetMojoTestConnector(base::WrapUnique(new MojoTestConnector)); | 72 test_suite_->SetMojoTestConnector(base::WrapUnique(new MojoTestConnector)); |
| 75 return test_suite_->mojo_test_connector(); | 73 return test_suite_->mojo_test_connector(); |
| 76 } | 74 } |
| 77 | 75 |
| 78 private: | 76 private: |
| 79 // ChromeTestLauncherDelegate: | 77 // ChromeTestLauncherDelegate: |
| 80 int RunTestSuite(int argc, char** argv) override { | 78 int RunTestSuite(int argc, char** argv) override { |
| 81 test_suite_.reset(new MashTestSuite(argc, argv)); | 79 test_suite_.reset(new MashTestSuite(argc, argv)); |
| 82 content::GetContentMainParams()->env_mode = aura::Env::Mode::MUS; | |
| 83 const int result = test_suite_->Run(); | 80 const int result = test_suite_->Run(); |
| 84 test_suite_.reset(); | 81 test_suite_.reset(); |
| 85 return result; | 82 return result; |
| 86 } | 83 } |
| 87 | 84 |
| 88 std::unique_ptr<content::TestState> PreRunTest( | 85 std::unique_ptr<content::TestState> PreRunTest( |
| 89 base::CommandLine* command_line, | 86 base::CommandLine* command_line, |
| 90 base::TestLauncher::LaunchOptions* test_launch_options) override { | 87 base::TestLauncher::LaunchOptions* test_launch_options) override { |
| 91 if (!mojo_test_connector_) { | 88 if (!mojo_test_connector_) { |
| 92 mojo_test_connector_ = base::MakeUnique<MojoTestConnector>(); | 89 mojo_test_connector_ = base::MakeUnique<MojoTestConnector>(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (command_line.HasSwitch(content::kSingleProcessTestsFlag) && | 164 if (command_line.HasSwitch(content::kSingleProcessTestsFlag) && |
| 168 !command_line.HasSwitch(switches::kPrimordialPipeToken)) { | 165 !command_line.HasSwitch(switches::kPrimordialPipeToken)) { |
| 169 service_manager_connection_factory = | 166 service_manager_connection_factory = |
| 170 base::Bind(&CreateServiceManagerConnection, &delegate); | 167 base::Bind(&CreateServiceManagerConnection, &delegate); |
| 171 content::ServiceManagerConnection::SetFactoryForTest( | 168 content::ServiceManagerConnection::SetFactoryForTest( |
| 172 &service_manager_connection_factory); | 169 &service_manager_connection_factory); |
| 173 } | 170 } |
| 174 *exit_code = LaunchChromeTests(default_jobs, &delegate, argc, argv); | 171 *exit_code = LaunchChromeTests(default_jobs, &delegate, argc, argv); |
| 175 return true; | 172 return true; |
| 176 } | 173 } |
| OLD | NEW |