summaryrefslogtreecommitdiffstats
path: root/components/enhanced_bookmarks/image_store_ios_unittest.mm
diff options
context:
space:
mode:
authorlpromero <lpromero@chromium.org>2015-01-23 12:17:36 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-23 20:18:40 +0000
commita110f52e83cebd2b6f0ed37c34abeac8bfcb1b72 (patch)
treeb0054fe1a2bbb25a9532fb7a1b9a1decb5b62a6d /components/enhanced_bookmarks/image_store_ios_unittest.mm
parent921392d21263c05b374d94ae3da3120094cd6a65 (diff)
downloadchromium_src-a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72.zip
chromium_src-a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72.tar.gz
chromium_src-a110f52e83cebd2b6f0ed37c34abeac8bfcb1b72.tar.bz2
★ Record the image dominant color in the image database.
This CL adds a column in the bookmarks images database. It contains the dominant color extracted from the image. Since this computation can be lengthy, it is done in the background, when the image is stored in the database. For old databases, a migration path is provided and the dominant color is computed and stored upon querying the image for the first time. BUG=448443 Review URL: https://codereview.chromium.org/875463003 Cr-Commit-Position: refs/heads/master@{#312916}
Diffstat (limited to 'components/enhanced_bookmarks/image_store_ios_unittest.mm')
-rw-r--r--components/enhanced_bookmarks/image_store_ios_unittest.mm23
1 files changed, 13 insertions, 10 deletions
diff --git a/components/enhanced_bookmarks/image_store_ios_unittest.mm b/components/enhanced_bookmarks/image_store_ios_unittest.mm
index 78c57cb..19dd5fa 100644
--- a/components/enhanced_bookmarks/image_store_ios_unittest.mm
+++ b/components/enhanced_bookmarks/image_store_ios_unittest.mm
@@ -8,6 +8,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/mac/scoped_cftyperef.h"
+#include "components/enhanced_bookmarks/image_record.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"
@@ -21,7 +22,7 @@ namespace {
// Generates a gfx::Image with a random UIImage representation. Uses off-center
// circle gradient to make all pixels slightly different in order to detect
// small image alterations.
-gfx::Image GenerateRandomUIImage(gfx::Size& size, float scale) {
+gfx::Image GenerateRandomUIImage(const gfx::Size& size, float scale) {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(size.width(),
size.height()),
YES, // opaque.
@@ -136,17 +137,19 @@ typedef testing::Types<TestImageStore,
TYPED_TEST_CASE(ImageStoreUnitTestIOS, Implementations);
TYPED_TEST(ImageStoreUnitTestIOS, StoringImagesPreservesScale) {
- CGFloat scales[] = { 0.0, 1.0, 2.0 };
- gfx::Size image_size(42, 24);
+ const CGFloat scales[] = {0.0, 1.0, 2.0};
+ const gfx::Size image_size(42, 24);
for (unsigned long i = 0; i < arraysize(scales); i++) {
- gfx::Image src_image(GenerateRandomUIImage(image_size, scales[i]));
const GURL url("foo://bar");
- const GURL image_url("a.jpg");
- this->store_->Insert(url, image_url, src_image);
- std::pair<gfx::Image, GURL> image_info = this->store_->Get(url);
-
- EXPECT_EQ(image_url, image_info.second);
- EXPECT_TRUE(CompareImages(src_image, image_info.first));
+ const enhanced_bookmarks::ImageRecord image_in(
+ GenerateRandomUIImage(image_size, scales[i]), GURL("http://a.jpg"),
+ SK_ColorGREEN);
+ this->store_->Insert(url, image_in);
+ const enhanced_bookmarks::ImageRecord image_out = this->store_->Get(url);
+
+ EXPECT_EQ(image_in.url, image_out.url);
+ EXPECT_TRUE(CompareImages(image_in.image, image_out.image));
+ EXPECT_EQ(image_in.dominant_color, image_out.dominant_color);
}
}