[Build] Fix some compile warnings.

This commit is contained in:
Dave Davenport 2022-07-23 00:28:55 +02:00
parent 820b19e09a
commit 0e90fb065f
28 changed files with 1437 additions and 1507 deletions

View File

@ -67,7 +67,7 @@ typedef char *(*_mode_get_display_value)(const Mode *sw,
*/
typedef cairo_surface_t *(*_mode_get_icon)(const Mode *sw,
unsigned int selected_line,
int height);
unsigned int height);
/**
* @param sw The #Mode pointer

View File

@ -139,7 +139,7 @@ char *mode_get_display_value(const Mode *mode, unsigned int selected_line,
* @returns allocated new cairo_surface_t if applicable
*/
cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line,
int height);
unsigned int height);
/**
* @param mode The mode to query

View File

@ -144,7 +144,7 @@ void rofi_theme_property_free(Property *p);
*
* @returns a copy of p
*/
Property *rofi_theme_property_copy(const Property *p);
Property *rofi_theme_property_copy(const Property *p, void *);
/**
* @param widget
*

View File

@ -22,6 +22,7 @@ flags = [
'-Wunreachable-code',
'-Werror=missing-prototypes',
'-Wno-inline', # A bit too noisy with Bison…
'-Wextra'
]
foreach f : flags
if c_compiler.has_argument(f)

View File

@ -73,7 +73,7 @@ char *mode_get_display_value(const Mode *mode, unsigned int selected_line,
}
cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line,
int height) {
unsigned int height) {
g_assert(mode != NULL);
if (mode->_get_icon != NULL) {

View File

@ -277,7 +277,7 @@ static char *combi_get_completion(const Mode *sw, unsigned int index) {
}
static cairo_surface_t *combi_get_icon(const Mode *sw, unsigned int index,
int height) {
unsigned int height) {
CombiModePrivateData *pd = mode_get_private_data(sw);
for (unsigned i = 0; i < pd->num_switchers; i++) {
if (index >= pd->starts[i] && index < (pd->starts[i] + pd->lengths[i])) {

View File

@ -56,8 +56,8 @@
static int dmenu_mode_init(Mode *sw);
static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens,
unsigned int index);
static cairo_surface_t *dmenu_get_icon(const Mode *sw,
unsigned int selected_line, int height);
static cairo_surface_t *
dmenu_get_icon(const Mode *sw, unsigned int selected_line, unsigned int height);
static char *dmenu_get_message(const Mode *sw);
static inline unsigned int bitget(uint32_t const *const array,
@ -192,9 +192,13 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition,
gpointer user_data) {
DmenuModePrivateData *pd = (DmenuModePrivateData *)user_data;
char command;
// Only interrested in read events.
if ((condition & G_IO_IN) != G_IO_IN) {
return G_SOURCE_CONTINUE;
}
// Read the entry from the pipe that was used to signal this action.
if (read(fd, &command, 1) == 1) {
if ( command == 'r' ){
if (command == 'r') {
Block *block = NULL;
gboolean changed = FALSE;
// Empty out the AsyncQueue (that is thread safe) from all blocks pushed
@ -204,10 +208,10 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition,
if (pd->cmd_list_real_length < (pd->cmd_list_length + block->length)) {
pd->cmd_list_real_length = MAX(pd->cmd_list_real_length * 2, 4096);
pd->cmd_list = g_realloc(pd->cmd_list, sizeof(DmenuScriptEntry) *
pd->cmd_list_real_length);
pd->cmd_list_real_length);
}
memcpy(&(pd->cmd_list[pd->cmd_list_length]), &(block->values[0]),
sizeof(DmenuScriptEntry) * block->length);
sizeof(DmenuScriptEntry) * block->length);
pd->cmd_list_length += block->length;
g_free(block);
changed = TRUE;
@ -215,8 +219,8 @@ static gboolean dmenu_async_read_proc(gint fd, GIOCondition condition,
if (changed) {
rofi_view_reload();
}
} else if ( command == 'q' ){
if ( pd->loading ) {
} else if (command == 'q') {
if (pd->loading) {
rofi_view_set_overlay(rofi_view_get_active(), NULL);
}
}
@ -239,7 +243,7 @@ static void read_input_sync(DmenuModePrivateData *pd, unsigned int pre_read) {
static gpointer read_input_thread(gpointer userdata) {
DmenuModePrivateData *pd = (DmenuModePrivateData *)userdata;
ssize_t nread = 0;
size_t len = 0;
ssize_t len = 0;
char *line = NULL;
// Create the message passing queue to the UI thread.
pd->async_queue = g_async_queue_new();
@ -276,7 +280,7 @@ static gpointer read_input_thread(gpointer userdata) {
if (readbytes > 0) {
nread += readbytes;
line[nread] = '\0';
size_t i = 0;
ssize_t i = 0;
while (i < nread) {
if (line[i] == pd->separator) {
line[i] = '\0';
@ -632,7 +636,8 @@ static char *dmenu_get_message(const Mode *sw) {
return NULL;
}
static cairo_surface_t *dmenu_get_icon(const Mode *sw,
unsigned int selected_line, int height) {
unsigned int selected_line,
unsigned int height) {
DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw);
g_return_val_if_fail(pd->cmd_list != NULL, NULL);
@ -650,7 +655,8 @@ static cairo_surface_t *dmenu_get_icon(const Mode *sw,
return rofi_icon_fetcher_get(uid);
}
static void dmenu_finish(DmenuModePrivateData *pd, RofiViewState *state, int retv) {
static void dmenu_finish(DmenuModePrivateData *pd, RofiViewState *state,
int retv) {
if (pd->reading_thread) {
// Stop listinig to new messages from reading thread.
@ -779,7 +785,7 @@ static void dmenu_finalize(RofiViewState *state) {
rofi_view_restart(state);
rofi_view_set_selected_line(state, pd->selected_line);
if (!restart) {
dmenu_finish(pd,state, retv);
dmenu_finish(pd, state, retv);
}
return;
}
@ -835,7 +841,7 @@ static void dmenu_finalize(RofiViewState *state) {
rofi_view_restart(state);
rofi_view_set_selected_line(state, pd->selected_line);
} else {
dmenu_finish(pd,state, retv);
dmenu_finish(pd, state, retv);
}
}

View File

@ -1330,7 +1330,7 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
}
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
int height) {
unsigned int height) {
DRunModePrivateData *pd = (DRunModePrivateData *)mode_get_private_data(sw);
if (pd->file_complete) {
return pd->completer->_get_icon(pd->completer, selected_line, height);

View File

@ -561,7 +561,7 @@ static int file_browser_token_match(const Mode *sw, rofi_int_matcher **tokens,
}
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
int height) {
unsigned int height) {
FileBrowserModePrivateData *pd =
(FileBrowserModePrivateData *)mode_get_private_data(sw);
g_return_val_if_fail(pd->array != NULL, NULL);

View File

@ -534,7 +534,7 @@ static char *run_get_message(const Mode *sw) {
return NULL;
}
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
int height) {
unsigned int height) {
RunModePrivateData *pd = (RunModePrivateData *)mode_get_private_data(sw);
if (pd->file_complete) {
return pd->completer->_get_icon(pd->completer, selected_line, height);

View File

@ -429,8 +429,9 @@ static char *script_get_message(const Mode *sw) {
ScriptModePrivateData *pd = sw->private_data;
return g_strdup(pd->message);
}
static cairo_surface_t *
script_get_icon(const Mode *sw, unsigned int selected_line, int height) {
static cairo_surface_t *script_get_icon(const Mode *sw,
unsigned int selected_line,
unsigned int height) {
ScriptModePrivateData *pd =
(ScriptModePrivateData *)mode_get_private_data(sw);
g_return_val_if_fail(pd->cmd_list != NULL, NULL);
@ -454,7 +455,7 @@ typedef struct ScriptUser {
} ScriptUser;
ScriptUser *user_scripts = NULL;
int num_scripts = 0;
size_t num_scripts = 0;
void script_mode_cleanup(void) {
for (size_t i = 0; i < num_scripts; i++) {
@ -493,7 +494,7 @@ void script_mode_gather_user_scripts(void) {
static int script_mode_has_user_script(char const *const user) {
for (int i = 0; i < num_scripts; i++) {
for (size_t i = 0; i < num_scripts; i++) {
if (g_strcmp0(user_scripts[i].name, user) == 0) {
return i;
}

View File

@ -399,7 +399,8 @@ static gboolean window_client_reload(G_GNUC_UNUSED void *data) {
}
return G_SOURCE_REMOVE;
}
void window_client_handle_signal(xcb_window_t win, gboolean create) {
void window_client_handle_signal(G_GNUC_UNUSED xcb_window_t win,
G_GNUC_UNUSED gboolean create) {
// g_idle_add_full(G_PRIORITY_HIGH_IDLE, window_client_reload, NULL, NULL);
if (window_reload_timeout > 0) {
g_source_remove(window_reload_timeout);
@ -1023,7 +1024,7 @@ static cairo_surface_t *get_net_wm_icon(xcb_window_t xid,
return surface;
}
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
int size) {
unsigned int size) {
WindowModePrivateData *rmpd = mode_get_private_data(sw);
client *c = window_client(rmpd, rmpd->ids->array[selected_line]);
if (c == NULL) {

View File

@ -772,7 +772,7 @@ static gboolean record(G_GNUC_UNUSED void *data) {
return G_SOURCE_CONTINUE;
}
static void rofi_custom_log_function(const char *log_domain,
GLogLevelFlags log_level,
G_GNUC_UNUSED GLogLevelFlags log_level,
const gchar *message, gpointer user_data) {
int fp = GPOINTER_TO_INT(user_data);
dprintf(fp, "[%s]: %s\n", log_domain == NULL ? "default" : log_domain,

View File

@ -120,7 +120,8 @@ RofiDistance rofi_theme_property_copy_distance(RofiDistance const distance) {
return retv;
}
Property *rofi_theme_property_copy(const Property *p) {
Property *rofi_theme_property_copy(const Property *p,
G_GNUC_UNUSED void *data) {
Property *retv = rofi_theme_property_create(p->type);
retv->name = g_strdup(p->name);
@ -137,7 +138,7 @@ Property *rofi_theme_property_copy(const Property *p) {
retv->value.link.ref = NULL;
if (p->value.link.def_value) {
retv->value.link.def_value =
rofi_theme_property_copy(p->value.link.def_value);
rofi_theme_property_copy(p->value.link.def_value, NULL);
}
break;
case P_PADDING: {
@ -635,7 +636,7 @@ void yyerror(YYLTYPE *yylloc, const char *what, const char *s) {
static void rofi_theme_copy_property_int(G_GNUC_UNUSED gpointer key,
gpointer value, gpointer user_data) {
GHashTable *table = (GHashTable *)user_data;
Property *p = rofi_theme_property_copy((Property *)value);
Property *p = rofi_theme_property_copy((Property *)value, NULL);
g_hash_table_replace(table, p->name, p);
}
void rofi_theme_widget_add_properties(ThemeWidget *widget, GHashTable *table) {

View File

@ -1007,8 +1007,8 @@ inline static void rofi_view_nav_last(RofiViewState *state) {
// state->selected = state->filtered_lines - 1;
listview_set_selected(state->list_view, -1);
}
static void selection_changed_callback(listview *lv, unsigned int index,
void *udata) {
static void selection_changed_callback(G_GNUC_UNUSED listview *lv,
unsigned int index, void *udata) {
RofiViewState *state = (RofiViewState *)udata;
if (state->tb_current_entry) {
if (index < state->filtered_lines) {

View File

@ -526,8 +526,10 @@ widget *widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y) {
return NULL;
}
WidgetTriggerActionResult widget_check_action(widget *wid, guint action, gint x,
gint y) {
WidgetTriggerActionResult widget_check_action(widget *wid,
G_GNUC_UNUSED guint action,
G_GNUC_UNUSED gint x,
G_GNUC_UNUSED gint y) {
if (wid == NULL) {
return FALSE;
}

View File

@ -744,13 +744,13 @@ gboolean config_parse_set_property(const Property *p, char **error) {
iter = g_list_next(iter)) {
if (g_strcmp0(((Property *)(iter->data))->name, p->name) == 0) {
rofi_theme_property_free((Property *)(iter->data));
iter->data = (void *)rofi_theme_property_copy(p);
iter->data = (void *)rofi_theme_property_copy(p, NULL);
return FALSE;
}
}
g_debug("Adding option: %s to backup list.", p->name);
extra_parsed_options =
g_list_append(extra_parsed_options, rofi_theme_property_copy(p));
g_list_append(extra_parsed_options, rofi_theme_property_copy(p, NULL));
return FALSE;
}

View File

@ -25,268 +25,255 @@
*
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <glib.h>
#include <string.h>
#include <theme.h>
#include <widgets/box.h>
#include <widgets/widget.h>
#include <widgets/widget-internal.h>
#include "rofi.h"
#include "xrmoptions.h"
#include "helper.h"
#include "rofi-icon-fetcher.h"
unsigned int test =0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
}
#include "rofi.h"
#include "xrmoptions.h"
#include <assert.h>
#include <glib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <theme.h>
#include <unistd.h>
#include <widgets/box.h>
#include <widgets/widget-internal.h>
#include <widgets/widget.h>
unsigned int test = 0;
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %3u passed (%s)\n", ++test, #a); \
}
#define TASSERTE( a, b ) { \
if ( ( a ) == ( b ) ) { \
printf ( "Test %u passed (%s == %s) (%d == %d)\n", ++test, # a, # b, a, b ); \
} else { \
printf ( "Test %u failed (%s == %s) (%d != %d)\n", ++test, # a, # b, a, b ); \
abort ( ); \
} \
}
#define TASSERTE(a, b) \
{ \
if ((a) == (b)) { \
printf("Test %u passed (%s == %s) (%d == %d)\n", ++test, #a, #b, a, b); \
} else { \
printf("Test %u failed (%s == %s) (%d != %d)\n", ++test, #a, #b, a, b); \
abort(); \
} \
}
#define TASSERTW( a, b ) { \
if ( ( a ) == ( b ) ) { \
printf ( "Test %u passed (%s == %s) (%p == %p)\n", ++test, # a, # b, (void *)a, (void *)b ); \
} else { \
printf ( "Test %u failed (%s == %s) (%p != %p)\n", ++test, # a, # b, (void *)a, (void *)b ); \
abort ( ); \
} \
}
#define TASSERTW(a, b) \
{ \
if ((a) == (b)) { \
printf("Test %u passed (%s == %s) (%p == %p)\n", ++test, #a, #b, \
(void *)a, (void *)b); \
} else { \
printf("Test %u failed (%s == %s) (%p != %p)\n", ++test, #a, #b, \
(void *)a, (void *)b); \
abort(); \
} \
}
ThemeWidget *rofi_configuration = NULL;
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
G_GNUC_UNUSED char **error) {
return FALSE;
}
char *rofi_expand_path(G_GNUC_UNUSED const char *path) { return NULL; }
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
{
return FALSE;
char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) {
return g_strdup(file);
}
char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
{
return NULL;
}
char * helper_get_theme_path ( const char *file, const char *ext)
{
return g_strdup ( file );
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
}
int textbox_get_estimated_char_height ( void );
int textbox_get_estimated_char_height ( void )
{
return 16;
}
double textbox_get_estimated_ch ( void );
double textbox_get_estimated_ch ( void )
{
return 8;
}
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
{
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
{
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_HORIZONTAL );
//box_set_padding ( b, 5 );
widget_resize ( WIDGET (b), 100, 20);
widget *wid1 = g_malloc0(sizeof(widget));
wid1->parent = WIDGET(b);
box_add ( b , WIDGET( wid1 ), TRUE );
// 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));
wid2->parent = WIDGET (b) ;
widget_enable ( WIDGET ( wid2 ) );
box_add ( b , WIDGET( wid2 ), TRUE );
TASSERTE ( wid1->h, 20);
TASSERTE ( wid1->w, 49);
TASSERTE ( wid2->h, 20);
TASSERTE ( wid2->w, 49);
widget *wid3 = g_malloc0(sizeof(widget));
wid3->parent = WIDGET (b);
widget_enable ( WIDGET ( wid3 ) );
box_add ( b , WIDGET( wid3 ), FALSE );
TASSERTE ( wid1->h, 20);
TASSERTE ( wid1->w, 48);
TASSERTE ( wid2->h, 20);
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, 38);
TASSERTE ( wid2->h, 20);
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, 88);
TASSERTE ( wid2->h, 20);
TASSERTE ( wid2->w, 88);
TASSERTE ( wid3->h, 20);
TASSERTE ( wid3->w, 20);
// TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
widget *wid4 = g_malloc0(sizeof(widget));
wid4->parent = WIDGET ( b );
widget_enable ( WIDGET ( wid4 ) );
widget_resize ( WIDGET ( wid4 ), 20, 20 );
box_add ( b , WIDGET( wid4 ), FALSE );
TASSERTE ( wid4->x, 200-20);
widget *wid5 = g_malloc0(sizeof(widget));
wid5->parent = WIDGET ( b );
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
box_add ( b , WIDGET( wid5 ), TRUE );
TASSERTE ( wid5->x, 149);
widget_free ( WIDGET ( b ) );
}
{
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 100);
//box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));
wid1->parent = WIDGET ( b );
box_add ( b , WIDGET( wid1 ), TRUE );
// 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));
wid2->parent = WIDGET ( b );
widget_enable ( WIDGET ( wid2 ) );
box_add ( b , WIDGET( wid2 ), TRUE );
TASSERTE ( wid1->w, 20);
TASSERTE ( wid1->h, 49);
TASSERTE ( wid2->w, 20);
TASSERTE ( wid2->h, 49);
widget *wid3 = g_malloc0(sizeof(widget));
wid3->parent = WIDGET ( b );
widget_enable ( WIDGET ( wid3 ) );
box_add ( b , WIDGET( wid3 ), FALSE );
TASSERTE ( wid1->w, 20);
TASSERTE ( wid1->h, 48);
TASSERTE ( wid2->w, 20);
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, 38);
TASSERTE ( wid2->w, 20);
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, 88);
TASSERTE ( wid2->w, 20);
TASSERTE ( wid2->h, 88);
TASSERTE ( wid3->w, 20);
TASSERTE ( wid3->h, 20);
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
widget *wid4 = g_malloc0(sizeof(widget));
wid4->parent = WIDGET ( b );
widget_enable ( WIDGET ( wid4 ) );
widget_resize ( WIDGET ( wid4 ), 20, 20 );
box_add ( b , WIDGET( wid4 ), FALSE );
TASSERTE ( wid4->y, 180);
widget *wid5 = g_malloc0(sizeof(widget));
wid5->parent = WIDGET ( b );
widget_enable ( WIDGET ( wid5 ) );
widget_resize ( WIDGET ( wid5 ), 20, 20 );
box_add ( b , WIDGET( wid5 ), TRUE );
TASSERTE ( wid5->y, 149);
widget_free ( WIDGET ( b ) );
}
{
box *b = box_create ( NULL, "box", ROFI_ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 90);
//box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));
wid1->parent = WIDGET ( b );
wid1->type = 1;
widget_enable(wid1);
box_add ( b , WIDGET( wid1 ), TRUE );
widget *wid2 = g_malloc0(sizeof(widget));
wid2->parent = WIDGET ( b );
wid2->type = 1;
widget_enable(wid2);
box_add ( b , WIDGET( wid2 ), TRUE );
widget *wid3 = g_malloc0(sizeof(widget));
wid3->parent = WIDGET ( b );
wid3->type = 2;
widget_enable(wid3);
box_add ( b , WIDGET( wid3 ), TRUE );
gint x = 10;
gint y = 50;
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
y = 30;
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
y = 27;
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid1) );
widget_disable ( wid2 );
y = 40;
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid1) );
widget_disable ( wid1 );
widget_enable ( wid2 );
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 1, x, y ), WIDGET(wid2) );
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 2, x, y ), NULL );
y = 55;
TASSERTW ( widget_find_mouse_target ( WIDGET(b), 2, x, y ), WIDGET(wid3) );
widget_free ( WIDGET ( b ) );
}
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
int textbox_get_estimated_char_height(void);
int textbox_get_estimated_char_height(void) { return 16; }
double textbox_get_estimated_ch(void);
double textbox_get_estimated_ch(void) { return 8; }
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
G_GNUC_UNUSED int *height) {}
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
{
box *b = box_create(NULL, "box", ROFI_ORIENTATION_HORIZONTAL);
// box_set_padding ( b, 5 );
widget_resize(WIDGET(b), 100, 20);
widget *wid1 = g_malloc0(sizeof(widget));
wid1->parent = WIDGET(b);
box_add(b, WIDGET(wid1), TRUE);
// 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));
wid2->parent = WIDGET(b);
widget_enable(WIDGET(wid2));
box_add(b, WIDGET(wid2), TRUE);
TASSERTE(wid1->h, 20);
TASSERTE(wid1->w, 49);
TASSERTE(wid2->h, 20);
TASSERTE(wid2->w, 49);
widget *wid3 = g_malloc0(sizeof(widget));
wid3->parent = WIDGET(b);
widget_enable(WIDGET(wid3));
box_add(b, WIDGET(wid3), FALSE);
TASSERTE(wid1->h, 20);
TASSERTE(wid1->w, 48);
TASSERTE(wid2->h, 20);
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, 38);
TASSERTE(wid2->h, 20);
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, 88);
TASSERTE(wid2->h, 20);
TASSERTE(wid2->w, 88);
TASSERTE(wid3->h, 20);
TASSERTE(wid3->w, 20);
// TASSERTE ( box_get_fixed_pixels ( b ) , 24 );
widget *wid4 = g_malloc0(sizeof(widget));
wid4->parent = WIDGET(b);
widget_enable(WIDGET(wid4));
widget_resize(WIDGET(wid4), 20, 20);
box_add(b, WIDGET(wid4), FALSE);
TASSERTE(wid4->x, 200 - 20);
widget *wid5 = g_malloc0(sizeof(widget));
wid5->parent = WIDGET(b);
widget_enable(WIDGET(wid5));
widget_resize(WIDGET(wid5), 20, 20);
box_add(b, WIDGET(wid5), TRUE);
TASSERTE(wid5->x, 149);
widget_free(WIDGET(b));
}
{
box *b = box_create(NULL, "box", ROFI_ORIENTATION_VERTICAL);
widget_resize(WIDGET(b), 20, 100);
// box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));
wid1->parent = WIDGET(b);
box_add(b, WIDGET(wid1), TRUE);
// 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));
wid2->parent = WIDGET(b);
widget_enable(WIDGET(wid2));
box_add(b, WIDGET(wid2), TRUE);
TASSERTE(wid1->w, 20);
TASSERTE(wid1->h, 49);
TASSERTE(wid2->w, 20);
TASSERTE(wid2->h, 49);
widget *wid3 = g_malloc0(sizeof(widget));
wid3->parent = WIDGET(b);
widget_enable(WIDGET(wid3));
box_add(b, WIDGET(wid3), FALSE);
TASSERTE(wid1->w, 20);
TASSERTE(wid1->h, 48);
TASSERTE(wid2->w, 20);
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, 38);
TASSERTE(wid2->w, 20);
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, 88);
TASSERTE(wid2->w, 20);
TASSERTE(wid2->h, 88);
TASSERTE(wid3->w, 20);
TASSERTE(wid3->h, 20);
// TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
widget *wid4 = g_malloc0(sizeof(widget));
wid4->parent = WIDGET(b);
widget_enable(WIDGET(wid4));
widget_resize(WIDGET(wid4), 20, 20);
box_add(b, WIDGET(wid4), FALSE);
TASSERTE(wid4->y, 180);
widget *wid5 = g_malloc0(sizeof(widget));
wid5->parent = WIDGET(b);
widget_enable(WIDGET(wid5));
widget_resize(WIDGET(wid5), 20, 20);
box_add(b, WIDGET(wid5), TRUE);
TASSERTE(wid5->y, 149);
widget_free(WIDGET(b));
}
{
box *b = box_create(NULL, "box", ROFI_ORIENTATION_VERTICAL);
widget_resize(WIDGET(b), 20, 90);
// box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));
wid1->parent = WIDGET(b);
wid1->type = 1;
widget_enable(wid1);
box_add(b, WIDGET(wid1), TRUE);
widget *wid2 = g_malloc0(sizeof(widget));
wid2->parent = WIDGET(b);
wid2->type = 1;
widget_enable(wid2);
box_add(b, WIDGET(wid2), TRUE);
widget *wid3 = g_malloc0(sizeof(widget));
wid3->parent = WIDGET(b);
wid3->type = 2;
widget_enable(wid3);
box_add(b, WIDGET(wid3), TRUE);
gint x = 10;
gint y = 50;
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid2));
y = 30;
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid2));
y = 27;
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid1));
widget_disable(wid2);
y = 40;
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid1));
widget_disable(wid1);
widget_enable(wid2);
TASSERTW(widget_find_mouse_target(WIDGET(b), 1, x, y), WIDGET(wid2));
TASSERTW(widget_find_mouse_target(WIDGET(b), 2, x, y), NULL);
y = 55;
TASSERTW(widget_find_mouse_target(WIDGET(b), 2, x, y), WIDGET(wid3));
widget_free(WIDGET(b));
}
}

View File

@ -25,139 +25,124 @@
*
*/
#include <assert.h>
#include <locale.h>
#include <glib.h>
#include <stdio.h>
#include <helper.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
#include "display.h"
#include "xcb.h"
#include "xcb-internal.h"
#include "rofi-icon-fetcher.h"
#include "rofi.h"
#include "settings.h"
#include "widgets/textbox.h"
#include "rofi-icon-fetcher.h"
#include "xcb-internal.h"
#include "xcb.h"
#include <assert.h>
#include <glib.h>
#include <helper.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
static int test = 0;
static int test = 0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %i 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 ( ); \
} \
}
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %i 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(); \
} \
}
#include "theme.h"
ThemeWidget *rofi_theme = NULL;
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
void rofi_clear_error_messages (void )
{
}
void rofi_clear_error_messages(void) {}
gboolean rofi_theme_parse_string ( const char *string )
{
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
return FALSE;
}
double textbox_get_estimated_char_height ( void )
{
return 12.0;
double textbox_get_estimated_char_height(void) { return 12.0; }
void rofi_view_get_current_monitor(int *width, int *height) {
*width = 1920;
*height = 1080;
}
void rofi_view_get_current_monitor ( int *width, int *height )
{
*width = 1920;
*height = 1080;
}
double textbox_get_estimated_ch ( void )
{
return 9.0;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
}
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
fputs ( msg, stderr );
return TRUE;
double textbox_get_estimated_ch(void) { return 9.0; }
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return TRUE;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
}
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
return EXIT_FAILURE;
}
char **list = NULL;
int llength = 0;
char * test_str =
"{host} {terminal} -e bash -c \"{ssh-client} {host}; echo '{terminal} {host}'\" -i -3 -u 4";
helper_parse_setup ( test_str, &list, &llength, "{host}", "chuck",
"{terminal}", "x-terminal-emulator", NULL );
TASSERT ( llength == 10);
TASSERT ( strcmp ( list[0], "chuck" ) == 0 );
TASSERT ( strcmp ( list[1], "x-terminal-emulator" ) == 0 );
TASSERT ( strcmp ( list[2], "-e" ) == 0 );
TASSERT ( strcmp ( list[3], "bash" ) == 0 );
TASSERT ( strcmp ( list[4], "-c" ) == 0 );
TASSERT ( strcmp ( list[5], "ssh chuck; echo 'x-terminal-emulator chuck'" ) == 0 );
TASSERT ( strcmp ( list[6], "-i" ) == 0 );
TASSERT ( strcmp ( list[7], "-3" ) == 0 );
TASSERT ( strcmp ( list[8], "-u" ) == 0 );
TASSERT ( strcmp ( list[9], "4" ) == 0 );
cmd_set_arguments ( llength, list);
TASSERT ( find_arg ( "-e") == 2 );
TASSERT ( find_arg ( "-x") == -1 );
char *str;
TASSERT ( find_arg_str ( "-e", &str) == TRUE );
TASSERT ( str == list[3] );
TASSERT ( find_arg_str ( "-x", &str) == FALSE );
// Should be unmodified.
TASSERT ( str == list[3] );
unsigned int u = 1234;
int d = -1234;
TASSERT ( find_arg_uint ( "-x", &u ) == FALSE );
TASSERT ( u == 1234 );
TASSERT ( find_arg_int ( "-x", &d ) == FALSE );
TASSERT ( d == -1234 );
TASSERT ( find_arg_uint ( "-u", &u ) == TRUE );
TASSERT ( u == 4 );
TASSERT ( find_arg_uint ( "-i", &u ) == TRUE );
TASSERT ( u == 4294967293 );
TASSERT ( find_arg_int ( "-i", &d ) == TRUE );
TASSERT ( d == -3 );
g_strfreev ( list );
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
if (setlocale(LC_ALL, "") == NULL) {
fprintf(stderr, "Failed to set locale.\n");
return EXIT_FAILURE;
}
char **list = NULL;
int llength = 0;
char *test_str = "{host} {terminal} -e bash -c \"{ssh-client} {host}; echo "
"'{terminal} {host}'\" -i -3 -u 4";
helper_parse_setup(test_str, &list, &llength, "{host}", "chuck", "{terminal}",
"x-terminal-emulator", NULL);
TASSERT(llength == 10);
TASSERT(strcmp(list[0], "chuck") == 0);
TASSERT(strcmp(list[1], "x-terminal-emulator") == 0);
TASSERT(strcmp(list[2], "-e") == 0);
TASSERT(strcmp(list[3], "bash") == 0);
TASSERT(strcmp(list[4], "-c") == 0);
TASSERT(strcmp(list[5], "ssh chuck; echo 'x-terminal-emulator chuck'") == 0);
TASSERT(strcmp(list[6], "-i") == 0);
TASSERT(strcmp(list[7], "-3") == 0);
TASSERT(strcmp(list[8], "-u") == 0);
TASSERT(strcmp(list[9], "4") == 0);
cmd_set_arguments(llength, list);
TASSERT(find_arg("-e") == 2);
TASSERT(find_arg("-x") == -1);
char *str;
TASSERT(find_arg_str("-e", &str) == TRUE);
TASSERT(str == list[3]);
TASSERT(find_arg_str("-x", &str) == FALSE);
// Should be unmodified.
TASSERT(str == list[3]);
unsigned int u = 1234;
int d = -1234;
TASSERT(find_arg_uint("-x", &u) == FALSE);
TASSERT(u == 1234);
TASSERT(find_arg_int("-x", &d) == FALSE);
TASSERT(d == -1234);
TASSERT(find_arg_uint("-u", &u) == TRUE);
TASSERT(u == 4);
TASSERT(find_arg_uint("-i", &u) == TRUE);
TASSERT(u == 4294967293);
TASSERT(find_arg_int("-i", &d) == TRUE);
TASSERT(d == -3);
g_strfreev(list);
}

