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

Unified Diff: chrome/test/base/mojo_test_connector.cc

Issue 2834693002: Mus Browser Tests (Closed)
Patch Set: Address Comments Created 3 years, 8 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 | « chrome/test/base/mojo_test_connector.h ('k') | chrome/test/base/mus_browser_tests_manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/mojo_test_connector.cc
diff --git a/chrome/test/base/mojo_test_connector.cc b/chrome/test/base/mojo_test_connector.cc
index cac5b9ebe9652fe128f797d11393dc7e96b807e5..129bcb73a906ac4f308a65f56ac8c23b62874ac8 100644
--- a/chrome/test/base/mojo_test_connector.cc
+++ b/chrome/test/base/mojo_test_connector.cc
@@ -36,7 +36,8 @@
namespace {
-const char kTestRunnerName[] = "mash_browser_tests";
+const char kMashTestRunnerName[] = "mash_browser_tests";
+const char kMusTestRunnerName[] = "mus_browser_tests";
// State created per test to register a client process with the background
// service manager.
@@ -49,10 +50,11 @@ class MojoTestState : public content::TestState {
~MojoTestState() override {}
void Init(base::CommandLine* command_line,
- base::TestLauncher::LaunchOptions* test_launch_options) {
+ base::TestLauncher::LaunchOptions* test_launch_options,
+ const std::string& mus_config_switch) {
command_line->AppendSwitch(MojoTestConnector::kTestSwitch);
command_line->AppendSwitch(switches::kChildProcess);
- command_line->AppendSwitchASCII(switches::kMusConfig, switches::kMash);
+ command_line->AppendSwitchASCII(switches::kMusConfig, mus_config_switch);
platform_channel_ = base::MakeUnique<mojo::edk::PlatformChannelPair>();
@@ -150,7 +152,9 @@ void RemoveMashFromBrowserTests(base::CommandLine* command_line) {
class MojoTestConnector::ServiceProcessLauncherDelegateImpl
: public service_manager::ServiceProcessLauncher::Delegate {
public:
- ServiceProcessLauncherDelegateImpl() {}
+ explicit ServiceProcessLauncherDelegateImpl(
+ const std::string& test_runner_name)
+ : test_runner_name_(test_runner_name) {}
~ServiceProcessLauncherDelegateImpl() override {}
private:
@@ -159,7 +163,7 @@ class MojoTestConnector::ServiceProcessLauncherDelegateImpl
const service_manager::Identity& target,
base::CommandLine* command_line) override {
if (target.name() != content::mojom::kPackagedServicesServiceName) {
- if (target.name() == kTestRunnerName) {
+ if (target.name() == test_runner_name_) {
RemoveMashFromBrowserTests(command_line);
command_line->SetProgram(
base::CommandLine::ForCurrentProcess()->GetProgram());
@@ -176,6 +180,8 @@ class MojoTestConnector::ServiceProcessLauncherDelegateImpl
*command_line = base::CommandLine(argv);
}
+ const std::string test_runner_name_;
+
DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl);
};
@@ -185,9 +191,12 @@ const char MojoTestConnector::kTestSwitch[] = "is_test";
const char MojoTestConnector::kMashApp[] = "mash-app";
MojoTestConnector::MojoTestConnector(
- std::unique_ptr<base::Value> catalog_contents)
- : service_process_launcher_delegate_(
- new ServiceProcessLauncherDelegateImpl),
+ std::unique_ptr<base::Value> catalog_contents,
+ Config config)
+ : config_(config),
+ service_process_launcher_delegate_(new ServiceProcessLauncherDelegateImpl(
+ config == MojoTestConnector::Config::MASH ? kMashTestRunnerName
+ : kMusTestRunnerName)),
background_service_manager_(nullptr),
catalog_contents_(std::move(catalog_contents)) {}
@@ -216,7 +225,9 @@ service_manager::mojom::ServiceRequest MojoTestConnector::Init() {
service_process_launcher_delegate_.get(),
std::move(catalog_contents_));
background_service_manager_->RegisterService(
- service_manager::Identity(kTestRunnerName,
+ service_manager::Identity(config_ == MojoTestConnector::Config::MASH
+ ? kMashTestRunnerName
+ : kMusTestRunnerName,
service_manager::mojom::kRootUserID),
std::move(service), nullptr);
return request;
@@ -229,6 +240,8 @@ std::unique_ptr<content::TestState> MojoTestConnector::PrepareForTest(
base::TestLauncher::LaunchOptions* test_launch_options) {
auto test_state =
base::MakeUnique<MojoTestState>(background_service_manager_.get());
- test_state->Init(command_line, test_launch_options);
+ test_state->Init(command_line, test_launch_options,
+ config_ == MojoTestConnector::Config::MASH ? switches::kMash
+ : switches::kMus);
return test_state;
}
« no previous file with comments | « chrome/test/base/mojo_test_connector.h ('k') | chrome/test/base/mus_browser_tests_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698