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

Unified Diff: content/browser/quota/quota_database_unittest.cc

Issue 1424653002: Add access count and time-since-accessed histograms to temp storage eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quota_uma
Patch Set: add quota database test Created 5 years, 2 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/quota/quota_database_unittest.cc
diff --git a/content/browser/quota/quota_database_unittest.cc b/content/browser/quota/quota_database_unittest.cc
index 4bfdd8b51b796fdb1333e39e34f4f7ab8e554153..907cb68e1513757b7ebe24a86bb2763f5d7a5079 100644
--- a/content/browser/quota/quota_database_unittest.cc
+++ b/content/browser/quota/quota_database_unittest.cc
@@ -445,6 +445,29 @@ class QuotaDatabaseTest : public testing::Test {
EXPECT_TRUE(verifier.table.empty());
}
+ void GetOriginInfo(const base::FilePath& kDbFile) {
+ const GURL kOrigin = GURL("http://go/");
+ typedef QuotaDatabase::OriginInfoTableEntry Entry;
+ Entry kTableEntries[] = {
+ Entry(kOrigin, kStorageTypeTemporary, 100, base::Time(), base::Time())
+ };
+ Entry* begin = kTableEntries;
+ Entry* end = kTableEntries + arraysize(kTableEntries);
+
+ QuotaDatabase db(kDbFile);
+ EXPECT_TRUE(db.LazyOpen(true));
+ AssignOriginInfoTable(db.db_.get(), begin, end);
+ db.Commit();
+
+ Entry entry;
+ EXPECT_TRUE(db.GetOriginInfo(kOrigin, kStorageTypeTemporary, &entry));
+ EXPECT_EQ(kTableEntries[0].type, entry.type);
+ EXPECT_EQ(kTableEntries[0].origin, entry.origin);
+ EXPECT_EQ(kTableEntries[0].used_count, entry.used_count);
+ EXPECT_EQ(kTableEntries[0].last_access_time, entry.last_access_time);
+ EXPECT_EQ(kTableEntries[0].last_modified_time, entry.last_modified_time);
michaeln 2015/10/30 00:49:02 can you add a test negative, try to get info for a
calamity 2015/11/02 06:27:44 Done.
+ }
+
private:
template <typename Iterator>
void AssignQuotaTable(sql::Connection* db, Iterator itr, Iterator end) {
@@ -645,6 +668,14 @@ TEST_F(QuotaDatabaseTest, DumpOriginInfoTable) {
DumpOriginInfoTable(base::FilePath());
}
+TEST_F(QuotaDatabaseTest, GetOriginInfo) {
+ base::ScopedTempDir data_dir;
+ ASSERT_TRUE(data_dir.CreateUniqueTempDir());
+ const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName);
+ GetOriginInfo(kDbFile);
michaeln 2015/10/30 00:49:02 Any test that touches the disk is incredibly slow.
calamity 2015/11/02 06:27:44 Done.
+ GetOriginInfo(base::FilePath());
+}
+
TEST_F(QuotaDatabaseTest, OpenCorruptedDatabase) {
base::ScopedTempDir data_dir;
ASSERT_TRUE(data_dir.CreateUniqueTempDir());
« no previous file with comments | « no previous file | content/browser/quota/quota_manager_unittest.cc » ('j') | storage/browser/quota/quota_database.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698