View File

@ -25,119 +25,106 @@
*
*/
#include <assert.h>
#include <locale.h>
#include <glib.h>
#include <stdio.h>
#include <helper.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
#include "theme.h"
#include "display.h"
#include "xcb.h"
#include "xcb-internal.h"
#include "rofi-icon-fetcher.h"
#include "rofi.h"
#include "settings.h"
#include "theme.h"
#include "widgets/textbox.h"
#include "rofi-icon-fetcher.h"
#include "xcb-internal.h"
#include "xcb.h"
#include <assert.h>
#include <glib.h>
#include <helper.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
static int test = 0;
static int test = 0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %i 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 ( ); \
} \
}
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %i 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(); \
} \
}
ThemeWidget *rofi_theme = NULL;
void rofi_clear_error_messages ( void ) {}
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
void rofi_clear_error_messages(void) {}
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
double textbox_get_estimated_char_height ( void )
{
return 12.0;
double textbox_get_estimated_char_height(void) { return 12.0; }
void rofi_view_get_current_monitor(int *width, int *height) {
*width = 1920;
*height = 1080;
}
void rofi_view_get_current_monitor ( int *width, int *height )
{
*width = 1920;
*height = 1080;
}
double textbox_get_estimated_ch ( void )
{
return 9.0;
}
gboolean rofi_theme_parse_string ( const char *string )
{
return 0;
double textbox_get_estimated_ch(void) { return 9.0; }
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) { return 0; }
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return TRUE;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
}
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
fputs ( msg, stderr );
return TRUE;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
}
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{
}
int main ( int argc, char **argv )
{
cmd_set_arguments ( argc, argv );
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
return EXIT_FAILURE;
}
/**
* Test some path functions. Not easy as not sure what is right output on travis.
*/
// Test if root is preserved.
char *str = rofi_expand_path ( "/" );
TASSERT ( strcmp ( str, "/" ) == 0 );
g_free ( str );
// Test is relative path is preserved.
str = rofi_expand_path ( "../AUTHORS" );
TASSERT ( strcmp ( str, "../AUTHORS" ) == 0 );
g_free ( str );
// Test another one.
str = rofi_expand_path ( "/bin/false" );
TASSERT ( strcmp ( str, "/bin/false" ) == 0 );
g_free ( str );
// See if user paths get expanded in full path.
str = rofi_expand_path ( "~/" );
const char *hd = g_get_home_dir ();
TASSERT ( strcmp ( str, hd ) == 0 );
g_free ( str );
str = rofi_expand_path ( "~root/" );
TASSERT ( str[0] == '/' );
g_free ( str );
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
int main(int argc, char **argv) {
cmd_set_arguments(argc, argv);
if (setlocale(LC_ALL, "") == NULL) {
fprintf(stderr, "Failed to set locale.\n");
return EXIT_FAILURE;
}
/**
* Test some path functions. Not easy as not sure what is right output on
* travis.
*/
// Test if root is preserved.
char *str = rofi_expand_path("/");
TASSERT(strcmp(str, "/") == 0);
g_free(str);
// Test is relative path is preserved.
str = rofi_expand_path("../AUTHORS");
TASSERT(strcmp(str, "../AUTHORS") == 0);
g_free(str);
// Test another one.
str = rofi_expand_path("/bin/false");
TASSERT(strcmp(str, "/bin/false") == 0);
g_free(str);
// See if user paths get expanded in full path.
str = rofi_expand_path("~/");
const char *hd = g_get_home_dir();
TASSERT(strcmp(str, hd) == 0);
g_free(str);
str = rofi_expand_path("~root/");
TASSERT(str[0] == '/');
g_free(str);
}

