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

Unified Diff: chrome/browser/extensions/settings/settings_quota_unittest.cc

Issue 9284013: Extension Storage API: expose storage quota information to extensions, via: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with use-after-free fixed Created 8 years, 11 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: chrome/browser/extensions/settings/settings_quota_unittest.cc
diff --git a/chrome/browser/extensions/settings/settings_quota_unittest.cc b/chrome/browser/extensions/settings/settings_quota_unittest.cc
index 0cb4c19a584fb6e9a30e86f32d550603378abbed..6314c47110f8b81a63f75c7e225bb6909815073a 100644
--- a/chrome/browser/extensions/settings/settings_quota_unittest.cc
+++ b/chrome/browser/extensions/settings/settings_quota_unittest.cc
@@ -49,10 +49,10 @@ class ExtensionSettingsQuotaTest : public testing::Test {
protected:
// Creates |storage_|. Must only be called once.
void CreateStorage(
- size_t quota_bytes, size_t quota_bytes_per_setting, size_t max_keys) {
+ size_t quota_bytes, size_t quota_bytes_per_item, size_t max_items) {
ASSERT_TRUE(storage_.get() == NULL);
SettingsStorageQuotaEnforcer::Limits limits =
- { quota_bytes, quota_bytes_per_setting, max_keys };
+ { quota_bytes, quota_bytes_per_item, max_items };
storage_.reset(new SettingsStorageQuotaEnforcer(limits, delegate_));
}
@@ -557,4 +557,39 @@ TEST_F(ExtensionSettingsQuotaTest,
EXPECT_TRUE(SettingsEqual(settings));
}
+TEST_F(ExtensionSettingsQuotaTest, GetBytesInUse) {
+ // Just testing GetBytesInUse, no need for a quota.
+ CreateStorage(UINT_MAX, UINT_MAX, UINT_MAX);
+
+ std::vector<std::string> ab;
+ ab.push_back("a");
+ ab.push_back("b");
+
+ EXPECT_EQ(0u, storage_->GetBytesInUse());
+ EXPECT_EQ(0u, storage_->GetBytesInUse("a"));
+ EXPECT_EQ(0u, storage_->GetBytesInUse("b"));
+ EXPECT_EQ(0u, storage_->GetBytesInUse(ab));
+
+ storage_->Set(DEFAULTS, "a", *byte_value_1_);
+
+ EXPECT_EQ(2u, storage_->GetBytesInUse());
+ EXPECT_EQ(2u, storage_->GetBytesInUse("a"));
+ EXPECT_EQ(0u, storage_->GetBytesInUse("b"));
+ EXPECT_EQ(2u, storage_->GetBytesInUse(ab));
+
+ storage_->Set(DEFAULTS, "b", *byte_value_1_);
+
+ EXPECT_EQ(4u, storage_->GetBytesInUse());
+ EXPECT_EQ(2u, storage_->GetBytesInUse("a"));
+ EXPECT_EQ(2u, storage_->GetBytesInUse("b"));
+ EXPECT_EQ(4u, storage_->GetBytesInUse(ab));
+
+ storage_->Set(DEFAULTS, "c", *byte_value_1_);
+
+ EXPECT_EQ(6u, storage_->GetBytesInUse());
+ EXPECT_EQ(2u, storage_->GetBytesInUse("a"));
+ EXPECT_EQ(2u, storage_->GetBytesInUse("b"));
+ EXPECT_EQ(4u, storage_->GetBytesInUse(ab));
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/settings/settings_leveldb_storage.cc ('k') | chrome/browser/extensions/settings/settings_storage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698