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

Unified Diff: ui/gfx/color_utils_unittest.cc

Issue 289283004: Add ability to constrain dominant color selection to a HSL range. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove C++11 features 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 | « ui/gfx/color_utils.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_utils_unittest.cc
diff --git a/ui/gfx/color_utils_unittest.cc b/ui/gfx/color_utils_unittest.cc
index 60106f4d8a4247cb948775049456882d3735aad9..b90ae8e2c4268c576f3b9bbe6153d516ab0ba24f 100644
--- a/ui/gfx/color_utils_unittest.cc
+++ b/ui/gfx/color_utils_unittest.cc
@@ -38,7 +38,6 @@ TEST(ColorUtils, HSLToSkColorWithAlpha) {
EXPECT_EQ(SkColorGetB(red), SkColorGetB(result));
}
-
TEST(ColorUtils, RGBtoHSLRoundTrip) {
// Just spot check values near the edges.
for (int r = 0; r < 10; ++r) {
@@ -69,6 +68,38 @@ TEST(ColorUtils, RGBtoHSLRoundTrip) {
}
}
+TEST(ColorUtils, IsWithinHSLRange) {
+ HSL hsl = {0.3, 0.4, 0.5};
+ HSL lower = {0.2, 0.3, 0.4};
+ HSL upper = {0.4, 0.5, 0.6};
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ // Bounds are inclusive.
+ hsl.h = 0.2;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.h = 0.4;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.s = 0.3;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.s = 0.5;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.l = 0.4;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.l = 0.6;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+}
+
+TEST(ColorUtils, IsWithinHSLRangeHueWrapAround) {
+ HSL hsl = {0.3, 0.4, 0.5};
+ HSL lower = {0.8, -1, -1};
+ HSL upper = {1.2, -1, -1};
+ hsl.h = 0.1;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.h = 0.9;
+ EXPECT_TRUE(IsWithinHSLRange(hsl, lower, upper));
+ hsl.h = 0.3;
+ EXPECT_FALSE(IsWithinHSLRange(hsl, lower, upper));
+}
+
TEST(ColorUtils, ColorToHSLRegisterSpill) {
// In a opt build on Linux, this was causing a register spill on my laptop
// (Pentium M) when converting from SkColor to HSL.
« no previous file with comments | « ui/gfx/color_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698