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

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

Issue 314293002: Mojo: Add a trivial end-to-end (in-process) test of Mojo shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments 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
« no previous file with comments | « mojo/shell/shell_test_base.h ('k') | mojo/shell/shell_test_base_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
8 #include "base/file_util.h"
9 #include "base/files/file_path.h"
10 #include "base/logging.h"
11 #include "build/build_config.h"
12 #include "mojo/shell/context.h"
13 #include "net/base/filename_util.h"
14 #include "url/gurl.h"
15
7 namespace mojo { 16 namespace mojo {
8 namespace shell { 17 namespace shell {
9 namespace test { 18 namespace test {
10 19
11 ShellTestBase::ShellTestBase() { 20 ShellTestBase::ShellTestBase() {
12 } 21 }
13 22
14 ShellTestBase::~ShellTestBase() { 23 ShellTestBase::~ShellTestBase() {
15 } 24 }
16 25
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(
34 const GURL& service_url,
35 const std::string& service_name,
36 ScopedMessagePipeHandle client_handle) {
37 DCHECK(message_loop_);
38 DCHECK(shell_context_);
39
40 base::FilePath base_dir = base::MakeAbsoluteFilePath(
41 base::CommandLine::ForCurrentProcess()->GetProgram().DirName());
42 // On Mac and Windows, libraries are dumped beside the executables.
43 #if defined(OS_MACOSX) || defined(OS_WIN)
44 base::FilePath service_dir(base_dir);
45 #else
46 // On Linux, they're under lib/.
47 base::FilePath service_dir(base_dir.AppendASCII("lib"));
48 #endif
49 shell_context_->set_mojo_origin(net::FilePathToFileURL(service_dir).spec());
50
51 shell_context_->service_manager()->ConnectToService(
52 service_url, service_name, client_handle.Pass(), GURL());
53 }
54
17 } // namespace test 55 } // namespace test
18 } // namespace shell 56 } // namespace shell
19 } // namespace mojo 57 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/shell_test_base.h ('k') | mojo/shell/shell_test_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698