| 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/process/launch.h" | 11 #include "base/process/launch.h" |
| 12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "chrome/test/base/chrome_test_launcher.h" | 13 #include "chrome/test/base/chrome_test_launcher.h" |
| 14 #include "chrome/test/base/chrome_test_suite.h" | 14 #include "chrome/test/base/chrome_test_suite.h" |
| 15 #include "chrome/test/base/mojo_test_connector.h" | 15 #include "chrome/test/base/mojo_test_connector.h" |
| 16 #include "content/public/common/mojo_shell_connection.h" | 16 #include "content/public/common/mojo_shell_connection.h" |
| 17 #include "content/public/test/test_launcher.h" | 17 #include "content/public/test/test_launcher.h" |
| 18 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
| 19 #include "services/shell/public/cpp/shell_client.h" | 19 #include "services/shell/public/cpp/service.h" |
| 20 #include "services/shell/public/cpp/shell_connection.h" | 20 #include "services/shell/public/cpp/shell_connection.h" |
| 21 #include "services/shell/runner/common/switches.h" | 21 #include "services/shell/runner/common/switches.h" |
| 22 #include "services/shell/runner/host/child_process.h" | 22 #include "services/shell/runner/host/child_process.h" |
| 23 #include "services/shell/runner/init.h" | 23 #include "services/shell/runner/init.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 void ConnectToDefaultApps(shell::Connector* connector) { | 27 void ConnectToDefaultApps(shell::Connector* connector) { |
| 28 connector->Connect("mojo:mash_session"); | 28 connector->Connect("mojo:mash_session"); |
| 29 } | 29 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 test_suite_.reset(new MashTestSuite(argc, argv)); | 73 test_suite_.reset(new MashTestSuite(argc, argv)); |
| 74 const int result = test_suite_->Run(); | 74 const int result = test_suite_->Run(); |
| 75 test_suite_.reset(); | 75 test_suite_.reset(); |
| 76 return result; | 76 return result; |
| 77 } | 77 } |
| 78 std::unique_ptr<content::TestState> PreRunTest( | 78 std::unique_ptr<content::TestState> PreRunTest( |
| 79 base::CommandLine* command_line, | 79 base::CommandLine* command_line, |
| 80 base::TestLauncher::LaunchOptions* test_launch_options) override { | 80 base::TestLauncher::LaunchOptions* test_launch_options) override { |
| 81 if (!mojo_test_connector_) { | 81 if (!mojo_test_connector_) { |
| 82 mojo_test_connector_.reset(new MojoTestConnector); | 82 mojo_test_connector_.reset(new MojoTestConnector); |
| 83 shell_client_.reset(new shell::ShellClient); | 83 service_.reset(new shell::Service); |
| 84 shell_connection_.reset(new shell::ShellConnection( | 84 shell_connection_.reset(new shell::ShellConnection( |
| 85 shell_client_.get(), mojo_test_connector_->Init())); | 85 service_.get(), mojo_test_connector_->Init())); |
| 86 ConnectToDefaultApps(shell_connection_->connector()); | 86 ConnectToDefaultApps(shell_connection_->connector()); |
| 87 } | 87 } |
| 88 return mojo_test_connector_->PrepareForTest(command_line, | 88 return mojo_test_connector_->PrepareForTest(command_line, |
| 89 test_launch_options); | 89 test_launch_options); |
| 90 } | 90 } |
| 91 void OnDoneRunningTests() override { | 91 void OnDoneRunningTests() override { |
| 92 // We have to shutdown this state here, while an AtExitManager is still | 92 // We have to shutdown this state here, while an AtExitManager is still |
| 93 // valid. | 93 // valid. |
| 94 shell_connection_.reset(); | 94 shell_connection_.reset(); |
| 95 shell_client_.reset(); | 95 service_.reset(); |
| 96 mojo_test_connector_.reset(); | 96 mojo_test_connector_.reset(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 std::unique_ptr<MashTestSuite> test_suite_; | 99 std::unique_ptr<MashTestSuite> test_suite_; |
| 100 std::unique_ptr<MojoTestConnector> mojo_test_connector_; | 100 std::unique_ptr<MojoTestConnector> mojo_test_connector_; |
| 101 std::unique_ptr<shell::ShellClient> shell_client_; | 101 std::unique_ptr<shell::Service> service_; |
| 102 std::unique_ptr<shell::ShellConnection> shell_connection_; | 102 std::unique_ptr<shell::ShellConnection> shell_connection_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(MashTestLauncherDelegate); | 104 DISALLOW_COPY_AND_ASSIGN(MashTestLauncherDelegate); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 std::unique_ptr<content::MojoShellConnection> CreateMojoShellConnection( | 107 std::unique_ptr<content::MojoShellConnection> CreateMojoShellConnection( |
| 108 MashTestLauncherDelegate* delegate) { | 108 MashTestLauncherDelegate* delegate) { |
| 109 std::unique_ptr<content::MojoShellConnection> connection( | 109 std::unique_ptr<content::MojoShellConnection> connection( |
| 110 content::MojoShellConnection::Create( | 110 content::MojoShellConnection::Create( |
| 111 delegate->GetMojoTestConnectorForSingleProcess()->Init())); | 111 delegate->GetMojoTestConnectorForSingleProcess()->Init())); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 !command_line.HasSwitch(switches::kPrimordialPipeToken)) { | 148 !command_line.HasSwitch(switches::kPrimordialPipeToken)) { |
| 149 shell_connection_factory = | 149 shell_connection_factory = |
| 150 base::Bind(&CreateMojoShellConnection, &delegate); | 150 base::Bind(&CreateMojoShellConnection, &delegate); |
| 151 content::MojoShellConnection::SetFactoryForTest(&shell_connection_factory); | 151 content::MojoShellConnection::SetFactoryForTest(&shell_connection_factory); |
| 152 } | 152 } |
| 153 *exit_code = LaunchChromeTests(default_jobs, &delegate, argc, argv); | 153 *exit_code = LaunchChromeTests(default_jobs, &delegate, argc, argv); |
| 154 // TODO(sky): nuke once resolve why test isn't shutting down: 594600. | 154 // TODO(sky): nuke once resolve why test isn't shutting down: 594600. |
| 155 LOG(ERROR) << "RunMashBrowserTests exit_code=" << *exit_code; | 155 LOG(ERROR) << "RunMashBrowserTests exit_code=" << *exit_code; |
| 156 return true; | 156 return true; |
| 157 } | 157 } |
| OLD | NEW |