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

Unified Diff: mojo/runner/url_resolver_unittest.cc

Issue 1186683008: Revert of Build Mojo apps in subdirectories, like application packages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/runner/url_resolver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/runner/url_resolver_unittest.cc
diff --git a/mojo/runner/url_resolver_unittest.cc b/mojo/runner/url_resolver_unittest.cc
index f9396573d7a21b9cd9e206505f9e1ec6e3b4c8aa..75d213f148ea6c41793fedaf717274d0da55db69 100644
--- a/mojo/runner/url_resolver_unittest.cc
+++ b/mojo/runner/url_resolver_unittest.cc
@@ -140,18 +140,42 @@
EXPECT_EQ("https://c.org/b/a/foo?a=b", mapped_url.spec());
}
-TEST_F(URLResolverTest, TestQueryForBaseFileURL) {
+TEST_F(URLResolverTest, TestQueryForBaseURL) {
URLResolver resolver;
resolver.SetMojoBaseURL(GURL("file:///base"));
GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b"));
- EXPECT_EQ("file:///base/foo/foo.mojo?a=b", mapped_url.spec());
+ EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec());
}
-TEST_F(URLResolverTest, TestQueryForBaseHttpURL) {
+// Verifies that ResolveMojoURL prefers the directory with the name of the host
+// over the raw file.
+TEST_F(URLResolverTest, PreferDirectory) {
+ base::ScopedTempDir tmp_dir;
+ ASSERT_TRUE(tmp_dir.CreateUniqueTempDir());
URLResolver resolver;
- resolver.SetMojoBaseURL(GURL("http://127.0.0.1:1234"));
- GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b"));
- EXPECT_EQ("http://127.0.0.1:1234/foo/foo.mojo?a=b", mapped_url.spec());
+ // With no directory |mojo:foo| maps to path/foo.mojo.
+ resolver.SetMojoBaseURL(util::FilePathToFileURL(tmp_dir.path()));
+ const GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo"));
+ EXPECT_EQ(util::FilePathToFileURL(tmp_dir.path()).spec() + "/foo.mojo",
+ mapped_url.spec());
+
+ // With an empty directory |mojo:foo| maps to path/foo.mojo.
+ const base::FilePath foo_file_path(
+ tmp_dir.path().Append(FILE_PATH_LITERAL("foo")));
+ ASSERT_TRUE(base::CreateDirectory(foo_file_path));
+ const GURL mapped_url_with_dir = resolver.ResolveMojoURL(GURL("mojo:foo"));
+ EXPECT_EQ(util::FilePathToFileURL(tmp_dir.path()).spec() + "/foo.mojo",
+ mapped_url_with_dir.spec());
+
+ // When foo.mojo exists in the directory (path/foo/foo.mojo), then it should
+ // be picked up.
+ // With an empty directory |mojo:foo| maps to path/foo/foo.mojo.
+ ASSERT_EQ(1,
+ base::WriteFile(foo_file_path.Append(FILE_PATH_LITERAL("foo.mojo")),
+ "a", 1));
+ const GURL mapped_url_in_dir = resolver.ResolveMojoURL(GURL("mojo:foo"));
+ EXPECT_EQ(util::FilePathToFileURL(tmp_dir.path()).spec() + "/foo/foo.mojo",
+ mapped_url_in_dir.spec());
}
} // namespace
« no previous file with comments | « mojo/runner/url_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698