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

Unified Diff: content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc

Issue 264483002: This is the implementation of the primary and secondary blob journals for (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Export kAllBlobsKey Created 6 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 | « content/browser/indexed_db/indexed_db_leveldb_coding.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc b/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc
index d159a81f93320a0590bee2fb60850bc30a06c576..0bd647cff3a360306986b87cc75019f281978bef 100644
--- a/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc
@@ -691,6 +691,76 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKeyPath) {
}
}
+TEST(IndexedDBLevelDBCodingTest, EncodeDecodeBlobJournal) {
+ std::vector<IndexedDBKeyPath> key_paths;
+ std::vector<std::string> encoded_paths;
+
+ std::vector<BlobJournalType> journals;
+
+ { // Empty journal
+ BlobJournalType journal;
+ journals.push_back(journal);
+ }
+
+ { // One item
+ BlobJournalType journal;
+ journal.push_back(std::make_pair(4, 7));
+ journals.push_back(journal);
+ }
+
+ { // kAllBlobsKey
+ BlobJournalType journal;
+ journal.push_back(std::make_pair(5, DatabaseMetaDataKey::kAllBlobsKey));
+ journals.push_back(journal);
+ }
+
+ { // A bunch of items
+ BlobJournalType journal;
+ journal.push_back(std::make_pair(4, 7));
+ journal.push_back(std::make_pair(5, 6));
+ journal.push_back(std::make_pair(4, 5));
+ journal.push_back(std::make_pair(4, 4));
+ journal.push_back(std::make_pair(1, 12));
+ journal.push_back(std::make_pair(4, 3));
+ journal.push_back(std::make_pair(15, 14));
+ journals.push_back(journal);
+ }
+
+ std::vector<BlobJournalType>::const_iterator journal_iter;
+ for (journal_iter = journals.begin(); journal_iter != journals.end();
+ ++journal_iter) {
+ std::string encoding;
+ EncodeBlobJournal(*journal_iter, &encoding);
+ StringPiece slice(encoding);
+ BlobJournalType journal_out;
+ EXPECT_TRUE(DecodeBlobJournal(&slice, &journal_out));
+ EXPECT_EQ(*journal_iter, journal_out);
+ }
+
+ journals.clear();
+
+ { // Illegal database id
+ BlobJournalType journal;
+ journal.push_back(std::make_pair(0, 3));
+ journals.push_back(journal);
+ }
+
+ { // Illegal blob id
+ BlobJournalType journal;
+ journal.push_back(std::make_pair(4, 0));
+ journals.push_back(journal);
+ }
+
+ for (journal_iter = journals.begin(); journal_iter != journals.end();
+ ++journal_iter) {
+ std::string encoding;
+ EncodeBlobJournal(*journal_iter, &encoding);
+ StringPiece slice(encoding);
+ BlobJournalType journal_out;
+ EXPECT_FALSE(DecodeBlobJournal(&slice, &journal_out));
+ }
+}
+
TEST(IndexedDBLevelDBCodingTest, DecodeLegacyIDBKeyPath) {
// Legacy encoding of string key paths.
std::vector<IndexedDBKeyPath> key_paths;
« no previous file with comments | « content/browser/indexed_db/indexed_db_leveldb_coding.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698