View File

@ -50,17 +50,25 @@ static int test = 0;
#include "theme.h"
ThemeWidget *rofi_theme = NULL;
uint32_t rofi_icon_fetcher_query(const char *name, const int size) { return 0; }
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
const int hsize) {
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; }
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
void rofi_clear_error_messages(void) {}
gboolean rofi_theme_parse_string(const char *string) { return FALSE; }
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
return FALSE;
}
double textbox_get_estimated_char_height(void) { return 12.0; }
void rofi_view_get_current_monitor(int *width, int *height) {
*width = 1920;

View File

@ -25,205 +25,221 @@
*
*/
#include <assert.h>
#include <locale.h>
#include <glib.h>
#include <stdio.h>
#include <helper.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
#include "theme.h"
#include "display.h"
#include "xcb.h"
#include "xcb-internal.h"
#include "rofi-icon-fetcher.h"
#include "rofi.h"
#include "settings.h"
#include "rofi-icon-fetcher.h"
#include "theme.h"
#include "xcb-internal.h"
#include "xcb.h"
#include <assert.h>
#include <glib.h>
#include <helper.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
static int test = 0;
static int test = 0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %i 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 ( ); \
} \
}
#define TASSERTL( a, b ) { \
if ( ( a ) == ( b ) ) { \
printf ( "Test %i passed (%s == %s) (%d == %d)\n", ++test, # a, # b, a, b ); \
} else { \
printf ( "Test %i failed (%s == %s) (%d != %d)\n", ++test, # a, # b, a, b ); \
abort ( ); \
} \
}
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %i 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(); \
} \
}
#define TASSERTL(a, b) \
{ \
if ((a) == (b)) { \
printf("Test %i passed (%s == %s) (%d == %d)\n", ++test, #a, #b, a, b); \
} else { \
printf("Test %i failed (%s == %s) (%d != %d)\n", ++test, #a, #b, a, b); \
abort(); \
} \
}
#include "widgets/textbox.h"
ThemeWidget *rofi_theme = NULL;
gboolean rofi_theme_parse_string ( const char *string )
{
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
return FALSE;
}
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
void rofi_clear_error_messages ( void ) {}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
void rofi_clear_error_messages(void) {}
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
double textbox_get_estimated_char_height ( void )
{
return 12.0;
double textbox_get_estimated_char_height(void) { return 12.0; }
void rofi_view_get_current_monitor(int *width, int *height) {
*width = 1920;
*height = 1080;
}
void rofi_view_get_current_monitor ( int *width, int *height )
{
*width = 1920;
*height = 1080;
}
double textbox_get_estimated_ch ( void )
{
return 9.0;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
double textbox_get_estimated_ch(void) { return 9.0; }
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return TRUE;
}
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
fputs ( msg, stderr );
return TRUE;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
}
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{
}
int main ( int argc, char **argv )
{
cmd_set_arguments ( argc, argv );
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
return EXIT_FAILURE;
}
/**
* Char function
*/
TASSERT ( helper_parse_char ( "\\n" ) == '\n' );
TASSERT ( helper_parse_char ( "\\a" ) == '\a' );
TASSERT ( helper_parse_char ( "\\b" ) == '\b' );
TASSERT ( helper_parse_char ( "\\t" ) == '\t' );
TASSERT ( helper_parse_char ( "\\v" ) == '\v' );
TASSERT ( helper_parse_char ( "\\f" ) == '\f' );
TASSERT ( helper_parse_char ( "\\r" ) == '\r' );
TASSERT ( helper_parse_char ( "\\\\" ) == '\\' );
TASSERT ( helper_parse_char ( "\\0" ) == 0 );
TASSERT ( helper_parse_char ( "\\x77" ) == 'w' );
TASSERT ( helper_parse_char ( "\\x0A" ) == '\n' );
/**
* tokenize
*/
TASSERT ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "aap", g_utf8_strlen ( "aap", -1) ) == 0 );
TASSERT ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "aap ", g_utf8_strlen ( "aap ", -1) ) == 1 );
TASSERT ( levenshtein ( "aap ", g_utf8_strlen ( "aap ", -1), "aap", g_utf8_strlen ( "aap", -1) ) == 1 );
TASSERTE ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "aap noot", g_utf8_strlen ( "aap noot", -1) ), 5u );
TASSERTE ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "noot aap", g_utf8_strlen ( "noot aap", -1) ), 5u );
TASSERTE ( levenshtein ( "aap", g_utf8_strlen ( "aap", -1), "noot aap mies", g_utf8_strlen ( "noot aap mies", -1) ), 10u );
TASSERTE ( levenshtein ( "noot aap mies", g_utf8_strlen ( "noot aap mies", -1), "aap", g_utf8_strlen ( "aap", -1) ), 10u );
TASSERTE ( levenshtein ( "otp", g_utf8_strlen ( "otp", -1), "noot aap", g_utf8_strlen ( "noot aap", -1) ), 5u );
/**
* Quick converision check.
*/
{
char *str = rofi_latin_to_utf8_strdup ( "\xA1\xB5", 2 );
TASSERT ( g_utf8_collate ( str, "¡µ" ) == 0 );
g_free ( str );
}
{
char *str = rofi_force_utf8 ( "Valid utf8", 10 );
TASSERT ( g_utf8_collate ( str, "Valid utf8" ) == 0 );
g_free ( str );
char in[] = "Valid utf8 until \xc3\x28 we continue here";
TASSERT ( g_utf8_validate ( in, -1, NULL ) == FALSE );
str = rofi_force_utf8 ( in, strlen ( in ) );
TASSERT ( g_utf8_validate ( str, -1, NULL ) == TRUE );
TASSERT ( g_utf8_collate ( str, "Valid utf8 until <20>( we continue here" ) == 0 );
g_free ( str );
}
{
TASSERT ( utf8_strncmp ( "aapno", "aap€",3) == 0 );
TASSERT ( utf8_strncmp ( "aapno", "aap€",4) != 0 );
TASSERT ( utf8_strncmp ( "aapno", "a",4) != 0 );
TASSERT ( utf8_strncmp ( "a", "aap€",4) != 0 );
// char in[] = "Valid utf8 until \xc3\x28 we continue here";
// TASSERT ( utf8_strncmp ( in, "Valid", 3 ) == 0);
}
{
TASSERTL ( rofi_scorer_fuzzy_evaluate ("aap noot mies", 12 , "aap noot mies", 12), -605);
TASSERTL ( rofi_scorer_fuzzy_evaluate ("anm", 3, "aap noot mies", 12), -155);
TASSERTL ( rofi_scorer_fuzzy_evaluate ("blu", 3, "aap noot mies", 12), 1073741824);
config.case_sensitive = TRUE;
TASSERTL ( rofi_scorer_fuzzy_evaluate ("Anm", 3, "aap noot mies", 12), 1073741754);
config.case_sensitive = FALSE;
TASSERTL ( rofi_scorer_fuzzy_evaluate ("Anm", 3, "aap noot mies", 12), -155);
TASSERTL ( rofi_scorer_fuzzy_evaluate ("aap noot mies", 12,"Anm", 3 ), 1073741824);
}
char *a;
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", "{terminal}", "rofi-sensible-terminal", NULL);
printf("%s\n",a);
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -t some title blub -e aap") == 0);
g_free(a);
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{terminal}", "rofi-sensible-terminal", NULL);
printf("%s\n",a);
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
g_free(a);
a = helper_string_replace_if_exists ( "{name} [<span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{category}", "Desktop app", "{terminal}", "rofi-sensible-terminal", NULL );
printf("%s\n",a);
TASSERT ( g_utf8_collate ( a, "Librecad <span weight='light' size='small'><i>(Desktop app)</i></span>") == 0);
g_free(a);
a = helper_string_replace_if_exists ( "{name}[ <span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{terminal}", "rofi-sensible-terminal", NULL );
TASSERT ( g_utf8_collate ( a, "Librecad") == 0);
g_free(a);
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", "{terminal}", "rofi-sensible-terminal", NULL);
printf("%s\n",a);
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal some title blub -e aap") == 0);
g_free(a);
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}",
"{cmd}", "aap",
"{title}", NULL,
"{terminal}", "rofi-sensible-terminal",
NULL);
printf("%s\n",a);
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
g_free(a);
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
int main(int argc, char **argv) {
cmd_set_arguments(argc, argv);
if (setlocale(LC_ALL, "") == NULL) {
fprintf(stderr, "Failed to set locale.\n");
return EXIT_FAILURE;
}
/**
* Char function
*/
TASSERT(helper_parse_char("\\n") == '\n');
TASSERT(helper_parse_char("\\a") == '\a');
TASSERT(helper_parse_char("\\b") == '\b');
TASSERT(helper_parse_char("\\t") == '\t');
TASSERT(helper_parse_char("\\v") == '\v');
TASSERT(helper_parse_char("\\f") == '\f');
TASSERT(helper_parse_char("\\r") == '\r');
TASSERT(helper_parse_char("\\\\") == '\\');
TASSERT(helper_parse_char("\\0") == 0);
TASSERT(helper_parse_char("\\x77") == 'w');
TASSERT(helper_parse_char("\\x0A") == '\n');
/**
* tokenize
*/
TASSERT(levenshtein("aap", g_utf8_strlen("aap", -1), "aap",
g_utf8_strlen("aap", -1)) == 0);
TASSERT(levenshtein("aap", g_utf8_strlen("aap", -1), "aap ",
g_utf8_strlen("aap ", -1)) == 1);
TASSERT(levenshtein("aap ", g_utf8_strlen("aap ", -1), "aap",
g_utf8_strlen("aap", -1)) == 1);
TASSERTE(levenshtein("aap", g_utf8_strlen("aap", -1), "aap noot",
g_utf8_strlen("aap noot", -1)),
5u);
TASSERTE(levenshtein("aap", g_utf8_strlen("aap", -1), "noot aap",
g_utf8_strlen("noot aap", -1)),
5u);
TASSERTE(levenshtein("aap", g_utf8_strlen("aap", -1), "noot aap mies",
g_utf8_strlen("noot aap mies", -1)),
10u);
TASSERTE(levenshtein("noot aap mies", g_utf8_strlen("noot aap mies", -1),
"aap", g_utf8_strlen("aap", -1)),
10u);
TASSERTE(levenshtein("otp", g_utf8_strlen("otp", -1), "noot aap",
g_utf8_strlen("noot aap", -1)),
5u);
/**
* Quick converision check.
*/
{
char *str = rofi_latin_to_utf8_strdup("\xA1\xB5", 2);
TASSERT(g_utf8_collate(str, "¡µ") == 0);
g_free(str);
}
{
char *str = rofi_force_utf8("Valid utf8", 10);
TASSERT(g_utf8_collate(str, "Valid utf8") == 0);
g_free(str);
char in[] = "Valid utf8 until \xc3\x28 we continue here";
TASSERT(g_utf8_validate(in, -1, NULL) == FALSE);
str = rofi_force_utf8(in, strlen(in));
TASSERT(g_utf8_validate(str, -1, NULL) == TRUE);
TASSERT(g_utf8_collate(str, "Valid utf8 until <20>( we continue here") == 0);
g_free(str);
}
{
TASSERT(utf8_strncmp("aapno", "aap€", 3) == 0);
TASSERT(utf8_strncmp("aapno", "aap€", 4) != 0);
TASSERT(utf8_strncmp("aapno", "a", 4) != 0);
TASSERT(utf8_strncmp("a", "aap€", 4) != 0);
// char in[] = "Valid utf8 until \xc3\x28 we continue here";
// TASSERT ( utf8_strncmp ( in, "Valid", 3 ) == 0);
}
{
TASSERTL(
rofi_scorer_fuzzy_evaluate("aap noot mies", 12, "aap noot mies", 12),
-605);
TASSERTL(rofi_scorer_fuzzy_evaluate("anm", 3, "aap noot mies", 12), -155);
TASSERTL(rofi_scorer_fuzzy_evaluate("blu", 3, "aap noot mies", 12),
1073741824);
config.case_sensitive = TRUE;
TASSERTL(rofi_scorer_fuzzy_evaluate("Anm", 3, "aap noot mies", 12),
1073741754);
config.case_sensitive = FALSE;
TASSERTL(rofi_scorer_fuzzy_evaluate("Anm", 3, "aap noot mies", 12), -155);
TASSERTL(rofi_scorer_fuzzy_evaluate("aap noot mies", 12, "Anm", 3),
1073741824);
}
char *a;
a = helper_string_replace_if_exists(
"{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}",
"some title", "{terminal}", "rofi-sensible-terminal", NULL);
printf("%s\n", a);
TASSERT(g_utf8_collate(
a, "rofi-sensible-terminal -t some title blub -e aap") == 0);
g_free(a);
a = helper_string_replace_if_exists("{terminal} [-t {title} blub ]-e {cmd}",
"{cmd}", "aap", "{terminal}",
"rofi-sensible-terminal", NULL);
printf("%s\n", a);
TASSERT(g_utf8_collate(a, "rofi-sensible-terminal -e aap") == 0);
g_free(a);
a = helper_string_replace_if_exists(
"{name} [<span weight='light' size='small'><i>({category})</i></span>]",
"{name}", "Librecad", "{category}", "Desktop app", "{terminal}",
"rofi-sensible-terminal", NULL);
printf("%s\n", a);
TASSERT(g_utf8_collate(a, "Librecad <span weight='light' "
"size='small'><i>(Desktop app)</i></span>") == 0);
g_free(a);
a = helper_string_replace_if_exists(
"{name}[ <span weight='light' size='small'><i>({category})</i></span>]",
"{name}", "Librecad", "{terminal}", "rofi-sensible-terminal", NULL);
TASSERT(g_utf8_collate(a, "Librecad") == 0);
g_free(a);
a = helper_string_replace_if_exists(
"{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}",
"some title", "{terminal}", "rofi-sensible-terminal", NULL);
printf("%s\n", a);
TASSERT(g_utf8_collate(a, "rofi-sensible-terminal some title blub -e aap") ==
0);
g_free(a);
a = helper_string_replace_if_exists(
"{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", NULL,
"{terminal}", "rofi-sensible-terminal", NULL);
printf("%s\n", a);
TASSERT(g_utf8_collate(a, "rofi-sensible-terminal -e aap") == 0);
g_free(a);
}

