| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/shell/shell_test_base.h" | 5 #include "mojo/shell/shell_test_base.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" | 
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" | 
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" | 
| 13 #include "mojo/shell/context.h" |  | 
| 14 #include "net/base/filename_util.h" | 13 #include "net/base/filename_util.h" | 
| 15 #include "url/gurl.h" | 14 #include "url/gurl.h" | 
| 16 | 15 | 
| 17 namespace mojo { | 16 namespace mojo { | 
| 18 namespace shell { | 17 namespace shell { | 
| 19 namespace test { | 18 namespace test { | 
| 20 | 19 | 
| 21 ShellTestBase::ShellTestBase() { | 20 ShellTestBase::ShellTestBase() { | 
| 22 } | 21 } | 
| 23 | 22 | 
| 24 ShellTestBase::~ShellTestBase() { | 23 ShellTestBase::~ShellTestBase() { | 
| 25 } | 24 } | 
| 26 | 25 | 
| 27 void ShellTestBase::InitMojo() { |  | 
| 28   DCHECK(!message_loop_); |  | 
| 29   DCHECK(!shell_context_); |  | 
| 30   message_loop_.reset(new base::MessageLoop()); |  | 
| 31   shell_context_.reset(new Context()); |  | 
| 32 } |  | 
| 33 |  | 
| 34 void ShellTestBase::LaunchServiceInProcess( | 26 void ShellTestBase::LaunchServiceInProcess( | 
| 35     const GURL& service_url, | 27     const GURL& service_url, | 
| 36     const std::string& service_name, | 28     const std::string& service_name, | 
| 37     ScopedMessagePipeHandle client_handle) { | 29     ScopedMessagePipeHandle client_handle) { | 
| 38   DCHECK(message_loop_); |  | 
| 39   DCHECK(shell_context_); |  | 
| 40 |  | 
| 41   base::FilePath base_dir; | 30   base::FilePath base_dir; | 
| 42   CHECK(PathService::Get(base::DIR_EXE, &base_dir)); | 31   CHECK(PathService::Get(base::DIR_EXE, &base_dir)); | 
| 43   // On android, the library is bundled with the app. | 32   // On android, the library is bundled with the app. | 
| 44 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) | 
| 45   base::FilePath service_dir; | 34   base::FilePath service_dir; | 
| 46   CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); | 35   CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); | 
| 47   // On Mac and Windows, libraries are dumped beside the executables. | 36   // On Mac and Windows, libraries are dumped beside the executables. | 
| 48 #elif defined(OS_MACOSX) || defined(OS_WIN) | 37 #elif defined(OS_MACOSX) || defined(OS_WIN) | 
| 49   base::FilePath service_dir(base_dir); | 38   base::FilePath service_dir(base_dir); | 
| 50 #else | 39 #else | 
| 51   // On Linux, they're under lib/. | 40   // On Linux, they're under lib/. | 
| 52   base::FilePath service_dir(base_dir.AppendASCII("lib")); | 41   base::FilePath service_dir(base_dir.AppendASCII("lib")); | 
| 53 #endif | 42 #endif | 
| 54   shell_context_->mojo_url_resolver()->set_origin( | 43   shell_context_.mojo_url_resolver()->set_origin( | 
| 55       net::FilePathToFileURL(service_dir).spec()); | 44       net::FilePathToFileURL(service_dir).spec()); | 
| 56 | 45 | 
| 57   shell_context_->service_manager()->ConnectToService( | 46   shell_context_.service_manager()->ConnectToService( | 
| 58       service_url, service_name, client_handle.Pass(), GURL()); | 47       service_url, service_name, client_handle.Pass(), GURL()); | 
| 59 } | 48 } | 
| 60 | 49 | 
| 61 }  // namespace test | 50 }  // namespace test | 
| 62 }  // namespace shell | 51 }  // namespace shell | 
| 63 }  // namespace mojo | 52 }  // namespace mojo | 
| OLD | NEW | 
|---|