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

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

Issue 2904603003: [IndexedDB] Adding txn, value, and key size metrics (Closed)
Patch Set: made sure size is 0'd out Created 3 years, 7 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_transaction_unittest.cc
diff --git a/content/browser/indexed_db/leveldb/leveldb_transaction_unittest.cc b/content/browser/indexed_db/leveldb/leveldb_transaction_unittest.cc
index d4870f13cf4c56f5081aeca29512b1b8d59c6f30..3428346eaed45e17234127588757f3afed4c8c87 100644
--- a/content/browser/indexed_db/leveldb/leveldb_transaction_unittest.cc
+++ b/content/browser/indexed_db/leveldb/leveldb_transaction_unittest.cc
@@ -106,6 +106,10 @@ class LevelDBTransactionTest : public testing::Test {
return new LevelDBTransaction(db());
}
+ static constexpr size_t SizeOfRecord() {
+ return sizeof(LevelDBTransaction::Record);
+ }
+
private:
base::ScopedTempDir temp_directory_;
SimpleComparator comparator_;
@@ -114,7 +118,7 @@ class LevelDBTransactionTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(LevelDBTransactionTest);
};
-TEST_F(LevelDBTransactionTest, GetAndPut) {
+TEST_F(LevelDBTransactionTest, GetPutDelete) {
leveldb::Status status;
const std::string key("key");
@@ -150,12 +154,19 @@ TEST_F(LevelDBTransactionTest, GetAndPut) {
const std::string another_key("another key");
const std::string another_value("another value");
+ EXPECT_EQ(0ull, transaction->GetTransactionSize());
TransactionPut(transaction.get(), another_key, another_value);
+ EXPECT_EQ(SizeOfRecord() + another_key.size() * 2 + another_value.size(),
+ transaction->GetTransactionSize());
status = transaction->Get(another_key, &got_value, &found);
EXPECT_TRUE(status.ok());
EXPECT_TRUE(found);
EXPECT_EQ(Compare(got_value, another_value), 0);
+
+ transaction->Remove(another_key);
+ EXPECT_EQ(SizeOfRecord() + another_key.size() * 2,
+ transaction->GetTransactionSize());
}
TEST_F(LevelDBTransactionTest, Iterator) {

Powered by Google App Engine
This is Rietveld 408576698