View File

@ -25,483 +25,439 @@
*
*/
#include <assert.h>
#include <locale.h>
#include <glib.h>
#include <stdio.h>
#include <helper.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
#include "display.h"
#include "theme.h"
#include "xcb.h"
#include "xcb-internal.h"
#include "rofi-icon-fetcher.h"
#include "rofi-types.h"
#include "rofi.h"
#include "settings.h"
#include "rofi-types.h"
#include "theme.h"
#include "widgets/textbox.h"
#include "rofi-icon-fetcher.h"
#include "xcb-internal.h"
#include "xcb.h"
#include <assert.h>
#include <glib.h>
#include <helper.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
#include <check.h>
ThemeWidget *rofi_theme = NULL;
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
void rofi_clear_error_messages ( void ) {}
void rofi_clear_error_messages(void) {}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
gboolean rofi_theme_parse_string ( G_GNUC_UNUSED const char *string )
{
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
return FALSE;
}
double textbox_get_estimated_char_height ( void )
{
return 12.0;
double textbox_get_estimated_char_height(void) { return 12.0; }
void rofi_view_get_current_monitor(int *width, int *height) {
*width = 1920;
*height = 1080;
}
void rofi_view_get_current_monitor ( int *width, int *height )
{
*width = 1920;
*height = 1080;
}
double textbox_get_estimated_ch ( void )
{
return 9.0;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
}
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
fputs ( msg, stderr );
return TRUE;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
double textbox_get_estimated_ch(void) { return 9.0; }
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return TRUE;
}
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{
}
START_TEST(test_tokenizer_free )
{
helper_tokenize_free ( NULL );
}
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
START_TEST(test_tokenizer_free) { helper_tokenize_free(NULL); }
END_TEST
START_TEST ( test_tokenizer_match_normal_single_ci )
{
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
START_TEST(test_tokenizer_match_normal_single_ci) {
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
helper_tokenize_free ( tokens );
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_normal_single_cs )
{
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
START_TEST(test_tokenizer_match_normal_single_cs) {
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
helper_tokenize_free ( tokens );
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_normal_multiple_ci )
{
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_normal_multiple_ci) {
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_normal_single_ci_negate )
{
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize ( "-noot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_normal_single_ci_negate) {
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize("-noot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_normal_multiple_ci_negate )
{
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize ( "-noot aap", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , FALSE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_normal_multiple_ci_negate) {
config.matching_method = MM_NORMAL;
rofi_int_matcher **tokens = helper_tokenize("-noot aap", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_glob_single_ci )
{
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
START_TEST(test_tokenizer_match_glob_single_ci) {
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
helper_tokenize_free ( tokens );
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_glob_single_cs )
{
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_glob_single_cs) {
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_glob_multiple_ci )
{
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_glob_multiple_ci) {
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_glob_single_ci_question )
{
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize ( "n?ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , FALSE);
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_glob_single_ci_question) {
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize("n?ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_glob_single_ci_star )
{
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize ( "n*ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_glob_single_ci_star) {
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize("n*ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_glob_multiple_ci_star )
{
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize ( "n* ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , TRUE);
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_glob_multiple_ci_star) {
config.matching_method = MM_GLOB;
rofi_int_matcher **tokens = helper_tokenize("n* ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "ot nap mies"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_fuzzy_single_ci )
{
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
START_TEST(test_tokenizer_match_fuzzy_single_ci) {
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
helper_tokenize_free ( tokens );
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_fuzzy_single_cs )
{
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
START_TEST(test_tokenizer_match_fuzzy_single_cs) {
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
helper_tokenize_free ( tokens );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_fuzzy_multiple_ci )
{
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_fuzzy_multiple_ci) {
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
tokens = helper_tokenize ( "n ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
helper_tokenize_free ( tokens );
tokens = helper_tokenize("n ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_fuzzy_single_ci_split )
{
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize ( "ont", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap nmiest") , TRUE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_fuzzy_single_ci_split) {
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize("ont", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap nmiest"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_fuzzy_multiple_ci_split )
{
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize ( "o n t", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , TRUE);
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_fuzzy_multiple_ci_split) {
config.matching_method = MM_FUZZY;
rofi_int_matcher **tokens = helper_tokenize("o n t", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "ot nap mies"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_regex_single_ci )
{
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE );
START_TEST(test_tokenizer_match_regex_single_ci) {
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize("noot", FALSE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), TRUE);
helper_tokenize_free ( tokens );
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_regex_single_cs )
{
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE );
START_TEST(test_tokenizer_match_regex_single_cs) {
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize("noot", TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE );
helper_tokenize_free ( tokens );
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap Noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "Nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noOTap mies"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_regex_multiple_ci )
{
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_regex_multiple_ci) {
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize("no ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_regex_single_ci_dq )
{
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize ( "n.?ot", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , FALSE);
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_regex_single_ci_dq) {
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize("n.?ot", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_regex_single_two_char )
{
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize ( "n[oa]{2}t", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE );
ck_assert_int_eq ( helper_token_match ( tokens, "noat miesot") , TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "noaat miesot") , FALSE);
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_regex_single_two_char) {
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize("n[oa]{2}t", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noat miesot"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "noaat miesot"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
START_TEST ( test_tokenizer_match_regex_single_two_word_till_end )
{
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize ( "^(aap|noap)\\sMie.*", FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , FALSE );
ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE);
ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , FALSE );
helper_tokenize_free ( tokens );
START_TEST(test_tokenizer_match_regex_single_two_word_till_end) {
config.matching_method = MM_REGEX;
rofi_int_matcher **tokens = helper_tokenize("^(aap|noap)\\sMie.*", FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap noot mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "aap mies"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "nooaap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "nootap mies"), FALSE);
ck_assert_int_eq(helper_token_match(tokens, "noap miesot"), TRUE);
ck_assert_int_eq(helper_token_match(tokens, "ot nap mies"), FALSE);
helper_tokenize_free(tokens);
}
END_TEST
static Suite * helper_tokenizer_suite (void)
{
Suite *s;
static Suite *helper_tokenizer_suite(void) {
Suite *s;
s = suite_create("Tokenizer");
s = suite_create("Tokenizer");
/* Core test case */
{
TCase *tc_core;
tc_core = tcase_create("Core");
tcase_add_test(tc_core, test_tokenizer_free);
suite_add_tcase(s, tc_core);
}
{
TCase *tc_normal = tcase_create ("Normal");
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci );
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_cs );
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci );
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci_negate );
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci_negate);
suite_add_tcase(s, tc_normal);
}
{
TCase *tc_glob = tcase_create ("Glob");
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci);
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_cs);
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci);
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_question);
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_star);
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci_star);
suite_add_tcase(s, tc_glob);
}
{
TCase *tc_fuzzy = tcase_create ("Fuzzy");
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_cs);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci_split);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci_split);
suite_add_tcase(s, tc_fuzzy);
}
{
TCase *tc_regex = tcase_create ("Regex");
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_cs);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci_dq);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_two_char);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_two_word_till_end);
tcase_add_test(tc_regex, test_tokenizer_match_regex_multiple_ci);
suite_add_tcase(s, tc_regex);
}
/* Core test case */
{
TCase *tc_core;
tc_core = tcase_create("Core");
tcase_add_test(tc_core, test_tokenizer_free);
suite_add_tcase(s, tc_core);
}
{
TCase *tc_normal = tcase_create("Normal");
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci);
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_cs);
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci);
tcase_add_test(tc_normal, test_tokenizer_match_normal_single_ci_negate);
tcase_add_test(tc_normal, test_tokenizer_match_normal_multiple_ci_negate);
suite_add_tcase(s, tc_normal);
}
{
TCase *tc_glob = tcase_create("Glob");
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci);
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_cs);
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci);
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_question);
tcase_add_test(tc_glob, test_tokenizer_match_glob_single_ci_star);
tcase_add_test(tc_glob, test_tokenizer_match_glob_multiple_ci_star);
suite_add_tcase(s, tc_glob);
}
{
TCase *tc_fuzzy = tcase_create("Fuzzy");
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_cs);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_single_ci_split);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci);
tcase_add_test(tc_fuzzy, test_tokenizer_match_fuzzy_multiple_ci_split);
suite_add_tcase(s, tc_fuzzy);
}
{
TCase *tc_regex = tcase_create("Regex");
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_cs);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_ci_dq);
tcase_add_test(tc_regex, test_tokenizer_match_regex_single_two_char);
tcase_add_test(tc_regex,
test_tokenizer_match_regex_single_two_word_till_end);
tcase_add_test(tc_regex, test_tokenizer_match_regex_multiple_ci);
suite_add_tcase(s, tc_regex);
}
return s;
return s;
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
return EXIT_FAILURE;
}
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
if (setlocale(LC_ALL, "") == NULL) {
fprintf(stderr, "Failed to set locale.\n");
return EXIT_FAILURE;
}
int number_failed = 0;
Suite *s;
SRunner *sr;
int number_failed = 0;
Suite *s;
SRunner *sr;
s = helper_tokenizer_suite();
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
s = helper_tokenizer_suite();
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -50,15 +50,23 @@
ThemeWidget *rofi_theme = NULL;
uint32_t rofi_icon_fetcher_query(const char *name, const int size) { return 0; }
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
const int hsize) {
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
void rofi_clear_error_messages(void) {}
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; }
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
gboolean rofi_theme_parse_string(const char *string) { return FALSE; }
gboolean rofi_theme_parse_string(G_GNUC_UNUSED const char *string) {
return FALSE;
}
double textbox_get_estimated_char_height(void) { return 16.0; }
double textbox_get_estimated_ch(void) { return 9.0; }

