mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Tests.
This commit is contained in:
parent
93cb9ee7eb
commit
6d0d6d9eb2
4 changed files with 16 additions and 89 deletions
|
@ -189,10 +189,6 @@ textbox_test_SOURCES=\
|
||||||
source/widget.c\
|
source/widget.c\
|
||||||
source/textbox.c\
|
source/textbox.c\
|
||||||
config/config.c\
|
config/config.c\
|
||||||
source/keyb.c\
|
|
||||||
source/x11-helper.c\
|
|
||||||
source/xrmoptions.c\
|
|
||||||
source/helper.c\
|
|
||||||
include/keyb.h\
|
include/keyb.h\
|
||||||
include/rofi.h\
|
include/rofi.h\
|
||||||
include/mode.h\
|
include/mode.h\
|
||||||
|
@ -201,7 +197,6 @@ textbox_test_SOURCES=\
|
||||||
include/widget.h\
|
include/widget.h\
|
||||||
include/textbox.h\
|
include/textbox.h\
|
||||||
include/widget.h\
|
include/widget.h\
|
||||||
include/x11-helper.h\
|
|
||||||
include/xrmoptions.h\
|
include/xrmoptions.h\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
test/textbox-test.c
|
test/textbox-test.c
|
||||||
|
@ -215,6 +210,7 @@ helper_test_SOURCES=\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
include/xrmoptions.h\
|
include/xrmoptions.h\
|
||||||
source/xrmoptions.c\
|
source/xrmoptions.c\
|
||||||
|
source/x11-helper.c\
|
||||||
test/helper-test.c
|
test/helper-test.c
|
||||||
|
|
||||||
helper_test_CFLAGS=\
|
helper_test_CFLAGS=\
|
||||||
|
@ -223,6 +219,7 @@ helper_test_CFLAGS=\
|
||||||
$(pango_CFLAGS)\
|
$(pango_CFLAGS)\
|
||||||
$(x11_CFLAGS)\
|
$(x11_CFLAGS)\
|
||||||
$(xinerama_CFLAGS)\
|
$(xinerama_CFLAGS)\
|
||||||
|
$(GW_XCB_CFLAGS)\
|
||||||
$(cairo_CFLAGS)\
|
$(cairo_CFLAGS)\
|
||||||
-I$(top_srcdir)/include/\
|
-I$(top_srcdir)/include/\
|
||||||
-I$(top_srcdir)/config/\
|
-I$(top_srcdir)/config/\
|
||||||
|
@ -232,6 +229,7 @@ helper_test_LDADD=\
|
||||||
$(glib_LIBS)\
|
$(glib_LIBS)\
|
||||||
$(pango_LIBS)\
|
$(pango_LIBS)\
|
||||||
$(x11_LIBS)\
|
$(x11_LIBS)\
|
||||||
|
$(GW_XCB_LIBS)\
|
||||||
$(xinerama_LIBS)\
|
$(xinerama_LIBS)\
|
||||||
$(cairo_LIBS)
|
$(cairo_LIBS)
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,6 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <X11/X.h>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xmd.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include <X11/XKBlib.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <helper.h>
|
#include <helper.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <xcb/xcb_ewmh.h>
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
static int test = 0;
|
static int test = 0;
|
||||||
|
@ -31,15 +32,10 @@ int show_error_message ( const char *msg, int markup )
|
||||||
rofi_view_error_dialog ( msg, markup );
|
rofi_view_error_dialog ( msg, markup );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
xcb_screen_t *xcb_screen;
|
||||||
|
xcb_ewmh_connection_t xcb_ewmh;
|
||||||
|
int xcb_screen_nbr;
|
||||||
#include <x11-helper.h>
|
#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 )
|
int main ( int argc, char ** argv )
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,12 +22,13 @@ unsigned int normal_window_mode = 0;
|
||||||
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
Display *display = NULL;
|
|
||||||
Colormap map = None;
|
|
||||||
XVisualInfo vinfo;
|
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
void rofi_view_queue_redraw ()
|
void rofi_view_queue_redraw ()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
Color color_get (const char *name)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||||
|
@ -35,72 +36,18 @@ void rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||||
fputs ( msg, stderr );
|
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 )
|
int show_error_message ( const char *msg, int markup )
|
||||||
{
|
{
|
||||||
rofi_view_error_dialog ( msg, markup );
|
rofi_view_error_dialog ( msg, markup );
|
||||||
return 0;
|
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 )
|
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,
|
textbox *box = textbox_create ( TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, 0, 0, -1, -1,
|
||||||
NORMAL, "test" );
|
NORMAL, "test" );
|
||||||
|
@ -172,7 +119,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
||||||
TASSERT ( box->cursor == 5 );
|
TASSERT ( box->cursor == 5 );
|
||||||
|
|
||||||
textbox_font ( box, HIGHLIGHT );
|
textbox_font ( box, HIGHLIGHT );
|
||||||
textbox_draw ( box, draw );
|
//textbox_draw ( box, draw );
|
||||||
|
|
||||||
widget_move ( WIDGET ( box ), 12, 13 );
|
widget_move ( WIDGET ( box ), 12, 13 );
|
||||||
TASSERT ( box->widget.x == 12 );
|
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_free ( box );
|
||||||
textbox_cleanup ( );
|
textbox_cleanup ( );
|
||||||
|
|
||||||
cleanup_abe ();
|
|
||||||
|
|
||||||
cairo_destroy ( draw );
|
|
||||||
cairo_surface_destroy ( surface );
|
|
||||||
XDestroyWindow ( display, mw );
|
|
||||||
XCloseDisplay ( display );
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue