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

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

Issue 1109993002: Adds support for mojo apps to live in their own directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to trunk and move filename_util to own dir Created 5 years, 8 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/url_resolver.cc ('k') | mojo/shell/BUILD.gn » ('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/runner/url_resolver.h" 5 #include "mojo/runner/url_resolver.h"
6 6
7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h"
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/util/filename_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
9 12
10 namespace mojo { 13 namespace mojo {
11 namespace shell { 14 namespace shell {
12 namespace test { 15 namespace test {
13 namespace { 16 namespace {
14 17
15 typedef testing::Test URLResolverTest; 18 typedef testing::Test URLResolverTest;
16 19
17 TEST_F(URLResolverTest, MojoURLsFallThrough) { 20 TEST_F(URLResolverTest, MojoURLsFallThrough) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 EXPECT_EQ("https://c.org/b/a/foo?a=b", mapped_url.spec()); 140 EXPECT_EQ("https://c.org/b/a/foo?a=b", mapped_url.spec());
138 } 141 }
139 142
140 TEST_F(URLResolverTest, TestQueryForBaseURL) { 143 TEST_F(URLResolverTest, TestQueryForBaseURL) {
141 URLResolver resolver; 144 URLResolver resolver;
142 resolver.SetMojoBaseURL(GURL("file:///base")); 145 resolver.SetMojoBaseURL(GURL("file:///base"));
143 GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b")); 146 GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b"));
144 EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec()); 147 EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec());
145 } 148 }
146 149
150 // Verifies that ResolveMojoURL prefers the directory with the name of the host
151 // over the raw file.
152 TEST_F(URLResolverTest, PreferDirectory) {
153 base::ScopedTempDir tmp_dir;
154 ASSERT_TRUE(tmp_dir.CreateUniqueTempDir());
155 URLResolver resolver;
156 // With no directory |mojo:foo| maps to path/foo.mojo.
157 resolver.SetMojoBaseURL(util::FilePathToFileURL(tmp_dir.path()));
158 const GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo"));
159 EXPECT_EQ(util::FilePathToFileURL(tmp_dir.path()).spec() + "/foo.mojo",
160 mapped_url.spec());
161
162 // With a directory |mojo:foo| maps to path/foo/foo.mojo.
163 const base::FilePath foo_file_path(
164 tmp_dir.path().Append(FILE_PATH_LITERAL("foo")));
165 ASSERT_TRUE(base::CreateDirectory(foo_file_path));
166 const GURL mapped_url_with_dir = resolver.ResolveMojoURL(GURL("mojo:foo"));
167 EXPECT_EQ(util::FilePathToFileURL(tmp_dir.path()).spec() + "/foo/foo.mojo",
168 mapped_url_with_dir.spec());
169 }
170
147 } // namespace 171 } // namespace
148 } // namespace test 172 } // namespace test
149 } // namespace shell 173 } // namespace shell
150 } // namespace mojo 174 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/url_resolver.cc ('k') | mojo/shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698