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

Unified Diff: chrome/browser/drive/fake_drive_service_unittest.cc

Issue 17589004: FakeDriveService::DeleteResource should keep deleted entry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: listing deleted resources Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/drive/fake_drive_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/fake_drive_service_unittest.cc
diff --git a/chrome/browser/drive/fake_drive_service_unittest.cc b/chrome/browser/drive/fake_drive_service_unittest.cc
index 70caa16bc0357958db661a9a6c609512cb5a09ac..0d168013b788cbd73d38e979d3c1d0deb27efbb7 100644
--- a/chrome/browser/drive/fake_drive_service_unittest.cc
+++ b/chrome/browser/drive/fake_drive_service_unittest.cc
@@ -59,7 +59,7 @@ class FakeDriveServiceTest : public testing::Test {
// Returns true if the resource identified by |resource_id| exists.
bool Exists(const std::string& resource_id) {
scoped_ptr<ResourceEntry> resource_entry = FindEntry(resource_id);
- return resource_entry;
+ return resource_entry && !resource_entry->deleted();
}
// Adds a new directory at |parent_resource_id| with the given name.
@@ -272,6 +272,31 @@ TEST_F(FakeDriveServiceTest, Search_Offline) {
EXPECT_FALSE(resource_list);
}
+TEST_F(FakeDriveServiceTest, Search_Deleted) {
+ ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
+ "chromeos/gdata/root_feed.json"));
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ fake_service_.DeleteResource("file:2_file_resource_id",
+ std::string(), // etag
+ test_util::CreateCopyResultCallback(&error));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(HTTP_SUCCESS, error);
+
+ error = GDATA_OTHER_ERROR;
+ scoped_ptr<ResourceList> resource_list;
+ fake_service_.Search(
+ "File", // search_query
+ test_util::CreateCopyResultCallback(&error, &resource_list));
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ ASSERT_TRUE(resource_list);
+ // Do some sanity check. There are 4 entries that contain "File" in their
+ // titles and one of them is deleted.
+ EXPECT_EQ(3U, resource_list->entries().size());
+}
+
TEST_F(FakeDriveServiceTest, SearchByTitle) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
"chromeos/gdata/root_feed.json"));
@@ -395,6 +420,43 @@ TEST_F(FakeDriveServiceTest, GetChangeList_Offline) {
EXPECT_FALSE(resource_list);
}
+TEST_F(FakeDriveServiceTest, GetChangeList_DeletedEntry) {
+ ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
+ "chromeos/gdata/root_feed.json"));
+ // Load the account_metadata.json as well to add the largest changestamp
+ // (654321) to the existing entries.
+ ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
+ "chromeos/gdata/account_metadata.json"));
+ // Add a new directory in the root directory. The new directory will have
+ // the changestamp of 654322.
+ ASSERT_TRUE(Exists("file:2_file_resource_id"));
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ fake_service_.DeleteResource("file:2_file_resource_id",
+ std::string(), // etag
+ test_util::CreateCopyResultCallback(&error));
+ base::RunLoop().RunUntilIdle();
+ ASSERT_EQ(HTTP_SUCCESS, error);
+ ASSERT_FALSE(Exists("file:2_file_resource_id"));
+
+ // Get the resource list newer than 654321.
+ error = GDATA_OTHER_ERROR;
+ scoped_ptr<ResourceList> resource_list;
+ fake_service_.GetChangeList(
+ 654321 + 1, // start_changestamp
+ test_util::CreateCopyResultCallback(&error, &resource_list));
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ ASSERT_TRUE(resource_list);
+ // The result should only contain the newly created directory.
+ ASSERT_EQ(1U, resource_list->entries().size());
+ const ResourceEntry& entry = *resource_list->entries()[0];
+ EXPECT_EQ("file:2_file_resource_id", entry.resource_id());
+ EXPECT_TRUE(entry.deleted());
+ EXPECT_EQ(1, fake_service_.change_list_load_count());
+}
+
TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetAllResourceList) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
"chromeos/gdata/root_feed.json"));
@@ -754,6 +816,14 @@ TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) {
EXPECT_EQ(HTTP_SUCCESS, error);
// Resource "file:2_file_resource_id" should be gone now.
EXPECT_FALSE(Exists("file:2_file_resource_id"));
+
+ error = GDATA_OTHER_ERROR;
+ fake_service_.DeleteResource("file:2_file_resource_id",
+ std::string(), // etag
+ test_util::CreateCopyResultCallback(&error));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(HTTP_NOT_FOUND, error);
+ EXPECT_FALSE(Exists("file:2_file_resource_id"));
}
TEST_F(FakeDriveServiceTest, DeleteResource_NonexistingFile) {
« no previous file with comments | « chrome/browser/drive/fake_drive_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698