From 74144db77d9106f8dcf84fdeada104797cb3a48f Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 15 Jun 2021 12:31:32 +0200 Subject: [Test] Fix the test. --- source/dialogs/combi.c | 22 +++++++++++----------- source/mode.c | 11 +++++++++-- source/rofi-types.c | 2 ++ test/box-test.c | 11 +++++++++++ test/helper-config-cmdline-parser.c | 10 ++++++++++ test/helper-expand.c | 10 ++++++++++ test/helper-pidfile.c | 10 ++++++++++ test/helper-test.c | 12 ++++++++++++ test/helper-tokenize.c | 10 ++++++++++ test/mode-test.c | 10 ++++++++++ test/scrollbar-test.c | 12 ++++++++++++ test/textbox-test.c | 13 +++++++++++++ test/theme-parser-test.c | 11 +++++++++++ test/widget-test.c | 13 +++++++++++++ 14 files changed, 144 insertions(+), 13 deletions(-) diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index 231b7f0f..d84a045a 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -218,22 +218,22 @@ static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *stat char * str = retv = mode_get_display_value ( pd->switchers[i].mode, selected_line - pd->starts[i], state, attr_list, TRUE ); const char *dname = mode_get_display_name ( pd->switchers[i].mode ); if ( !config.combi_hide_mode_prefix ) { - retv = g_strdup_printf ( "%s %s", dname, str ); - g_free ( str ); - } + retv = g_strdup_printf ( "%s %s", dname, str ); + g_free ( str ); - if ( attr_list != NULL ) { + if ( attr_list != NULL ) { ThemeWidget *wid = rofi_config_find_widget ( sw->name, NULL, TRUE ); Property *p = rofi_theme_find_property ( wid, P_COLOR, pd->switchers[i].mode->name, TRUE ); if ( p != NULL ) { - PangoAttribute *pa = pango_attr_foreground_new ( - p->value.color.red * 65535, - p->value.color.green * 65535, - p->value.color.blue * 65535 ); - pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING; - pa->end_index = strlen ( dname ); - *attr_list = g_list_append ( *attr_list, pa ); + PangoAttribute *pa = pango_attr_foreground_new ( + p->value.color.red * 65535, + p->value.color.green * 65535, + p->value.color.blue * 65535 ); + pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING; + pa->end_index = strlen ( dname ); + *attr_list = g_list_append ( *attr_list, pa ); } + } } return retv; } diff --git a/source/mode.c b/source/mode.c index 39cfddcf..8c0a9fc0 100644 --- a/source/mode.c +++ b/source/mode.c @@ -153,8 +153,15 @@ void mode_set_private_data ( Mode *mode, void *pd ) const char *mode_get_display_name ( const Mode *mode ) { - if ( mode->display_name != NULL ) { - return mode->display_name; + ThemeWidget *wid = rofi_config_find_widget ( mode->name, NULL, TRUE ); + if ( wid ) { + Property *p = rofi_theme_find_property ( wid, P_STRING, "display-name", FALSE ); + if ( p != NULL ) { + return p->value.s; + } + } + if ( mode->display_name != NULL ) { + return mode->display_name; } return mode->name; } diff --git a/source/rofi-types.c b/source/rofi-types.c index 2ff4e3e8..f641c240 100644 --- a/source/rofi-types.c +++ b/source/rofi-types.c @@ -16,6 +16,8 @@ const char * const PropertyTypeName[P_NUM_TYPES] = { "Boolean", /** Color */ "Color", + /** Image */ + "Iamge", /** Padding */ "Padding", /** Link to global setting */ diff --git a/test/box-test.c b/test/box-test.c index 82d0ef70..0e1aa48f 100644 --- a/test/box-test.c +++ b/test/box-test.c @@ -62,6 +62,17 @@ unsigned int test =0; abort ( ); \ } \ } +ThemeWidget *rofi_configuration = NULL; + +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} int monitor_active ( G_GNUC_UNUSED workarea *mon ) diff --git a/test/helper-config-cmdline-parser.c b/test/helper-config-cmdline-parser.c index 14e8e926..93e29ab8 100644 --- a/test/helper-config-cmdline-parser.c +++ b/test/helper-config-cmdline-parser.c @@ -55,6 +55,16 @@ 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; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + gboolean rofi_theme_parse_string ( const char *string ) { diff --git a/test/helper-expand.c b/test/helper-expand.c index f589309b..573878ea 100644 --- a/test/helper-expand.c +++ b/test/helper-expand.c @@ -56,6 +56,16 @@ static int test = 0; } ThemeWidget *rofi_theme = NULL; +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + double textbox_get_estimated_char_height ( void ) { return 12.0; diff --git a/test/helper-pidfile.c b/test/helper-pidfile.c index 31e42770..b9ddac66 100644 --- a/test/helper-pidfile.c +++ b/test/helper-pidfile.c @@ -48,6 +48,16 @@ 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; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + gboolean rofi_theme_parse_string ( const char *string ) { return FALSE; diff --git a/test/helper-test.c b/test/helper-test.c index 2d145dbc..274d8296 100644 --- a/test/helper-test.c +++ b/test/helper-test.c @@ -63,12 +63,24 @@ static int test = 0; } #include "widgets/textbox.h" + ThemeWidget *rofi_theme = NULL; + gboolean rofi_theme_parse_string ( const char *string ) { return FALSE; } +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + double textbox_get_estimated_char_height ( void ) { return 12.0; diff --git a/test/helper-tokenize.c b/test/helper-tokenize.c index 71aff9e1..1629303c 100644 --- a/test/helper-tokenize.c +++ b/test/helper-tokenize.c @@ -45,6 +45,16 @@ ThemeWidget *rofi_theme = NULL; +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + gboolean rofi_theme_parse_string ( G_GNUC_UNUSED const char *string ) { return FALSE; diff --git a/test/mode-test.c b/test/mode-test.c index bd032e49..6c773a2b 100644 --- a/test/mode-test.c +++ b/test/mode-test.c @@ -49,6 +49,16 @@ ThemeWidget *rofi_theme = NULL; +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + gboolean rofi_theme_parse_string ( const char *string ) { return FALSE; diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c index 64193cb8..b0287e26 100644 --- a/test/scrollbar-test.c +++ b/test/scrollbar-test.c @@ -56,6 +56,18 @@ unsigned int test =0; } \ } +ThemeWidget *rofi_configuration = NULL; + +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + int monitor_active ( G_GNUC_UNUSED workarea *mon ) { return 0; diff --git a/test/textbox-test.c b/test/textbox-test.c index cd5ff528..d4e646f0 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -52,6 +52,19 @@ unsigned int normal_window_mode = 0; #include "view.h" + +ThemeWidget *rofi_configuration = NULL; + +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error ) { return FALSE; diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index ab0800bd..6d16c165 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -48,6 +48,17 @@ #define REAL_COMPARE_DELTA 0.001 +uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) +{ + return 0; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + + int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup ) { fputs ( msg, stderr ); diff --git a/test/widget-test.c b/test/widget-test.c index 06625664..b49e2a56 100644 --- a/test/widget-test.c +++ b/test/widget-test.c @@ -43,6 +43,19 @@ unsigned int test =0; 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; +} + +cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) +{ + return NULL; +} + gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error ) { return FALSE; -- cgit v1.2.3