View File

@ -25,134 +25,116 @@
*
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <glib.h>
#include <string.h>
#include <widgets/scrollbar.h>
#include <widgets/textbox.h>
#include <widgets/icon.h>
#include <widgets/listview.h>
#include <widgets/widget.h>
#include <widgets/widget-internal.h>
#include "rofi.h"
#include "xrmoptions.h"
#include "helper.h"
#include "rofi-icon-fetcher.h"
unsigned int test =0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
}
#include "rofi.h"
#include "xrmoptions.h"
#include <assert.h>
#include <glib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <widgets/icon.h>
#include <widgets/listview.h>
#include <widgets/scrollbar.h>
#include <widgets/textbox.h>
#include <widgets/widget-internal.h>
#include <widgets/widget.h>
unsigned int test = 0;
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %3u passed (%s)\n", ++test, #a); \
}
#define TASSERTE( a, b ) { \
if ( ( a ) == ( b ) ) { \
printf ( "Test %u passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
} else { \
printf ( "Test %u failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
abort ( ); \
} \
}
#define TASSERTE(a, b) \
{ \
if ((a) == (b)) { \
printf("Test %u passed (%s == %s) (%u == %u)\n", ++test, #a, #b, a, b); \
} else { \
printf("Test %u failed (%s == %s) (%u != %u)\n", ++test, #a, #b, a, b); \
abort(); \
} \
}
ThemeWidget *rofi_configuration = NULL;
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) {
return g_strdup(file);
}
char * helper_get_theme_path ( const char *file, const char *ext )
{
return g_strdup ( file );
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
G_GNUC_UNUSED char **error) {
return FALSE;
}
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
{
return FALSE;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{}
char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
{
return NULL;
}
double textbox_get_estimated_char_height ( void )
{
return 16;
}
double textbox_get_estimated_ch ( void )
{
return 8.0;
}
void listview_set_selected ( G_GNUC_UNUSED listview *lv, G_GNUC_UNUSED unsigned int selected )
{
}
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
{
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
scrollbar * sb = scrollbar_create ( NULL, "scrollbar" );
widget_resize ( WIDGET (sb), 10, 100);
scrollbar_set_handle ( NULL, 10213);
scrollbar_set_max_value ( NULL, 10 );
scrollbar_set_handle_length ( NULL , 1000);
scrollbar_set_max_value ( sb, 10000);
TASSERTE ( sb->length, 10000u );
scrollbar_set_handle_length ( sb, 10);
TASSERTE ( sb->pos_length, 10u );
scrollbar_set_handle ( sb , 5000 );
TASSERTE ( sb->pos, 5000u );
scrollbar_set_handle ( sb , 15000 );
TASSERTE ( sb->pos, 10000u );
scrollbar_set_handle ( sb , UINT32_MAX );
TASSERTE ( sb->pos, 10000u );
scrollbar_set_handle_length ( sb, 15000);
TASSERTE ( sb->pos_length, 10000u );
scrollbar_set_handle_length ( sb, 0);
TASSERTE ( sb->pos_length, 1u );
guint cl = scrollbar_scroll_get_line ( sb, 10 );
TASSERTE ( cl, 1010u);
cl = scrollbar_scroll_get_line ( sb, 20 );
TASSERTE ( cl, 2020u);
cl = scrollbar_scroll_get_line ( sb, 0 );
TASSERTE ( cl, 0u);
cl = scrollbar_scroll_get_line ( sb, 99 );
TASSERTE ( cl, 9999u);
scrollbar_set_handle_length ( sb, 1000);
cl = scrollbar_scroll_get_line ( sb, 10 );
TASSERTE ( cl, 555u);
cl = scrollbar_scroll_get_line ( sb, 20 );
TASSERTE ( cl, 1666u);
cl = scrollbar_scroll_get_line ( sb, 0 );
TASSERTE ( cl, 0u);
cl = scrollbar_scroll_get_line ( sb, 99 );
TASSERTE ( cl, 9999u);
widget_free( WIDGET (sb ) );
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
char *rofi_expand_path(G_GNUC_UNUSED const char *path) { return NULL; }
double textbox_get_estimated_char_height(void) { return 16; }
double textbox_get_estimated_ch(void) { return 8.0; }
void listview_set_selected(G_GNUC_UNUSED listview *lv,
G_GNUC_UNUSED unsigned int selected) {}
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
G_GNUC_UNUSED int *height) {}
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
scrollbar *sb = scrollbar_create(NULL, "scrollbar");
widget_resize(WIDGET(sb), 10, 100);
scrollbar_set_handle(NULL, 10213);
scrollbar_set_max_value(NULL, 10);
scrollbar_set_handle_length(NULL, 1000);
scrollbar_set_max_value(sb, 10000);
TASSERTE(sb->length, 10000u);
scrollbar_set_handle_length(sb, 10);
TASSERTE(sb->pos_length, 10u);
scrollbar_set_handle(sb, 5000);
TASSERTE(sb->pos, 5000u);
scrollbar_set_handle(sb, 15000);
TASSERTE(sb->pos, 10000u);
scrollbar_set_handle(sb, UINT32_MAX);
TASSERTE(sb->pos, 10000u);
scrollbar_set_handle_length(sb, 15000);
TASSERTE(sb->pos_length, 10000u);
scrollbar_set_handle_length(sb, 0);
TASSERTE(sb->pos_length, 1u);
guint cl = scrollbar_scroll_get_line(sb, 10);
TASSERTE(cl, 1010u);
cl = scrollbar_scroll_get_line(sb, 20);
TASSERTE(cl, 2020u);
cl = scrollbar_scroll_get_line(sb, 0);
TASSERTE(cl, 0u);
cl = scrollbar_scroll_get_line(sb, 99);
TASSERTE(cl, 9999u);
scrollbar_set_handle_length(sb, 1000);
cl = scrollbar_scroll_get_line(sb, 10);
TASSERTE(cl, 555u);
cl = scrollbar_scroll_get_line(sb, 20);
TASSERTE(cl, 1666u);
cl = scrollbar_scroll_get_line(sb, 0);
TASSERTE(cl, 0u);
cl = scrollbar_scroll_get_line(sb, 99);
TASSERTE(cl, 9999u);
widget_free(WIDGET(sb));
}

View File

@ -25,192 +25,184 @@
*
*/
#include <unistd.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include "display.h"
#include "settings.h"
#include "xcb.h"
#include "xrmoptions.h"
#include <assert.h>
#include <cairo-xlib.h>
#include <glib.h>
#include <history.h>
#include <string.h>
#include <xcb/xcb.h>
#include <widgets/textbox.h>
#include <rofi.h>
#include <cairo-xlib.h>
#include "display.h"
#include "xcb.h"
#include "settings.h"
#include "xrmoptions.h"
#include <stdio.h>
#include <string.h>
#include <widgets/textbox.h>
#include <xcb/xcb.h>
#include "rofi-icon-fetcher.h"
static int test = 0;
static int test = 0;
unsigned int normal_window_mode = 0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
}
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %3i passed (%s)\n", ++test, #a); \
}
#include "view.h"
ThemeWidget *rofi_configuration = NULL;
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
{
return FALSE;
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
G_GNUC_UNUSED char **error) {
return FALSE;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
}
void rofi_view_queue_redraw ()
{
}
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
{
}
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
fputs ( msg, stderr );
return FALSE;
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
void rofi_view_queue_redraw() {}
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
G_GNUC_UNUSED int *height) {}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return FALSE;
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
}
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
cairo_surface_t *surf = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, 100, 100 );
cairo_t *draw = cairo_create ( surf );
PangoContext *p = pango_cairo_create_context ( draw );
textbox_setup();
textbox_set_pango_context ( "default", p );
textbox *box = textbox_create ( NULL, WIDGET_TYPE_TEXTBOX_TEXT, "textbox", TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "test",0,0 );
TASSERT ( box != NULL );
textbox_keybinding ( box, MOVE_END );
TASSERT ( box->cursor == 4 );
textbox_cursor ( box, -1 );
TASSERT ( box->cursor == 0 );
textbox_cursor ( box, 8 );
TASSERT ( box->cursor == 4 );
textbox_cursor ( box, 2 );
TASSERT ( box->cursor == 2 );
textbox_insert ( box, 3, "bo", 2 );
TASSERT ( strcmp ( box->text, "tesbot" ) == 0 );
textbox_keybinding ( box, MOVE_END );
TASSERT ( box->cursor == 6 );
TASSERT ( widget_get_width ( WIDGET ( box ) ) > 0 );
TASSERT ( textbox_get_height ( box ) > 0 );
TASSERT ( widget_get_width ( WIDGET ( box ) ) >= textbox_get_font_width ( box ) );
TASSERT ( textbox_get_height ( box ) >= textbox_get_font_height ( box ) );
TASSERT ( textbox_get_estimated_char_width ( ) > 0 );
textbox_keybinding ( box, REMOVE_CHAR_BACK );
TASSERT ( strcmp ( box->text, "tesbo" ) == 0 );
TASSERT ( box->cursor == 5 );
textbox_keybinding ( box, MOVE_CHAR_BACK );
TASSERT ( box->cursor == 4 );
textbox_keybinding ( box, REMOVE_CHAR_FORWARD );
TASSERT ( strcmp ( box->text, "tesb" ) == 0 );
textbox_keybinding ( box, MOVE_CHAR_BACK );
TASSERT ( box->cursor == 3 );
textbox_keybinding ( box, MOVE_CHAR_FORWARD );
TASSERT ( box->cursor == 4 );
textbox_keybinding ( box, MOVE_CHAR_FORWARD );
TASSERT ( box->cursor == 4 );
// Cursor after delete section.
textbox_delete ( box, 0, 1 );
TASSERT ( strcmp ( box->text, "esb" ) == 0 );
TASSERT ( box->cursor == 3 );
// Cursor before delete.
textbox_text ( box, "aap noot mies" );
TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
textbox_cursor ( box, 3 );
TASSERT ( box->cursor == 3 );
textbox_delete ( box, 3, 6 );
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
TASSERT ( box->cursor == 3 );
// Cursor within delete
textbox_text ( box, "aap noot mies" );
TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
textbox_cursor ( box, 5 );
TASSERT ( box->cursor == 5 );
textbox_delete ( box, 3, 6 );
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
TASSERT ( box->cursor == 3 );
// Cursor after delete.
textbox_text ( box, "aap noot mies" );
TASSERT ( strcmp ( box->text, "aap noot mies" ) == 0 );
textbox_cursor ( box, 11 );
TASSERT ( box->cursor == 11 );
textbox_delete ( box, 3, 6 );
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
TASSERT ( box->cursor == 5 );
textbox_text ( box, "aap noot mies" );
textbox_cursor ( box, 8 );
textbox_keybinding ( box, REMOVE_WORD_BACK );
TASSERT ( box->cursor == 4 );
TASSERT ( strcmp ( box->text, "aap mies" ) == 0 );
textbox_keybinding ( box, REMOVE_TO_EOL );
TASSERT ( box->cursor == 4 );
TASSERT ( strcmp ( box->text, "aap " ) == 0 );
textbox_text ( box, "aap noot mies" );
textbox_cursor ( box, 8 );
textbox_keybinding ( box, REMOVE_WORD_FORWARD );
TASSERT ( strcmp ( box->text, "aap noot" ) == 0 );
textbox_keybinding ( box, MOVE_FRONT );
TASSERT ( box->cursor == 0 );
textbox_keybinding ( box, CLEAR_LINE );
TASSERT ( strcmp ( box->text, "" ) == 0 );
textbox_text ( box, "aap noot mies" );
textbox_keybinding ( box, MOVE_END );
textbox_keybinding ( box, MOVE_WORD_BACK );
TASSERT ( box->cursor == 9 );
textbox_keybinding ( box, MOVE_WORD_BACK );
TASSERT ( box->cursor == 4 );
textbox_keybinding ( box, REMOVE_TO_SOL );
TASSERT ( strcmp ( box->text, "noot mies" ) == 0 );
TASSERT ( box->cursor == 0 );
textbox_font ( box, HIGHLIGHT );
//textbox_draw ( box, draw );
widget_move ( WIDGET ( box ), 12, 13 );
TASSERT ( box->widget.x == 12 );
TASSERT ( box->widget.y == 13 );
widget_free ( WIDGET ( box ) );
textbox_cleanup ( );
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
cairo_surface_t *surf =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);
cairo_t *draw = cairo_create(surf);
PangoContext *p = pango_cairo_create_context(draw);
textbox_setup();
textbox_set_pango_context("default", p);
textbox *box = textbox_create(NULL, WIDGET_TYPE_TEXTBOX_TEXT, "textbox",
TB_EDITABLE | TB_AUTOWIDTH | TB_AUTOHEIGHT,
NORMAL, "test", 0, 0);
TASSERT(box != NULL);
textbox_keybinding(box, MOVE_END);
TASSERT(box->cursor == 4);
textbox_cursor(box, -1);
TASSERT(box->cursor == 0);
textbox_cursor(box, 8);
TASSERT(box->cursor == 4);
textbox_cursor(box, 2);
TASSERT(box->cursor == 2);
textbox_insert(box, 3, "bo", 2);
TASSERT(strcmp(box->text, "tesbot") == 0);
textbox_keybinding(box, MOVE_END);
TASSERT(box->cursor == 6);
TASSERT(widget_get_width(WIDGET(box)) > 0);
TASSERT(textbox_get_height(box) > 0);
TASSERT(widget_get_width(WIDGET(box)) >= textbox_get_font_width(box));
TASSERT(textbox_get_height(box) >= textbox_get_font_height(box));
TASSERT(textbox_get_estimated_char_width() > 0);
textbox_keybinding(box, REMOVE_CHAR_BACK);
TASSERT(strcmp(box->text, "tesbo") == 0);
TASSERT(box->cursor == 5);
textbox_keybinding(box, MOVE_CHAR_BACK);
TASSERT(box->cursor == 4);
textbox_keybinding(box, REMOVE_CHAR_FORWARD);
TASSERT(strcmp(box->text, "tesb") == 0);
textbox_keybinding(box, MOVE_CHAR_BACK);
TASSERT(box->cursor == 3);
textbox_keybinding(box, MOVE_CHAR_FORWARD);
TASSERT(box->cursor == 4);
textbox_keybinding(box, MOVE_CHAR_FORWARD);
TASSERT(box->cursor == 4);
// Cursor after delete section.
textbox_delete(box, 0, 1);
TASSERT(strcmp(box->text, "esb") == 0);
TASSERT(box->cursor == 3);
// Cursor before delete.
textbox_text(box, "aap noot mies");
TASSERT(strcmp(box->text, "aap noot mies") == 0);
textbox_cursor(box, 3);
TASSERT(box->cursor == 3);
textbox_delete(box, 3, 6);
TASSERT(strcmp(box->text, "aapmies") == 0);
TASSERT(box->cursor == 3);
// Cursor within delete
textbox_text(box, "aap noot mies");
TASSERT(strcmp(box->text, "aap noot mies") == 0);
textbox_cursor(box, 5);
TASSERT(box->cursor == 5);
textbox_delete(box, 3, 6);
TASSERT(strcmp(box->text, "aapmies") == 0);
TASSERT(box->cursor == 3);
// Cursor after delete.
textbox_text(box, "aap noot mies");
TASSERT(strcmp(box->text, "aap noot mies") == 0);
textbox_cursor(box, 11);
TASSERT(box->cursor == 11);
textbox_delete(box, 3, 6);
TASSERT(strcmp(box->text, "aapmies") == 0);
TASSERT(box->cursor == 5);
textbox_text(box, "aap noot mies");
textbox_cursor(box, 8);
textbox_keybinding(box, REMOVE_WORD_BACK);
TASSERT(box->cursor == 4);
TASSERT(strcmp(box->text, "aap mies") == 0);
textbox_keybinding(box, REMOVE_TO_EOL);
TASSERT(box->cursor == 4);
TASSERT(strcmp(box->text, "aap ") == 0);
textbox_text(box, "aap noot mies");
textbox_cursor(box, 8);
textbox_keybinding(box, REMOVE_WORD_FORWARD);
TASSERT(strcmp(box->text, "aap noot") == 0);
textbox_keybinding(box, MOVE_FRONT);
TASSERT(box->cursor == 0);
textbox_keybinding(box, CLEAR_LINE);
TASSERT(strcmp(box->text, "") == 0);
textbox_text(box, "aap noot mies");
textbox_keybinding(box, MOVE_END);
textbox_keybinding(box, MOVE_WORD_BACK);
TASSERT(box->cursor == 9);
textbox_keybinding(box, MOVE_WORD_BACK);
TASSERT(box->cursor == 4);
textbox_keybinding(box, REMOVE_TO_SOL);
TASSERT(strcmp(box->text, "noot mies") == 0);
TASSERT(box->cursor == 0);
textbox_font(box, HIGHLIGHT);
// textbox_draw ( box, draw );
widget_move(WIDGET(box), 12, 13);
TASSERT(box->widget.x == 12);
TASSERT(box->widget.y == 13);
widget_free(WIDGET(box));
textbox_cleanup();
}

