diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-05-15 15:05:40 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-05-15 15:05:40 +0200 |
commit | e397c346da38f71c8b8f6e5e4cf57f7ee01b2404 (patch) | |
tree | dc9826da709910dd40b8dcf92ce4c2692894cf8b /test | |
parent | f0ceeb86d8f11526fc2fd52c3ef8e3c9e340a20f (diff) |
[ThemeParser] Extend color formats.
- Support whitespace format.
- Support deg,rad, grad, turn angle.
- Add alpha channel support to hwb
Diffstat (limited to 'test')
-rw-r--r-- | test/theme-parser-test.c | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 5aa0b298..488aa203 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -643,7 +643,7 @@ START_TEST ( test_properties_color_hwb ) widget wid; wid.name = "blaat"; wid.state = NULL; - rofi_theme_parse_string ( "* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, 29%); }"); + rofi_theme_parse_string ( "* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, 29%); testa: hwb(265, 31%, 29%, 40%); }"); ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); @@ -658,6 +658,40 @@ START_TEST ( test_properties_color_hwb ) ck_assert_double_eq_tol ( p->value.color.red , 166/255.0, 0.004); ck_assert_double_eq_tol ( p->value.color.green ,240/255.0, 0.004 ); ck_assert_double_eq_tol ( p->value.color.blue , 255/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "testa", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.4 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); +} +END_TEST +START_TEST ( test_properties_color_hwb_ws ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hwb(190 deg 65 %0%); test2: hwb(295 grad 31% 29%);testa: hwb(0.736 turn 31% 29% / 40%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test1", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 166/255.0, 0.004); + ck_assert_double_eq_tol ( p->value.color.green ,240/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 255/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "testa", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 0.4 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); } END_TEST START_TEST ( test_properties_color_cmyk ) @@ -682,6 +716,28 @@ START_TEST ( test_properties_color_cmyk ) ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); } END_TEST +START_TEST ( test_properties_color_cmyk_ws ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: cmyk ( 41% 0% 100% 0%); test2: cmyk ( 0 1.0 1.0 0);}"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test1", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x96/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 1.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 1 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); +} +END_TEST START_TEST ( test_properties_padding_2 ) { widget wid; @@ -909,7 +965,9 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_hsl); tcase_add_test ( tc_prop_color, test_properties_color_hsla); tcase_add_test ( tc_prop_color, test_properties_color_hwb); + tcase_add_test ( tc_prop_color, test_properties_color_hwb_ws); tcase_add_test ( tc_prop_color, test_properties_color_cmyk); + tcase_add_test ( tc_prop_color, test_properties_color_cmyk_ws); suite_add_tcase(s, tc_prop_color ); } { |