From 12b2b385781194bb3a03ac68605ec8051e42f154 Mon Sep 17 00:00:00 2001 From: TonCherAmi Date: Sat, 5 Jun 2021 13:58:07 +0300 Subject: [PATCH] Fix tests. (#1323) --- Makefile.am | 2 ++ meson.build | 2 ++ test/helper-tokenize.c | 24 +++++++++++++++++++++++- test/mode-test.c | 24 ++++++++++++++++++------ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index 55713287..11656189 100644 --- a/Makefile.am +++ b/Makefile.am @@ -543,6 +543,7 @@ mode_test_SOURCES=\ test/mode-test.c\ source/dialogs/help-keys.c\ source/helper.c\ + source/theme.c\ source/mode.c\ source/rofi-types.c\ include/rofi-types.h\ @@ -558,6 +559,7 @@ helper_tokenize_SOURCES=\ include/mode.h\ include/mode-private.h\ source/helper.c\ + source/theme.c\ source/rofi-types.c\ include/rofi-types.h\ include/helper.h\ diff --git a/meson.build b/meson.build index 62e7f780..8d6d2ea6 100644 --- a/meson.build +++ b/meson.build @@ -441,6 +441,7 @@ if check.found() 'config/config.c', 'source/dialogs/help-keys.c', 'source/helper.c', + 'source/theme.c', 'source/mode.c', 'source/xrmoptions.c', 'source/rofi-types.c', @@ -455,6 +456,7 @@ if check.found() objects: rofi.extract_objects([ 'config/config.c', 'source/helper.c', + 'source/theme.c', 'source/xrmoptions.c', 'source/rofi-types.c', ]), diff --git a/test/helper-tokenize.c b/test/helper-tokenize.c index 66cfb60f..71aff9e1 100644 --- a/test/helper-tokenize.c +++ b/test/helper-tokenize.c @@ -33,14 +33,36 @@ #include #include #include "display.h" +#include "theme.h" #include "xcb.h" #include "xcb-internal.h" #include "rofi.h" #include "settings.h" #include "rofi-types.h" +#include "widgets/textbox.h" #include +ThemeWidget *rofi_theme = NULL; + +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; +*height = 1080; +} +double textbox_get_estimated_ch ( void ) +{ + return 9.0; +} void rofi_add_error_message ( G_GNUC_UNUSED GString *msg ) { } @@ -465,5 +487,5 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char ** argv ) number_failed = srunner_ntests_failed(sr); srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; - + } diff --git a/test/mode-test.c b/test/mode-test.c index a36880ab..bd032e49 100644 --- a/test/mode-test.c +++ b/test/mode-test.c @@ -37,14 +37,31 @@ #include #include #include +#include "theme.h" #include "rofi.h" #include "display.h" #include "xcb.h" +#include "widgets/textbox.h" #include #include #include +ThemeWidget *rofi_theme = NULL; + +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 ) { } @@ -57,11 +74,6 @@ int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup ) fputs ( msg, stderr ); return TRUE; } -int textbox_get_estimated_char_height ( void ); -int textbox_get_estimated_char_height ( void ) -{ - return 16; -} void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height ) { @@ -119,7 +131,7 @@ END_TEST START_TEST(test_mode_num_items) { unsigned int rows = mode_get_num_entries ( &help_keys_mode); - ck_assert_int_eq ( rows, 72); + ck_assert_int_eq ( rows, 73); for ( unsigned int i =0; i < rows; i++ ){ int state = 0; GList *list = NULL;