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

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

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