| 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
|
|
|