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

Unified Diff: chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc

Issue 14249007: chromeos: Perform strict check on parent-shild relationship of DriveResourceMetadata DB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/chromeos/drive/drive_resource_metadata_storage.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc
diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc b/chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc
index f9f7c6277e42fa620a79fc009080ba33373fb2b1..5c38664dcd831681d94e62cb7cac684f680a192f 100644
--- a/chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc
+++ b/chrome/browser/chromeos/drive/drive_resource_metadata_storage_unittest.cc
@@ -272,6 +272,9 @@ TEST_F(DriveResourceMetadataStorageTest, CheckValidity) {
const std::string key3 = "boo";
const std::string name3 = "piyo";
+ // Empty storage is valid.
+ EXPECT_TRUE(CheckValidity());
+
// Put entry with key1.
DriveEntryProto entry;
entry.set_resource_id(key1);
@@ -290,20 +293,44 @@ TEST_F(DriveResourceMetadataStorageTest, CheckValidity) {
storage_->PutChild(key1, name2, key2);
EXPECT_TRUE(CheckValidity());
- // Add parent-child relationship between key1 and key3.
- storage_->PutChild(key1, name3, key3);
+ // Add parent-child relationship between key2 and key3.
+ storage_->PutChild(key2, name3, key3);
EXPECT_FALSE(CheckValidity()); // key3 is not stored in the storage.
- // Put entry with key3 under key1.
+ // Put entry with key3 under key2.
entry.set_resource_id(key3);
- entry.set_parent_resource_id(key1);
+ entry.set_parent_resource_id(key2);
entry.set_base_name(name3);
storage_->PutEntry(entry);
EXPECT_TRUE(CheckValidity());
// Parent-child relationship with wrong name.
- storage_->PutChild(key1, name2, key3);
+ storage_->RemoveChild(key2, name3);
+ EXPECT_FALSE(CheckValidity());
+ storage_->PutChild(key2, name2, key3);
+ EXPECT_FALSE(CheckValidity());
+
+ // Fix up the relationship between key2 and key3.
+ storage_->RemoveChild(key2, name2);
+ EXPECT_FALSE(CheckValidity());
+ storage_->PutChild(key2, name3, key3);
+ EXPECT_TRUE(CheckValidity());
+
+ // Remove key2.
+ storage_->RemoveChild(key1, name2);
EXPECT_FALSE(CheckValidity());
+ storage_->RemoveEntry(key2);
+ EXPECT_FALSE(CheckValidity());
+
+ // Remove key3.
+ storage_->RemoveChild(key2, name3);
+ EXPECT_FALSE(CheckValidity());
+ storage_->RemoveEntry(key3);
+ EXPECT_TRUE(CheckValidity());
+
+ // Remove key1.
+ storage_->RemoveEntry(key1);
+ EXPECT_TRUE(CheckValidity());
}
} // namespace drive
« no previous file with comments | « chrome/browser/chromeos/drive/drive_resource_metadata_storage.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698