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

Unified Diff: content/browser/leveldb_wrapper_impl_unittest.cc

Issue 2605133002: Add method to delete storage for origins to LocalStorageContextMojo. (Closed)
Patch Set: delete storage for physical origin Created 4 years 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 | « content/browser/leveldb_wrapper_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/leveldb_wrapper_impl_unittest.cc
diff --git a/content/browser/leveldb_wrapper_impl_unittest.cc b/content/browser/leveldb_wrapper_impl_unittest.cc
index 62803fd9ebcc980934d8018d9328f1bf3c0119fb..8e81ff4e2567044d243d99bc6453d0d551504b51 100644
--- a/content/browser/leveldb_wrapper_impl_unittest.cc
+++ b/content/browser/leveldb_wrapper_impl_unittest.cc
@@ -75,6 +75,8 @@ void SuccessCallback(const base::Closure& callback,
callback.Run();
}
+void NoOpSuccessCallback(bool success) {}
+
} // namespace
class LevelDBWrapperImplTest : public testing::Test,
@@ -174,10 +176,7 @@ class LevelDBWrapperImplTest : public testing::Test,
return success;
}
- void CommitChanges() {
- ASSERT_TRUE(level_db_wrapper_.commit_batch_);
- level_db_wrapper_.CommitChanges();
- }
+ void CommitChanges() { level_db_wrapper_.ScheduleImmediateCommit(); }
const std::vector<Observation>& observations() { return observations_; }
@@ -332,7 +331,7 @@ TEST_F(LevelDBWrapperImplTest, DeleteExistingKey) {
EXPECT_FALSE(has_mock_data(kTestPrefix + key));
}
-TEST_F(LevelDBWrapperImplTest, DeleteAll) {
+TEST_F(LevelDBWrapperImplTest, DeleteAllWithoutLoadedMap) {
std::string key = "newkey";
std::string value = "foo";
std::string dummy_key = "foobar";
@@ -362,6 +361,48 @@ TEST_F(LevelDBWrapperImplTest, DeleteAll) {
std::vector<uint8_t>()));
}
+TEST_F(LevelDBWrapperImplTest, DeleteAllWithLoadedMap) {
+ std::string key = "newkey";
+ std::string value = "foo";
+ std::string dummy_key = "foobar";
+ set_mock_data(dummy_key, value);
+
+ EXPECT_TRUE(
+ PutSync(StdStringToUint8Vector(key), StdStringToUint8Vector(value)));
+
+ EXPECT_TRUE(DeleteAllSync());
+ ASSERT_EQ(2u, observations().size());
+ EXPECT_EQ(Observation::kDeleteAll, observations()[1].type);
+ EXPECT_EQ(kTestSource, observations()[1].source);
+
+ EXPECT_TRUE(has_mock_data(dummy_key));
+
+ CommitChanges();
+ EXPECT_FALSE(has_mock_data(kTestPrefix + key));
+ EXPECT_TRUE(has_mock_data(dummy_key));
+}
+
+TEST_F(LevelDBWrapperImplTest, DeleteAllWithPendingMapLoad) {
+ std::string key = "newkey";
+ std::string value = "foo";
+ std::string dummy_key = "foobar";
+ set_mock_data(dummy_key, value);
+
+ wrapper()->Put(StdStringToUint8Vector(key), StdStringToUint8Vector(value),
+ kTestSource, base::Bind(&NoOpSuccessCallback));
+
+ EXPECT_TRUE(DeleteAllSync());
+ ASSERT_EQ(2u, observations().size());
+ EXPECT_EQ(Observation::kDeleteAll, observations()[1].type);
+ EXPECT_EQ(kTestSource, observations()[1].source);
+
+ EXPECT_TRUE(has_mock_data(dummy_key));
+
+ CommitChanges();
+ EXPECT_FALSE(has_mock_data(kTestPrefix + key));
+ EXPECT_TRUE(has_mock_data(dummy_key));
+}
+
TEST_F(LevelDBWrapperImplTest, PutOverQuotaLargeValue) {
std::vector<uint8_t> key = StdStringToUint8Vector("newkey");
std::vector<uint8_t> value(kTestSizeLimit, 4);
« no previous file with comments | « content/browser/leveldb_wrapper_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698