Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: chrome/browser/chromeos/drive/file_system_unittest.cc

Issue 276313002: drive: Change FileCache::GetCacheEntry's return type to FileError (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 ASSERT_TRUE(entry); 782 ASSERT_TRUE(entry);
783 783
784 // Pin the file. 784 // Pin the file.
785 FileError error = FILE_ERROR_FAILED; 785 FileError error = FILE_ERROR_FAILED;
786 file_system_->Pin(file_path, 786 file_system_->Pin(file_path,
787 google_apis::test_util::CreateCopyResultCallback(&error)); 787 google_apis::test_util::CreateCopyResultCallback(&error));
788 test_util::RunBlockingPoolTask(); 788 test_util::RunBlockingPoolTask();
789 EXPECT_EQ(FILE_ERROR_OK, error); 789 EXPECT_EQ(FILE_ERROR_OK, error);
790 790
791 FileCacheEntry cache_entry; 791 FileCacheEntry cache_entry;
792 EXPECT_TRUE(cache_->GetCacheEntry(entry->local_id(), &cache_entry)); 792 EXPECT_EQ(FILE_ERROR_OK,
793 cache_->GetCacheEntry(entry->local_id(), &cache_entry));
793 EXPECT_TRUE(cache_entry.is_pinned()); 794 EXPECT_TRUE(cache_entry.is_pinned());
794 EXPECT_TRUE(cache_entry.is_present()); 795 EXPECT_TRUE(cache_entry.is_present());
795 796
796 // Unpin the file. 797 // Unpin the file.
797 error = FILE_ERROR_FAILED; 798 error = FILE_ERROR_FAILED;
798 file_system_->Unpin(file_path, 799 file_system_->Unpin(file_path,
799 google_apis::test_util::CreateCopyResultCallback(&error)); 800 google_apis::test_util::CreateCopyResultCallback(&error));
800 test_util::RunBlockingPoolTask(); 801 test_util::RunBlockingPoolTask();
801 EXPECT_EQ(FILE_ERROR_OK, error); 802 EXPECT_EQ(FILE_ERROR_OK, error);
802 803
803 EXPECT_TRUE(cache_->GetCacheEntry(entry->local_id(), &cache_entry)); 804 EXPECT_EQ(FILE_ERROR_OK,
805 cache_->GetCacheEntry(entry->local_id(), &cache_entry));
804 EXPECT_FALSE(cache_entry.is_pinned()); 806 EXPECT_FALSE(cache_entry.is_pinned());
805 807
806 // Pinned file gets synced and it results in entry state changes. 808 // Pinned file gets synced and it results in entry state changes.
807 ASSERT_EQ(1u, mock_directory_observer_->changed_directories().size()); 809 ASSERT_EQ(1u, mock_directory_observer_->changed_directories().size());
808 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("drive/root")), 810 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("drive/root")),
809 mock_directory_observer_->changed_directories()[0]); 811 mock_directory_observer_->changed_directories()[0]);
810 } 812 }
811 813
812 TEST_F(FileSystemTest, PinAndUnpin_NotSynced) { 814 TEST_F(FileSystemTest, PinAndUnpin_NotSynced) {
813 ASSERT_TRUE(LoadFullResourceList()); 815 ASSERT_TRUE(LoadFullResourceList());
(...skipping 14 matching lines...) Expand all
828 file_system_->Unpin( 830 file_system_->Unpin(
829 file_path, 831 file_path,
830 google_apis::test_util::CreateCopyResultCallback(&error_unpin)); 832 google_apis::test_util::CreateCopyResultCallback(&error_unpin));
831 833
832 test_util::RunBlockingPoolTask(); 834 test_util::RunBlockingPoolTask();
833 EXPECT_EQ(FILE_ERROR_OK, error_pin); 835 EXPECT_EQ(FILE_ERROR_OK, error_pin);
834 EXPECT_EQ(FILE_ERROR_OK, error_unpin); 836 EXPECT_EQ(FILE_ERROR_OK, error_unpin);
835 837
836 // No cache file available because the sync was cancelled by Unpin(). 838 // No cache file available because the sync was cancelled by Unpin().
837 FileCacheEntry cache_entry; 839 FileCacheEntry cache_entry;
838 EXPECT_FALSE(cache_->GetCacheEntry(entry->local_id(), &cache_entry)); 840 EXPECT_EQ(FILE_ERROR_NOT_FOUND,
841 cache_->GetCacheEntry(entry->local_id(), &cache_entry));
839 } 842 }
840 843
841 TEST_F(FileSystemTest, GetAvailableSpace) { 844 TEST_F(FileSystemTest, GetAvailableSpace) {
842 FileError error = FILE_ERROR_OK; 845 FileError error = FILE_ERROR_OK;
843 int64 bytes_total; 846 int64 bytes_total;
844 int64 bytes_used; 847 int64 bytes_used;
845 file_system_->GetAvailableSpace( 848 file_system_->GetAvailableSpace(
846 google_apis::test_util::CreateCopyResultCallback( 849 google_apis::test_util::CreateCopyResultCallback(
847 &error, &bytes_total, &bytes_used)); 850 &error, &bytes_total, &bytes_used));
848 test_util::RunBlockingPoolTask(); 851 test_util::RunBlockingPoolTask();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 kEmbedOrigin, 907 kEmbedOrigin,
905 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); 908 google_apis::test_util::CreateCopyResultCallback(&error, &share_url));
906 test_util::RunBlockingPoolTask(); 909 test_util::RunBlockingPoolTask();
907 910
908 // Verify the share url to the sharing dialog. 911 // Verify the share url to the sharing dialog.
909 EXPECT_EQ(FILE_ERROR_OK, error); 912 EXPECT_EQ(FILE_ERROR_OK, error);
910 EXPECT_TRUE(share_url.is_valid()); 913 EXPECT_TRUE(share_url.is_valid());
911 } 914 }
912 915
913 } // namespace drive 916 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698