diff options
author | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-04-23 10:21:43 +0200 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-04-24 15:52:48 +0200 |
commit | 2e85c6ba344852242290bac55621a9d0e6e0829f (patch) | |
tree | 84085ef85b6015fc85038ef63c2e924a1ea080ad | |
parent | e9c49d0f70e9052ff40968ecfb43d89442a65aec (diff) | |
download | efl-2e85c6ba344852242290bac55621a9d0e6e0829f.tar.gz |
efl_ui_spec_suite: move the information about tests to the test files
for now the widgets which are tested are encoded in the test files where
the tests are implemented. This is for now done in a simple json format,
just for the sake of simplicity.
ref T7815
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D8685
-rw-r--r-- | src/tests/elementary/spec/efl_test_content.c | 9 | ||||
-rw-r--r-- | src/tests/elementary/spec/efl_test_pack.c | 6 | ||||
-rw-r--r-- | src/tests/elementary/spec/efl_test_pack_linear.c | 5 | ||||
-rwxr-xr-x | src/tests/elementary/spec/generator.py | 30 | ||||
-rw-r--r-- | src/tests/elementary/spec/meson.build | 17 |
5 files changed, 49 insertions, 18 deletions
diff --git a/src/tests/elementary/spec/efl_test_content.c b/src/tests/elementary/spec/efl_test_content.c index e0652b6e02..1231d7096f 100644 --- a/src/tests/elementary/spec/efl_test_content.c +++ b/src/tests/elementary/spec/efl_test_content.c @@ -6,6 +6,15 @@ #include "efl_ui_spec_suite.h" #include "suite_helpers.h" +/* spec-meta-start + {"test-interface":"Efl.Content", + "test-widgets": ["Efl.Ui.Button", "Efl.Ui.Frame", "Efl.Ui.Grid_Default_Item", + "Efl.Ui.List_Default_Item", "Efl.Ui.List_Empty_Item", + "Efl.Ui.Navigation_Layout", "Efl.Ui.Panel", "Efl.Ui.Progressbar", + "Efl.Ui.Radio", "Efl.Ui.Popup", "Efl.Ui.Tab_Page", "Efl.Ui.Scroller"]} + + spec-meta-end */ + EFL_START_TEST(content_set_get) { Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win); diff --git a/src/tests/elementary/spec/efl_test_pack.c b/src/tests/elementary/spec/efl_test_pack.c index 626e3e9b5b..61b3bafa57 100644 --- a/src/tests/elementary/spec/efl_test_pack.c +++ b/src/tests/elementary/spec/efl_test_pack.c @@ -6,6 +6,12 @@ #include "efl_ui_spec_suite.h" #include "suite_helpers.h" +/* spec-meta-start + {"test-interface":"Efl.Pack", + "test-widgets": ["Efl.Ui.Table"]} + + spec-meta-end */ + /* In general: - If a subobject is deleted the box simply forgets about it. Never return this element again container. diff --git a/src/tests/elementary/spec/efl_test_pack_linear.c b/src/tests/elementary/spec/efl_test_pack_linear.c index cf85f9192b..31647fa0b2 100644 --- a/src/tests/elementary/spec/efl_test_pack_linear.c +++ b/src/tests/elementary/spec/efl_test_pack_linear.c @@ -7,6 +7,11 @@ #include "suite_helpers.h" #include <limits.h> +/* spec-meta-start + {"test-interface":"Efl.Pack_Linear", + "test-widgets": ["Efl.Ui.Box"]} + spec-meta-end */ + static void _fill_array(Efl_Ui_Widget *wid[3]) { diff --git a/src/tests/elementary/spec/generator.py b/src/tests/elementary/spec/generator.py index 3a84b01862..c6f73edce2 100755 --- a/src/tests/elementary/spec/generator.py +++ b/src/tests/elementary/spec/generator.py @@ -1,14 +1,5 @@ #!/usr/bin/python -tests = [ - ["Efl.Pack_Linear" , "Efl.Ui.Box"], - ["Efl.Pack" , "Efl.Ui.Table"], - ["Efl.Content" , "Efl.Ui.Button", "Efl.Ui.Frame", "Efl.Ui.Grid_Default_Item", - "Efl.Ui.List_Default_Item", "Efl.Ui.List_Empty_Item", - "Efl.Ui.Navigation_Layout", "Efl.Ui.Panel", "Efl.Ui.Progressbar", - "Efl.Ui.Radio", "Efl.Ui.Popup", "Efl.Ui.Tab_Page", "Efl.Ui.Scroller"] -] - fixture_gen_template = """ static void _{}_fixture(void) @@ -37,7 +28,10 @@ file_gen_template = """ """ import sys +import json +output_file = sys.argv[-1] +input_files = sys.argv[1:-1] list_of_tcases = "static const Efl_Test_Case etc[] = {\n" list_entry = " {{ \"{}-{}\", {}}},\n" generated_api = "" @@ -51,11 +45,23 @@ def to_func_name(class_name): def to_class_getter(class_name): return class_name.replace('.','_').upper()+'_CLASS' +tests = [] + +for input_file in input_files: + with open(input_file, 'r') as content_file: + content = content_file.read() + start = content.index('spec-meta-start') + len('spec-meta-start') + end = content.index('spec-meta-end') + resulting_json = content[start:end] + tmp = json.loads(resulting_json) + if "test-interface" in tmp and "test-widgets" in tmp: + tests.append(tmp) + widgets = [] for test in tests: - interface_test = to_func_name(test[0]) - for widget_class in test[1:]: + interface_test = to_func_name(test["test-interface"]) + for widget_class in test["test-widgets"]: combo_name = "_{}_{}".format(to_func_name(interface_test), to_func_name(widget_class)); list_of_tcases += list_entry.format(interface_test, to_func_name(widget_class), combo_name) generated_api += tcase_gen_template.format(combo_name, to_func_name(widget_class), interface_to_api(interface_test)) @@ -67,5 +73,5 @@ for widget in widgets: list_of_tcases += " { NULL, NULL }\n};" -output = open(sys.argv[1], "w") +output = open(output_file, "w") output.write(file_gen_template.format(list_of_tcases, generated_api)) diff --git a/src/tests/elementary/spec/meson.build b/src/tests/elementary/spec/meson.build index 7f87d8e8e4..6dfa87c1bd 100644 --- a/src/tests/elementary/spec/meson.build +++ b/src/tests/elementary/spec/meson.build @@ -1,19 +1,24 @@ -efl_ui_suite_behavior_src = [ + +efl_ui_suite_behavior_test_files = files([ + 'efl_test_pack.c', + 'efl_test_pack_linear.c', + 'efl_test_content.c', +]) + +efl_ui_suite_behavior_src = files([ join_paths('..','suite_helpers.c'), join_paths('..','suite_helpers.h'), join_paths('..','elm_test_init.c'), 'efl_ui_spec_suite.c', - 'efl_test_pack.c', - 'efl_test_pack_linear.c', 'efl_test_container.c', - 'efl_test_content.c', -] +]) + efl_ui_suite_behavior_test_files test_generator = find_program('generator.py') generated_test_parts = custom_target('generate_test_suite', + input: efl_ui_suite_behavior_test_files, output: 'efl_ui_spec_suite_gen.x', - command: [test_generator, '@OUTPUT@'], + command: [test_generator, '@INPUT@', '@OUTPUT@'], ) efl_ui_behavior_suite = executable('efl_ui_spec_suite', |