From 17e9789f6c0b676484609b61e3abbebca8c93f88 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Mon, 19 Apr 2021 16:25:58 +0200 Subject: reduce copy pasta with Color::GetLuminance() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2eda3607a3be6ee56f0a9ddd14131be783b9698a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114294 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- tools/qa/cppunit/test_color.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/qa/cppunit') diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index 05616b8f64a2..f3ffd9c692cd 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -25,6 +25,7 @@ public: void testGetColorError(); void testInvert(); void testBColor(); + void testLuminance(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testVariables); @@ -33,6 +34,7 @@ public: CPPUNIT_TEST(testGetColorError); CPPUNIT_TEST(testInvert); CPPUNIT_TEST(testBColor); + CPPUNIT_TEST(testLuminance); CPPUNIT_TEST_SUITE_END(); }; @@ -218,6 +220,18 @@ void Test::testBColor() } +void Test::testLuminance() +{ + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), COL_BLACK.GetLuminance()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), COL_WHITE.GetLuminance()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(128), Color(128, 128, 128).GetLuminance()); + CPPUNIT_ASSERT(COL_WHITE.IsBright()); + CPPUNIT_ASSERT(COL_BLACK.IsDark()); + CPPUNIT_ASSERT(Color(249, 250, 251).IsBright()); + CPPUNIT_ASSERT(Color(9, 10, 11).IsDark()); + CPPUNIT_ASSERT(COL_WHITE.GetLuminance() > COL_BLACK.GetLuminance()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } -- cgit