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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6c51469bfd59a77e28ef2fa9efc8eeea9fd909e8 |
--- /dev/null |
+++ b/chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc |
@@ -0,0 +1,66 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/chromeos/fileapi/external_file_url_util.h" |
+ |
+#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/chromeos/drive/file_system_util.h" |
+#include "chrome/test/base/testing_browser_process.h" |
+#include "chrome/test/base/testing_profile_manager.h" |
+#include "content/public/test/test_browser_thread_bundle.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace chromeos { |
+ |
+namespace { |
+ |
+// Sets up ProfileManager for testing and marks the current thread as UI by |
+// TestBrowserThreadBundle. We need the thread since Profile objects must be |
+// touched from UI and hence has CHECK/DCHECKs for it. |
+class ProfileRelatedFileSystemUtilTest : public testing::Test { |
+ protected: |
+ ProfileRelatedFileSystemUtilTest() |
+ : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
+ |
+ virtual void SetUp() OVERRIDE { |
+ ASSERT_TRUE(testing_profile_manager_.SetUp()); |
+ } |
+ |
+ TestingProfileManager& testing_profile_manager() { |
+ return testing_profile_manager_; |
+ } |
+ |
+ private: |
+ content::TestBrowserThreadBundle thread_bundle_; |
+ TestingProfileManager testing_profile_manager_; |
+}; |
+ |
+} // namespace |
+ |
+TEST(FileSystemUtilTest, FilePathToExternalFileURL) { |
+ base::FilePath path; |
+ |
+ // Path with alphabets and numbers. |
+ path = drive::util::GetDriveMyDriveRootPath().AppendASCII("foo/bar012.txt"); |
+ EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path))); |
+ |
+ // Path with symbols. |
+ path = drive::util::GetDriveMyDriveRootPath().AppendASCII( |
+ " !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~"); |
+ EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path))); |
+ |
+ // Path with '%'. |
+ path = drive::util::GetDriveMyDriveRootPath().AppendASCII("%19%20%21.txt"); |
+ EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path))); |
+ |
+ // 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( |
+ base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt")); |
+ EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path))); |
+} |
+ |
+} // namespace chromeos |