mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
conform: Add operators tests for ClutterColor
The clutter_color_add() and clutter_color_subtract() functions are lacking unit testing to catch eventual regressions.
This commit is contained in:
parent
4388509a15
commit
c6ce9c3389
1
.gitignore
vendored
1
.gitignore
vendored
@ -239,6 +239,7 @@ TAGS
|
||||
/tests/conform/test-script-animation
|
||||
/tests/conform/test-script-named-object
|
||||
/tests/conform/test-actor-destruction
|
||||
/tests/conform/test-color-operators
|
||||
/tests/micro-bench/test-text-perf
|
||||
/tests/micro-bench/test-text
|
||||
/tests/micro-bench/test-picking
|
||||
|
@ -166,3 +166,60 @@ test_color_to_string (TestConformSimpleFixture *fixture,
|
||||
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
void
|
||||
test_color_operators (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterColor op1, op2;
|
||||
ClutterColor res;
|
||||
|
||||
clutter_color_from_pixel (&op1, 0xff0000ff);
|
||||
g_assert_cmpint (op1.red, ==, 0xff);
|
||||
g_assert_cmpint (op1.green, ==, 0);
|
||||
g_assert_cmpint (op1.blue, ==, 0);
|
||||
g_assert_cmpint (op1.alpha, ==, 0xff);
|
||||
|
||||
clutter_color_from_pixel (&op2, 0x00ff00ff);
|
||||
g_assert_cmpint (op2.red, ==, 0);
|
||||
g_assert_cmpint (op2.green, ==, 0xff);
|
||||
g_assert_cmpint (op2.blue, ==, 0);
|
||||
g_assert_cmpint (op2.alpha, ==, 0xff);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("Adding %x, %x; expected result: %x\n",
|
||||
clutter_color_to_pixel (&op1),
|
||||
clutter_color_to_pixel (&op2),
|
||||
0xffff00ff);
|
||||
|
||||
clutter_color_add (&op1, &op2, &res);
|
||||
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0xffff00ff);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("Checking alpha channel on color add\n");
|
||||
|
||||
op1.alpha = 0xdd;
|
||||
op2.alpha = 0xcc;
|
||||
clutter_color_add (&op1, &op2, &res);
|
||||
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0xffff00dd);
|
||||
|
||||
clutter_color_from_pixel (&op1, 0xffffffff);
|
||||
clutter_color_from_pixel (&op2, 0xff00ffff);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("Subtracting %x, %x; expected result: %x\n",
|
||||
clutter_color_to_pixel (&op1),
|
||||
clutter_color_to_pixel (&op2),
|
||||
0x00ff00ff);
|
||||
|
||||
clutter_color_subtract (&op1, &op2, &res);
|
||||
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0x00ff00ff);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("Checking alpha channel on color subtract\n");
|
||||
|
||||
op1.alpha = 0xdd;
|
||||
op2.alpha = 0xcc;
|
||||
clutter_color_subtract (&op1, &op2, &res);
|
||||
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0x00ff00cc);
|
||||
}
|
||||
|
@ -160,6 +160,7 @@ main (int argc, char **argv)
|
||||
TEST_CONFORM_SIMPLE ("/color", test_color_from_string);
|
||||
TEST_CONFORM_SIMPLE ("/color", test_color_to_string);
|
||||
TEST_CONFORM_SIMPLE ("/color", test_color_hls_roundtrip);
|
||||
TEST_CONFORM_SIMPLE ("/color", test_color_operators);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/units", test_units_constructors);
|
||||
TEST_CONFORM_SIMPLE ("/units", test_units_string);
|
||||
|
Loading…
Reference in New Issue
Block a user