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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/runner/url_resolver.cc ('k') | mojo/shell/BUILD.gn » ('j') | 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 5862b51c46466c32053a73601b35d1d1e30c8457..26a67f210402a27a7f2f9cd5cca3661e1e108e0e 100644
--- a/mojo/runner/url_resolver_unittest.cc
+++ b/mojo/runner/url_resolver_unittest.cc
@@ -4,7 +4,10 @@
#include "mojo/runner/url_resolver.h"
+#include "base/files/file_util.h"
+#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
+#include "mojo/util/filename_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
@@ -144,6 +147,27 @@ TEST_F(URLResolverTest, TestQueryForBaseURL) {
EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec());
}
+// 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;
+ // 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 a directory |mojo:foo| maps to path/foo/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/foo.mojo",
+ mapped_url_with_dir.spec());
+}
+
} // namespace
} // namespace test
} // namespace shell
« 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