| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 const GetResourceEntryCallback& callback = base::Bind( | 536 const GetResourceEntryCallback& callback = base::Bind( |
| 537 &AsyncInitializationCallback, &counter, 2, loop.QuitClosure()); | 537 &AsyncInitializationCallback, &counter, 2, loop.QuitClosure()); |
| 538 | 538 |
| 539 file_system_->GetResourceEntry( | 539 file_system_->GetResourceEntry( |
| 540 base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); | 540 base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); |
| 541 file_system_->GetResourceEntry( | 541 file_system_->GetResourceEntry( |
| 542 base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); | 542 base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); |
| 543 loop.Run(); // Wait to get our result | 543 loop.Run(); // Wait to get our result |
| 544 EXPECT_EQ(2, counter); | 544 EXPECT_EQ(2, counter); |
| 545 | 545 |
| 546 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); | 546 EXPECT_EQ(1, fake_drive_service_->file_list_load_count()); |
| 547 } | 547 } |
| 548 | 548 |
| 549 TEST_F(FileSystemTest, GetGrandRootEntry) { | 549 TEST_F(FileSystemTest, GetGrandRootEntry) { |
| 550 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive")); | 550 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive")); |
| 551 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 551 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
| 552 ASSERT_TRUE(entry); | 552 ASSERT_TRUE(entry); |
| 553 EXPECT_EQ(util::kDriveGrandRootLocalId, entry->local_id()); | 553 EXPECT_EQ(util::kDriveGrandRootLocalId, entry->local_id()); |
| 554 } | 554 } |
| 555 | 555 |
| 556 TEST_F(FileSystemTest, GetOtherDirEntry) { | 556 TEST_F(FileSystemTest, GetOtherDirEntry) { |
| 557 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/other")); | 557 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/other")); |
| 558 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 558 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
| 559 ASSERT_TRUE(entry); | 559 ASSERT_TRUE(entry); |
| 560 EXPECT_EQ(util::kDriveOtherDirLocalId, entry->local_id()); | 560 EXPECT_EQ(util::kDriveOtherDirLocalId, entry->local_id()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 TEST_F(FileSystemTest, GetMyDriveRoot) { | 563 TEST_F(FileSystemTest, GetMyDriveRoot) { |
| 564 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root")); | 564 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root")); |
| 565 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 565 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
| 566 ASSERT_TRUE(entry); | 566 ASSERT_TRUE(entry); |
| 567 EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); | 567 EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); |
| 568 | 568 |
| 569 // After "fast fetch" is done, full resource list is fetched. | 569 // After "fast fetch" is done, full resource list is fetched. |
| 570 EXPECT_EQ(1, fake_drive_service_->resource_list_load_count()); | 570 EXPECT_EQ(1, fake_drive_service_->file_list_load_count()); |
| 571 } | 571 } |
| 572 | 572 |
| 573 TEST_F(FileSystemTest, GetExistingFile) { | 573 TEST_F(FileSystemTest, GetExistingFile) { |
| 574 // Simulate the situation that full feed fetching takes very long time, | 574 // Simulate the situation that full feed fetching takes very long time, |
| 575 // to test the recursive "fast fetch" feature is properly working. | 575 // to test the recursive "fast fetch" feature is properly working. |
| 576 fake_drive_service_->set_never_return_all_resource_list(true); | 576 fake_drive_service_->set_never_return_all_file_list(true); |
| 577 | 577 |
| 578 const base::FilePath kFilePath( | 578 const base::FilePath kFilePath( |
| 579 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); | 579 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| 580 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 580 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
| 581 ASSERT_TRUE(entry); | 581 ASSERT_TRUE(entry); |
| 582 EXPECT_EQ("file:subdirectory_file_1_id", entry->resource_id()); | 582 EXPECT_EQ("file:subdirectory_file_1_id", entry->resource_id()); |
| 583 | 583 |
| 584 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); | 584 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); |
| 585 EXPECT_EQ(2, fake_drive_service_->directory_load_count()); | 585 EXPECT_EQ(2, fake_drive_service_->directory_load_count()); |
| 586 EXPECT_EQ(1, fake_drive_service_->blocked_resource_list_load_count()); | 586 EXPECT_EQ(1, fake_drive_service_->blocked_file_list_load_count()); |
| 587 } | 587 } |
| 588 | 588 |
| 589 TEST_F(FileSystemTest, GetExistingDocument) { | 589 TEST_F(FileSystemTest, GetExistingDocument) { |
| 590 const base::FilePath kFilePath( | 590 const base::FilePath kFilePath( |
| 591 FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); | 591 FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); |
| 592 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 592 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
| 593 ASSERT_TRUE(entry); | 593 ASSERT_TRUE(entry); |
| 594 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); | 594 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); |
| 595 } | 595 } |
| 596 | 596 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 | 654 |
| 655 TEST_F(FileSystemTest, LoadFileSystemFromUpToDateCache) { | 655 TEST_F(FileSystemTest, LoadFileSystemFromUpToDateCache) { |
| 656 ASSERT_NO_FATAL_FAILURE(SetUpTestFileSystem(USE_SERVER_TIMESTAMP)); | 656 ASSERT_NO_FATAL_FAILURE(SetUpTestFileSystem(USE_SERVER_TIMESTAMP)); |
| 657 | 657 |
| 658 // Kicks loading of cached file system and query for server update. | 658 // Kicks loading of cached file system and query for server update. |
| 659 EXPECT_TRUE(ReadDirectorySync(util::GetDriveMyDriveRootPath())); | 659 EXPECT_TRUE(ReadDirectorySync(util::GetDriveMyDriveRootPath())); |
| 660 | 660 |
| 661 // SetUpTestFileSystem and FakeDriveService have the same | 661 // SetUpTestFileSystem and FakeDriveService have the same |
| 662 // changestamp (i.e. the local metadata is up-to-date), so no request for | 662 // changestamp (i.e. the local metadata is up-to-date), so no request for |
| 663 // new resource list (i.e., call to GetResourceList) should happen. | 663 // new resource list (i.e., call to GetResourceList) should happen. |
| 664 EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); | 664 EXPECT_EQ(0, fake_drive_service_->file_list_load_count()); |
| 665 | 665 |
| 666 // Since the file system has verified that it holds the latest snapshot, | 666 // Since the file system has verified that it holds the latest snapshot, |
| 667 // it should change its state to "loaded", which admits periodic refresh. | 667 // it should change its state to "loaded", which admits periodic refresh. |
| 668 // To test it, call CheckForUpdates and verify it does try to check updates. | 668 // To test it, call CheckForUpdates and verify it does try to check updates. |
| 669 const int about_resource_load_count_before = | 669 const int about_resource_load_count_before = |
| 670 fake_drive_service_->about_resource_load_count(); | 670 fake_drive_service_->about_resource_load_count(); |
| 671 file_system_->CheckForUpdates(); | 671 file_system_->CheckForUpdates(); |
| 672 test_util::RunBlockingPoolTask(); | 672 test_util::RunBlockingPoolTask(); |
| 673 EXPECT_LT(about_resource_load_count_before, | 673 EXPECT_LT(about_resource_load_count_before, |
| 674 fake_drive_service_->about_resource_load_count()); | 674 fake_drive_service_->about_resource_load_count()); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 kEmbedOrigin, | 915 kEmbedOrigin, |
| 916 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); | 916 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); |
| 917 test_util::RunBlockingPoolTask(); | 917 test_util::RunBlockingPoolTask(); |
| 918 | 918 |
| 919 // Verify the share url to the sharing dialog. | 919 // Verify the share url to the sharing dialog. |
| 920 EXPECT_EQ(FILE_ERROR_OK, error); | 920 EXPECT_EQ(FILE_ERROR_OK, error); |
| 921 EXPECT_TRUE(share_url.is_valid()); | 921 EXPECT_TRUE(share_url.is_valid()); |
| 922 } | 922 } |
| 923 | 923 |
| 924 } // namespace drive | 924 } // namespace drive |
| OLD | NEW |