diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-10-25 18:26:18 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-10-25 18:26:18 +0200 |
commit | 8a186726f8fa8f2015c1faa9db0d34fe2eb13cfd (patch) | |
tree | 4ef16feb22e1f9886b6489a64a560576109f87b7 | |
parent | 2ee72b6c12e7dfc490837ecde5373343246bb84b (diff) |
Update box test with some click injections
-rw-r--r-- | test/box-test.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/test/box-test.c b/test/box-test.c index 909943dd..d45f468c 100644 --- a/test/box-test.c +++ b/test/box-test.c @@ -23,11 +23,16 @@ unsigned int test =0; } \ } +static gboolean test_widget_clicked ( G_GNUC_UNUSED widget *wid, G_GNUC_UNUSED xcb_button_press_event_t* xce, G_GNUC_UNUSED void *data ) +{ + return TRUE; +} + int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) { { - box *b = box_create ( BOX_HORIZONTAL, 0, 0, 100, 20 ); - box_set_padding ( b, 5 ); + box *b = box_create ( BOX_HORIZONTAL, 0, 0, 100, 20 ); + box_set_padding ( b, 5 ); widget *wid1 = g_malloc0(sizeof(widget)); box_add ( b , WIDGET( wid1 ), TRUE, FALSE ); @@ -35,7 +40,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) TASSERTE ( wid1->h, 0); TASSERTE ( wid1->w, 0 ); widget_enable ( WIDGET ( wid1 ) ); - widget_update ( WIDGET ( b ) ) ; + widget_update ( WIDGET ( b ) ) ; // Widget enabled. so width allocated. TASSERTE ( wid1->h, 20); TASSERTE ( wid1->w, 100 ); @@ -73,7 +78,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) TASSERTE ( wid3->h, 20); TASSERTE ( wid3->w, 20); TASSERTE ( box_get_fixed_pixels ( b ) , 30 ); - + widget *wid4 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid4 ) ); widget_resize ( WIDGET ( wid4 ), 20, 20 ); @@ -87,8 +92,8 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) widget_free ( WIDGET ( b ) ); } { - box *b = box_create ( BOX_VERTICAL, 0, 0, 20, 100 ); - box_set_padding ( b, 5 ); + box *b = box_create ( BOX_VERTICAL, 0, 0, 20, 100 ); + box_set_padding ( b, 5 ); widget *wid1 = g_malloc0(sizeof(widget)); box_add ( b , WIDGET( wid1 ), TRUE, FALSE ); @@ -96,7 +101,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) TASSERTE ( wid1->h, 0); TASSERTE ( wid1->w, 0 ); widget_enable ( WIDGET ( wid1 ) ); - widget_update ( WIDGET ( b ) ) ; + widget_update ( WIDGET ( b ) ) ; // Widget enabled. so width allocated. TASSERTE ( wid1->h, 100); TASSERTE ( wid1->w, 20 ); @@ -146,4 +151,32 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) TASSERTE ( wid5->y, 200-20-20-6); widget_free ( WIDGET ( b ) ); } + { + box *b = box_create ( BOX_VERTICAL, 0, 0, 20, 100 ); + box_set_padding ( b, 5 ); + widget *wid1 = g_malloc0(sizeof(widget)); + widget_enable(wid1); + wid1->clicked = test_widget_clicked; + box_add ( b , WIDGET( wid1 ), TRUE, FALSE ); + widget *wid2 = g_malloc0(sizeof(widget)); + widget_enable(wid2); + box_add ( b , WIDGET( wid2 ), TRUE, FALSE ); + + xcb_button_press_event_t xce; + xce.event_x = 10; + xce.event_y = 60; + TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0); + + xce.event_y = 50; + TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0); + xce.event_y = 45; + TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1); + widget_disable ( wid2 ); + xce.event_y = 60; + TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1); + widget_disable ( wid1 ); + widget_enable ( wid2 ); + TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0); + widget_free ( WIDGET ( b ) ); + } } |