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

Unified Diff: content/browser/leveldb_wrapper_impl_unittest.cc

Issue 2697953002: Remove incorrect optimization in LevelDBWrapperImpl::DeleteAll(). (Closed)
Patch Set: fix web platform test Created 3 years, 10 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 | « content/browser/leveldb_wrapper_impl.cc ('k') | third_party/WebKit/LayoutTests/external/wpt/MANIFEST.json » ('j') | 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 a753a94b74b13d2fcb16f5ae2836050425f6869e..012d436305d9f77bf74bb94656f80615876da214 100644
--- a/content/browser/leveldb_wrapper_impl_unittest.cc
+++ b/content/browser/leveldb_wrapper_impl_unittest.cc
@@ -132,6 +132,8 @@ class LevelDBWrapperImplTest : public testing::Test,
: "";
}
+ void clear_mock_data() { mock_data_.clear(); }
+
mojom::LevelDBWrapper* wrapper() { return level_db_wrapper_ptr_.get(); }
mojo::AssociatedGroup* associated_group() {
return level_db_wrapper_ptr_.associated_group();
@@ -309,6 +311,11 @@ TEST_F(LevelDBWrapperImplTest, PutObservations) {
EXPECT_EQ(value1, observations()[1].old_value);
EXPECT_EQ(value2, observations()[1].new_value);
EXPECT_EQ(source2, observations()[1].source);
+
+ // Same put should not cause another observation.
+ EXPECT_TRUE(PutSync(StdStringToUint8Vector(key),
+ StdStringToUint8Vector(value2), source2));
+ ASSERT_EQ(2u, observations().size());
}
TEST_F(LevelDBWrapperImplTest, DeleteNonExistingKey) {
@@ -353,11 +360,9 @@ TEST_F(LevelDBWrapperImplTest, DeleteAllWithoutLoadedMap) {
EXPECT_FALSE(has_mock_data(kTestPrefix + key));
EXPECT_TRUE(has_mock_data(dummy_key));
- // Deleting all again should still work, an cause an observation.
+ // Deleting all again should still work, but not cause an observation.
EXPECT_TRUE(DeleteAllSync());
- ASSERT_EQ(2u, observations().size());
- EXPECT_EQ(Observation::kDeleteAll, observations()[1].type);
- EXPECT_EQ(kTestSource, observations()[1].source);
+ ASSERT_EQ(1u, observations().size());
// And now we've deleted all, writing something the quota size should work.
EXPECT_TRUE(PutSync(std::vector<uint8_t>(kTestSizeLimit, 'b'),
@@ -406,6 +411,13 @@ TEST_F(LevelDBWrapperImplTest, DeleteAllWithPendingMapLoad) {
EXPECT_TRUE(has_mock_data(dummy_key));
}
+TEST_F(LevelDBWrapperImplTest, DeleteAllWithoutLoadedEmptyMap) {
+ clear_mock_data();
+
+ EXPECT_TRUE(DeleteAllSync());
+ ASSERT_EQ(0u, observations().size());
+}
+
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') | third_party/WebKit/LayoutTests/external/wpt/MANIFEST.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698