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

Unified Diff: ui/gfx/color_analysis_unittest.cc

Issue 2943333003: Extracting more than one wallpaper prominent color (Closed)
Patch Set: UMA Created 3 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 side-by-side diff with in-line comments
Download patch
« ui/gfx/color_analysis.cc ('K') | « ui/gfx/color_analysis.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_analysis_unittest.cc
diff --git a/ui/gfx/color_analysis_unittest.cc b/ui/gfx/color_analysis_unittest.cc
index 93fc2db63bc4bccc3ae67a12db9c93aa26ae8a02..3d1337b92531b8ddb067e463059b0c5ec00b3c2f 100644
--- a/ui/gfx/color_analysis_unittest.cc
+++ b/ui/gfx/color_analysis_unittest.cc
@@ -497,16 +497,15 @@ TEST_F(ColorAnalysisTest, ComputePrincipalComponentImage) {
EXPECT_EQ(93U, SkColorGetA(result.getColor(150, 0)));
}
-TEST_F(ColorAnalysisTest, ComputeProminentColor) {
- struct {
- LumaRange luma;
- SaturationRange saturation;
- } color_profiles[] = {{LumaRange::DARK, SaturationRange::VIBRANT},
- {LumaRange::NORMAL, SaturationRange::VIBRANT},
- {LumaRange::LIGHT, SaturationRange::VIBRANT},
- {LumaRange::DARK, SaturationRange::MUTED},
- {LumaRange::NORMAL, SaturationRange::MUTED},
- {LumaRange::LIGHT, SaturationRange::MUTED}};
+TEST_F(ColorAnalysisTest, ComputeProminentColors) {
+ LumaRange lumas[] = {LumaRange::DARK, LumaRange::NORMAL, LumaRange::LIGHT};
+ SaturationRange saturations[] = {SaturationRange::VIBRANT,
+ SaturationRange::MUTED};
+ ColorProfiles color_profiles;
+ for (auto s : saturations) {
+ for (auto l : lumas)
+ color_profiles.push_back(ColorProfile(l, s));
danakj 2017/06/20 23:22:03 nit: .emplace_back(l, s)
Qiang(Joe) Xu 2017/06/21 01:10:52 Done.
+ }
// A totally dark gray image, which yields no prominent color as it's too
// close to black.
@@ -515,12 +514,10 @@ TEST_F(ColorAnalysisTest, ComputeProminentColor) {
SkBitmap bitmap = canvas.GetBitmap();
// All expectations start at SK_ColorTRANSPARENT (i.e. 0).
- SkColor expectations[arraysize(color_profiles)] = {};
- for (size_t i = 0; i < arraysize(color_profiles); ++i) {
- EXPECT_EQ(expectations[i],
- CalculateProminentColorOfBitmap(bitmap, color_profiles[i].luma,
- color_profiles[i].saturation));
- }
+ std::vector<SkColor> expectations(color_profiles.size(), 0);
+ std::vector<SkColor> computations =
+ CalculateProminentColorsOfBitmap(bitmap, color_profiles);
+ EXPECT_EQ(expectations, computations);
// Add a green that could hit a couple values.
const SkColor kVibrantGreen = SkColorSetRGB(25, 200, 25);
@@ -528,22 +525,16 @@ TEST_F(ColorAnalysisTest, ComputeProminentColor) {
bitmap = canvas.GetBitmap();
expectations[0] = kVibrantGreen;
expectations[1] = kVibrantGreen;
- for (size_t i = 0; i < arraysize(color_profiles); ++i) {
- EXPECT_EQ(expectations[i],
- CalculateProminentColorOfBitmap(bitmap, color_profiles[i].luma,
- color_profiles[i].saturation));
- }
+ computations = CalculateProminentColorsOfBitmap(bitmap, color_profiles);
+ EXPECT_EQ(expectations, computations);
// Add a stripe of a dark, muted green (saturation .33, luma .29).
const SkColor kDarkGreen = SkColorSetRGB(50, 100, 50);
canvas.FillRect(gfx::Rect(0, 2, 300, 1), kDarkGreen);
bitmap = canvas.GetBitmap();
expectations[3] = kDarkGreen;
- for (size_t i = 0; i < arraysize(color_profiles); ++i) {
- EXPECT_EQ(expectations[i],
- CalculateProminentColorOfBitmap(bitmap, color_profiles[i].luma,
- color_profiles[i].saturation));
- }
+ computations = CalculateProminentColorsOfBitmap(bitmap, color_profiles);
+ EXPECT_EQ(expectations, computations);
// Now draw a little bit of pure green. That should be closer to the goal for
// normal vibrant, but is out of range for other color profiles.
@@ -551,11 +542,8 @@ TEST_F(ColorAnalysisTest, ComputeProminentColor) {
canvas.FillRect(gfx::Rect(0, 3, 300, 1), kPureGreen);
bitmap = canvas.GetBitmap();
expectations[1] = kPureGreen;
- for (size_t i = 0; i < arraysize(color_profiles); ++i) {
- EXPECT_EQ(expectations[i],
- CalculateProminentColorOfBitmap(bitmap, color_profiles[i].luma,
- color_profiles[i].saturation));
- }
+ computations = CalculateProminentColorsOfBitmap(bitmap, color_profiles);
+ EXPECT_EQ(expectations, computations);
}
} // namespace color_utils
« ui/gfx/color_analysis.cc ('K') | « ui/gfx/color_analysis.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698