mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Test] Expand the CI test for theme.
This commit is contained in:
parent
47d71a2032
commit
36d4aee490
1 changed files with 226 additions and 0 deletions
|
@ -253,6 +253,41 @@ START_TEST(test_properties_distance_em_linestyle) {
|
|||
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_properties_distance_ch) {
|
||||
widget wid;
|
||||
wid.name = "blaat";
|
||||
wid.state = NULL;
|
||||
rofi_theme_parse_string("* { test: 10ch;}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
RofiDistance d = (RofiDistance){
|
||||
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
|
||||
RofiPadding pi = (RofiPadding){d, d, d, d};
|
||||
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
|
||||
ck_assert_int_eq(p.left.base.distance, 10);
|
||||
ck_assert_int_eq(p.left.base.type, ROFI_PU_CH);
|
||||
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_properties_distance_ch_linestyle) {
|
||||
widget wid;
|
||||
wid.name = "blaat";
|
||||
wid.state = NULL;
|
||||
rofi_theme_parse_string("* { sol: 1.3ch solid; dash: 1.5ch dash;}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
RofiDistance d = (RofiDistance){
|
||||
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
|
||||
RofiPadding pi = (RofiPadding){d, d, d, d};
|
||||
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
|
||||
ck_assert_double_eq_tol(p.left.base.distance, 1.3, REAL_COMPARE_DELTA);
|
||||
ck_assert_int_eq(p.left.base.type, ROFI_PU_CH);
|
||||
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
|
||||
|
||||
p = rofi_theme_get_padding(&wid, "dash", pi);
|
||||
ck_assert_double_eq_tol(p.left.base.distance, 1.5, REAL_COMPARE_DELTA);
|
||||
ck_assert_int_eq(p.left.base.type, ROFI_PU_CH);
|
||||
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_properties_distance_px) {
|
||||
widget wid;
|
||||
wid.name = "blaat";
|
||||
|
@ -321,6 +356,42 @@ START_TEST(test_properties_distance_percent_linestyle) {
|
|||
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_properties_distance_mm) {
|
||||
widget wid;
|
||||
wid.name = "blaat";
|
||||
wid.state = NULL;
|
||||
rofi_theme_parse_string("* { test: 10mm;}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
RofiDistance d = (RofiDistance){
|
||||
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
|
||||
RofiPadding pi = (RofiPadding){d, d, d, d};
|
||||
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
|
||||
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
|
||||
ck_assert_int_eq(p.left.base.type, ROFI_PU_MM);
|
||||
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_properties_distance_mm_linestyle) {
|
||||
widget wid;
|
||||
wid.name = "blaat";
|
||||
wid.state = NULL;
|
||||
rofi_theme_parse_string("* { sol: 10mm solid; dash: 10mm dash;}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
RofiDistance d = (RofiDistance){
|
||||
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
|
||||
RofiPadding pi = (RofiPadding){d, d, d, d};
|
||||
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
|
||||
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
|
||||
ck_assert_int_eq(p.left.base.type, ROFI_PU_MM);
|
||||
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
|
||||
p = rofi_theme_get_padding(&wid, "dash", pi);
|
||||
ck_assert_double_eq_tol(p.left.base.distance, 10, REAL_COMPARE_DELTA);
|
||||
ck_assert_int_eq(p.left.base.type, ROFI_PU_MM);
|
||||
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_properties_position) {
|
||||
widget wid;
|
||||
wid.name = "blaat";
|
||||
|
@ -1276,6 +1347,139 @@ START_TEST(test_prepare_array) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_prepare_math_floor) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 1024 floor 30 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 1020);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_ceil) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 1024 ceil 30 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 1050);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_round) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 1036 round 30 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 1050);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_add) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 1036 + 30 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 1066);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_subtract) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 1036 - 30 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 1006);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_multiply) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 256*4 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 1024);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_prepare_math_min) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 256 min 4 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 4);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_prepare_math_max) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 256 max 4 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 256);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_default) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("@import \"default\"");
|
||||
|
||||
ck_assert_ptr_null(error_msg);
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_prepare_path) {
|
||||
char *current_dir = g_get_current_dir();
|
||||
ck_assert_ptr_nonnull(current_dir);
|
||||
|
@ -1348,10 +1552,15 @@ static Suite *theme_parser_suite(void) {
|
|||
tcase_add_checked_fixture(tc_prop_distance, theme_parser_setup,
|
||||
theme_parser_teardown);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_em);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_ch);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_px);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_percent);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_em_linestyle);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_ch_linestyle);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_px_linestyle);
|
||||
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_mm);
|
||||
tcase_add_test(tc_prop_distance, test_properties_distance_mm_linestyle);
|
||||
tcase_add_test(tc_prop_distance,
|
||||
test_properties_distance_percent_linestyle);
|
||||
suite_add_tcase(s, tc_prop_distance);
|
||||
|
@ -1487,6 +1696,23 @@ static Suite *theme_parser_suite(void) {
|
|||
tcase_add_test(tc_prepare_array, test_prepare_array);
|
||||
suite_add_tcase(s, tc_prepare_array);
|
||||
}
|
||||
{
|
||||
TCase *tc_prepare_default = tcase_create("default");
|
||||
tcase_add_test(tc_prepare_default, test_prepare_default);
|
||||
suite_add_tcase(s, tc_prepare_default);
|
||||
}
|
||||
{
|
||||
TCase *tc_prepare_math = tcase_create("math");
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_add);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_subtract);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_multiply);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_floor);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_ceil);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_round);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_min);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_max);
|
||||
suite_add_tcase(s, tc_prepare_math);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue