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..f61663e5bca7afc40fd60b053121207bc45db4f3 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}; |
+ { |
+ 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)); |
+ } |
+ { |
+ // Check hue wrap-around. |
Alexei Svitkine (slow)
2014/05/22 13:05:22
Can this be a separate TEST?
calamity
2014/05/23 03:03:40
Done.
|
+ 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)); |
+ } |
+} |
Alexei Svitkine (slow)
2014/05/22 13:05:22
Nit: Add blank line after this.
calamity
2014/05/23 03:03:40
Done.
|
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. |