diff --git a/Makefile.am b/Makefile.am index 13e1a902..71cf53c4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -80,15 +80,15 @@ SOURCES=\ source/xrmoptions.c\ source/xcb.c\ source/css-colors.c\ - source/dialogs/run.c\ - source/dialogs/ssh.c\ - source/dialogs/drun.c\ - source/dialogs/dmenu.c\ - source/dialogs/combi.c\ - source/dialogs/window.c\ - source/dialogs/script.c\ - source/dialogs/help-keys.c\ - source/dialogs/filebrowser.c\ + source/modes/run.c\ + source/modes/ssh.c\ + source/modes/drun.c\ + source/modes/dmenu.c\ + source/modes/combi.c\ + source/modes/window.c\ + source/modes/script.c\ + source/modes/help-keys.c\ + source/modes/filebrowser.c\ include/display.h\ include/xcb.h\ include/xcb-internal.h\ @@ -116,17 +116,17 @@ SOURCES=\ include/widgets/listview.h\ include/widgets/scrollbar.h\ include/xrmoptions.h\ - include/dialogs/ssh.h\ - include/dialogs/run.h\ - include/dialogs/drun.h\ - include/dialogs/dmenu.h\ - include/dialogs/combi.h\ - include/dialogs/script.h\ - include/dialogs/window.h\ - include/dialogs/dialogs.h\ - include/dialogs/help-keys.h\ - include/dialogs/filebrowser.h\ - include/dialogs/dmenuscriptshared.h\ + include/modes/ssh.h\ + include/modes/run.h\ + include/modes/drun.h\ + include/modes/dmenu.h\ + include/modes/combi.h\ + include/modes/script.h\ + include/modes/window.h\ + include/modes/modes.h\ + include/modes/help-keys.h\ + include/modes/filebrowser.h\ + include/modes/dmenuscriptshared.h\ resources/resources.c\ resources/resources.h @@ -534,7 +534,7 @@ mode_test_LDADD=$(textbox_test_LDADD) $(check_LIBS) mode_test_SOURCES=\ config/config.c\ test/mode-test.c\ - source/dialogs/help-keys.c\ + source/modes/help-keys.c\ source/helper.c\ source/theme.c\ source/css-colors.c\ diff --git a/doc/rofi.1 b/doc/rofi.1 index 4db14fb9..f5ba483b 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1452,19 +1452,19 @@ View: The main window view functions. .IP \(bu 2 Widgets.Box: The Box widget. .IP \(bu 2 -Dialogs.DMenu: The dmenu mode. +Modes.DMenu: The dmenu mode. .IP \(bu 2 -Dialogs.Run: The run mode. +Modes.Run: The run mode. .IP \(bu 2 -Dialogs.DRun: The desktop file run mode. +Modes.DRun: The desktop file run mode. .IP \(bu 2 -Dialogs.Window: The window mode. +Modes.Window: The window mode. .IP \(bu 2 -Dialogs.Script: The script mode. +Modes.Script: The script mode. .IP \(bu 2 -Dialogs.Combi: The script mode. +Modes.Combi: The script mode. .IP \(bu 2 -Dialogs.Ssh: The ssh mode. +Modes.Ssh: The ssh mode. .IP \(bu 2 Rofi: The main application. .IP \(bu 2 diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 08ebfbf0..979a501e 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -919,13 +919,13 @@ environment variable. At the time of creation of this page, the following debug * X11Helper: The X11 Helper functions. * View: The main window view functions. * Widgets.Box: The Box widget. - * Dialogs.DMenu: The dmenu mode. - * Dialogs.Run: The run mode. - * Dialogs.DRun: The desktop file run mode. - * Dialogs.Window: The window mode. - * Dialogs.Script: The script mode. - * Dialogs.Combi: The script mode. - * Dialogs.Ssh: The ssh mode. + * Modes.DMenu: The dmenu mode. + * Modes.Run: The run mode. + * Modes.DRun: The desktop file run mode. + * Modes.Window: The window mode. + * Modes.Script: The script mode. + * Modes.Combi: The script mode. + * Modes.Ssh: The ssh mode. * Rofi: The main application. * Timings: Get timing output. * Theme: Theme engine debug output. (warning lots of output). diff --git a/include/dialogs/combi.h b/include/modes/combi.h similarity index 100% rename from include/dialogs/combi.h rename to include/modes/combi.h diff --git a/include/dialogs/dmenu.h b/include/modes/dmenu.h similarity index 100% rename from include/dialogs/dmenu.h rename to include/modes/dmenu.h diff --git a/include/dialogs/dmenuscriptshared.h b/include/modes/dmenuscriptshared.h similarity index 100% rename from include/dialogs/dmenuscriptshared.h rename to include/modes/dmenuscriptshared.h diff --git a/include/dialogs/drun.h b/include/modes/drun.h similarity index 100% rename from include/dialogs/drun.h rename to include/modes/drun.h diff --git a/include/dialogs/filebrowser.h b/include/modes/filebrowser.h similarity index 100% rename from include/dialogs/filebrowser.h rename to include/modes/filebrowser.h diff --git a/include/dialogs/help-keys.h b/include/modes/help-keys.h similarity index 100% rename from include/dialogs/help-keys.h rename to include/modes/help-keys.h diff --git a/include/dialogs/dialogs.h b/include/modes/modes.h similarity index 76% rename from include/dialogs/dialogs.h rename to include/modes/modes.h index 09734f6b..72b8b6ee 100644 --- a/include/dialogs/dialogs.h +++ b/include/modes/modes.h @@ -25,23 +25,23 @@ * */ -#ifndef ROFI_DIALOGS_DIALOGS_H -#define ROFI_DIALOGS_DIALOGS_H +#ifndef ROFI_MODES_MODES_H +#define ROFI_MODES_MODES_H /** * @defgroup MODES Modes */ /** - * List of available dialogs. + * List of available modes. */ -#include "dialogs/combi.h" -#include "dialogs/dmenu.h" -#include "dialogs/drun.h" -#include "dialogs/filebrowser.h" -#include "dialogs/help-keys.h" -#include "dialogs/run.h" -#include "dialogs/script.h" -#include "dialogs/ssh.h" -#include "dialogs/window.h" -#endif // ROFI_DIALOGS_DIALOGS_H +#include "modes/combi.h" +#include "modes/dmenu.h" +#include "modes/drun.h" +#include "modes/filebrowser.h" +#include "modes/help-keys.h" +#include "modes/run.h" +#include "modes/script.h" +#include "modes/ssh.h" +#include "modes/window.h" +#endif // ROFI_MODES_MODES_H diff --git a/include/dialogs/run.h b/include/modes/run.h similarity index 100% rename from include/dialogs/run.h rename to include/modes/run.h diff --git a/include/dialogs/script.h b/include/modes/script.h similarity index 100% rename from include/dialogs/script.h rename to include/modes/script.h diff --git a/include/dialogs/ssh.h b/include/modes/ssh.h similarity index 100% rename from include/dialogs/ssh.h rename to include/modes/ssh.h diff --git a/include/dialogs/window.h b/include/modes/window.h similarity index 100% rename from include/dialogs/window.h rename to include/modes/window.h diff --git a/meson.build b/meson.build index 9c960d8c..40ee135d 100644 --- a/meson.build +++ b/meson.build @@ -159,15 +159,15 @@ rofi_sources = files( 'source/xrmoptions.c', 'source/rofi-types.c', 'source/xcb.c', - 'source/dialogs/run.c', - 'source/dialogs/ssh.c', - 'source/dialogs/drun.c', - 'source/dialogs/dmenu.c', - 'source/dialogs/combi.c', - 'source/dialogs/window.c', - 'source/dialogs/script.c', - 'source/dialogs/help-keys.c', - 'source/dialogs/filebrowser.c', + 'source/modes/run.c', + 'source/modes/ssh.c', + 'source/modes/drun.c', + 'source/modes/dmenu.c', + 'source/modes/combi.c', + 'source/modes/window.c', + 'source/modes/script.c', + 'source/modes/help-keys.c', + 'source/modes/filebrowser.c', 'include/display.h', 'include/xcb.h', 'include/xcb-internal.h', @@ -195,17 +195,17 @@ rofi_sources = files( 'include/widgets/listview.h', 'include/widgets/scrollbar.h', 'include/xrmoptions.h', - 'include/dialogs/ssh.h', - 'include/dialogs/run.h', - 'include/dialogs/drun.h', - 'include/dialogs/dmenu.h', - 'include/dialogs/combi.h', - 'include/dialogs/script.h', - 'include/dialogs/window.h', - 'include/dialogs/dialogs.h', - 'include/dialogs/help-keys.h', - 'include/dialogs/filebrowser.h', - 'include/dialogs/dmenuscriptshared.h', + 'include/modes/ssh.h', + 'include/modes/run.h', + 'include/modes/drun.h', + 'include/modes/dmenu.h', + 'include/modes/combi.h', + 'include/modes/script.h', + 'include/modes/window.h', + 'include/modes/modes.h', + 'include/modes/help-keys.h', + 'include/modes/filebrowser.h', + 'include/modes/dmenuscriptshared.h', ) theme_lexer_sources = files('lexer/theme-lexer.l') theme_parser_sources = files('lexer/theme-parser.y') @@ -452,7 +452,7 @@ if check.found() ], objects: rofi.extract_objects([ 'config/config.c', - 'source/dialogs/help-keys.c', + 'source/modes/help-keys.c', 'source/helper.c', 'source/theme.c', 'source/css-colors.c', diff --git a/source/dialogs/combi.c b/source/modes/combi.c similarity index 99% rename from source/dialogs/combi.c rename to source/modes/combi.c index 27fc4a3a..cc60c33c 100644 --- a/source/dialogs/combi.c +++ b/source/modes/combi.c @@ -26,7 +26,7 @@ */ /** The log domain of this dialog. */ -#define G_LOG_DOMAIN "Dialogs.Combi" +#define G_LOG_DOMAIN "Modes.Combi" #include "helper.h" #include "settings.h" @@ -36,7 +36,7 @@ #include "mode-private.h" #include "widgets/textbox.h" -#include +#include #include #include diff --git a/source/dialogs/dmenu.c b/source/modes/dmenu.c similarity index 99% rename from source/dialogs/dmenu.c rename to source/modes/dmenu.c index 5ca6d353..53416c3f 100644 --- a/source/dialogs/dmenu.c +++ b/source/modes/dmenu.c @@ -26,9 +26,9 @@ */ /** The log domain of this dialog. */ -#define G_LOG_DOMAIN "Dialogs.DMenu" +#define G_LOG_DOMAIN "Modes.DMenu" -#include "dialogs/dmenu.h" +#include "modes/dmenu.h" #include "helper.h" #include "rofi-icon-fetcher.h" #include "rofi.h" @@ -50,7 +50,7 @@ #include #include -#include "dialogs/dmenuscriptshared.h" +#include "modes/dmenuscriptshared.h" static int dmenu_mode_init(Mode *sw); static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens, diff --git a/source/dialogs/drun.c b/source/modes/drun.c similarity index 99% rename from source/dialogs/drun.c rename to source/modes/drun.c index c943483a..48296919 100644 --- a/source/dialogs/drun.c +++ b/source/modes/drun.c @@ -26,7 +26,7 @@ */ /** The log domain of this dialog. */ -#define G_LOG_DOMAIN "Dialogs.DRun" +#define G_LOG_DOMAIN "Modes.DRun" #include #ifdef ENABLE_DRUN @@ -44,8 +44,8 @@ #include #include -#include "dialogs/drun.h" -#include "dialogs/filebrowser.h" +#include "modes/drun.h" +#include "modes/filebrowser.h" #include "helper.h" #include "history.h" #include "mode-private.h" diff --git a/source/dialogs/filebrowser.c b/source/modes/filebrowser.c similarity index 99% rename from source/dialogs/filebrowser.c rename to source/modes/filebrowser.c index daffcd66..2964f6a4 100644 --- a/source/dialogs/filebrowser.c +++ b/source/modes/filebrowser.c @@ -36,7 +36,7 @@ #include #include -#include "dialogs/filebrowser.h" +#include "modes/filebrowser.h" #include "helper.h" #include "history.h" #include "mode-private.h" diff --git a/source/dialogs/help-keys.c b/source/modes/help-keys.c similarity index 99% rename from source/dialogs/help-keys.c rename to source/modes/help-keys.c index fdf522a8..3659209d 100644 --- a/source/dialogs/help-keys.c +++ b/source/modes/help-keys.c @@ -38,7 +38,7 @@ #include #include -#include "dialogs/help-keys.h" +#include "modes/help-keys.h" #include "helper.h" #include "rofi.h" #include "settings.h" diff --git a/source/dialogs/run.c b/source/modes/run.c similarity index 99% rename from source/dialogs/run.c rename to source/modes/run.c index dcab35bb..47a9634e 100644 --- a/source/dialogs/run.c +++ b/source/modes/run.c @@ -31,7 +31,7 @@ */ /** The log domain of this dialog. */ -#define G_LOG_DOMAIN "Dialogs.Run" +#define G_LOG_DOMAIN "Modes.Run" #include #include @@ -46,8 +46,8 @@ #include #include -#include "dialogs/filebrowser.h" -#include "dialogs/run.h" +#include "modes/filebrowser.h" +#include "modes/run.h" #include "helper.h" #include "history.h" #include "rofi.h" diff --git a/source/dialogs/script.c b/source/modes/script.c similarity index 99% rename from source/dialogs/script.c rename to source/modes/script.c index da2af78c..f8c1dc7f 100644 --- a/source/dialogs/script.c +++ b/source/modes/script.c @@ -26,9 +26,9 @@ */ /** The log domain of this dialog. */ -#define G_LOG_DOMAIN "Dialogs.Script" +#define G_LOG_DOMAIN "Modes.Script" -#include "dialogs/script.h" +#include "modes/script.h" #include "helper.h" #include "rofi.h" #include @@ -46,7 +46,7 @@ #include "rofi-icon-fetcher.h" -#include "dialogs/dmenuscriptshared.h" +#include "modes/dmenuscriptshared.h" typedef struct { /** ID of the current script. */ diff --git a/source/dialogs/ssh.c b/source/modes/ssh.c similarity index 99% rename from source/dialogs/ssh.c rename to source/modes/ssh.c index 077d09ce..261e5c3c 100644 --- a/source/dialogs/ssh.c +++ b/source/modes/ssh.c @@ -33,7 +33,7 @@ /** * Log domain for the ssh mode. */ -#define G_LOG_DOMAIN "Dialogs.Ssh" +#define G_LOG_DOMAIN "Modes.Ssh" #include #include @@ -51,7 +51,7 @@ #include #include -#include "dialogs/ssh.h" +#include "modes/ssh.h" #include "history.h" #include "rofi.h" #include "settings.h" diff --git a/source/dialogs/window.c b/source/modes/window.c similarity index 99% rename from source/dialogs/window.c rename to source/modes/window.c index eacbec3d..e5f78686 100644 --- a/source/dialogs/window.c +++ b/source/modes/window.c @@ -26,7 +26,7 @@ */ /** The log domain of this dialog. */ -#define G_LOG_DOMAIN "Dialogs.Window" +#define G_LOG_DOMAIN "Modes.Window" #include @@ -49,8 +49,8 @@ #include "xcb-internal.h" #include "xcb.h" -#include "dialogs/window.h" #include "helper.h" +#include "modes/window.h" #include "rofi.h" #include "settings.h" #include "widgets/textbox.h" diff --git a/source/rofi.c b/source/rofi.c index 7f2992d9..9d549fe6 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -59,9 +59,9 @@ #include "rofi.h" #include "settings.h" -#include "dialogs/dialogs.h" #include "helper.h" #include "mode.h" +#include "modes/modes.h" #include "widgets/textbox.h" #include "xrmoptions.h" diff --git a/source/view.c b/source/view.c index b15b138d..6df1fa70 100644 --- a/source/view.c +++ b/source/view.c @@ -54,11 +54,11 @@ #include "settings.h" #include "timings.h" -#include "dialogs/dialogs.h" #include "display.h" #include "helper-theme.h" #include "helper.h" #include "mode.h" +#include "modes/modes.h" #include "xcb-internal.h" #include "xrmoptions.h" diff --git a/source/xcb.c b/source/xcb.c index de93b4ee..de3a1925 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -63,7 +63,7 @@ #include "xcb.h" #include -#include "dialogs/window.h" +#include "modes/window.h" #include "mode.h" #include diff --git a/test/mode-test.c b/test/mode-test.c index 8b76d65d..de19b47a 100644 --- a/test/mode-test.c +++ b/test/mode-test.c @@ -25,217 +25,184 @@ * */ -#include -#include -#include -#include #include #include +#include +#include +#include #include +#include -#include -#include -#include -#include -#include "theme.h" -#include "rofi.h" #include "display.h" -#include "xcb.h" +#include "rofi.h" +#include "theme.h" #include "widgets/textbox.h" -#include +#include "xcb.h" #include +#include +#include +#include +#include +#include -#include #include "rofi-icon-fetcher.h" +#include ThemeWidget *rofi_theme = NULL; -uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) -{ +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) { return 0; } -uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize ) -{ - return 0; -} -void rofi_clear_error_messages ( void ) {} -cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) -{ - return NULL; -} +void rofi_clear_error_messages(void) {} +cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) { return NULL; } -gboolean rofi_theme_parse_string ( const char *string ) -{ +gboolean rofi_theme_parse_string(const char *string) { return FALSE; } + +double textbox_get_estimated_char_height(void) { return 16.0; } +double textbox_get_estimated_ch(void) { return 9.0; } +void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {} +int monitor_active(G_GNUC_UNUSED workarea *d) { return 0; } +int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) { + fputs(msg, stderr); + return TRUE; +} +void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width, + G_GNUC_UNUSED int *height) {} +RofiViewState *rofi_view_get_active(void) { return NULL; } +gboolean rofi_view_check_action(G_GNUC_UNUSED RofiViewState *state, + G_GNUC_UNUSED BindingsScope scope, + G_GNUC_UNUSED guint action) { return FALSE; } +void rofi_view_trigger_action(G_GNUC_UNUSED RofiViewState *state, + G_GNUC_UNUSED BindingsScope scope, + G_GNUC_UNUSED guint action) {} -double textbox_get_estimated_char_height ( void ) -{ - return 16.0; -} -double textbox_get_estimated_ch ( void ) -{ - return 9.0; -} -void rofi_add_error_message ( G_GNUC_UNUSED GString *msg ) -{ -} -int monitor_active ( G_GNUC_UNUSED workarea *d ) -{ - return 0; -} -int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup ) -{ - fputs ( msg, stderr ); - return TRUE; -} -void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height ) -{ - -} -RofiViewState * rofi_view_get_active ( void ) -{ - return NULL; -} -gboolean rofi_view_check_action ( G_GNUC_UNUSED RofiViewState *state, G_GNUC_UNUSED BindingsScope scope, G_GNUC_UNUSED guint action ) -{ - return FALSE; -} -void rofi_view_trigger_action ( G_GNUC_UNUSED RofiViewState *state, G_GNUC_UNUSED BindingsScope scope, G_GNUC_UNUSED guint action ) -{ -} - -void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data ) -{ -} +void display_startup_notification( + G_GNUC_UNUSED RofiHelperExecuteContext *context, + G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, + G_GNUC_UNUSED gpointer *user_data) {} #ifndef _ck_assert_ptr_null /* Pointer against NULL comparison macros with improved output * compared to ck_assert(). */ /* OP may only be == or != */ -#define _ck_assert_ptr_null(X, OP) do { \ - const void* _ck_x = (X); \ - ck_assert_msg(_ck_x OP NULL, \ - "Assertion '%s' failed: %s == %#x", \ - #X" "#OP" NULL", \ - #X, _ck_x); \ -} while (0) +#define _ck_assert_ptr_null(X, OP) \ + do { \ + const void *_ck_x = (X); \ + ck_assert_msg(_ck_x OP NULL, "Assertion '%s' failed: %s == %#x", \ + #X " " #OP " NULL", #X, _ck_x); \ + } while (0) #define ck_assert_ptr_null(X) _ck_assert_ptr_null(X, ==) #define ck_assert_ptr_nonnull(X) _ck_assert_ptr_null(X, !=) #endif -static void test_mode_setup ( void ) -{ - ck_assert_int_eq ( mode_init ( &help_keys_mode ), TRUE); -} -static void test_mode_teardown ( void ) -{ - mode_destroy ( &help_keys_mode ); +static void test_mode_setup(void) { + ck_assert_int_eq(mode_init(&help_keys_mode), TRUE); } +static void test_mode_teardown(void) { mode_destroy(&help_keys_mode); } -START_TEST(test_mode_create) -{ - ck_assert_ptr_nonnull ( help_keys_mode.private_data ); +START_TEST(test_mode_create) { + ck_assert_ptr_nonnull(help_keys_mode.private_data); } END_TEST -START_TEST(test_mode_destroy) -{ - mode_destroy ( &help_keys_mode ); - ck_assert_ptr_null ( help_keys_mode.private_data ); +START_TEST(test_mode_destroy) { + mode_destroy(&help_keys_mode); + ck_assert_ptr_null(help_keys_mode.private_data); } END_TEST -START_TEST(test_mode_num_items) -{ - unsigned int rows = mode_get_num_entries ( &help_keys_mode); - ck_assert_int_eq ( rows, 74); - for ( unsigned int i =0; i < rows; i++ ) { - int state = 0; - GList *list = NULL; - char *v = mode_get_display_value ( &help_keys_mode, i, &state, &list, TRUE ); - ck_assert_ptr_nonnull ( v ); - g_free ( v ); - v = mode_get_display_value ( &help_keys_mode, i, &state, &list, FALSE ); - ck_assert_ptr_null ( v ); - } - mode_destroy ( &help_keys_mode ); +START_TEST(test_mode_num_items) { + unsigned int rows = mode_get_num_entries(&help_keys_mode); + ck_assert_int_eq(rows, 74); + for (unsigned int i = 0; i < rows; i++) { + int state = 0; + GList *list = NULL; + char *v = mode_get_display_value(&help_keys_mode, i, &state, &list, TRUE); + ck_assert_ptr_nonnull(v); + g_free(v); + v = mode_get_display_value(&help_keys_mode, i, &state, &list, FALSE); + ck_assert_ptr_null(v); + } + mode_destroy(&help_keys_mode); } END_TEST -START_TEST(test_mode_result) -{ - char *res; +START_TEST(test_mode_result) { + char *res; - res = NULL; - ck_assert_int_eq ( mode_result ( &help_keys_mode, MENU_NEXT, &res,0), NEXT_DIALOG); - g_free ( res ); + res = NULL; + ck_assert_int_eq(mode_result(&help_keys_mode, MENU_NEXT, &res, 0), + NEXT_DIALOG); + g_free(res); - res = NULL; - ck_assert_int_eq ( mode_result ( &help_keys_mode, MENU_PREVIOUS, &res,0), PREVIOUS_DIALOG); - g_free ( res ); + res = NULL; + ck_assert_int_eq(mode_result(&help_keys_mode, MENU_PREVIOUS, &res, 0), + PREVIOUS_DIALOG); + g_free(res); - res = NULL; - ck_assert_int_eq ( mode_result ( &help_keys_mode, MENU_QUICK_SWITCH|1, &res,0), 1); - g_free ( res ); + res = NULL; + ck_assert_int_eq(mode_result(&help_keys_mode, MENU_QUICK_SWITCH | 1, &res, 0), + 1); + g_free(res); - res = NULL; - ck_assert_int_eq ( mode_result ( &help_keys_mode, MENU_QUICK_SWITCH|2, &res,0), 2); - g_free ( res ); + res = NULL; + ck_assert_int_eq(mode_result(&help_keys_mode, MENU_QUICK_SWITCH | 2, &res, 0), + 2); + g_free(res); } END_TEST -START_TEST(test_mode_match_entry) -{ - rofi_int_matcher **t = helper_tokenize( "primary-paste", FALSE ); - ck_assert_ptr_nonnull ( t ); +START_TEST(test_mode_match_entry) { + rofi_int_matcher **t = helper_tokenize("primary-paste", FALSE); + ck_assert_ptr_nonnull(t); - ck_assert_int_eq ( mode_token_match ( &help_keys_mode, t, 0), TRUE ); - ck_assert_int_eq ( mode_token_match ( &help_keys_mode, t, 1), FALSE ); - helper_tokenize_free ( t ); - t = helper_tokenize( "y-paste", FALSE ); - ck_assert_ptr_nonnull ( t ); - - ck_assert_int_eq ( mode_token_match ( &help_keys_mode, t, 0), TRUE ); - ck_assert_int_eq ( mode_token_match ( &help_keys_mode, t, 1), TRUE ); - ck_assert_int_eq ( mode_token_match ( &help_keys_mode, t, 2), FALSE ); - helper_tokenize_free ( t ); + ck_assert_int_eq(mode_token_match(&help_keys_mode, t, 0), TRUE); + ck_assert_int_eq(mode_token_match(&help_keys_mode, t, 1), FALSE); + helper_tokenize_free(t); + t = helper_tokenize("y-paste", FALSE); + ck_assert_ptr_nonnull(t); + ck_assert_int_eq(mode_token_match(&help_keys_mode, t, 0), TRUE); + ck_assert_int_eq(mode_token_match(&help_keys_mode, t, 1), TRUE); + ck_assert_int_eq(mode_token_match(&help_keys_mode, t, 2), FALSE); + helper_tokenize_free(t); } END_TEST -static Suite * mode_suite (void) -{ - Suite *s; - TCase *tc_core; +static Suite *mode_suite(void) { + Suite *s; + TCase *tc_core; - s = suite_create("Mode"); + s = suite_create("Mode"); - /* Core test case */ - tc_core = tcase_create("HelpKeys"); - tcase_add_checked_fixture(tc_core, test_mode_setup, test_mode_teardown); - tcase_add_test(tc_core, test_mode_create); - tcase_add_test(tc_core, test_mode_num_items); - tcase_add_test(tc_core, test_mode_result ); - tcase_add_test(tc_core, test_mode_destroy); - tcase_add_test(tc_core, test_mode_match_entry ); - suite_add_tcase(s, tc_core); + /* Core test case */ + tc_core = tcase_create("HelpKeys"); + tcase_add_checked_fixture(tc_core, test_mode_setup, test_mode_teardown); + tcase_add_test(tc_core, test_mode_create); + tcase_add_test(tc_core, test_mode_num_items); + tcase_add_test(tc_core, test_mode_result); + tcase_add_test(tc_core, test_mode_destroy); + tcase_add_test(tc_core, test_mode_match_entry); + suite_add_tcase(s, tc_core); - return s; + return s; } -int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) -{ - setup_abe (); - int number_failed = 0; - Suite *s; - SRunner *sr; +int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) { + setup_abe(); + int number_failed = 0; + Suite *s; + SRunner *sr; - s = mode_suite(); - sr = srunner_create(s); + s = mode_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; + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }