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

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: Fixed. 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
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..a844e68408763e7abf862fbf6d9bf29433757573 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 CreateExpectedURL(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,39 +46,44 @@ class ExternalFileURLUtilTest : public testing::Test {
} // namespace
-TEST(ExternalFileURLUtilTest, FilePathToExternalFileURL) {
- base::FilePath path;
+TEST_F(ExternalFileURLUtilTest, FilePathToExternalFileURL) {
+ storage::FileSystemURL url;
// Path with alphabets and numbers.
- path = drive::util::GetDriveMyDriveRootPath().AppendASCII("foo/bar012.txt");
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ url = CreateExpectedURL(base::FilePath("foo/bar012.txt"));
+ EXPECT_EQ(url.virtual_path(),
+ ExternalFileURLToVirtualPath(FileSystemURLToExternalFileURL(url)));
// Path with symbols.
- path = drive::util::GetDriveMyDriveRootPath().AppendASCII(
- " !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~");
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ url = CreateExpectedURL(base::FilePath(" !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~"));
+ EXPECT_EQ(url.virtual_path(),
+ ExternalFileURLToVirtualPath(FileSystemURLToExternalFileURL(url)));
// Path with '%'.
- path = drive::util::GetDriveMyDriveRootPath().AppendASCII("%19%20%21.txt");
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ url = CreateExpectedURL(base::FilePath("%19%20%21.txt"));
+ EXPECT_EQ(url.virtual_path(),
+ ExternalFileURLToVirtualPath(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 = CreateExpectedURL(
base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt"));
- EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
+ EXPECT_EQ(url.virtual_path().AsUTF8Unsafe(),
+ ExternalFileURLToVirtualPath(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());
- ASSERT_FALSE(
- storage::FileSystemURL::CreateForTest(
- GURL("filesystem:externalfile:/external/drive/file.txt")).is_valid());
+ ASSERT_FALSE(storage::FileSystemURL::CreateForTest(
+ GURL(
+ "filesystem:externalfile:/external/drive-test-user-hash/"
+ "file.txt")).is_valid());
}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698