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

Unified Diff: mojo/shell/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: rename 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
« mojo/mojo_application_package.gni ('K') | « mojo/shell/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/shell/url_resolver_unittest.cc
diff --git a/mojo/shell/url_resolver_unittest.cc b/mojo/shell/url_resolver_unittest.cc
index dd8da75541195fa87190198f4501018ceb3844d4..83d7df9d318b0c16a1eba108ca54e64e743574b3 100644
--- a/mojo/shell/url_resolver_unittest.cc
+++ b/mojo/shell/url_resolver_unittest.cc
@@ -4,7 +4,10 @@
#include "mojo/shell/url_resolver.h"
+#include "base/files/file_util.h"
+#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
+#include "mojo/shell/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(FilePathToFileURL(tmp_dir.path()));
+ const GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo"));
+ EXPECT_EQ(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(FilePathToFileURL(tmp_dir.path()).spec() + "/foo/foo.mojo",
+ mapped_url_with_dir.spec());
+}
+
} // namespace
} // namespace test
} // namespace shell
« mojo/mojo_application_package.gni ('K') | « mojo/shell/url_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698