| 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/gdata/gdata_directory_service.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 TEST(GDataDirectoryServiceTest, GetEntryByResourceId_RootDirectory) { | 309 TEST(GDataDirectoryServiceTest, GetEntryByResourceId_RootDirectory) { |
| 310 GDataDirectoryService directory_service; | 310 GDataDirectoryService directory_service; |
| 311 // Look up the root directory by its resource ID. | 311 // Look up the root directory by its resource ID. |
| 312 GDataEntry* entry = directory_service.GetEntryByResourceId( | 312 GDataEntry* entry = directory_service.GetEntryByResourceId( |
| 313 kGDataRootDirectoryResourceId); | 313 kGDataRootDirectoryResourceId); |
| 314 ASSERT_TRUE(entry); | 314 ASSERT_TRUE(entry); |
| 315 EXPECT_EQ(kGDataRootDirectoryResourceId, entry->resource_id()); | 315 EXPECT_EQ(kGDataRootDirectoryResourceId, entry->resource_id()); |
| 316 } | 316 } |
| 317 | 317 |
| 318 TEST(GDataDirectoryServiceTest, GetEntryInfoByResourceId) { |
| 319 MessageLoopForUI message_loop; |
| 320 content::TestBrowserThread ui_thread(content::BrowserThread::UI, |
| 321 &message_loop); |
| 322 GDataDirectoryService directory_service; |
| 323 InitDirectoryService(&directory_service); |
| 324 |
| 325 // Confirm that an existing file is found. |
| 326 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
| 327 scoped_ptr<GDataEntryProto> entry_proto; |
| 328 directory_service.GetEntryInfoByResourceId( |
| 329 "file_resource_id:file4", |
| 330 base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback, |
| 331 &error, &entry_proto)); |
| 332 test_util::RunBlockingPoolTask(); |
| 333 EXPECT_EQ(GDATA_FILE_OK, error); |
| 334 ASSERT_TRUE(entry_proto.get()); |
| 335 EXPECT_EQ("file4", entry_proto->base_name()); |
| 336 |
| 337 // Confirm that a non existing file is not found. |
| 338 error = GDATA_FILE_ERROR_FAILED; |
| 339 entry_proto.reset(); |
| 340 directory_service.GetEntryInfoByResourceId( |
| 341 "file:non_existing", |
| 342 base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback, |
| 343 &error, &entry_proto)); |
| 344 test_util::RunBlockingPoolTask(); |
| 345 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, error); |
| 346 EXPECT_FALSE(entry_proto.get()); |
| 347 } |
| 348 |
| 318 TEST(GDataDirectoryServiceTest, GetEntryInfoByPath) { | 349 TEST(GDataDirectoryServiceTest, GetEntryInfoByPath) { |
| 319 MessageLoopForUI message_loop; | 350 MessageLoopForUI message_loop; |
| 320 content::TestBrowserThread ui_thread(content::BrowserThread::UI, | 351 content::TestBrowserThread ui_thread(content::BrowserThread::UI, |
| 321 &message_loop); | 352 &message_loop); |
| 322 GDataDirectoryService directory_service; | 353 GDataDirectoryService directory_service; |
| 323 InitDirectoryService(&directory_service); | 354 InitDirectoryService(&directory_service); |
| 324 | 355 |
| 325 // Confirm that an existing file is found. | 356 // Confirm that an existing file is found. |
| 326 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 357 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
| 327 scoped_ptr<GDataEntryProto> entry_proto; | 358 scoped_ptr<GDataEntryProto> entry_proto; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 GDataDirectoryService directory_service2; | 524 GDataDirectoryService directory_service2; |
| 494 // InitFromDB should succeed with GDATA_FILE_OK as the db now exists. | 525 // InitFromDB should succeed with GDATA_FILE_OK as the db now exists. |
| 495 directory_service2.InitFromDB(db_path, blocking_task_runner, | 526 directory_service2.InitFromDB(db_path, blocking_task_runner, |
| 496 base::Bind(&InitFromDBCallback, GDATA_FILE_OK)); | 527 base::Bind(&InitFromDBCallback, GDATA_FILE_OK)); |
| 497 test_util::RunBlockingPoolTask(); | 528 test_util::RunBlockingPoolTask(); |
| 498 | 529 |
| 499 VerifyDirectoryService(&directory_service2); | 530 VerifyDirectoryService(&directory_service2); |
| 500 } | 531 } |
| 501 | 532 |
| 502 } // namespace gdata | 533 } // namespace gdata |
| OLD | NEW |