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

Unified Diff: chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc

Issue 589473002: Files.app: Enable externalfile: protocol for MTP volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « chrome/browser/chromeos/fileapi/external_file_url_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc
diff --git a/chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc b/chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc
index b4f569001d581c4695d21fa97b607e4ce7ce5389..73e1f966a4aec63ee3644c0cb1760626c42834e4 100644
--- a/chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc
+++ b/chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc
@@ -32,6 +32,13 @@ class ExternalFileURLUtilTest : public testing::Test {
return testing_profile_manager_;
}
+ storage::FileSystemURL CreateTestURL(const base::FilePath& path) {
+ return storage::FileSystemURL::CreateForTest(
+ GURL("chrome-extension://xxx"),
+ storage::kFileSystemTypeDrive,
+ base::FilePath("drive-test-user-hash").Append(path));
+ }
+
private:
content::TestBrowserThreadBundle thread_bundle_;
TestingProfileManager testing_profile_manager_;
@@ -39,33 +46,41 @@ class ExternalFileURLUtilTest : public testing::Test {
} // namespace
-TEST(ExternalFileURLUtilTest, FilePathToExternalFileURL) {
- base::FilePath path;
-
+TEST_F(ExternalFileURLUtilTest, FilePathToExternalFileURL) {
+ storage::FileSystemURL url;
+ Profile* profile =
+ testing_profile_manager().CreateTestingProfile("test-user");
// Path with alphabets and numbers.
- path = drive::util::GetDriveMyDriveRootPath().AppendASCII("foo/bar012.txt");
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ url = CreateTestURL(base::FilePath("foo/bar012.txt"));
+ EXPECT_EQ(url.virtual_path(),
+ ExternalFileURLToVirtualPath(profile,
+ FileSystemURLToExternalFileURL(url)));
// Path with symbols.
- path = drive::util::GetDriveMyDriveRootPath().AppendASCII(
- " !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~");
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ url = CreateTestURL(base::FilePath(" !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~"));
+ EXPECT_EQ(url.virtual_path(),
+ ExternalFileURLToVirtualPath(profile,
+ FileSystemURLToExternalFileURL(url)));
// Path with '%'.
- path = drive::util::GetDriveMyDriveRootPath().AppendASCII("%19%20%21.txt");
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ url = CreateTestURL(base::FilePath("%19%20%21.txt"));
+ EXPECT_EQ(url.virtual_path(),
+ ExternalFileURLToVirtualPath(profile,
+ FileSystemURLToExternalFileURL(url)));
// Path with multi byte characters.
base::string16 utf16_string;
utf16_string.push_back(0x307b); // HIRAGANA_LETTER_HO
utf16_string.push_back(0x3052); // HIRAGANA_LETTER_GE
- path = drive::util::GetDriveMyDriveRootPath().Append(
+ url = CreateTestURL(
base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt"));
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ EXPECT_EQ(url.virtual_path().AsUTF8Unsafe(),
+ ExternalFileURLToVirtualPath(
+ profile, FileSystemURLToExternalFileURL(url)).AsUTF8Unsafe());
}
-TEST(ExternalFileURLUtilTest, ParseFileURLWithExternalFileOrigin) {
- // filesystem:externalfile:/*** is used only internally. It should not parsed
+TEST_F(ExternalFileURLUtilTest, ParseFileURLWithExternalFileOrigin) {
+ // filesystem:externalfile:/xxx is used only internally. It should not parsed
// directly.
ASSERT_FALSE(storage::FileSystemURL::CreateForTest(
GURL("filesystem:externalfile:/")).is_valid());
« no previous file with comments | « chrome/browser/chromeos/fileapi/external_file_url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698