View File

@ -47,14 +47,21 @@
#define REAL_COMPARE_DELTA 0.001
uint32_t rofi_icon_fetcher_query(const char *name, const int size) { return 0; }
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
void rofi_clear_error_messages(void) {}
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
const int hsize) {
uint32_t
rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; }
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);

View File

@ -25,200 +25,190 @@
*
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include "display.h"
#include "rofi-icon-fetcher.h"
#include "rofi.h"
#include "xcb.h"
#include "xrmoptions.h"
#include <assert.h>
#include <glib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <widgets/widget.h>
#include <unistd.h>
#include <widgets/widget-internal.h>
#include "rofi.h"
#include "display.h"
#include "xrmoptions.h"
#include "xcb.h"
#include "rofi-icon-fetcher.h"
unsigned int test =0;
#define TASSERT( a ) { \
assert ( a ); \
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
}
#include <widgets/widget.h>
unsigned int test = 0;
#define TASSERT(a) \
{ \
assert(a); \
printf("Test %3u passed (%s)\n", ++test, #a); \
}
ThemeWidget *rofi_configuration = NULL;
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
{
return 0;
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
{
return 0;
uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
{
return NULL;
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
{
return FALSE;
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
G_GNUC_UNUSED char **error) {
return FALSE;
}
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
{
}
void rofi_view_queue_redraw ( void )
{
}
int monitor_active ( G_GNUC_UNUSED workarea *mon )
{
return 0;
}
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
{
}
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
{
fputs ( msg, stderr );
return FALSE;
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
void rofi_view_queue_redraw(void) {}
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,
G_GNUC_UNUSED int *height) {}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return FALSE;
}
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{
}
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
// box 20 by 40
widget *wid= (widget*)g_malloc0(sizeof(widget));
widget_resize ( wid, 20, 40);
widget_move ( wid, 10, 10);
// Getter, setter x pos
//
TASSERT ( widget_get_x_pos ( wid ) == 10 );
TASSERT ( widget_get_y_pos ( wid ) == 10 );
// Left of box
TASSERT ( widget_intersect ( wid, 0, 0) == 0 );
TASSERT ( widget_intersect ( wid, 0, 10) == 0 );
TASSERT ( widget_intersect ( wid, 0, 25) == 0 );
TASSERT ( widget_intersect ( wid, 0, 40) == 0 );
TASSERT ( widget_intersect ( wid, 0, 50) == 0 );
TASSERT ( widget_intersect ( wid, 9, 0) == 0 );
TASSERT ( widget_intersect ( wid, 9, 10) == 0 );
TASSERT ( widget_intersect ( wid, 9, 25) == 0 );
TASSERT ( widget_intersect ( wid, 9, 40) == 0 );
TASSERT ( widget_intersect ( wid, 9, 50) == 0 );
TASSERT ( widget_intersect ( wid, 10, 0) == 0 );
TASSERT ( widget_intersect ( wid, 10, 10) == 1 );
TASSERT ( widget_intersect ( wid, 10, 25) == 1 );
TASSERT ( widget_intersect ( wid, 10, 40) == 1 );
TASSERT ( widget_intersect ( wid, 10, 50) == 0 );
// Middle
TASSERT ( widget_intersect ( wid, 25, 0) == 0 );
TASSERT ( widget_intersect ( wid, 25, 10) == 1 );
TASSERT ( widget_intersect ( wid, 25, 25) == 1 );
TASSERT ( widget_intersect ( wid, 25, 40) == 1 );
TASSERT ( widget_intersect ( wid, 25, 50) == 0 );
// Right
TASSERT ( widget_intersect ( wid, 29, 0) == 0 );
TASSERT ( widget_intersect ( wid, 29, 10) == 1 );
TASSERT ( widget_intersect ( wid, 29, 25) == 1 );
TASSERT ( widget_intersect ( wid, 29, 40) == 1 );
TASSERT ( widget_intersect ( wid, 29, 50) == 0 );
TASSERT ( widget_intersect ( wid, 30, 0) == 0 );
TASSERT ( widget_intersect ( wid, 30, 10) == 0 );
TASSERT ( widget_intersect ( wid, 30, 25) == 0 );
TASSERT ( widget_intersect ( wid, 30, 40) == 0 );
TASSERT ( widget_intersect ( wid, 30, 50) == 0 );
widget_move ( wid, 30, 30);
// Left of box
TASSERT ( widget_intersect ( wid, 10, 20) == 0 );
TASSERT ( widget_intersect ( wid, 10, 30) == 0 );
TASSERT ( widget_intersect ( wid, 10, 45) == 0 );
TASSERT ( widget_intersect ( wid, 10, 60) == 0 );
TASSERT ( widget_intersect ( wid, 10, 70) == 0 );
TASSERT ( widget_intersect ( wid, 19, 20) == 0 );
TASSERT ( widget_intersect ( wid, 19, 30) == 0 );
TASSERT ( widget_intersect ( wid, 19, 45) == 0 );
TASSERT ( widget_intersect ( wid, 19, 60) == 0 );
TASSERT ( widget_intersect ( wid, 19, 70) == 0 );
TASSERT ( widget_intersect ( wid, 30, 20) == 0 );
TASSERT ( widget_intersect ( wid, 30, 30) == 1 );
TASSERT ( widget_intersect ( wid, 30, 45) == 1 );
TASSERT ( widget_intersect ( wid, 30, 60) == 1 );
TASSERT ( widget_intersect ( wid, 30, 70) == 0 );
// Middle
TASSERT ( widget_intersect ( wid, 20+25,20+ 0) == 0 );
TASSERT ( widget_intersect ( wid, 20+25,20+ 10) == 1 );
TASSERT ( widget_intersect ( wid, 20+25,20+ 25) == 1 );
TASSERT ( widget_intersect ( wid, 20+25,20+ 40) == 1 );
TASSERT ( widget_intersect ( wid, 20+25,20+ 50) == 0 );
TASSERT ( widget_intersect ( wid, 20+29, 20+0) == 0 );
TASSERT ( widget_intersect ( wid, 20+29, 20+10) == 1 );
TASSERT ( widget_intersect ( wid, 20+29, 20+25) == 1 );
TASSERT ( widget_intersect ( wid, 20+29, 20+40) == 1 );
TASSERT ( widget_intersect ( wid, 20+29, 20+50) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+0) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+10) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+25) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 );
// Right
TASSERT ( widget_intersect ( wid, 20+29, 20+0) == 0 );
TASSERT ( widget_intersect ( wid, 20+29, 20+10) == 1 );
TASSERT ( widget_intersect ( wid, 20+29, 20+25) == 1 );
TASSERT ( widget_intersect ( wid, 20+29, 20+40) == 1 );
TASSERT ( widget_intersect ( wid, 20+29, 20+50) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+0) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+10) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+25) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 );
TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 );
TASSERT ( widget_intersect ( wid, -100, -100) == 0);
TASSERT ( widget_intersect ( wid, INT_MIN, INT_MIN) == 0);
TASSERT ( widget_intersect ( wid, INT_MAX, INT_MAX) == 0);
// Other wrappers.
TASSERT ( widget_get_height ( wid ) == wid->h);
TASSERT ( widget_get_width ( wid ) == wid->w);
TASSERT ( widget_enabled ( wid ) == FALSE );
widget_enable ( wid );
TASSERT ( widget_enabled ( wid ) == TRUE );
widget_disable ( wid );
TASSERT ( widget_enabled ( wid ) == FALSE );
// Null pointer tests.
TASSERT ( widget_intersect ( NULL, 0, 0) == 0 );
widget_move ( NULL, 0, 0 );
TASSERT ( widget_get_height ( NULL ) == 0);
TASSERT ( widget_get_width ( NULL ) == 0);
TASSERT ( widget_enabled ( NULL ) == 0);
widget_disable ( NULL );
widget_enable ( NULL );
widget_draw ( NULL, NULL );
widget_free ( NULL );
widget_resize ( NULL, 0, 0);
widget_update ( NULL );
widget_queue_redraw ( NULL );
TASSERT (widget_need_redraw ( NULL ) == FALSE);
widget_trigger_action ( NULL, 0, 0, 0 );
widget_set_trigger_action_handler ( NULL, NULL, NULL );
g_free(wid);
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
// box 20 by 40
widget *wid = (widget *)g_malloc0(sizeof(widget));
widget_resize(wid, 20, 40);
widget_move(wid, 10, 10);
// Getter, setter x pos
//
TASSERT(widget_get_x_pos(wid) == 10);
TASSERT(widget_get_y_pos(wid) == 10);
// Left of box
TASSERT(widget_intersect(wid, 0, 0) == 0);
TASSERT(widget_intersect(wid, 0, 10) == 0);
TASSERT(widget_intersect(wid, 0, 25) == 0);
TASSERT(widget_intersect(wid, 0, 40) == 0);
TASSERT(widget_intersect(wid, 0, 50) == 0);
TASSERT(widget_intersect(wid, 9, 0) == 0);
TASSERT(widget_intersect(wid, 9, 10) == 0);
TASSERT(widget_intersect(wid, 9, 25) == 0);
TASSERT(widget_intersect(wid, 9, 40) == 0);
TASSERT(widget_intersect(wid, 9, 50) == 0);
TASSERT(widget_intersect(wid, 10, 0) == 0);
TASSERT(widget_intersect(wid, 10, 10) == 1);
TASSERT(widget_intersect(wid, 10, 25) == 1);
TASSERT(widget_intersect(wid, 10, 40) == 1);
TASSERT(widget_intersect(wid, 10, 50) == 0);
// Middle
TASSERT(widget_intersect(wid, 25, 0) == 0);
TASSERT(widget_intersect(wid, 25, 10) == 1);
TASSERT(widget_intersect(wid, 25, 25) == 1);
TASSERT(widget_intersect(wid, 25, 40) == 1);
TASSERT(widget_intersect(wid, 25, 50) == 0);
// Right
TASSERT(widget_intersect(wid, 29, 0) == 0);
TASSERT(widget_intersect(wid, 29, 10) == 1);
TASSERT(widget_intersect(wid, 29, 25) == 1);
TASSERT(widget_intersect(wid, 29, 40) == 1);
TASSERT(widget_intersect(wid, 29, 50) == 0);
TASSERT(widget_intersect(wid, 30, 0) == 0);
TASSERT(widget_intersect(wid, 30, 10) == 0);
TASSERT(widget_intersect(wid, 30, 25) == 0);
TASSERT(widget_intersect(wid, 30, 40) == 0);
TASSERT(widget_intersect(wid, 30, 50) == 0);
widget_move(wid, 30, 30);
// Left of box
TASSERT(widget_intersect(wid, 10, 20) == 0);
TASSERT(widget_intersect(wid, 10, 30) == 0);
TASSERT(widget_intersect(wid, 10, 45) == 0);
TASSERT(widget_intersect(wid, 10, 60) == 0);
TASSERT(widget_intersect(wid, 10, 70) == 0);
TASSERT(widget_intersect(wid, 19, 20) == 0);
TASSERT(widget_intersect(wid, 19, 30) == 0);
TASSERT(widget_intersect(wid, 19, 45) == 0);
TASSERT(widget_intersect(wid, 19, 60) == 0);
TASSERT(widget_intersect(wid, 19, 70) == 0);
TASSERT(widget_intersect(wid, 30, 20) == 0);
TASSERT(widget_intersect(wid, 30, 30) == 1);
TASSERT(widget_intersect(wid, 30, 45) == 1);
TASSERT(widget_intersect(wid, 30, 60) == 1);
TASSERT(widget_intersect(wid, 30, 70) == 0);
// Middle
TASSERT(widget_intersect(wid, 20 + 25, 20 + 0) == 0);
TASSERT(widget_intersect(wid, 20 + 25, 20 + 10) == 1);
TASSERT(widget_intersect(wid, 20 + 25, 20 + 25) == 1);
TASSERT(widget_intersect(wid, 20 + 25, 20 + 40) == 1);
TASSERT(widget_intersect(wid, 20 + 25, 20 + 50) == 0);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 0) == 0);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 10) == 1);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 25) == 1);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 40) == 1);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 50) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 0) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 10) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 25) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 40) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 50) == 0);
// Right
TASSERT(widget_intersect(wid, 20 + 29, 20 + 0) == 0);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 10) == 1);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 25) == 1);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 40) == 1);
TASSERT(widget_intersect(wid, 20 + 29, 20 + 50) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 0) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 10) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 25) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 40) == 0);
TASSERT(widget_intersect(wid, 20 + 30, 20 + 50) == 0);
TASSERT(widget_intersect(wid, -100, -100) == 0);
TASSERT(widget_intersect(wid, INT_MIN, INT_MIN) == 0);
TASSERT(widget_intersect(wid, INT_MAX, INT_MAX) == 0);
// Other wrappers.
TASSERT(widget_get_height(wid) == wid->h);
TASSERT(widget_get_width(wid) == wid->w);
TASSERT(widget_enabled(wid) == FALSE);
widget_enable(wid);
TASSERT(widget_enabled(wid) == TRUE);
widget_disable(wid);
TASSERT(widget_enabled(wid) == FALSE);
// Null pointer tests.
TASSERT(widget_intersect(NULL, 0, 0) == 0);
widget_move(NULL, 0, 0);
TASSERT(widget_get_height(NULL) == 0);
TASSERT(widget_get_width(NULL) == 0);
TASSERT(widget_enabled(NULL) == 0);
widget_disable(NULL);
widget_enable(NULL);
widget_draw(NULL, NULL);
widget_free(NULL);
widget_resize(NULL, 0, 0);
widget_update(NULL);
widget_queue_redraw(NULL);
TASSERT(widget_need_redraw(NULL) == FALSE);
widget_trigger_action(NULL, 0, 0, 0);
widget_set_trigger_action_handler(NULL, NULL, NULL);
g_free(wid);
}