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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 570 |
571 TEST_F(FileSystemTest, GetExistingFile) { | 571 TEST_F(FileSystemTest, GetExistingFile) { |
572 // Simulate the situation that full feed fetching takes very long time, | 572 // Simulate the situation that full feed fetching takes very long time, |
573 // to test the recursive "fast fetch" feature is properly working. | 573 // to test the recursive "fast fetch" feature is properly working. |
574 fake_drive_service_->set_never_return_all_file_list(true); | 574 fake_drive_service_->set_never_return_all_file_list(true); |
575 | 575 |
576 const base::FilePath kFilePath( | 576 const base::FilePath kFilePath( |
577 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); | 577 FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
578 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 578 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
579 ASSERT_TRUE(entry); | 579 ASSERT_TRUE(entry); |
580 EXPECT_EQ("file:subdirectory_file_1_id", entry->resource_id()); | 580 EXPECT_EQ("subdirectory_file_1_id", entry->resource_id()); |
581 | 581 |
582 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); | 582 EXPECT_EQ(1, fake_drive_service_->about_resource_load_count()); |
583 EXPECT_EQ(2, fake_drive_service_->directory_load_count()); | 583 EXPECT_EQ(2, fake_drive_service_->directory_load_count()); |
584 EXPECT_EQ(1, fake_drive_service_->blocked_file_list_load_count()); | 584 EXPECT_EQ(1, fake_drive_service_->blocked_file_list_load_count()); |
585 } | 585 } |
586 | 586 |
587 TEST_F(FileSystemTest, GetExistingDocument) { | 587 TEST_F(FileSystemTest, GetExistingDocument) { |
588 const base::FilePath kFilePath( | 588 const base::FilePath kFilePath( |
589 FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); | 589 FILE_PATH_LITERAL("drive/root/Document 1 excludeDir-test.gdoc")); |
590 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 590 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
591 ASSERT_TRUE(entry); | 591 ASSERT_TRUE(entry); |
592 EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); | 592 EXPECT_EQ("5_document_resource_id", entry->resource_id()); |
593 } | 593 } |
594 | 594 |
595 TEST_F(FileSystemTest, GetNonExistingFile) { | 595 TEST_F(FileSystemTest, GetNonExistingFile) { |
596 const base::FilePath kFilePath( | 596 const base::FilePath kFilePath( |
597 FILE_PATH_LITERAL("drive/root/nonexisting.file")); | 597 FILE_PATH_LITERAL("drive/root/nonexisting.file")); |
598 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 598 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
599 EXPECT_FALSE(entry); | 599 EXPECT_FALSE(entry); |
600 } | 600 } |
601 | 601 |
602 TEST_F(FileSystemTest, GetInSubSubdir) { | 602 TEST_F(FileSystemTest, GetInSubSubdir) { |
603 const base::FilePath kFilePath( | 603 const base::FilePath kFilePath( |
604 FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" | 604 FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" |
605 "Sub Sub Directory Folder")); | 605 "Sub Sub Directory Folder")); |
606 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 606 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
607 ASSERT_TRUE(entry); | 607 ASSERT_TRUE(entry); |
608 ASSERT_EQ("folder:sub_sub_directory_folder_id", entry->resource_id()); | 608 ASSERT_EQ("sub_sub_directory_folder_id", entry->resource_id()); |
609 } | 609 } |
610 | 610 |
611 TEST_F(FileSystemTest, GetOrphanFile) { | 611 TEST_F(FileSystemTest, GetOrphanFile) { |
612 ASSERT_TRUE(LoadFullResourceList()); | 612 ASSERT_TRUE(LoadFullResourceList()); |
613 | 613 |
614 // Entry without parents are placed under "drive/other". | 614 // Entry without parents are placed under "drive/other". |
615 const base::FilePath kFilePath( | 615 const base::FilePath kFilePath( |
616 FILE_PATH_LITERAL("drive/other/Orphan File 1.txt")); | 616 FILE_PATH_LITERAL("drive/other/Orphan File 1.txt")); |
617 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); | 617 scoped_ptr<ResourceEntry> entry = GetResourceEntrySync(kFilePath); |
618 ASSERT_TRUE(entry); | 618 ASSERT_TRUE(entry); |
619 EXPECT_EQ("file:1_orphanfile_resource_id", entry->resource_id()); | 619 EXPECT_EQ("1_orphanfile_resource_id", entry->resource_id()); |
620 } | 620 } |
621 | 621 |
622 TEST_F(FileSystemTest, ReadDirectory_Root) { | 622 TEST_F(FileSystemTest, ReadDirectory_Root) { |
623 // ReadDirectory() should kick off the resource list loading. | 623 // ReadDirectory() should kick off the resource list loading. |
624 scoped_ptr<ResourceEntryVector> entries( | 624 scoped_ptr<ResourceEntryVector> entries( |
625 ReadDirectorySync(base::FilePath::FromUTF8Unsafe("drive"))); | 625 ReadDirectorySync(base::FilePath::FromUTF8Unsafe("drive"))); |
626 // The root directory should be read correctly. | 626 // The root directory should be read correctly. |
627 ASSERT_TRUE(entries); | 627 ASSERT_TRUE(entries); |
628 ASSERT_EQ(3U, entries->size()); | 628 ASSERT_EQ(3U, entries->size()); |
629 | 629 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 kEmbedOrigin, | 916 kEmbedOrigin, |
917 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); | 917 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); |
918 content::RunAllBlockingPoolTasksUntilIdle(); | 918 content::RunAllBlockingPoolTasksUntilIdle(); |
919 | 919 |
920 // Verify the share url to the sharing dialog. | 920 // Verify the share url to the sharing dialog. |
921 EXPECT_EQ(FILE_ERROR_OK, error); | 921 EXPECT_EQ(FILE_ERROR_OK, error); |
922 EXPECT_TRUE(share_url.is_valid()); | 922 EXPECT_TRUE(share_url.is_valid()); |
923 } | 923 } |
924 | 924 |
925 } // namespace drive | 925 } // namespace drive |
OLD | NEW |