summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-01-01 16:32:01 +0100
committerDave Davenport <qball@gmpclient.org>2017-01-01 16:32:01 +0100
commitd20587da543dfa0f67474a5070a5eb3620deb2e4 (patch)
tree48f0d0ddeb9fa268ca9c05ef6e66d2e29e82731f /test
parent7d16d1a55269e58e3d9068685524a220cec360e6 (diff)
Fix? tests
Diffstat (limited to 'test')
-rw-r--r--test/box-test.c57
-rw-r--r--test/scrollbar-test.c8
-rw-r--r--test/textbox-test.c8
-rw-r--r--test/widget-test.c8
4 files changed, 49 insertions, 32 deletions
diff --git a/test/box-test.c b/test/box-test.c
index ce4d0b31..54c0f001 100644
--- a/test/box-test.c
+++ b/test/box-test.c
@@ -22,6 +22,12 @@ unsigned int test =0;
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 )
{
@@ -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 )
{
{
- box *b = box_create ( "box", BOX_HORIZONTAL, 0, 0, 100, 20 );
+ box *b = box_create ( "box", BOX_HORIZONTAL );
//box_set_padding ( b, 5 );
+ widget_resize ( WIDGET (b), 100, 20);
widget *wid1 = g_malloc0(sizeof(widget));
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 ) );
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
TASSERTE ( wid1->h, 20);
- TASSERTE ( wid1->w, 47);
+ TASSERTE ( wid1->w, 49);
TASSERTE ( wid2->h, 20);
- TASSERTE ( wid2->w, 48);
+ TASSERTE ( wid2->w, 49);
widget *wid3 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid3 ) );
box_add ( b , WIDGET( wid3 ), FALSE, FALSE );
TASSERTE ( wid1->h, 20);
- TASSERTE ( wid1->w, 45);
+ TASSERTE ( wid1->w, 48);
TASSERTE ( wid2->h, 20);
- TASSERTE ( wid2->w, 45);
+ TASSERTE ( wid2->w, 48);
widget_resize ( WIDGET (wid3) , 20, 10 );
// TODO should this happen automagically?
widget_update ( WIDGET ( b ) ) ;
TASSERTE ( wid1->h, 20);
- TASSERTE ( wid1->w, 35);
+ TASSERTE ( wid1->w, 38);
TASSERTE ( wid2->h, 20);
- TASSERTE ( wid2->w, 35);
+ TASSERTE ( wid2->w, 38);
TASSERTE ( wid3->h, 20);
TASSERTE ( wid3->w, 20);
widget_resize ( WIDGET (b ), 200, 20 );
TASSERTE ( wid1->h, 20);
- TASSERTE ( wid1->w, 85);
+ TASSERTE ( wid1->w, 88);
TASSERTE ( wid2->h, 20);
- TASSERTE ( wid2->w, 85);
+ TASSERTE ( wid2->w, 88);
TASSERTE ( wid3->h, 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_enable ( WIDGET ( wid4 ) );
@@ -88,11 +95,12 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
- TASSERTE ( wid5->x, 128);
+ TASSERTE ( wid5->x, 127);
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 );
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 ) );
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
TASSERTE ( wid1->w, 20);
- TASSERTE ( wid1->h, 47);
+ TASSERTE ( wid1->h, 49);
TASSERTE ( wid2->w, 20);
- TASSERTE ( wid2->h, 48);
+ TASSERTE ( wid2->h, 49);
widget *wid3 = g_malloc0(sizeof(widget));
widget_enable ( WIDGET ( wid3 ) );
box_add ( b , WIDGET( wid3 ), FALSE, FALSE );
TASSERTE ( wid1->w, 20);
- TASSERTE ( wid1->h, 45);
+ TASSERTE ( wid1->h, 48);
TASSERTE ( wid2->w, 20);
- TASSERTE ( wid2->h, 45);
+ TASSERTE ( wid2->h, 48);
widget_resize ( WIDGET (wid3) , 10, 20 );
// TODO should this happen automagically?
widget_update ( WIDGET ( b ) ) ;
TASSERTE ( wid1->w, 20);
- TASSERTE ( wid1->h, 35);
+ TASSERTE ( wid1->h, 38);
TASSERTE ( wid2->w, 20);
- TASSERTE ( wid2->h, 35);
+ TASSERTE ( wid2->h, 38);
TASSERTE ( wid3->w, 20);
TASSERTE ( wid3->h, 20);
widget_resize ( WIDGET (b ), 20, 200 );
TASSERTE ( wid1->w, 20);
- TASSERTE ( wid1->h, 85);
+ TASSERTE ( wid1->h, 88);
TASSERTE ( wid2->w, 20);
- TASSERTE ( wid2->h, 85);
+ TASSERTE ( wid2->h, 88);
TASSERTE ( wid3->w, 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_enable ( WIDGET ( wid4 ) );
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_resize ( WIDGET ( wid5 ), 20, 20 );
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
- TASSERTE ( wid5->y, 128);
+ TASSERTE ( wid5->y, 127);
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 );
widget *wid1 = g_malloc0(sizeof(widget));
widget_enable(wid1);
@@ -169,7 +178,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
xce.event_y = 50;
TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0);
- xce.event_y = 45;
+ xce.event_y = 48;
TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1);
widget_disable ( wid2 );
xce.event_y = 60;
diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c
index b0cdc95d..3e658b48 100644
--- a/test/scrollbar-test.c
+++ b/test/scrollbar-test.c
@@ -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 )
{
@@ -30,7 +35,8 @@ void color_separator ( G_GNUC_UNUSED void *d )
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_max_value ( NULL, 10 );
diff --git a/test/textbox-test.c b/test/textbox-test.c
index 3196ab0e..6ed31c3c 100644
--- a/test/textbox-test.c
+++ b/test/textbox-test.c
@@ -24,11 +24,6 @@ unsigned int normal_window_mode = 0;
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 )
{
@@ -53,8 +48,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
PangoContext *p = pango_cairo_create_context ( draw );
textbox_set_pango_context ( p );
- textbox *box = textbox_create ( "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, 0, 0, -1, -1,
- NORMAL, "test" );
+ textbox *box = textbox_create ( "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "test" );
TASSERT ( box != NULL );
textbox_keybinding ( box, MOVE_END );
diff --git a/test/widget-test.c b/test/widget-test.c
index 109197cb..6d11d7da 100644
--- a/test/widget-test.c
+++ b/test/widget-test.c
@@ -12,7 +12,15 @@ unsigned int test =0;
assert ( 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 )
{