This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch eolian/improvements
in repository efl.
View the commit online.
commit 42d0d72b6aed82769d54ca5849e068cd9c0c8b1a
Author: [email protected] <[email protected]>
AuthorDate: Mon Oct 26 12:43:06 2026 -0600
tests: every style a class declares is in the default theme
Classes now declare their theme styles in Eolian, and bindings and
documentation offer exactly those names. A declared style the theme
lacks would still look as if it worked: the widget falls back to its
default style and says so only through a return code.
efl-ui-theme-styles parses the .eo files, and for every class that
declares styles makes a widget of it with each one and fails unless
the theme applies cleanly. It goes through the widget rather than
guessing group names, so it checks what a widget really loads.
The other way round is a report, not a check: --undeclared lists the
styles the default theme has for a widget class that the class does
not declare, for when classes catch up.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
---
src/tests/elementary/efl_ui_theme_styles.c | 181 +++++++++++++++++++++++++++++
src/tests/elementary/meson.build | 13 +++
2 files changed, 194 insertions(+)
diff --git a/src/tests/elementary/efl_ui_theme_styles.c b/src/tests/elementary/efl_ui_theme_styles.c
new file mode 100644
index 0000000000..f6f58f417c
--- /dev/null
+++ b/src/tests/elementary/efl_ui_theme_styles.c
@@ -0,0 +1,181 @@
+/* Every theme style a class declares in its .eo file is in the default theme.
+ *
+ * A class lists its styles -- the values Efl.Ui.Widget.style accepts -- in a
+ * styles {} block, and bindings and documentation offer exactly those. A style
+ * the theme lacks still "works": the widget falls back to its default style and
+ * says so only through a return code. So each declared style is applied here,
+ * on a widget of the class that declares it, and anything but a clean apply
+ * fails the check. Going through the widget rather than guessing group names
+ * keeps the check honest about how a class names its theme groups.
+ *
+ * The other way round is a report rather than a check, with --undeclared:
+ * the styles the default theme has for a widget class that the class does
+ * not declare, which is most of them until classes catch up.
+ *
+ * Arguments are the -I directories eolian_gen is given.
+ */
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <Eolian.h>
+#include <Elementary.h>
+#include <Efl_Ui.h>
+#include "elm_widget.h"
+
+typedef const Efl_Class *(*Class_Get)(void);
+
+static int
+_class_check(const Eolian_Class *cl, Eo *win, int *checked)
+{
+ Eina_Iterator *styles = eolian_class_styles_get(cl);
+ const Eolian_Style *st;
+ Eina_Stringshare *getter;
+ Class_Get get;
+ int missing = 0;
+
+ if (!styles) return 0;
+
+ getter = eolian_class_c_get_function_name_get(cl);
+ get = (Class_Get) dlsym(RTLD_DEFAULT, getter);
+ if (!get || (eolian_class_type_get(cl) != EOLIAN_CLASS_REGULAR))
+ {
+ fprintf(stderr, "%s declares styles, but no widget of it can be made "
+ "(%s() %s)\n", eolian_class_name_get(cl), getter,
+ get ? "is not a regular class's" : "is not exported");
+ eina_stringshare_del(getter);
+ eina_iterator_free(styles);
+ return 1;
+ }
+ eina_stringshare_del(getter);
+
+ EINA_ITERATOR_FOREACH(styles, st)
+ {
+ const char *name = eolian_style_name_get(st);
+ Eina_Error err = -1;
+ Eo *obj;
+
+ (*checked)++;
+ obj = efl_add(get(), win, err = efl_ui_widget_style_set(efl_added, name));
+ if (!obj || (err != EFL_UI_THEME_APPLY_ERROR_NONE))
+ {
+ fprintf(stderr, "%s declares the style '%s', which the default "
+ "theme does not have\n", eolian_class_name_get(cl), name);
+ missing++;
+ }
+ efl_del(obj);
+ }
+ eina_iterator_free(styles);
+ return missing;
+}
+
+/* Prints the styles the theme has for cl's widgets that cl and its parents
+ do not declare. */
+static int
+_class_report(const Eolian_Class *cl, Eo *win, Eina_List *groups)
+{
+ Eina_Stringshare *getter = eolian_class_c_get_function_name_get(cl);
+ Class_Get get = (Class_Get) dlsym(RTLD_DEFAULT, getter);
+ const char *klass, *group;
+ char prefix[256];
+ Eina_List *l;
+ int n = 0;
+ Eo *obj;
+
+ eina_stringshare_del(getter);
+ if (!get || (eolian_class_type_get(cl) != EOLIAN_CLASS_REGULAR)) return 0;
+ if (!efl_isa(get(), EFL_UI_WIDGET_CLASS) || efl_isa(get(), EFL_UI_WIN_CLASS)) return 0;
+
+ obj = efl_add(get(), win);
+ klass = obj ? elm_widget_theme_klass_get(obj) : NULL;
+ if (klass)
+ {
+ snprintf(prefix, sizeof(prefix), "efl/%s:", klass);
+ EINA_LIST_FOREACH(groups, l, group)
+ {
+ const Eolian_Class *c;
+ Eina_Bool declared = EINA_FALSE;
+ const char *style;
+
+ if (strncmp(group, prefix, strlen(prefix))) continue;
+ style = group + strlen(prefix);
+ for (c = cl; c && !declared; c = eolian_class_parent_get(c))
+ {
+ Eina_Iterator *styles = eolian_class_styles_get(c);
+ const Eolian_Style *st;
+
+ EINA_ITERATOR_FOREACH(styles, st)
+ if (!strcmp(eolian_style_name_get(st), style)) declared = EINA_TRUE;
+ eina_iterator_free(styles);
+ }
+ if (declared) continue;
+ printf("%s: style '%s' (%s) is not declared\n", eolian_class_name_get(cl), style, group);
+ n++;
+ }
+ }
+ efl_del(obj);
+ return n;
+}
+
+int
+main(int argc, char **argv)
+{
+ const Eolian_Class *cl;
+ Eolian_State *eos;
+ Eina_Iterator *classes;
+ int i, missing = 0, checked = 0;
+ Eina_Bool report = EINA_FALSE;
+ Eo *win;
+
+ setenv("ELM_ENGINE", "buffer", 1);
+ eolian_init();
+ eos = eolian_state_new();
+ for (i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "-I") && (i + 1 < argc))
+ eolian_state_directory_add(eos, argv[++i]);
+ else if (!strcmp(argv[i], "--undeclared"))
+ report = EINA_TRUE;
+ }
+ if (!eolian_state_all_eo_files_parse(eos))
+ {
+ fprintf(stderr, "could not parse the .eo files\n");
+ return 1;
+ }
+
+ elm_init(argc, argv);
+ win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
+ efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC));
+
+ if (report)
+ {
+ Eina_List *groups = edje_file_collection_list(elm_theme_list_item_path_get("default", NULL));
+ int n = 0;
+
+ classes = eolian_state_classes_get(eos);
+ EINA_ITERATOR_FOREACH(classes, cl)
+ n += _class_report(cl, win, groups);
+ eina_iterator_free(classes);
+ edje_file_collection_list_free(groups);
+ printf("%d styles in the default theme not declared by their class\n", n);
+ }
+
+ classes = eolian_state_classes_get(eos);
+ EINA_ITERATOR_FOREACH(classes, cl)
+ missing += _class_check(cl, win, &checked);
+ eina_iterator_free(classes);
+
+ printf("%d declared styles checked, %d not in the default theme\n", checked, missing);
+
+ efl_del(win);
+ elm_shutdown();
+ eolian_state_free(eos);
+ eolian_shutdown();
+
+ /* nothing declared is a check that checked nothing */
+ return (missing || !checked) ? 1 : 0;
+}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 07c0d5c1e2..4d683fc09e 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -215,6 +215,19 @@ test('efl-ui-suite', efl_ui_suite,
timeout : master_timeout
)
+# The styles classes declare in their .eo files are all in the default theme.
+efl_ui_theme_styles = executable('efl_ui_theme_styles',
+ 'efl_ui_theme_styles.c',
+ dependencies: [eina, eolian, elementary, meson.get_compiler('c').find_library('dl', required: false)],
+ include_directories : [config_dir] + [elementary_config_dir],
+)
+
+test('efl-ui-theme-styles', efl_ui_theme_styles,
+ args : eolian_include_directories,
+ env : test_env,
+ timeout : master_timeout
+)
+
install_data(files(['testdiff.diff', 'testfile-windows.txt', 'testfile-withblanks.txt', 'testfile.txt']),
install_dir : join_paths(dir_data, 'elementary')
)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.