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

Unified Diff: content/browser/indexed_db/leveldb/leveldb_unittest.cc

Issue 17462005: IndexedDB: Replace transaction's AVLTree with std::map (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased; store node pointers in map to avoid copies Created 7 years, 4 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
Index: content/browser/indexed_db/leveldb/leveldb_unittest.cc
diff --git a/content/browser/indexed_db/leveldb/leveldb_unittest.cc b/content/browser/indexed_db/leveldb/leveldb_unittest.cc
index 9ce06641c611809154269b690c4252ee3807072e..de506c575976553fa13398506c6917e6d82bffdc 100644
--- a/content/browser/indexed_db/leveldb/leveldb_unittest.cc
+++ b/content/browser/indexed_db/leveldb/leveldb_unittest.cc
@@ -197,6 +197,52 @@ TEST(LevelDBDatabaseTest, TransactionIterator) {
EXPECT_FALSE(it->IsValid());
}
+TEST(LevelDBDatabaseTest, TransactionCommitTest) {
+ base::ScopedTempDir temp_directory;
+ ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
+
+ const std::string key1("key1");
+ const std::string key2("key2");
+ const std::string value1("value1");
+ const std::string value2("value2");
+ const std::string value3("value3");
+
+ std::string put_value;
+ std::string got_value;
+ SimpleComparator comparator;
+ bool success;
+ bool found;
+
+ scoped_ptr<LevelDBDatabase> leveldb;
+ LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb);
+ EXPECT_TRUE(leveldb);
+
+ scoped_refptr<LevelDBTransaction> transaction =
+ new LevelDBTransaction(leveldb.get());
+
+ put_value = value1;
+ transaction->Put(key1, &put_value);
+
+ put_value = value2;
+ transaction->Put(key2, &put_value);
+
+ put_value = value3;
+ transaction->Put(key2, &put_value);
+
+ success = transaction->Commit();
+ EXPECT_TRUE(success);
+
+ success = leveldb->Get(key1, &got_value, &found);
+ EXPECT_TRUE(success);
+ EXPECT_TRUE(found);
+ EXPECT_EQ(value1, got_value);
+
+ success = leveldb->Get(key2, &got_value, &found);
+ EXPECT_TRUE(success);
+ EXPECT_TRUE(found);
+ EXPECT_EQ(value3, got_value);
+}
+
} // namespace
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698