OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
kinaba
2014/09/19 01:56:27
I think you can keep the year as is
| |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/drive/file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/file_system_util.h" |
6 | 6 |
7 #include <vector> | |
8 | |
7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
13 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
14 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
15 #include "chrome/test/base/testing_profile_manager.h" | 17 #include "chrome/test/base/testing_profile_manager.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
45 return testing_profile_manager_; | 47 return testing_profile_manager_; |
46 } | 48 } |
47 | 49 |
48 private: | 50 private: |
49 content::TestBrowserThreadBundle thread_bundle_; | 51 content::TestBrowserThreadBundle thread_bundle_; |
50 TestingProfileManager testing_profile_manager_; | 52 TestingProfileManager testing_profile_manager_; |
51 }; | 53 }; |
52 | 54 |
53 } // namespace | 55 } // namespace |
54 | 56 |
55 TEST(FileSystemUtilTest, FilePathToDriveURL) { | |
56 base::FilePath path; | |
57 | |
58 // Path with alphabets and numbers. | |
59 path = GetDriveMyDriveRootPath().AppendASCII("foo/bar012.txt"); | |
60 EXPECT_EQ(path, DriveURLToFilePath(FilePathToDriveURL(path))); | |
61 | |
62 // Path with symbols. | |
63 path = GetDriveMyDriveRootPath().AppendASCII( | |
64 " !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~"); | |
65 EXPECT_EQ(path, DriveURLToFilePath(FilePathToDriveURL(path))); | |
66 | |
67 // Path with '%'. | |
68 path = GetDriveMyDriveRootPath().AppendASCII("%19%20%21.txt"); | |
69 EXPECT_EQ(path, DriveURLToFilePath(FilePathToDriveURL(path))); | |
70 | |
71 // Path with multi byte characters. | |
72 base::string16 utf16_string; | |
73 utf16_string.push_back(0x307b); // HIRAGANA_LETTER_HO | |
74 utf16_string.push_back(0x3052); // HIRAGANA_LETTER_GE | |
75 path = GetDriveMyDriveRootPath().Append( | |
76 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt")); | |
77 EXPECT_EQ(path, DriveURLToFilePath(FilePathToDriveURL(path))); | |
78 } | |
79 | |
80 TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) { | 57 TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) { |
81 Profile* profile = testing_profile_manager().CreateTestingProfile("user1"); | 58 Profile* profile = testing_profile_manager().CreateTestingProfile("user1"); |
82 const std::string user_id_hash = | 59 const std::string user_id_hash = |
83 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); | 60 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); |
84 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash), | 61 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash), |
85 GetDriveMountPointPath(profile)); | 62 GetDriveMountPointPath(profile)); |
86 } | 63 } |
87 | 64 |
88 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) { | 65 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) { |
89 Profile* profile1 = testing_profile_manager().CreateTestingProfile("user1"); | 66 Profile* profile1 = testing_profile_manager().CreateTestingProfile("user1"); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // Non GDoc file. | 263 // Non GDoc file. |
287 file = temp_dir.path().AppendASCII("test.txt"); | 264 file = temp_dir.path().AppendASCII("test.txt"); |
288 std::string data = "Hello world!"; | 265 std::string data = "Hello world!"; |
289 EXPECT_TRUE(google_apis::test_util::WriteStringToFile(file, data)); | 266 EXPECT_TRUE(google_apis::test_util::WriteStringToFile(file, data)); |
290 EXPECT_TRUE(ReadUrlFromGDocFile(file).is_empty()); | 267 EXPECT_TRUE(ReadUrlFromGDocFile(file).is_empty()); |
291 EXPECT_TRUE(ReadResourceIdFromGDocFile(file).empty()); | 268 EXPECT_TRUE(ReadResourceIdFromGDocFile(file).empty()); |
292 } | 269 } |
293 | 270 |
294 } // namespace util | 271 } // namespace util |
295 } // namespace drive | 272 } // namespace drive |
OLD | NEW |