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

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

Issue 1342503003: Move fetching logic out of ApplicationManager, eliminate url mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 3 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
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/runner/shell_test_base.h" 5 #include "mojo/runner/shell_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 12 matching lines...) Expand all
23 23
24 void QuitIfRunning() { 24 void QuitIfRunning() {
25 if (base::MessageLoop::current() && 25 if (base::MessageLoop::current() &&
26 base::MessageLoop::current()->is_running()) { 26 base::MessageLoop::current()->is_running()) {
27 base::MessageLoop::current()->QuitWhenIdle(); 27 base::MessageLoop::current()->QuitWhenIdle();
28 } 28 }
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 ShellTestBase::ShellTestBase() { 33 ShellTestBase::ShellTestBase() : shell_context_(GetTestAppFilePath()) {
34 } 34 }
35 35
36 ShellTestBase::~ShellTestBase() { 36 ShellTestBase::~ShellTestBase() {
37 } 37 }
38 38
39 void ShellTestBase::SetUp() { 39 void ShellTestBase::SetUp() {
40 CHECK(shell_context_.Init()); 40 CHECK(shell_context_.Init());
41 SetUpTestApplications();
42 } 41 }
43 42
44 void ShellTestBase::TearDown() { 43 void ShellTestBase::TearDown() {
45 shell_context_.Shutdown(); 44 shell_context_.Shutdown();
46 } 45 }
47 46
48 ScopedMessagePipeHandle ShellTestBase::ConnectToService( 47 ScopedMessagePipeHandle ShellTestBase::ConnectToService(
49 const GURL& application_url, 48 const GURL& application_url,
50 const std::string& service_name) { 49 const std::string& service_name) {
51 ServiceProviderPtr services; 50 ServiceProviderPtr services;
52 mojo::URLRequestPtr request(mojo::URLRequest::New()); 51 mojo::URLRequestPtr request(mojo::URLRequest::New());
53 request->url = mojo::String::From(application_url.spec()); 52 request->url = mojo::String::From(application_url.spec());
54 shell_context_.application_manager()->ConnectToApplication( 53 shell_context_.application_manager()->ConnectToApplication(
55 nullptr, request.Pass(), std::string(), GetProxy(&services), nullptr, 54 nullptr, request.Pass(), std::string(), GetProxy(&services), nullptr,
56 shell::GetPermissiveCapabilityFilter(), base::Bind(&QuitIfRunning), 55 shell::GetPermissiveCapabilityFilter(), base::Bind(&QuitIfRunning),
57 shell::EmptyConnectCallback()); 56 shell::EmptyConnectCallback());
58 MessagePipe pipe; 57 MessagePipe pipe;
59 services->ConnectToService(service_name, pipe.handle1.Pass()); 58 services->ConnectToService(service_name, pipe.handle1.Pass());
60 return pipe.handle0.Pass(); 59 return pipe.handle0.Pass();
61 } 60 }
62 61
63 #if !defined(OS_ANDROID) 62 #if !defined(OS_ANDROID)
64 void ShellTestBase::SetUpTestApplications() { 63 base::FilePath ShellTestBase::GetTestAppFilePath() const {
65 // Set the URLResolver origin to be the same as the base file path for 64 base::FilePath shell_dir;
66 // local files. This is primarily for test convenience, so that references 65 PathService::Get(base::DIR_MODULE, &shell_dir);
67 // to unknown mojo: URLs that do not have specific local file or custom 66 return shell_dir;
68 // mappings registered on the URL resolver are treated as shared libraries.
69 base::FilePath service_dir;
70 CHECK(PathService::Get(base::DIR_MODULE, &service_dir));
71 shell_context_.url_resolver()->SetMojoBaseURL(
72 util::FilePathToFileURL(service_dir));
73 } 67 }
74 #endif 68 #endif
75 69
76 } // namespace test 70 } // namespace test
77 } // namespace runner 71 } // namespace runner
78 } // namespace mojo 72 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698