mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Fix? tests
This commit is contained in:
parent
7d16d1a552
commit
d20587da54
6 changed files with 76 additions and 47 deletions
12
Makefile.am
12
Makefile.am
|
@ -96,7 +96,8 @@ rofi_CFLAGS=\
|
||||||
-I$(top_srcdir)/config/\
|
-I$(top_srcdir)/config/\
|
||||||
-I$(top_builddir)/\
|
-I$(top_builddir)/\
|
||||||
-Werror=missing-prototypes\
|
-Werror=missing-prototypes\
|
||||||
-DSYSCONFDIR=\"$(sysconfdir)\"
|
-DSYSCONFDIR=\"$(sysconfdir)\"\
|
||||||
|
-DTHEME_CONVERTER
|
||||||
|
|
||||||
rofi_LDADD=\
|
rofi_LDADD=\
|
||||||
$(glib_LIBS)\
|
$(glib_LIBS)\
|
||||||
|
@ -268,6 +269,13 @@ widget_test_LDADD=$(textbox_test_LDADD)
|
||||||
widget_test_CFLAGS=$(textbox_test_CFLAGS)
|
widget_test_CFLAGS=$(textbox_test_CFLAGS)
|
||||||
widget_test_SOURCES=\
|
widget_test_SOURCES=\
|
||||||
source/widgets/widget.c\
|
source/widgets/widget.c\
|
||||||
|
source/widgets/textbox.c\
|
||||||
|
source/theme.c\
|
||||||
|
source/helper.c\
|
||||||
|
source/x11-helper.c\
|
||||||
|
config/config.c\
|
||||||
|
lexer/theme-parser.y\
|
||||||
|
lexer/theme-lexer.l\
|
||||||
test/widget-test.c
|
test/widget-test.c
|
||||||
|
|
||||||
box_test_LDADD=$(textbox_test_LDADD)
|
box_test_LDADD=$(textbox_test_LDADD)
|
||||||
|
@ -298,6 +306,8 @@ textbox_test_SOURCES=\
|
||||||
lexer/theme-parser.y\
|
lexer/theme-parser.y\
|
||||||
lexer/theme-lexer.l\
|
lexer/theme-lexer.l\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/helper.c\
|
||||||
|
source/x11-helper.c\
|
||||||
config/config.c\
|
config/config.c\
|
||||||
include/keyb.h\
|
include/keyb.h\
|
||||||
include/rofi.h\
|
include/rofi.h\
|
||||||
|
|
|
@ -204,19 +204,6 @@ void rofi_theme_widget_add_properties ( Widget *widget, GHashTable *table )
|
||||||
* Public API
|
* Public API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void rofi_theme_parse_file ( const char *file )
|
|
||||||
{
|
|
||||||
char *filename = rofi_expand_path ( file );
|
|
||||||
yyin = fopen ( filename, "rb");
|
|
||||||
if ( yyin == NULL ){
|
|
||||||
fprintf(stderr, "Failed to open file: %s: '%s'\n", filename, strerror ( errno ) );
|
|
||||||
g_free(filename);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while ( yyparse() );
|
|
||||||
yylex_destroy();
|
|
||||||
g_free(filename);
|
|
||||||
}
|
|
||||||
static Widget *rofi_theme_find_single ( Widget *widget, const char *name)
|
static Widget *rofi_theme_find_single ( Widget *widget, const char *name)
|
||||||
{
|
{
|
||||||
for ( unsigned int j = 0; j < widget->num_widgets;j++){
|
for ( unsigned int j = 0; j < widget->num_widgets;j++){
|
||||||
|
@ -366,7 +353,6 @@ Padding rofi_theme_get_padding ( const char *wclass, const char *name, const ch
|
||||||
}
|
}
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
int distance_get_pixel ( Distance d )
|
int distance_get_pixel ( Distance d )
|
||||||
{
|
{
|
||||||
if ( d.type == PW_EM ){
|
if ( d.type == PW_EM ){
|
||||||
|
@ -375,6 +361,8 @@ int distance_get_pixel ( Distance d )
|
||||||
return d.distance;
|
return d.distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef THEME_CONVERTER
|
||||||
|
|
||||||
static Property* rofi_theme_convert_get_color ( const char *color, const char *name )
|
static Property* rofi_theme_convert_get_color ( const char *color, const char *name )
|
||||||
{
|
{
|
||||||
Color c = color_get ( color );
|
Color c = color_get ( color );
|
||||||
|
@ -540,3 +528,17 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void rofi_theme_parse_file ( const char *file )
|
||||||
|
{
|
||||||
|
char *filename = rofi_expand_path ( file );
|
||||||
|
yyin = fopen ( filename, "rb");
|
||||||
|
if ( yyin == NULL ){
|
||||||
|
fprintf(stderr, "Failed to open file: %s: '%s'\n", filename, strerror ( errno ) );
|
||||||
|
g_free(filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while ( yyparse() );
|
||||||
|
yylex_destroy();
|
||||||
|
g_free(filename);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -22,6 +22,12 @@ unsigned int test =0;
|
||||||
abort ( ); \
|
abort ( ); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
int textbox_get_estimated_char_height ( void );
|
||||||
|
int textbox_get_estimated_char_height ( void )
|
||||||
|
{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean test_widget_clicked ( G_GNUC_UNUSED widget *wid, G_GNUC_UNUSED xcb_button_press_event_t* xce, G_GNUC_UNUSED void *data )
|
static gboolean test_widget_clicked ( G_GNUC_UNUSED widget *wid, G_GNUC_UNUSED xcb_button_press_event_t* xce, G_GNUC_UNUSED void *data )
|
||||||
{
|
{
|
||||||
|
@ -31,8 +37,9 @@ static gboolean test_widget_clicked ( G_GNUC_UNUSED widget *wid, G_GNUC_UNUSED x
|
||||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
box *b = box_create ( "box", BOX_HORIZONTAL, 0, 0, 100, 20 );
|
box *b = box_create ( "box", BOX_HORIZONTAL );
|
||||||
//box_set_padding ( b, 5 );
|
//box_set_padding ( b, 5 );
|
||||||
|
widget_resize ( WIDGET (b), 100, 20);
|
||||||
|
|
||||||
widget *wid1 = g_malloc0(sizeof(widget));
|
widget *wid1 = g_malloc0(sizeof(widget));
|
||||||
box_add ( b , WIDGET( wid1 ), TRUE, FALSE );
|
box_add ( b , WIDGET( wid1 ), TRUE, FALSE );
|
||||||
|
@ -48,36 +55,36 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
widget_enable ( WIDGET ( wid2 ) );
|
widget_enable ( WIDGET ( wid2 ) );
|
||||||
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
|
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
|
||||||
TASSERTE ( wid1->h, 20);
|
TASSERTE ( wid1->h, 20);
|
||||||
TASSERTE ( wid1->w, 47);
|
TASSERTE ( wid1->w, 49);
|
||||||
TASSERTE ( wid2->h, 20);
|
TASSERTE ( wid2->h, 20);
|
||||||
TASSERTE ( wid2->w, 48);
|
TASSERTE ( wid2->w, 49);
|
||||||
|
|
||||||
widget *wid3 = g_malloc0(sizeof(widget));
|
widget *wid3 = g_malloc0(sizeof(widget));
|
||||||
widget_enable ( WIDGET ( wid3 ) );
|
widget_enable ( WIDGET ( wid3 ) );
|
||||||
box_add ( b , WIDGET( wid3 ), FALSE, FALSE );
|
box_add ( b , WIDGET( wid3 ), FALSE, FALSE );
|
||||||
TASSERTE ( wid1->h, 20);
|
TASSERTE ( wid1->h, 20);
|
||||||
TASSERTE ( wid1->w, 45);
|
TASSERTE ( wid1->w, 48);
|
||||||
TASSERTE ( wid2->h, 20);
|
TASSERTE ( wid2->h, 20);
|
||||||
TASSERTE ( wid2->w, 45);
|
TASSERTE ( wid2->w, 48);
|
||||||
|
|
||||||
widget_resize ( WIDGET (wid3) , 20, 10 );
|
widget_resize ( WIDGET (wid3) , 20, 10 );
|
||||||
// TODO should this happen automagically?
|
// TODO should this happen automagically?
|
||||||
widget_update ( WIDGET ( b ) ) ;
|
widget_update ( WIDGET ( b ) ) ;
|
||||||
TASSERTE ( wid1->h, 20);
|
TASSERTE ( wid1->h, 20);
|
||||||
TASSERTE ( wid1->w, 35);
|
TASSERTE ( wid1->w, 38);
|
||||||
TASSERTE ( wid2->h, 20);
|
TASSERTE ( wid2->h, 20);
|
||||||
TASSERTE ( wid2->w, 35);
|
TASSERTE ( wid2->w, 38);
|
||||||
TASSERTE ( wid3->h, 20);
|
TASSERTE ( wid3->h, 20);
|
||||||
TASSERTE ( wid3->w, 20);
|
TASSERTE ( wid3->w, 20);
|
||||||
|
|
||||||
widget_resize ( WIDGET (b ), 200, 20 );
|
widget_resize ( WIDGET (b ), 200, 20 );
|
||||||
TASSERTE ( wid1->h, 20);
|
TASSERTE ( wid1->h, 20);
|
||||||
TASSERTE ( wid1->w, 85);
|
TASSERTE ( wid1->w, 88);
|
||||||
TASSERTE ( wid2->h, 20);
|
TASSERTE ( wid2->h, 20);
|
||||||
TASSERTE ( wid2->w, 85);
|
TASSERTE ( wid2->w, 88);
|
||||||
TASSERTE ( wid3->h, 20);
|
TASSERTE ( wid3->h, 20);
|
||||||
TASSERTE ( wid3->w, 20);
|
TASSERTE ( wid3->w, 20);
|
||||||
TASSERTE ( box_get_fixed_pixels ( b ) , 30 );
|
TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
|
||||||
|
|
||||||
widget *wid4 = g_malloc0(sizeof(widget));
|
widget *wid4 = g_malloc0(sizeof(widget));
|
||||||
widget_enable ( WIDGET ( wid4 ) );
|
widget_enable ( WIDGET ( wid4 ) );
|
||||||
|
@ -88,11 +95,12 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
widget_enable ( WIDGET ( wid5 ) );
|
widget_enable ( WIDGET ( wid5 ) );
|
||||||
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
||||||
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
|
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
|
||||||
TASSERTE ( wid5->x, 128);
|
TASSERTE ( wid5->x, 127);
|
||||||
widget_free ( WIDGET ( b ) );
|
widget_free ( WIDGET ( b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
box *b = box_create ( "box", BOX_VERTICAL, 0, 0, 20, 100 );
|
box *b = box_create ( "box", BOX_VERTICAL );
|
||||||
|
widget_resize ( WIDGET (b), 20, 100);
|
||||||
//box_set_padding ( b, 5 );
|
//box_set_padding ( b, 5 );
|
||||||
|
|
||||||
widget *wid1 = g_malloc0(sizeof(widget));
|
widget *wid1 = g_malloc0(sizeof(widget));
|
||||||
|
@ -109,36 +117,36 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
widget_enable ( WIDGET ( wid2 ) );
|
widget_enable ( WIDGET ( wid2 ) );
|
||||||
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
|
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
|
||||||
TASSERTE ( wid1->w, 20);
|
TASSERTE ( wid1->w, 20);
|
||||||
TASSERTE ( wid1->h, 47);
|
TASSERTE ( wid1->h, 49);
|
||||||
TASSERTE ( wid2->w, 20);
|
TASSERTE ( wid2->w, 20);
|
||||||
TASSERTE ( wid2->h, 48);
|
TASSERTE ( wid2->h, 49);
|
||||||
|
|
||||||
widget *wid3 = g_malloc0(sizeof(widget));
|
widget *wid3 = g_malloc0(sizeof(widget));
|
||||||
widget_enable ( WIDGET ( wid3 ) );
|
widget_enable ( WIDGET ( wid3 ) );
|
||||||
box_add ( b , WIDGET( wid3 ), FALSE, FALSE );
|
box_add ( b , WIDGET( wid3 ), FALSE, FALSE );
|
||||||
TASSERTE ( wid1->w, 20);
|
TASSERTE ( wid1->w, 20);
|
||||||
TASSERTE ( wid1->h, 45);
|
TASSERTE ( wid1->h, 48);
|
||||||
TASSERTE ( wid2->w, 20);
|
TASSERTE ( wid2->w, 20);
|
||||||
TASSERTE ( wid2->h, 45);
|
TASSERTE ( wid2->h, 48);
|
||||||
|
|
||||||
widget_resize ( WIDGET (wid3) , 10, 20 );
|
widget_resize ( WIDGET (wid3) , 10, 20 );
|
||||||
// TODO should this happen automagically?
|
// TODO should this happen automagically?
|
||||||
widget_update ( WIDGET ( b ) ) ;
|
widget_update ( WIDGET ( b ) ) ;
|
||||||
TASSERTE ( wid1->w, 20);
|
TASSERTE ( wid1->w, 20);
|
||||||
TASSERTE ( wid1->h, 35);
|
TASSERTE ( wid1->h, 38);
|
||||||
TASSERTE ( wid2->w, 20);
|
TASSERTE ( wid2->w, 20);
|
||||||
TASSERTE ( wid2->h, 35);
|
TASSERTE ( wid2->h, 38);
|
||||||
TASSERTE ( wid3->w, 20);
|
TASSERTE ( wid3->w, 20);
|
||||||
TASSERTE ( wid3->h, 20);
|
TASSERTE ( wid3->h, 20);
|
||||||
|
|
||||||
widget_resize ( WIDGET (b ), 20, 200 );
|
widget_resize ( WIDGET (b ), 20, 200 );
|
||||||
TASSERTE ( wid1->w, 20);
|
TASSERTE ( wid1->w, 20);
|
||||||
TASSERTE ( wid1->h, 85);
|
TASSERTE ( wid1->h, 88);
|
||||||
TASSERTE ( wid2->w, 20);
|
TASSERTE ( wid2->w, 20);
|
||||||
TASSERTE ( wid2->h, 85);
|
TASSERTE ( wid2->h, 88);
|
||||||
TASSERTE ( wid3->w, 20);
|
TASSERTE ( wid3->w, 20);
|
||||||
TASSERTE ( wid3->h, 20);
|
TASSERTE ( wid3->h, 20);
|
||||||
TASSERTE ( box_get_fixed_pixels ( b ) , 30 );
|
TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
|
||||||
widget *wid4 = g_malloc0(sizeof(widget));
|
widget *wid4 = g_malloc0(sizeof(widget));
|
||||||
widget_enable ( WIDGET ( wid4 ) );
|
widget_enable ( WIDGET ( wid4 ) );
|
||||||
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
||||||
|
@ -148,11 +156,12 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
widget_enable ( WIDGET ( wid5 ) );
|
widget_enable ( WIDGET ( wid5 ) );
|
||||||
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
||||||
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
|
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
|
||||||
TASSERTE ( wid5->y, 128);
|
TASSERTE ( wid5->y, 127);
|
||||||
widget_free ( WIDGET ( b ) );
|
widget_free ( WIDGET ( b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
box *b = box_create ( "box", BOX_VERTICAL, 0, 0, 20, 100 );
|
box *b = box_create ( "box", BOX_VERTICAL );
|
||||||
|
widget_resize ( WIDGET (b), 20, 100);
|
||||||
//box_set_padding ( b, 5 );
|
//box_set_padding ( b, 5 );
|
||||||
widget *wid1 = g_malloc0(sizeof(widget));
|
widget *wid1 = g_malloc0(sizeof(widget));
|
||||||
widget_enable(wid1);
|
widget_enable(wid1);
|
||||||
|
@ -169,7 +178,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
|
|
||||||
xce.event_y = 50;
|
xce.event_y = 50;
|
||||||
TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0);
|
TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0);
|
||||||
xce.event_y = 45;
|
xce.event_y = 48;
|
||||||
TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1);
|
TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1);
|
||||||
widget_disable ( wid2 );
|
widget_disable ( wid2 );
|
||||||
xce.event_y = 60;
|
xce.event_y = 60;
|
||||||
|
|
|
@ -23,6 +23,11 @@ unsigned int test =0;
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int textbox_get_estimated_char_height ( void );
|
||||||
|
int textbox_get_estimated_char_height ( void )
|
||||||
|
{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
void color_separator ( G_GNUC_UNUSED void *d )
|
void color_separator ( G_GNUC_UNUSED void *d )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,7 +35,8 @@ void color_separator ( G_GNUC_UNUSED void *d )
|
||||||
|
|
||||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
{
|
{
|
||||||
scrollbar * sb = scrollbar_create ( 0, 0, 10, 100);
|
scrollbar * sb = scrollbar_create ( "scrollbar", 3);
|
||||||
|
widget_resize ( WIDGET (sb), 10, 100);
|
||||||
|
|
||||||
scrollbar_set_handle ( NULL, 10213);
|
scrollbar_set_handle ( NULL, 10213);
|
||||||
scrollbar_set_max_value ( NULL, 10 );
|
scrollbar_set_max_value ( NULL, 10 );
|
||||||
|
|
|
@ -24,11 +24,6 @@ unsigned int normal_window_mode = 0;
|
||||||
void rofi_view_queue_redraw ()
|
void rofi_view_queue_redraw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Color color_get ( G_GNUC_UNUSED const char *name )
|
|
||||||
{
|
|
||||||
Color retv = { 1.0, 1.0, 1.0, 1.0 };
|
|
||||||
return retv;
|
|
||||||
}
|
|
||||||
|
|
||||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||||
{
|
{
|
||||||
|
@ -53,8 +48,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
PangoContext *p = pango_cairo_create_context ( draw );
|
PangoContext *p = pango_cairo_create_context ( draw );
|
||||||
textbox_set_pango_context ( p );
|
textbox_set_pango_context ( p );
|
||||||
|
|
||||||
textbox *box = textbox_create ( "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, 0, 0, -1, -1,
|
textbox *box = textbox_create ( "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "test" );
|
||||||
NORMAL, "test" );
|
|
||||||
TASSERT ( box != NULL );
|
TASSERT ( box != NULL );
|
||||||
|
|
||||||
textbox_keybinding ( box, MOVE_END );
|
textbox_keybinding ( box, MOVE_END );
|
||||||
|
|
|
@ -12,7 +12,15 @@ unsigned int test =0;
|
||||||
assert ( a ); \
|
assert ( a ); \
|
||||||
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
||||||
}
|
}
|
||||||
|
void rofi_view_queue_redraw ( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||||
|
{
|
||||||
|
fputs ( msg, stderr );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue