From 9af191de26611ce5025e3363dafd0cdbf8ab38b9 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 20 Jun 2017 21:02:13 +0200 Subject: [PATCH] Fix tests by splitting types name into separate file. --- Makefile.am | 24 ++++++++++++++++++++++++ include/rofi-types.h | 6 ++++++ meson.build | 13 +++++++++++++ source/rofi-types.c | 29 +++++++++++++++++++++++++++++ source/theme.c | 28 +--------------------------- source/xrmoptions.c | 1 + test/box-test.c | 3 ++- test/scrollbar-test.c | 3 ++- test/textbox-test.c | 3 ++- test/widget-test.c | 3 ++- 10 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 include/rofi-types.h create mode 100644 source/rofi-types.c diff --git a/Makefile.am b/Makefile.am index f992c5ec..a1644f5f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,7 @@ SOURCES=\ source/timings.c\ source/history.c\ source/theme.c\ + source/rofi-types.c\ source/widgets/box.c\ source/widgets/container.c\ source/widgets/widget.c\ @@ -77,6 +78,7 @@ SOURCES=\ include/xcb.h\ include/xcb-internal.h\ include/rofi.h\ + include/rofi-types.h\ include/mode.h\ include/mode-private.h\ include/settings.h\ @@ -306,6 +308,8 @@ helper_pidfile_SOURCES=\ include/mode.h\ include/mode-private.h\ source/helper.c\ + source/rofi-types.c\ + include/rofi-types.h\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ @@ -320,6 +324,8 @@ helper_tokenize_SOURCES=\ include/mode.h\ include/mode-private.h\ source/helper.c\ + source/rofi-types.c\ + include/rofi-types.h\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ @@ -332,6 +338,8 @@ widget_test_SOURCES=\ source/widgets/widget.c\ source/widgets/textbox.c\ source/theme.c\ + source/rofi-types.c\ + include/rofi-types.h\ source/css-colors.c\ source/helper.c\ config/config.c\ @@ -347,6 +355,8 @@ box_test_SOURCES=\ lexer/theme-parser.y\ lexer/theme-lexer.l\ source/theme.c\ + source/rofi-types.c\ + include/rofi-types.h\ source/css-colors.c\ include/theme.h\ include/css-colors.h\ @@ -360,6 +370,8 @@ scrollbar_test_SOURCES=\ lexer/theme-parser.y\ lexer/theme-lexer.l\ source/theme.c\ + source/rofi-types.c\ + include/rofi-types.h\ source/css-colors.c\ include/theme.h\ include/css-colors.h\ @@ -371,6 +383,8 @@ textbox_test_SOURCES=\ lexer/theme-parser.y\ lexer/theme-lexer.l\ source/theme.c\ + source/rofi-types.c\ + include/rofi-types.h\ source/css-colors.c\ source/helper.c\ config/config.c\ @@ -406,6 +420,8 @@ theme_parser_test_SOURCES=\ lexer/theme-parser.c\ lexer/theme-parser.h\ source/theme.c\ + source/rofi-types.c\ + include/rofi-types.h\ source/css-colors.c\ test/theme-parser-test.c endif @@ -420,6 +436,8 @@ helper_test_SOURCES=\ include/helper-theme.h\ include/xrmoptions.h\ source/xrmoptions.c\ + source/rofi-types.c\ + include/rofi-types.h\ test/helper-test.c @@ -460,6 +478,8 @@ helper_expand_SOURCES=\ include/helper-theme.h\ include/xrmoptions.h\ source/xrmoptions.c\ + source/rofi-types.c\ + include/rofi-types.h\ test/helper-expand.c helper_expand_CFLAGS=${helper_test_CFLAGS} @@ -475,6 +495,8 @@ helper_config_cmdline_parser_SOURCES=\ include/mode.h\ include/mode-private.h\ source/helper.c\ + source/rofi-types.c\ + include/rofi-types.h\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ @@ -491,6 +513,8 @@ mode_test_SOURCES=\ source/dialogs/help-keys.c\ source/helper.c\ source/mode.c\ + source/rofi-types.c\ + include/rofi-types.h\ source/xrmoptions.c\ source/keyb.c\ include/mode.h\ diff --git a/include/rofi-types.h b/include/rofi-types.h new file mode 100644 index 00000000..4970e453 --- /dev/null +++ b/include/rofi-types.h @@ -0,0 +1,6 @@ +#ifndef INCLUDE_ROFI_TYPES_H +#define INCLUDE_ROFI_TYPES_H + +extern const char *PropertyTypeName[]; + +#endif // INCLUDE_ROFI_TYPES_H diff --git a/meson.build b/meson.build index 35d97f65..ac827d16 100644 --- a/meson.build +++ b/meson.build @@ -155,6 +155,7 @@ rofi_sources = files( 'source/widgets/listview.c', 'source/widgets/scrollbar.c', 'source/xrmoptions.c', + 'source/rofi-types.c', 'source/xcb.c', 'source/dialogs/run.c', 'source/dialogs/ssh.c', @@ -179,6 +180,7 @@ rofi_sources = files( 'include/timings.h', 'include/history.h', 'include/theme.h', + 'include/rofi-types.h', 'include/css-colors.h', 'include/default-theme.h', 'include/widgets/box.h', @@ -278,6 +280,7 @@ test('helper_pidfile test', executable('helper_pidfile.test', [ 'config/config.c', 'source/helper.c', 'source/xrmoptions.c', + 'source/rofi-types.c', ]), dependencies: deps, )) @@ -289,6 +292,7 @@ test('helper_tokenize test', executable('helper_tokenize.test', [ 'config/config.c', 'source/helper.c', 'source/xrmoptions.c', + 'source/rofi-types.c', ]), dependencies: deps, )) @@ -302,6 +306,7 @@ test('widget test', executable('widget.test', [ 'source/widgets/widget.c', 'source/widgets/textbox.c', 'source/theme.c', + 'source/rofi-types.c', 'source/css-colors.c', 'source/helper.c', 'config/config.c', @@ -318,6 +323,7 @@ test('box test', executable('box.test', [ 'source/widgets/widget.c', 'source/widgets/box.c', 'source/theme.c', + 'source/rofi-types.c', 'source/css-colors.c', 'config/config.c', ]), @@ -333,6 +339,7 @@ test('scrollbar test', executable('scrollbar.test', [ 'source/widgets/widget.c', 'source/widgets/scrollbar.c', 'source/theme.c', + 'source/rofi-types.c', 'source/css-colors.c', 'config/config.c', ]), @@ -348,6 +355,7 @@ test('textbox test', executable('textbox.test', [ 'source/widgets/widget.c', 'source/widgets/textbox.c', 'source/theme.c', + 'source/rofi-types.c', 'source/css-colors.c', 'source/helper.c', 'config/config.c', @@ -362,6 +370,7 @@ test('helper test', executable('helper.test', [ 'config/config.c', 'source/helper.c', 'source/xrmoptions.c', + 'source/rofi-types.c', ]), dependencies: deps, )) @@ -373,6 +382,7 @@ test('helper_expand test', executable('helper_expand.test', [ 'config/config.c', 'source/helper.c', 'source/xrmoptions.c', + 'source/rofi-types.c', ]), dependencies: deps, )) @@ -384,6 +394,7 @@ test('helper_config_cmdline_parser test', executable('helper_config_cmdline_pars 'config/config.c', 'source/helper.c', 'source/xrmoptions.c', + 'source/rofi-types.c', ]), dependencies: deps, )) @@ -401,6 +412,7 @@ if check.found() 'source/helper.c', 'source/xrmoptions.c', 'source/theme.c', + 'source/rofi-types.c', 'source/css-colors.c', ]), dependencies: deps, @@ -415,6 +427,7 @@ if check.found() 'source/helper.c', 'source/mode.c', 'source/xrmoptions.c', + 'source/rofi-types.c', 'source/keyb.c', ]), dependencies: deps, diff --git a/source/rofi-types.c b/source/rofi-types.c new file mode 100644 index 00000000..d0676f40 --- /dev/null +++ b/source/rofi-types.c @@ -0,0 +1,29 @@ +#include "rofi-types.h" + +/** + * Name of the property type + */ +const char *PropertyTypeName[] = { + /** Integer */ + "Integer", + /** Double */ + "Double", + /** String */ + "String", + /** Boolean */ + "Boolean", + /** Color */ + "Color", + /** RofiPadding */ + "RofiPadding", + /** Link to global setting */ + "Reference", + /** Position */ + "Position", + /** Highlight */ + "Highlight", + /** List */ + "List", + /** Orientation */ + "Orientation", +}; diff --git a/source/theme.c b/source/theme.c index 25cbd4ee..b929a9ea 100644 --- a/source/theme.c +++ b/source/theme.c @@ -41,34 +41,8 @@ #include "widgets/textbox.h" #include "view.h" #include "rofi.h" +#include "rofi-types.h" -/** - * Name of the property type - */ -const char *PropertyTypeName[] = { - /** Integer */ - "Integer", - /** Double */ - "Double", - /** String */ - "String", - /** Boolean */ - "Boolean", - /** Color */ - "Color", - /** RofiPadding */ - "RofiPadding", - /** Link to global setting */ - "Reference", - /** Position */ - "Position", - /** Highlight */ - "Highlight", - /** List */ - "List", - /** Orientation */ - "Orientation", -}; void yyerror ( YYLTYPE *yylloc, const char *, const char * ); static gboolean distance_compare ( RofiDistance d, RofiDistance e ) { diff --git a/source/xrmoptions.c b/source/xrmoptions.c index c79b1959..91d69c3a 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -40,6 +40,7 @@ #include "xrmoptions.h" #include "settings.h" #include "helper.h" +#include "rofi-types.h" /** Different sources of configuration. */ const char * const ConfigSourceStr[] = { diff --git a/test/box-test.c b/test/box-test.c index e2fdb2d5..7cc437d3 100644 --- a/test/box-test.c +++ b/test/box-test.c @@ -63,8 +63,9 @@ unsigned int test =0; } \ } -void config_parse_set_property ( G_GNUC_UNUSED const Property *p ) +gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, char **error ) { + return FALSE; } char * rofi_expand_path ( G_GNUC_UNUSED const char *path ) { diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c index c9fdc140..f69b3eb7 100644 --- a/test/scrollbar-test.c +++ b/test/scrollbar-test.c @@ -59,8 +59,9 @@ char * helper_get_theme_path ( const char *file ) { return g_strdup ( file ); } -void config_parse_set_property ( G_GNUC_UNUSED const Property *p ) +gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, char **error ) { + return FALSE; } void rofi_add_error_message ( G_GNUC_UNUSED GString *msg ) {} diff --git a/test/textbox-test.c b/test/textbox-test.c index be53516e..94703a85 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -52,8 +52,9 @@ unsigned int normal_window_mode = 0; #include "view.h" -void config_parse_set_property ( G_GNUC_UNUSED const Property *p ) +gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, char **error ) { + return FALSE; } void rofi_add_error_message ( G_GNUC_UNUSED GString *msg) diff --git a/test/widget-test.c b/test/widget-test.c index 78cd4c4a..3313ac7e 100644 --- a/test/widget-test.c +++ b/test/widget-test.c @@ -43,8 +43,9 @@ unsigned int test =0; assert ( a ); \ printf ( "Test %3i passed (%s)\n", ++test, # a ); \ } -void config_parse_set_property ( G_GNUC_UNUSED const Property *p ) +gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, char **error ) { + return FALSE; } void rofi_add_error_message ( G_GNUC_UNUSED GString *msg ) {