efl_ui_spec_suite: move the information about tests to the test files
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Tue, 23 Apr 2019 08:21:43 +0000 (10:21 +0200)
committerWoochanlee <wc0917.lee@samsung.com>
Tue, 30 Apr 2019 00:47:50 +0000 (09:47 +0900)
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

src/tests/elementary/spec/efl_test_content.c
src/tests/elementary/spec/efl_test_pack.c
src/tests/elementary/spec/efl_test_pack_linear.c
src/tests/elementary/spec/generator.py
src/tests/elementary/spec/meson.build

index e0652b6..1231d70 100644 (file)
@@ -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);
index 626e3e9..61b3baf 100644 (file)
@@ -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.
index cf85f91..31647fa 100644 (file)
@@ -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])
 {
index 3a84b01..c6f73ed 100755 (executable)
@@ -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))
index 7f87d8e..6dfa87c 100644 (file)
@@ -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',