1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/shell/shell_test_helper.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "mojo/shell/init.h"
14 class ShellTestHelper::TestServiceProvider : public ServiceProvider {
16 TestServiceProvider() {}
17 virtual ~TestServiceProvider() {}
20 virtual void ConnectToService(
21 const mojo::String& service_url,
22 const mojo::String& service_name,
23 ScopedMessagePipeHandle client_handle,
24 const mojo::String& requestor_url) OVERRIDE {}
27 DISALLOW_COPY_AND_ASSIGN(TestServiceProvider);
30 ShellTestHelper::ShellTestHelper() {
31 base::CommandLine::Init(0, NULL);
32 mojo::shell::InitializeLogging();
35 ShellTestHelper::~ShellTestHelper() {
38 void ShellTestHelper::Init() {
39 context_.reset(new Context);
40 test_api_.reset(new ServiceManager::TestAPI(context_->service_manager()));
41 local_service_provider_.reset(new TestServiceProvider);
42 service_provider_.Bind(test_api_->GetServiceProviderHandle().Pass());
43 service_provider_.set_client(local_service_provider_.get());
46 void ShellTestHelper::SetLoaderForURL(scoped_ptr<ServiceLoader> loader,
48 context_->service_manager()->SetLoaderForURL(loader.Pass(), url);