OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fake_drive_file_system.h" | 5 #include "chrome/browser/chromeos/drive/fake_drive_file_system.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 8 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
9 #include "chrome/browser/google_apis/fake_drive_service.h" | 9 #include "chrome/browser/google_apis/fake_drive_service.h" |
10 #include "chrome/browser/google_apis/test_util.h" | 10 #include "chrome/browser/google_apis/test_util.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 google_apis::test_util::RunBlockingPoolTask(); | 56 google_apis::test_util::RunBlockingPoolTask(); |
57 | 57 |
58 ASSERT_EQ(DRIVE_FILE_OK, error); | 58 ASSERT_EQ(DRIVE_FILE_OK, error); |
59 EXPECT_EQ( | 59 EXPECT_EQ( |
60 util::GetDriveMyDriveRootPath().AppendASCII( | 60 util::GetDriveMyDriveRootPath().AppendASCII( |
61 "Directory 1/Sub Directory Folder"), | 61 "Directory 1/Sub Directory Folder"), |
62 file_path); | 62 file_path); |
63 EXPECT_TRUE(entry); // Just make sure something is returned. | 63 EXPECT_TRUE(entry); // Just make sure something is returned. |
64 } | 64 } |
65 | 65 |
| 66 TEST_F(FakeDriveFileSystemTest, |
| 67 GetEntryInfoByResourceId_PathCompatibleWithGetEntryInfoByPath) { |
| 68 const std::string document_resource_id = "document:5_document_resource_id"; |
| 69 |
| 70 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 71 scoped_ptr<DriveEntryProto> entry; |
| 72 base::FilePath file_path; |
| 73 |
| 74 // Get entry info by resource id. |
| 75 fake_drive_file_system_->GetEntryInfoByResourceId( |
| 76 document_resource_id, |
| 77 google_apis::test_util::CreateCopyResultCallback( |
| 78 &error, &file_path, &entry)); |
| 79 google_apis::test_util::RunBlockingPoolTask(); |
| 80 |
| 81 ASSERT_EQ(DRIVE_FILE_OK, error); |
| 82 ASSERT_TRUE(entry); |
| 83 EXPECT_TRUE(entry->file_specific_info().is_hosted_document()); |
| 84 |
| 85 // Get entry info by path given by GetEntryInfoByResourceId. |
| 86 error = DRIVE_FILE_ERROR_FAILED; |
| 87 entry.reset(); |
| 88 fake_drive_file_system_->GetEntryInfoByPath( |
| 89 file_path, |
| 90 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
| 91 google_apis::test_util::RunBlockingPoolTask(); |
| 92 |
| 93 ASSERT_EQ(DRIVE_FILE_OK, error); |
| 94 ASSERT_TRUE(entry); |
| 95 EXPECT_EQ(document_resource_id, entry->resource_id()); |
| 96 } |
| 97 |
66 TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath) { | 98 TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath) { |
67 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 99 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
68 scoped_ptr<DriveEntryProto> entry; | 100 scoped_ptr<DriveEntryProto> entry; |
69 fake_drive_file_system_->GetEntryInfoByPath( | 101 fake_drive_file_system_->GetEntryInfoByPath( |
70 util::GetDriveMyDriveRootPath().AppendASCII( | 102 util::GetDriveMyDriveRootPath().AppendASCII( |
71 "Directory 1/Sub Directory Folder"), | 103 "Directory 1/Sub Directory Folder"), |
72 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); | 104 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
73 google_apis::test_util::RunBlockingPoolTask(); | 105 google_apis::test_util::RunBlockingPoolTask(); |
74 | 106 |
75 ASSERT_EQ(DRIVE_FILE_OK, error); | 107 ASSERT_EQ(DRIVE_FILE_OK, error); |
(...skipping 23 matching lines...) Expand all Loading... |
99 util::GetDriveMyDriveRootPath().AppendASCII("Invalid File Name"), | 131 util::GetDriveMyDriveRootPath().AppendASCII("Invalid File Name"), |
100 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); | 132 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
101 google_apis::test_util::RunBlockingPoolTask(); | 133 google_apis::test_util::RunBlockingPoolTask(); |
102 | 134 |
103 ASSERT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 135 ASSERT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
104 ASSERT_FALSE(entry); | 136 ASSERT_FALSE(entry); |
105 } | 137 } |
106 | 138 |
107 } // namespace test_util | 139 } // namespace test_util |
108 } // namespace drive | 140 } // namespace drive |
OLD | NEW |