| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Migration cases. | 227 // Migration cases. |
| 228 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive/root"), | 228 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive/root"), |
| 229 drive::util::ConvertToMyDriveNamespace( | 229 drive::util::ConvertToMyDriveNamespace( |
| 230 base::FilePath::FromUTF8Unsafe("/special/drive"))); | 230 base::FilePath::FromUTF8Unsafe("/special/drive"))); |
| 231 | 231 |
| 232 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive/root/dir1"), | 232 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive/root/dir1"), |
| 233 drive::util::ConvertToMyDriveNamespace( | 233 drive::util::ConvertToMyDriveNamespace( |
| 234 base::FilePath::FromUTF8Unsafe("/special/drive/dir1"))); | 234 base::FilePath::FromUTF8Unsafe("/special/drive/dir1"))); |
| 235 } | 235 } |
| 236 | 236 |
| 237 TEST(FileSystemUtilTest, IsSpecialResourceId) { | |
| 238 EXPECT_FALSE(util::IsSpecialResourceId("abc")); | |
| 239 EXPECT_FALSE(util::IsSpecialResourceId("file:123")); | |
| 240 EXPECT_FALSE(util::IsSpecialResourceId("folder:root")); | |
| 241 EXPECT_FALSE(util::IsSpecialResourceId("folder:xyz")); | |
| 242 | |
| 243 EXPECT_TRUE(util::IsSpecialResourceId("<drive>")); | |
| 244 EXPECT_TRUE(util::IsSpecialResourceId("<other>")); | |
| 245 } | |
| 246 | |
| 247 TEST(FileSystemUtilTest, GDocFile) { | 237 TEST(FileSystemUtilTest, GDocFile) { |
| 248 base::ScopedTempDir temp_dir; | 238 base::ScopedTempDir temp_dir; |
| 249 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 239 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 250 | 240 |
| 251 GURL url("https://docs.google.com/document/d/" | 241 GURL url("https://docs.google.com/document/d/" |
| 252 "1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug/edit"); | 242 "1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug/edit"); |
| 253 std::string resource_id("1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug"); | 243 std::string resource_id("1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug"); |
| 254 | 244 |
| 255 // Read and write gdoc. | 245 // Read and write gdoc. |
| 256 base::FilePath file = temp_dir.path().AppendASCII("test.gdoc"); | 246 base::FilePath file = temp_dir.path().AppendASCII("test.gdoc"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 file = temp_dir.path().AppendASCII("test.txt"); | 288 file = temp_dir.path().AppendASCII("test.txt"); |
| 299 std::string data = "Hello world!"; | 289 std::string data = "Hello world!"; |
| 300 EXPECT_TRUE(google_apis::test_util::WriteStringToFile(file, data)); | 290 EXPECT_TRUE(google_apis::test_util::WriteStringToFile(file, data)); |
| 301 EXPECT_FALSE(HasGDocFileExtension(file)); | 291 EXPECT_FALSE(HasGDocFileExtension(file)); |
| 302 EXPECT_TRUE(ReadUrlFromGDocFile(file).is_empty()); | 292 EXPECT_TRUE(ReadUrlFromGDocFile(file).is_empty()); |
| 303 EXPECT_TRUE(ReadResourceIdFromGDocFile(file).empty()); | 293 EXPECT_TRUE(ReadResourceIdFromGDocFile(file).empty()); |
| 304 } | 294 } |
| 305 | 295 |
| 306 } // namespace util | 296 } // namespace util |
| 307 } // namespace drive | 297 } // namespace drive |
| OLD | NEW |