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

Side by Side Diff: mojo/shell/shell_test_base.cc

Issue 343843002: mojo: remove need for ShellTestBase::InitMojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "build/build_config.h" 11 #include "build/build_config.h"
12 #include "mojo/shell/context.h"
13 #include "net/base/filename_util.h" 12 #include "net/base/filename_util.h"
14 #include "url/gurl.h" 13 #include "url/gurl.h"
15 14
16 namespace mojo { 15 namespace mojo {
17 namespace shell { 16 namespace shell {
18 namespace test { 17 namespace test {
19 18
20 ShellTestBase::ShellTestBase() { 19 ShellTestBase::ShellTestBase() {
21 } 20 }
22 21
23 ShellTestBase::~ShellTestBase() { 22 ShellTestBase::~ShellTestBase() {
24 } 23 }
25 24
26 void ShellTestBase::InitMojo() {
27 DCHECK(!message_loop_);
28 DCHECK(!shell_context_);
29 message_loop_.reset(new base::MessageLoop());
30 shell_context_.reset(new Context());
31 }
32
33 void ShellTestBase::LaunchServiceInProcess( 25 void ShellTestBase::LaunchServiceInProcess(
34 const GURL& service_url, 26 const GURL& service_url,
35 const std::string& service_name, 27 const std::string& service_name,
36 ScopedMessagePipeHandle client_handle) { 28 ScopedMessagePipeHandle client_handle) {
37 DCHECK(message_loop_);
38 DCHECK(shell_context_);
39
40 base::FilePath base_dir = base::MakeAbsoluteFilePath( 29 base::FilePath base_dir = base::MakeAbsoluteFilePath(
41 base::CommandLine::ForCurrentProcess()->GetProgram().DirName()); 30 base::CommandLine::ForCurrentProcess()->GetProgram().DirName());
42 // On Mac and Windows, libraries are dumped beside the executables. 31 // On Mac and Windows, libraries are dumped beside the executables.
43 #if defined(OS_MACOSX) || defined(OS_WIN) 32 #if defined(OS_MACOSX) || defined(OS_WIN)
44 base::FilePath service_dir(base_dir); 33 base::FilePath service_dir(base_dir);
45 #else 34 #else
46 // On Linux, they're under lib/. 35 // On Linux, they're under lib/.
47 base::FilePath service_dir(base_dir.AppendASCII("lib")); 36 base::FilePath service_dir(base_dir.AppendASCII("lib"));
48 #endif 37 #endif
49 shell_context_->mojo_url_resolver()->set_origin( 38 shell_context_.mojo_url_resolver()->set_origin(
50 net::FilePathToFileURL(service_dir).spec()); 39 net::FilePathToFileURL(service_dir).spec());
51 40
52 shell_context_->service_manager()->ConnectToService( 41 shell_context_.service_manager()->ConnectToService(
53 service_url, service_name, client_handle.Pass(), GURL()); 42 service_url, service_name, client_handle.Pass(), GURL());
54 } 43 }
55 44
56 } // namespace test 45 } // namespace test
57 } // namespace shell 46 } // namespace shell
58 } // namespace mojo 47 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698