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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/enhanced_bookmarks/image_store.h" 5 #include "components/enhanced_bookmarks/image_store.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/strings/string_number_conversions.h"
8 #include "components/enhanced_bookmarks/image_store_util.h" 9 #include "components/enhanced_bookmarks/image_store_util.h"
9 #include "components/enhanced_bookmarks/persistent_image_store.h" 10 #include "components/enhanced_bookmarks/persistent_image_store.h"
10 #include "components/enhanced_bookmarks/test_image_store.h" 11 #include "components/enhanced_bookmarks/test_image_store.h"
11 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace { 16 namespace {
16 17
17 const SkBitmap CreateBitmap(int width, int height, int a, int r, int g, int b) { 18 const SkBitmap CreateBitmap(int width, int height, int a, int r, int g, int b) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 EXPECT_EQ(image_url, image_info.second); 212 EXPECT_EQ(image_url, image_info.second);
212 EXPECT_TRUE(CompareImages(src_image, image_info.first)); 213 EXPECT_TRUE(CompareImages(src_image, image_info.first));
213 } else { 214 } else {
214 std::set<GURL> all_urls; 215 std::set<GURL> all_urls;
215 this->store_->GetAllPageUrls(&all_urls); 216 this->store_->GetAllPageUrls(&all_urls);
216 EXPECT_EQ(0u, all_urls.size()); 217 EXPECT_EQ(0u, all_urls.size());
217 EXPECT_FALSE(this->store_->HasKey(GURL("foo://bar"))); 218 EXPECT_FALSE(this->store_->HasKey(GURL("foo://bar")));
218 } 219 }
219 } 220 }
220 221
222 TYPED_TEST(ImageStoreUnitTest, GetSize) {
223 gfx::Image src_image = GenerateBlackImage();
224 const GURL url("foo://bar");
225 const GURL image_url("a.jpg");
226
227 int64 size = 0;
228 if (this->use_persistent_store()) {
229 // File shouldn't exist before we actually start using it since we do lazy
230 // initialization.
231 EXPECT_EQ(this->store_->GetStoreSizeInBytes(), -1);
232 } else {
233 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 1024);
234 }
235 for (int i = 0; i < 100; ++i) {
236 this->store_->Insert(
237 GURL(url.spec() + '/' + base::IntToString(i)), image_url, src_image);
238 EXPECT_GE(this->store_->GetStoreSizeInBytes(), size);
239 size = this->store_->GetStoreSizeInBytes();
240 }
241
242 if (this->use_persistent_store()) {
243 EXPECT_GE(this->store_->GetStoreSizeInBytes(), 100 * 1024); // 100kb
244 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 200 * 1024); // 200kb
245 } else {
246 EXPECT_GE(this->store_->GetStoreSizeInBytes(), 400 * 1024); // 400kb
247 EXPECT_LE(this->store_->GetStoreSizeInBytes(), 500 * 1024); // 500kb
248 }
249 }
250
221 } // namespace 251 } // namespace
OLDNEW
« 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