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

Side by Side Diff: mojo/runner/native_runner_unittest.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
« no previous file with comments | « mojo/runner/in_process_native_runner_unittest.cc ('k') | mojo/runner/shell_test_base.h » ('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 "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/path_service.h"
7 #include "mojo/fetcher/base_application_fetcher.h"
6 #include "mojo/runner/context.h" 8 #include "mojo/runner/context.h"
7 #include "mojo/runner/url_resolver.h"
8 #include "mojo/shell/application_manager.h" 9 #include "mojo/shell/application_manager.h"
9 #include "mojo/util/filename_util.h" 10 #include "mojo/util/filename_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace mojo { 13 namespace mojo {
13 namespace runner { 14 namespace runner {
14 namespace { 15 namespace {
15 16
16 struct TestState { 17 struct TestState {
17 TestState() 18 TestState()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 explicit TestNativeRunnerFactory(TestState* state) : state_(state) {} 52 explicit TestNativeRunnerFactory(TestState* state) : state_(state) {}
52 ~TestNativeRunnerFactory() override {} 53 ~TestNativeRunnerFactory() override {}
53 scoped_ptr<shell::NativeRunner> Create(const Options& options) override { 54 scoped_ptr<shell::NativeRunner> Create(const Options& options) override {
54 return scoped_ptr<shell::NativeRunner>(new TestNativeRunner(state_)); 55 return scoped_ptr<shell::NativeRunner>(new TestNativeRunner(state_));
55 } 56 }
56 57
57 private: 58 private:
58 TestState* state_; 59 TestState* state_;
59 }; 60 };
60 61
61 class NativeApplicationLoaderTest : public testing::Test, 62 class NativeApplicationLoaderTest : public testing::Test {
62 public shell::ApplicationManager::Delegate {
63 public: 63 public:
64 NativeApplicationLoaderTest() : application_manager_(this) {} 64 NativeApplicationLoaderTest() {
65 ~NativeApplicationLoaderTest() override {} 65 base::FilePath shell_dir;
66 PathService::Get(base::DIR_MODULE, &shell_dir);
67 context_.reset(new Context(shell_dir));
68 loop_.reset(new base::MessageLoop);
69 }
70 ~NativeApplicationLoaderTest() override {
71 loop_.reset();
72 context_.reset();
73 }
66 void SetUp() override { 74 void SetUp() override {
67 context_.Init(); 75 context_->Init();
68 scoped_ptr<shell::NativeRunnerFactory> factory( 76 scoped_ptr<shell::NativeRunnerFactory> factory(
69 new TestNativeRunnerFactory(&state_)); 77 new TestNativeRunnerFactory(&state_));
70 application_manager_.set_native_runner_factory(factory.Pass()); 78 context_->application_manager()->set_native_runner_factory(factory.Pass());
71 application_manager_.set_blocking_pool( 79 context_->application_manager()->set_blocking_pool(
72 context_.task_runners()->blocking_pool()); 80 context_->task_runners()->blocking_pool());
73 } 81 }
74 void TearDown() override { context_.Shutdown(); } 82 void TearDown() override { context_->Shutdown(); }
75 83
76 protected: 84 protected:
77 Context context_; 85 scoped_ptr<base::MessageLoop> loop_;
78 base::MessageLoop loop_; 86 scoped_ptr<Context> context_;
79 shell::ApplicationManager application_manager_;
80 TestState state_; 87 TestState state_;
81
82 private:
83 // shell::ApplicationManager::Delegate
84 GURL ResolveMappings(const GURL& url) override {
85 return context_.url_resolver()->ApplyMappings(url);
86 }
87 GURL ResolveMojoURL(const GURL& url) override {
88 return context_.url_resolver()->ResolveMojoURL(url);
89 }
90 bool CreateFetcher(
91 const GURL& url,
92 const shell::Fetcher::FetchCallback& loader_callback) override {
93 return false;
94 }
95 }; 88 };
96 89
97 TEST_F(NativeApplicationLoaderTest, DoesNotExist) { 90 TEST_F(NativeApplicationLoaderTest, DoesNotExist) {
98 base::ScopedTempDir temp_dir; 91 base::ScopedTempDir temp_dir;
99 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 92 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
100 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt")); 93 base::FilePath nonexistent_file(FILE_PATH_LITERAL("nonexistent.txt"));
101 GURL url(util::FilePathToFileURL(temp_dir.path().Append(nonexistent_file))); 94 GURL url(util::FilePathToFileURL(temp_dir.path().Append(nonexistent_file)));
102 InterfaceRequest<ServiceProvider> services; 95 InterfaceRequest<ServiceProvider> services;
103 ServiceProviderPtr service_provider; 96 ServiceProviderPtr service_provider;
104 mojo::URLRequestPtr request(mojo::URLRequest::New()); 97 mojo::URLRequestPtr request(mojo::URLRequest::New());
105 request->url = mojo::String::From(url.spec()); 98 request->url = mojo::String::From(url.spec());
106 application_manager_.ConnectToApplication( 99 context_->application_manager()->ConnectToApplication(
107 nullptr, request.Pass(), std::string(), services.Pass(), 100 nullptr, request.Pass(), std::string(), services.Pass(),
108 service_provider.Pass(), shell::GetPermissiveCapabilityFilter(), 101 service_provider.Pass(), shell::GetPermissiveCapabilityFilter(),
109 base::Closure(), shell::EmptyConnectCallback()); 102 base::Closure(), shell::EmptyConnectCallback());
110 EXPECT_FALSE(state_.runner_was_created); 103 EXPECT_FALSE(state_.runner_was_created);
111 EXPECT_FALSE(state_.runner_was_started); 104 EXPECT_FALSE(state_.runner_was_started);
112 EXPECT_FALSE(state_.runner_was_destroyed); 105 EXPECT_FALSE(state_.runner_was_destroyed);
113 } 106 }
114 107
115 } // namespace 108 } // namespace
116 } // namespace runner 109 } // namespace runner
117 } // namespace mojo 110 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/in_process_native_runner_unittest.cc ('k') | mojo/runner/shell_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698