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

Unified Diff: components/enhanced_bookmarks/image_store_unittest.cc

Issue 305963004: Add GetStoreSize() to ImageStore to know the actual db size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size += bitmap.getSize(); Created 6 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
« no previous file with comments | « components/enhanced_bookmarks/image_store.h ('k') | components/enhanced_bookmarks/persistent_image_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/enhanced_bookmarks/image_store_unittest.cc
diff --git a/components/enhanced_bookmarks/image_store_unittest.cc b/components/enhanced_bookmarks/image_store_unittest.cc
index 778c1e3e69886dc4e06415d3e87fcec5cea41128..14766481dd42c3ed260dcd79d626702b3e471d8a 100644
--- a/components/enhanced_bookmarks/image_store_unittest.cc
+++ b/components/enhanced_bookmarks/image_store_unittest.cc
@@ -5,6 +5,7 @@
#include "components/enhanced_bookmarks/image_store.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/strings/string_number_conversions.h"
#include "components/enhanced_bookmarks/image_store_util.h"
#include "components/enhanced_bookmarks/persistent_image_store.h"
#include "components/enhanced_bookmarks/test_image_store.h"
@@ -218,4 +219,33 @@ TYPED_TEST(ImageStoreUnitTest, Persistence) {
}
}
+TYPED_TEST(ImageStoreUnitTest, GetSize) {
+ gfx::Image src_image = GenerateBlackImage();
+ const GURL url("foo://bar");
+ const GURL image_url("a.jpg");
+
+ int64 size = 0;
+ if (this->use_persistent_store()) {
+ // File shouldn't exist before we actually start using it since we do lazy
+ // initialization.
+ EXPECT_EQ(this->store_->GetStoreSizeInBytes(), -1);
+ } else {
+ EXPECT_LE(this->store_->GetStoreSizeInBytes(), 1024);
+ }
+ for (int i = 0; i < 100; ++i) {
+ this->store_->Insert(
+ GURL(url.spec() + '/' + base::IntToString(i)), image_url, src_image);
+ EXPECT_GE(this->store_->GetStoreSizeInBytes(), size);
+ size = this->store_->GetStoreSizeInBytes();
+ }
+
+ if (this->use_persistent_store()) {
+ EXPECT_GE(this->store_->GetStoreSizeInBytes(), 100 * 1024); // 100kb
+ EXPECT_LE(this->store_->GetStoreSizeInBytes(), 200 * 1024); // 200kb
+ } else {
+ EXPECT_GE(this->store_->GetStoreSizeInBytes(), 400 * 1024); // 400kb
+ EXPECT_LE(this->store_->GetStoreSizeInBytes(), 500 * 1024); // 500kb
+ }
+}
+
} // namespace
« no previous file with comments | « components/enhanced_bookmarks/image_store.h ('k') | components/enhanced_bookmarks/persistent_image_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698