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

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: rebase 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
« ui/gfx/color_utils.cc ('K') | « 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 59eaeba1e3e8c779b3a475cc768003e54113a1f7..96730a1053f751eb09fe0e7201e1ffc38ff1623c 100644
--- a/ui/gfx/color_utils_unittest.cc
+++ b/ui/gfx/color_utils_unittest.cc
@@ -36,7 +36,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) {
@@ -67,6 +66,38 @@ TEST(ColorUtils, RGBtoHSLRoundTrip) {
}
}
+TEST(ColorUtils, IsWithinHSLRange) {
+ color_utils::HSL hsl = {0.3, 0.4, 0.5};
Alexei Svitkine (slow) 2014/05/30 14:56:39 Nit: Make the test file have namespace color_utils
calamity 2014/06/02 03:53:17 Done.
+ color_utils::HSL lower = {0.2, 0.3, 0.4};
+ color_utils::HSL upper = {0.4, 0.5, 0.6};
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ // Bounds are inclusive.
+ hsl.h = 0.2;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.h = 0.4;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.s = 0.3;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.s = 0.5;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.l = 0.4;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.l = 0.6;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+}
+
+TEST(ColorUtils, IsWithinHSLRangeHueWrapAround) {
+ color_utils::HSL hsl = {0.3, 0.4, 0.5};
+ color_utils::HSL lower = {0.8, -1, -1};
+ color_utils::HSL upper = {1.2, -1, -1};
+ hsl.h = 0.1;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.h = 0.9;
+ EXPECT_TRUE(color_utils::IsWithinHSLRange(hsl, lower, upper));
+ hsl.h = 0.3;
+ EXPECT_FALSE(color_utils::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.
« ui/gfx/color_utils.cc ('K') | « ui/gfx/color_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698