diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/helper-test.c | 12 | ||||
-rw-r--r-- | test/textbox-test.c | 77 |
2 files changed, 13 insertions, 76 deletions
diff --git a/test/helper-test.c b/test/helper-test.c index fe575034..e02e63d9 100644 --- a/test/helper-test.c +++ b/test/helper-test.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <helper.h> #include <string.h> +#include <xcb/xcb_ewmh.h> #include "settings.h" static int test = 0; @@ -31,15 +32,10 @@ int show_error_message ( const char *msg, int markup ) rofi_view_error_dialog ( msg, markup ); return 0; } +xcb_screen_t *xcb_screen; +xcb_ewmh_connection_t xcb_ewmh; +int xcb_screen_nbr; #include <x11-helper.h> -int monitor_get_smallest_size ( G_GNUC_UNUSED Display *d ) -{ - return 0; -} -int monitor_get_dimension ( G_GNUC_UNUSED Display *d, G_GNUC_UNUSED Screen *screen, G_GNUC_UNUSED int monitor, G_GNUC_UNUSED workarea *mon ) -{ - return 0; -} int main ( int argc, char ** argv ) { diff --git a/test/textbox-test.c b/test/textbox-test.c index fba5350e..8ba2434f 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -22,85 +22,32 @@ unsigned int normal_window_mode = 0; printf ( "Test %3i passed (%s)\n", ++test, # a ); \ } -Display *display = NULL; -Colormap map = None; -XVisualInfo vinfo; #include "view.h" void rofi_view_queue_redraw () { } +Color color_get (const char *name) +{ + +} void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup ) { fputs ( msg, stderr ); } +int abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key ) +{ + return FALSE; +} int show_error_message ( const char *msg, int markup ) { rofi_view_error_dialog ( msg, markup ); return 0; } -static unsigned int color_get ( Display *display, const char *const name ) -{ - XColor color; - // Special format. - if ( strncmp ( name, "argb:", 5 ) == 0 ) { - return strtoul ( &name[5], NULL, 16 ); - } - else { - return XAllocNamedColor ( display, map, name, &color, &color ) ? color.pixel : None; - } -} - -static void create_visual_and_colormap () -{ - map = None; - // Try to create TrueColor map - if ( XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo ) ) { - // Visual found, lets try to create map. - map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone ); - } - // Failed to create map. - if ( map == None ) { - // Two fields we use. - vinfo.visual = DefaultVisual ( display, DefaultScreen ( display ) ); - vinfo.depth = DefaultDepth ( display, DefaultScreen ( display ) ); - map = DefaultColormap ( display, DefaultScreen ( display ) ); - } -} int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) { - // Get DISPLAY - const char *display_str = getenv ( "DISPLAY" ); - if ( !( display = XOpenDisplay ( display_str ) ) ) { - fprintf ( stderr, "cannot open display!\n" ); - return EXIT_FAILURE; - } - create_visual_and_colormap (); - - setup_abe (); - TASSERT ( display != NULL ); - XSetWindowAttributes attr; - attr.colormap = map; - attr.border_pixel = color_get ( display, "white" ); - attr.background_pixel = color_get ( display, "black" ); - Window mw = XCreateWindow ( display, DefaultRootWindow ( display ), - 0, 0, 200, 100, config.menu_bw, vinfo.depth, InputOutput, - vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, &attr ); - TASSERT ( mw != None ); - - cairo_surface_t *surface = cairo_xlib_surface_create ( display, mw, vinfo.visual, 200, 100 ); - // Create a drawable. - cairo_t *draw = cairo_create ( surface ); - cairo_set_operator ( draw, CAIRO_OPERATOR_SOURCE ); - // Set alternate row to normal row. - config.menu_bg_alt = config.menu_bg; - textbox_setup ( display ); - PangoContext *p = pango_cairo_create_context ( draw ); - textbox_set_pango_context ( p ); - // cleanup - g_object_unref ( p ); textbox *box = textbox_create ( TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, 0, 0, -1, -1, NORMAL, "test" ); @@ -172,7 +119,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) TASSERT ( box->cursor == 5 ); textbox_font ( box, HIGHLIGHT ); - textbox_draw ( box, draw ); + //textbox_draw ( box, draw ); widget_move ( WIDGET ( box ), 12, 13 ); TASSERT ( box->widget.x == 12 ); @@ -181,10 +128,4 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) textbox_free ( box ); textbox_cleanup ( ); - cleanup_abe (); - - cairo_destroy ( draw ); - cairo_surface_destroy ( surface ); - XDestroyWindow ( display, mw ); - XCloseDisplay ( display ); } |