mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Merge branch 'master' of github:DaveDavenport/rofi
This commit is contained in:
commit
8d39b0e035
2 changed files with 160 additions and 2 deletions
13
Makefile.am
13
Makefile.am
|
@ -151,7 +151,8 @@ check_PROGRAMS=\
|
|||
helper_pidfile\
|
||||
helper_tokenize\
|
||||
helper_config_cmdline_parser\
|
||||
widget_test
|
||||
widget_test\
|
||||
box_test
|
||||
|
||||
|
||||
history_test_CFLAGS=\
|
||||
|
@ -229,6 +230,13 @@ widget_test_CFLAGS=$(textbox_test_CFLAGS)
|
|||
widget_test_SOURCES=\
|
||||
source/widgets/widget.c\
|
||||
test/widget-test.c
|
||||
|
||||
box_test_LDADD=$(textbox_test_LDADD)
|
||||
box_test_CFLAGS=$(textbox_test_CFLAGS)
|
||||
box_test_SOURCES=\
|
||||
source/widgets/widget.c\
|
||||
source/widgets/box.c\
|
||||
test/box-test.c
|
||||
textbox_test_SOURCES=\
|
||||
source/widgets/widget.c\
|
||||
source/widgets/textbox.c\
|
||||
|
@ -314,7 +322,8 @@ TESTS=\
|
|||
helper_tokenize\
|
||||
helper_config_cmdline_parser\
|
||||
textbox_test\
|
||||
widget_test
|
||||
widget_test\
|
||||
box_test
|
||||
|
||||
.PHONY: test-x
|
||||
test-x: $(bin_PROGRAMS)
|
||||
|
|
149
test/box-test.c
Normal file
149
test/box-test.c
Normal file
|
@ -0,0 +1,149 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <widgets/box.h>
|
||||
#include <widgets/widget.h>
|
||||
#include <widgets/widget-internal.h>
|
||||
unsigned int test =0;
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
|
||||
#define TASSERTE( a, b ) { \
|
||||
if ( ( a ) == ( b ) ) { \
|
||||
printf ( "Test %i passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
||||
}else { \
|
||||
printf ( "Test %i failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
||||
abort ( ); \
|
||||
} \
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
widget *wid1 = g_malloc0(sizeof(widget));
|
||||
box_add ( b , WIDGET( wid1 ), TRUE, FALSE );
|
||||
// Widget not enabled. no width allocated.
|
||||
TASSERTE ( wid1->h, 0);
|
||||
TASSERTE ( wid1->w, 0 );
|
||||
widget_enable ( WIDGET ( wid1 ) );
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
// Widget enabled. so width allocated.
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 100 );
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
widget_enable ( WIDGET ( wid2 ) );
|
||||
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 47);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 48);
|
||||
|
||||
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 ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 45);
|
||||
|
||||
widget_resize ( WIDGET (wid3) , 20, 10 );
|
||||
// TODO should this happen automagically?
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 35);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 35);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
|
||||
widget_resize ( WIDGET (b ), 200, 20 );
|
||||
TASSERTE ( wid1->h, 20);
|
||||
TASSERTE ( wid1->w, 85);
|
||||
TASSERTE ( wid2->h, 20);
|
||||
TASSERTE ( wid2->w, 85);
|
||||
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 );
|
||||
box_add ( b , WIDGET( wid4 ), FALSE, TRUE );
|
||||
TASSERTE ( wid4->x, 200-20);
|
||||
widget *wid5 = g_malloc0(sizeof(widget));
|
||||
widget_enable ( WIDGET ( wid5 ) );
|
||||
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
|
||||
TASSERTE ( wid5->x, 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));
|
||||
box_add ( b , WIDGET( wid1 ), TRUE, FALSE );
|
||||
// Widget not enabled. no width allocated.
|
||||
TASSERTE ( wid1->h, 0);
|
||||
TASSERTE ( wid1->w, 0 );
|
||||
widget_enable ( WIDGET ( wid1 ) );
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
// Widget enabled. so width allocated.
|
||||
TASSERTE ( wid1->h, 100);
|
||||
TASSERTE ( wid1->w, 20 );
|
||||
widget *wid2 = g_malloc0(sizeof(widget));
|
||||
widget_enable ( WIDGET ( wid2 ) );
|
||||
box_add ( b , WIDGET( wid2 ), TRUE, FALSE );
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 47);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 48);
|
||||
|
||||
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 ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 45);
|
||||
|
||||
widget_resize ( WIDGET (wid3) , 10, 20 );
|
||||
// TODO should this happen automagically?
|
||||
widget_update ( WIDGET ( b ) ) ;
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 35);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 35);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
|
||||
widget_resize ( WIDGET (b ), 20, 200 );
|
||||
TASSERTE ( wid1->w, 20);
|
||||
TASSERTE ( wid1->h, 85);
|
||||
TASSERTE ( wid2->w, 20);
|
||||
TASSERTE ( wid2->h, 85);
|
||||
TASSERTE ( wid3->w, 20);
|
||||
TASSERTE ( wid3->h, 20);
|
||||
TASSERTE ( box_get_fixed_pixels ( b ) , 30 );
|
||||
widget *wid4 = g_malloc0(sizeof(widget));
|
||||
widget_enable ( WIDGET ( wid4 ) );
|
||||
widget_resize ( WIDGET ( wid4 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid4 ), FALSE, TRUE );
|
||||
TASSERTE ( wid4->y, 200-20);
|
||||
widget *wid5 = g_malloc0(sizeof(widget));
|
||||
widget_enable ( WIDGET ( wid5 ) );
|
||||
widget_resize ( WIDGET ( wid5 ), 20, 20 );
|
||||
box_add ( b , WIDGET( wid5 ), TRUE, TRUE );
|
||||
TASSERTE ( wid5->y, 200-20-20-6);
|
||||
widget_free ( WIDGET ( b ) );
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue