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/drive/fake_drive_service.h" | 5 #include "chrome/browser/drive/fake_drive_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 "new title", | 1221 "new title", |
1222 base::Time(), | 1222 base::Time(), |
1223 base::Time(), | 1223 base::Time(), |
1224 test_util::CreateCopyResultCallback(&error, &entry)); | 1224 test_util::CreateCopyResultCallback(&error, &entry)); |
1225 base::RunLoop().RunUntilIdle(); | 1225 base::RunLoop().RunUntilIdle(); |
1226 | 1226 |
1227 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1227 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1228 EXPECT_FALSE(entry); | 1228 EXPECT_FALSE(entry); |
1229 } | 1229 } |
1230 | 1230 |
1231 TEST_F(FakeDriveServiceTest, RenameResource_ExistingFile) { | |
1232 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | |
1233 | |
1234 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | |
1235 | |
1236 const std::string kResourceId = "2_file_resource_id"; | |
1237 | |
1238 GDataErrorCode error = GDATA_OTHER_ERROR; | |
1239 fake_service_.RenameResource(kResourceId, | |
1240 "new title", | |
1241 test_util::CreateCopyResultCallback(&error)); | |
1242 base::RunLoop().RunUntilIdle(); | |
1243 | |
1244 EXPECT_EQ(HTTP_SUCCESS, error); | |
1245 | |
1246 scoped_ptr<FileResource> entry = FindEntry(kResourceId); | |
1247 ASSERT_TRUE(entry); | |
1248 EXPECT_EQ("new title", entry->title()); | |
1249 // Should be incremented as a file was renamed. | |
1250 EXPECT_EQ(old_largest_change_id + 1, | |
1251 fake_service_.about_resource().largest_change_id()); | |
1252 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | |
1253 } | |
1254 | |
1255 TEST_F(FakeDriveServiceTest, RenameResource_NonexistingFile) { | |
1256 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | |
1257 | |
1258 const std::string kResourceId = "nonexisting_file"; | |
1259 | |
1260 GDataErrorCode error = GDATA_OTHER_ERROR; | |
1261 fake_service_.RenameResource(kResourceId, | |
1262 "new title", | |
1263 test_util::CreateCopyResultCallback(&error)); | |
1264 base::RunLoop().RunUntilIdle(); | |
1265 | |
1266 EXPECT_EQ(HTTP_NOT_FOUND, error); | |
1267 } | |
1268 | |
1269 TEST_F(FakeDriveServiceTest, RenameResource_Offline) { | |
1270 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | |
1271 fake_service_.set_offline(true); | |
1272 | |
1273 const std::string kResourceId = "2_file_resource_id"; | |
1274 | |
1275 GDataErrorCode error = GDATA_OTHER_ERROR; | |
1276 fake_service_.RenameResource(kResourceId, | |
1277 "new title", | |
1278 test_util::CreateCopyResultCallback(&error)); | |
1279 base::RunLoop().RunUntilIdle(); | |
1280 | |
1281 EXPECT_EQ(GDATA_NO_CONNECTION, error); | |
1282 } | |
1283 | |
1284 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { | 1231 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { |
1285 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); | 1232 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1286 | 1233 |
1287 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1234 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1288 | 1235 |
1289 const std::string kResourceId = "2_file_resource_id"; | 1236 const std::string kResourceId = "2_file_resource_id"; |
1290 const std::string kOldParentResourceId = fake_service_.GetRootResourceId(); | 1237 const std::string kOldParentResourceId = fake_service_.GetRootResourceId(); |
1291 const std::string kNewParentResourceId = "1_folder_resource_id"; | 1238 const std::string kNewParentResourceId = "1_folder_resource_id"; |
1292 | 1239 |
1293 // Here's the original parent link. | 1240 // Here's the original parent link. |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 test_util::CreateCopyResultCallback(&error, &entry)); | 2148 test_util::CreateCopyResultCallback(&error, &entry)); |
2202 base::RunLoop().RunUntilIdle(); | 2149 base::RunLoop().RunUntilIdle(); |
2203 | 2150 |
2204 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 2151 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
2205 EXPECT_FALSE(entry); | 2152 EXPECT_FALSE(entry); |
2206 } | 2153 } |
2207 | 2154 |
2208 } // namespace | 2155 } // namespace |
2209 | 2156 |
2210 } // namespace drive | 2157 } // namespace drive |
OLD | NEW |