cec75ce47d4389f2a08c383a9a3465c4382e5d9a
[platform/framework/web/crosswalk.git] / src / mojo / shell / shell_test_helper.cc
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.
4
5 #include "mojo/shell/shell_test_helper.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "mojo/shell/init.h"
10
11 namespace mojo {
12 namespace shell {
13
14 class ShellTestHelper::TestServiceProvider : public ServiceProvider {
15  public:
16   TestServiceProvider() {}
17   virtual ~TestServiceProvider() {}
18
19   // ServiceProvider:
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 {}
25
26  private:
27   DISALLOW_COPY_AND_ASSIGN(TestServiceProvider);
28 };
29
30 ShellTestHelper::ShellTestHelper() {
31   base::CommandLine::Init(0, NULL);
32   mojo::shell::InitializeLogging();
33 }
34
35 ShellTestHelper::~ShellTestHelper() {
36 }
37
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());
44 }
45
46 void ShellTestHelper::SetLoaderForURL(scoped_ptr<ServiceLoader> loader,
47                                       const GURL& url) {
48   context_->service_manager()->SetLoaderForURL(loader.Pass(), url);
49 }
50
51 }  // namespace shell
52 }  // namespace mojo