[Test] Fix compiler warning, theme test (bug in lexer) and more.

This commit is contained in:
Dave Davenport 2020-04-26 11:43:14 +02:00
parent 09704eb49c
commit 9a3d4b1d2e
5 changed files with 54 additions and 65 deletions

View file

@ -96,7 +96,7 @@ Settings config = {
/** Sort the displayed list */
.sort = FALSE,
/** Use levenshtein sorting when matching */
.sorting_method = SORT_NORMAL,
.sorting_method = "normal",
/** Case sensitivity of the search */
.case_sensitive = FALSE,
/** Cycle through in the element list */

View file

@ -185,7 +185,6 @@ ENV $\{[[:alnum:]]*\}
MODIFIER_ADD \+
MODIFIER_SUBTRACT -
MODIFIER_DIVIDE \/
MODIFIER_MULTIPLY \*
/* Position */
@ -459,7 +458,6 @@ if ( queue == NULL ){
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{MODIFIER_ADD} { return T_MODIFIER_ADD; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{MODIFIER_SUBTRACT} { return T_MODIFIER_SUBTRACT; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{MODIFIER_MULTIPLY} { return T_MODIFIER_MULTIPLY; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{MODIFIER_DIVIDE} { return T_MODIFIER_DIVIDE; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CALC} { return T_CALC; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ENV} {

View file

@ -213,7 +213,6 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token T_MODIFIER_ADD "Add ('+')"
%token T_MODIFIER_SUBTRACT "Subtract ('-')"
%token T_MODIFIER_DIVIDE "Divide ('/')"
%token T_MODIFIER_MULTIPLY "Multiply ('*')"
%token T_CALC "calc"
@ -649,7 +648,7 @@ t_property_distance_unit
| T_PARENT_LEFT t_property_distance_unit_math2 T_PARENT_RIGHT {
$$ = g_slice_new0(RofiDistanceUnit);
$$->distance = 0;
$$->type = ROFI_DISTANCE_MODIFIER_NONE;
$$->type = ROFI_PU_PX;
$$->left = $2;
$$->right = 0;
$$->modtype = ROFI_DISTANCE_MODIFIER_GROUP;
@ -666,7 +665,7 @@ t_property_distance_unit_math
$$->right = $3;
$$->modtype = ROFI_DISTANCE_MODIFIER_MULTIPLY;
}
| t_property_distance_unit_math T_MODIFIER_DIVIDE t_property_distance_unit {
| t_property_distance_unit_math T_FORWARD_SLASH t_property_distance_unit {
$$ = g_slice_new0(RofiDistanceUnit);
$$->left = $1;
$$->right = $3;
@ -723,7 +722,7 @@ t_property_distance
}
| T_CALC T_PARENT_LEFT t_property_distance_unit_math2 T_PARENT_RIGHT t_property_line_style {
$$.base.distance = 0;
$$.base.type = ROFI_DISTANCE_MODIFIER_NONE;
$$.base.type = ROFI_PU_PX;
$$.base.left = $3;
$$.base.right = NULL;
$$.base.modtype = ROFI_DISTANCE_MODIFIER_GROUP;

View file

@ -45,13 +45,10 @@
/**
* Orientation of the listview
*/
typedef enum
{
/** Vertical (classical) list */
LISTVIEW = ROFI_ORIENTATION_VERTICAL,
#define LISTVIEW ROFI_ORIENTATION_VERTICAL
/** Horizontal list. (barview) */
BARVIEW = ROFI_ORIENTATION_HORIZONTAL,
} ViewType;
#define BARVIEW ROFI_ORIENTATION_HORIZONTAL
/**
* The moving direction of the selection, this (in barview) affects the scrolling.
@ -74,7 +71,7 @@ struct _listview
{
widget widget;
ViewType type;
RofiOrientation type;
// RChanged
// Text needs to be repainted.
@ -555,16 +552,10 @@ static void listview_resize ( widget *wid, short w, short h )
lv->max_rows = ( spacing_vert + height ) / ( lv->element_height + spacing_vert );
lv->max_elements = lv->max_rows * lv->menu_columns;
if ( /*lv->scrollbar->widget.index ==*/ 0 ) {
widget_move ( WIDGET ( lv->scrollbar ),
widget_padding_get_left ( WIDGET ( lv ) ),
widget_padding_get_top ( WIDGET ( lv ) ) );
}
else {
widget_move ( WIDGET ( lv->scrollbar ),
lv->widget.w - widget_padding_get_right ( WIDGET ( lv ) ) - widget_get_width ( WIDGET ( lv->scrollbar ) ),
widget_padding_get_top ( WIDGET ( lv ) ) );
}
widget_move ( WIDGET ( lv->scrollbar ),
lv->widget.w - widget_padding_get_right ( WIDGET ( lv ) ) - widget_get_width ( WIDGET ( lv->scrollbar ) ),
widget_padding_get_top ( WIDGET ( lv ) ) );
widget_resize ( WIDGET ( lv->scrollbar ), widget_get_width ( WIDGET ( lv->scrollbar ) ), height );
if ( lv->type == BARVIEW ) {

View file

@ -242,8 +242,8 @@ START_TEST ( test_properties_distance_em)
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.distance , 10 );
ck_assert_int_eq( p.left.type , ROFI_PU_EM );
ck_assert_int_eq ( p.left.base.distance , 10 );
ck_assert_int_eq( p.left.base.type , ROFI_PU_EM );
ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
}
@ -258,13 +258,13 @@ START_TEST ( test_properties_distance_em_linestyle)
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.distance , 1.3 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_EM );
ck_assert_double_eq_tol ( p.left.base.distance , 1.3 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_EM );
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.distance , 1.5 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_EM );
ck_assert_double_eq_tol ( p.left.base.distance , 1.5 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_EM );
ck_assert_int_eq( p.left.style, ROFI_HL_DASH);
}
END_TEST
@ -278,8 +278,8 @@ START_TEST ( test_properties_distance_px)
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.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.left.base.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_PX );
ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
}
END_TEST
@ -293,12 +293,12 @@ START_TEST ( test_properties_distance_px_linestyle)
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.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.left.base.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_PX );
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.distance , 14.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.left.base.distance , 14.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_PX );
ck_assert_int_eq( p.left.style, ROFI_HL_DASH);
}
END_TEST
@ -312,8 +312,8 @@ START_TEST ( test_properties_distance_percent)
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.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_PERCENT);
ck_assert_double_eq_tol ( p.left.base.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_PERCENT);
ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
}
END_TEST
@ -327,12 +327,12 @@ START_TEST ( test_properties_distance_percent_linestyle)
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.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_PERCENT);
ck_assert_double_eq_tol ( p.left.base.distance , 10.0 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_PERCENT);
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.distance , 10 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.type , ROFI_PU_PERCENT);
ck_assert_double_eq_tol ( p.left.base.distance , 10 , REAL_COMPARE_DELTA );
ck_assert_int_eq( p.left.base.type , ROFI_PU_PERCENT);
ck_assert_int_eq( p.left.style, ROFI_HL_DASH);
}
END_TEST
@ -642,6 +642,7 @@ START_TEST ( test_properties_color_rgba )
wid.state = NULL;
rofi_theme_parse_string ( "* { red: rgba(255,0,0,0.3); green: rgba(0,255,0,0.2); blue: rgba(0 0 255 /0.7); }");
ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE );
ck_assert_ptr_nonnull ( twid );
Property *p = rofi_theme_find_property ( twid, P_COLOR, "red", FALSE );
ck_assert_ptr_nonnull ( p );
ck_assert_double_eq_tol ( p->value.color.alpha , 0.3 , REAL_COMPARE_DELTA );
@ -981,14 +982,14 @@ START_TEST ( test_properties_padding_2 )
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_double_eq_tol ( p.left.distance , 20, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.left.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.right.distance , 20, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.right.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.top.distance , 10, REAL_COMPARE_DELTA);
ck_assert_int_eq ( p.top.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.bottom.distance , 10, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.bottom.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.left.base.distance , 20, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.left.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.right.base.distance , 20, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.right.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.top.base.distance , 10, REAL_COMPARE_DELTA);
ck_assert_int_eq ( p.top.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.bottom.base.distance , 10, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.bottom.base.type , ROFI_PU_PX );
}
END_TEST
@ -1001,14 +1002,14 @@ START_TEST ( test_properties_padding_3 )
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_double_eq_tol ( p.left.distance , 30, REAL_COMPARE_DELTA);
ck_assert_int_eq ( p.left.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.right.distance , 30, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.right.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.top.distance , 10, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.top.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.bottom.distance , 20, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.bottom.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.left.base.distance , 30, REAL_COMPARE_DELTA);
ck_assert_int_eq ( p.left.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.right.base.distance , 30, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.right.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.top.base.distance , 10, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.top.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.bottom.base.distance , 20, REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.bottom.base.type , ROFI_PU_PX );
}
END_TEST
@ -1021,14 +1022,14 @@ START_TEST ( test_properties_padding_4 )
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_double_eq_tol ( p.left.distance , 40 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.left.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.right.distance , 30 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.right.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.top.distance , 10 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.top.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.bottom.distance , 20 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.bottom.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.left.base.distance , 40 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.left.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.right.base.distance , 30 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.right.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.top.base.distance , 10 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.top.base.type , ROFI_PU_PX );
ck_assert_double_eq_tol ( p.bottom.base.distance , 20 , REAL_COMPARE_DELTA );
ck_assert_int_eq ( p.bottom.base.type , ROFI_PU_PX );
}
END_TEST