| 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.h" | 5 #include "chrome/browser/chromeos/drive/file_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // After "fast fetch" is done, full resource list is fetched. | 357 // After "fast fetch" is done, full resource list is fetched. |
| 358 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); | 358 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); |
| 359 | 359 |
| 360 // "Fast fetch" will fire an OnirectoryChanged event. | 360 // "Fast fetch" will fire an OnirectoryChanged event. |
| 361 ASSERT_EQ(1u, mock_directory_observer_->changed_directories().size()); | 361 ASSERT_EQ(1u, mock_directory_observer_->changed_directories().size()); |
| 362 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("drive")), | 362 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("drive")), |
| 363 mock_directory_observer_->changed_directories()[0]); | 363 mock_directory_observer_->changed_directories()[0]); |
| 364 } | 364 } |
| 365 | 365 |
| 366 TEST_F(FileSystemTest, GetExistingFile) { | 366 TEST_F(FileSystemTest, GetExistingFile) { |
| 367 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 367 // Simulate the situation that full feed fetching takes very long time, |
| 368 // to test the recursive "fast fetch" feature is properly working. |
| 369 fake_drive_service_->set_never_return_all_resource_list(true); |
| 370 |
| 371 const base::FilePath kFilePath( |
| 372 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 368 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); | 373 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); |
| 369 ASSERT_TRUE(entry); | 374 ASSERT_TRUE(entry); |
| 370 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); | 375 EXPECT_EQ("file:subdirectory_file_1_id", entry->resource_id()); |
| 371 | 376 |
| 372 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); | 377 // One server changestamp check (about_resource), three directory load for |
| 373 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); | 378 // "drive", "drive/root", and "drive/root/Directory 1", and one background |
| 379 // full resource list loading. Note that the directory load for "drive" is |
| 380 // special and resorts to about_resource. |
| 381 EXPECT_EQ(2, fake_drive_service_->about_resource_load_count()); |
| 382 EXPECT_EQ(2, fake_drive_service_->directory_load_count()); |
| 383 EXPECT_EQ(1, fake_drive_service_->blocked_resource_list_load_count()); |
| 374 } | 384 } |
| 375 | 385 |
| 376 TEST_F(FileSystemTest, GetExistingDocument) { | 386 TEST_F(FileSystemTest, GetExistingDocument) { |
| 377 const base::FilePath kFilePath( | 387 const base::FilePath kFilePath( |
| 378 FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); | 388 FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); |
| 379 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); | 389 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); |
| 380 ASSERT_TRUE(entry); | 390 ASSERT_TRUE(entry); |
| 381 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); | 391 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); |
| 382 } | 392 } |
| 383 | 393 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 402 TEST_F(FileSystemTest, GetInSubSubdir) { | 412 TEST_F(FileSystemTest, GetInSubSubdir) { |
| 403 const base::FilePath kFilePath( | 413 const base::FilePath kFilePath( |
| 404 FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" | 414 FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" |
| 405 "Sub Sub Directory Folder")); | 415 "Sub Sub Directory Folder")); |
| 406 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); | 416 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); |
| 407 ASSERT_TRUE(entry); | 417 ASSERT_TRUE(entry); |
| 408 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); | 418 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); |
| 409 } | 419 } |
| 410 | 420 |
| 411 TEST_F(FileSystemTest, GetOrphanFile) { | 421 TEST_F(FileSystemTest, GetOrphanFile) { |
| 422 ASSERT_TRUE(LoadFullResourceList()); |
| 423 |
| 424 // Entry without parents are placed under "drive/other". |
| 412 const base::FilePath kFilePath( | 425 const base::FilePath kFilePath( |
| 413 FILE_PATH_LITERAL("drive/other/Orphan File 1.txt")); | 426 FILE_PATH_LITERAL("drive/other/Orphan File 1.txt")); |
| 414 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); | 427 scoped_ptr<ResourceEntry> entry = GetResourceEntryByPathSync(kFilePath); |
| 415 ASSERT_TRUE(entry); | 428 ASSERT_TRUE(entry); |
| 416 EXPECT_EQ("file:1_orphanfile_resource_id", entry->resource_id()); | 429 EXPECT_EQ("file:1_orphanfile_resource_id", entry->resource_id()); |
| 417 } | 430 } |
| 418 | 431 |
| 419 TEST_F(FileSystemTest, ReadDirectoryByPath_Root) { | 432 TEST_F(FileSystemTest, ReadDirectoryByPath_Root) { |
| 420 // ReadDirectoryByPath() should kick off the resource list loading. | 433 // ReadDirectoryByPath() should kick off the resource list loading. |
| 421 scoped_ptr<ResourceEntryVector> entries( | 434 scoped_ptr<ResourceEntryVector> entries( |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 kEmbedOrigin, | 741 kEmbedOrigin, |
| 729 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); | 742 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); |
| 730 test_util::RunBlockingPoolTask(); | 743 test_util::RunBlockingPoolTask(); |
| 731 | 744 |
| 732 // Verify the error and the share url, which should be empty. | 745 // Verify the error and the share url, which should be empty. |
| 733 EXPECT_EQ(FILE_ERROR_FAILED, error); | 746 EXPECT_EQ(FILE_ERROR_FAILED, error); |
| 734 EXPECT_TRUE(share_url.is_empty()); | 747 EXPECT_TRUE(share_url.is_empty()); |
| 735 } | 748 } |
| 736 | 749 |
| 737 } // namespace drive | 750 } // namespace drive |
| OLD | NEW |