summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2018-04-16 19:12:33 -0300
committerLarry Jr <larry.olj@gmail.com>2018-04-16 19:12:33 -0300
commit4ed3bfe4f8f5d7c5656fbba09f49bdf3f7d45942 (patch)
tree291fa1b9de6f68d87c7c48aa51063a83edf2a1f2
parenta09a8030f93a6669302db4430a0a82d9212112c3 (diff)
automatedtest-mono: fixed directions and complex typesdevs/felipealmeida/automatedtests
-rwxr-xr-xsrc/scripts/pyolian/testgenerator.py113
-rw-r--r--src/scripts/pyolian/testgenerator_suite.cs.template8
2 files changed, 90 insertions, 31 deletions
diff --git a/src/scripts/pyolian/testgenerator.py b/src/scripts/pyolian/testgenerator.py
index aa846c2a69..7ec22be127 100755
--- a/src/scripts/pyolian/testgenerator.py
+++ b/src/scripts/pyolian/testgenerator.py
@@ -42,13 +42,9 @@ def load_file(filename):
42 return f.read() 42 return f.read()
43 return None 43 return None
44 44
45dicttypes = {}
46 45
47keywords = [] 46def cs_types(suite):
48 47 suite.dicttypes = {"byte": "sbyte"
49def cs_types():
50 global keywords
51 dicttypes.update({"byte": "sbyte"
52 , "llong": "long" 48 , "llong": "long"
53 , "int8": "sbyte" 49 , "int8": "sbyte"
54 , "int16": "short" 50 , "int16": "short"
@@ -79,31 +75,67 @@ def cs_types():
79 , "array": "eina.Array" 75 , "array": "eina.Array"
80 , "inarray": "eina.Inarray" 76 , "inarray": "eina.Inarray"
81 , "hash": "eina.Hash" 77 , "hash": "eina.Hash"
82 , "promise": " int" 78 , "promise": "int"
83 , "future": " int" 79 , "future": "int"
84 , "iterator": "eina.Iterator" 80 , "iterator": "eina.Iterator"
85 , "accessor": " int" 81 , "accessor": "int"
86 }) 82 }
87 83
88 keywords = ["delete", "do", "lock", "event", "in", "object", 84 suite.dictwords = {'INOUT':'ref ', 'OUT': 'out '}
89 "interface", "string", "internal", "fixed", "base"]
90 85
91def escape_keyword(key): 86 suite.keywords = ["delete", "do", "lock", "event", "in", "object",
92 if key in keywords: 87 "interface", "string", "internal", "fixed", "base"]
88 suite.blist_func = [
89 "efl_event_callback_array_priority_add"
90 , "efl_player_position_get"
91 , "efl_text_font_source_get"
92 , "efl_text_font_source_set"
93 , "efl_ui_focus_manager_focus_get"
94 , "efl_ui_widget_focus_set"
95 , "efl_ui_widget_focus_get"
96 , "efl_ui_text_password_get"
97 , "efl_ui_text_password_set"
98 , "elm_interface_scrollable_repeat_events_get"
99 , "elm_interface_scrollable_repeat_events_set"
100 , "elm_wdg_item_del"
101 , "elm_wdg_item_focus_get"
102 , "elm_wdg_item_focus_set"
103 , "elm_interface_scrollable_mirrored_set"
104 , "evas_obj_table_mirrored_get"
105 , "evas_obj_table_mirrored_set"
106 , "edje_obj_load_error_get"
107 , "efl_ui_focus_user_parent_get"
108 , "efl_canvas_object_scale_get" # duplicated signature
109 , "efl_canvas_object_scale_set" # duplicated signature
110 , "efl_access_parent_get"
111 , "efl_access_name_get"
112 , "efl_access_name_set"
113 , "efl_access_root_get"
114 , "efl_access_type_get"
115 , "efl_access_role_get"
116 , "efl_access_action_description_get"
117 , "efl_access_action_description_set"
118 , "efl_access_image_description_get"
119 , "efl_access_image_description_set"
120 , "efl_access_component_layer_get" # duplicated signature
121 , "efl_access_component_alpha_get"
122 , "efl_access_component_size_get"
123 , "efl_ui_spin_button_loop_get"
124 , "efl_ui_list_model_size_get"
125 , "efl_ui_list_relayout_layout_do"
126 ]
127
128def escape_keyword(suite, key):
129 if key in suite.keywords:
93 return "kw_{}".format(key) 130 return "kw_{}".format(key)
94 return key 131 return key
95 132
96def to_csharp_klass_name(eo_name): 133def to_csharp_klass_name(suite, eo_name):
97 names = eo_name.split('.') 134 names = eo_name.split('.')
98 namespaces = [escape_keyword(x.lower()) for x in names[:-1]] 135 namespaces = [escape_keyword(suite, x.lower()) for x in names[:-1]]
99 klass_name = names[-1] 136 klass_name = names[-1]
100 return '.'.join(namespaces + [klass_name]) 137 return '.'.join(namespaces + [klass_name])
101 138
102def type_convert(eotype):
103 if eotype.type == eotype.type.VOID:
104 return 'System.IntPtr'
105 return dicttypes.get(eotype.name, to_csharp_klass_name(eotype.name))
106
107""" 139"""
108It will find methods and functions with owned return and without other params 140It will find methods and functions with owned return and without other params
109""" 141"""
@@ -138,9 +170,6 @@ class Template(pyratemp.Template):
138 # Build the context for the template 170 # Build the context for the template
139 ctx = {} 171 ctx = {}
140 ctx['suite'] = suite 172 ctx['suite'] = suite
141 ctx['type_convert'] = type_convert
142 ctx['keywords'] = keywords
143
144 # render with the augmented context 173 # render with the augmented context
145 output = self(**ctx) 174 output = self(**ctx)
146 175
@@ -166,8 +195,14 @@ class SuiteCase():
166 "dup", "reset", "unload", "close", "set", "interpolate", "has", "grab", "check", "find", "ungrab", 195 "dup", "reset", "unload", "close", "set", "interpolate", "has", "grab", "check", "find", "ungrab",
167 "unset", "clear", "pop", "new", "peek", "push", "update", "show", "move", "hide", "calculate", 196 "unset", "clear", "pop", "new", "peek", "push", "update", "show", "move", "hide", "calculate",
168 "resize", "attach", "pack", "unpack", "emit", "call", "append"] 197 "resize", "attach", "pack", "unpack", "emit", "call", "append"]
198
199 self.dicttypes = {}
200 self.dictwords = {}
201 self.blist_func = []
202 self.keywords = []
203
169 if self.ext == '.cs': 204 if self.ext == '.cs':
170 cs_types() 205 cs_types(self)
171 206
172 def __del__(self): 207 def __del__(self):
173 for cls in self.clslist: 208 for cls in self.clslist:
@@ -179,6 +214,29 @@ class SuiteCase():
179 214
180 self.clslist = None 215 self.clslist = None
181 216
217 def type_convert(self, eotype):
218 if eotype.type == eotype.type.VOID:
219 return 'System.IntPtr'
220
221 new_type = self.dicttypes.get(eotype.name, to_csharp_klass_name(self, eotype.name))
222 if new_type != 'int' and eotype.base_type:
223 new_type = "{}<{}>".format(new_type, self.dicttypes.get(eotype.base_type.name, to_csharp_klass_name(self, eotype.base_type.name)))
224
225 return new_type
226
227 def print_arg(self, eoarg):
228 r = 'arg_{}'.format(eoarg.name)
229
230 prefix = self.dictwords.get(eoarg.direction.name)
231
232 if prefix == 'out' and (eoarg.type.name == "Eina.Slice" or eoarg.type.name == "Eina.Rw_Slice"):
233 prefix = 'ref'
234
235 if not prefix and eoarg.type.is_ptr and eoarg.type.type == eoarg.type.type.REGULAR and eoarg.type.typedecl and eoarg.type.typedecl.type == eoarg.type.typedecl.type.STRUCT:
236 prefix = 'ref'
237
238 return prefix and ' '.join([prefix, r]) or r
239
182 def load(self, testdir, eofiles): 240 def load(self, testdir, eofiles):
183 self.clslist = [] 241 self.clslist = []
184 self.custom = load_file(os.path.join(testdir, "{}_custom{}".format(self.name, self.ext))) or '' 242 self.custom = load_file(os.path.join(testdir, "{}_custom{}".format(self.name, self.ext))) or ''
@@ -197,7 +255,7 @@ class SuiteCase():
197 cls.init = load_file(os.path.join(filedir, "init{}".format(self.ext))) 255 cls.init = load_file(os.path.join(filedir, "init{}".format(self.ext)))
198 cls.shutdown = load_file(os.path.join(filedir, "shutdown{}".format(self.ext))) 256 cls.shutdown = load_file(os.path.join(filedir, "shutdown{}".format(self.ext)))
199 257
200 cls.mlist = list(cls.methods) 258 cls.mlist = [ m for m in cls.methods if m.full_c_method_name not in self.blist_func ]
201 for func in cls.mlist: 259 for func in cls.mlist:
202 cls.custom += load_file(os.path.join(filedir, func.name, "custom{}".format(self.ext))) or '' 260 cls.custom += load_file(os.path.join(filedir, func.name, "custom{}".format(self.ext))) or ''
203 func.init = load_file(os.path.join(filedir, func.name, "init{}".format(self.ext))) 261 func.init = load_file(os.path.join(filedir, func.name, "init{}".format(self.ext)))
@@ -205,7 +263,8 @@ class SuiteCase():
205 func.arg_init = load_file(os.path.join(filedir, func.name, "arg_init{}".format(self.ext))) or '' 263 func.arg_init = load_file(os.path.join(filedir, func.name, "arg_init{}".format(self.ext))) or ''
206 func.arg_shutdown = load_file(os.path.join(filedir, func.name, "arg_shutdown{}".format(self.ext))) or '' 264 func.arg_shutdown = load_file(os.path.join(filedir, func.name, "arg_shutdown{}".format(self.ext))) or ''
207 265
208 cls.plist = [ p for p in cls.properties if p.getter_scope == p.getter_scope.PUBLIC or p.setter_scope == p.setter_scope.PUBLIC ] 266 cls.plist = [ p for p in cls.properties if (p.getter_scope == p.getter_scope.PUBLIC and p.full_c_getter_name not in self.blist_func) or
267 (p.setter_scope == p.setter_scope.PUBLIC and p.full_c_setter_name not in self.blist_func)]
209 for func in cls.plist: 268 for func in cls.plist:
210 if func.getter_scope == func.getter_scope.PUBLIC: 269 if func.getter_scope == func.getter_scope.PUBLIC:
211 cls.custom += load_file(os.path.join(filedir, '{}_get'.format(func.name), "custom{}".format(self.ext))) or '' 270 cls.custom += load_file(os.path.join(filedir, '{}_get'.format(func.name), "custom{}".format(self.ext))) or ''
diff --git a/src/scripts/pyolian/testgenerator_suite.cs.template b/src/scripts/pyolian/testgenerator_suite.cs.template
index 54fe4b3197..b068018fc7 100644
--- a/src/scripts/pyolian/testgenerator_suite.cs.template
+++ b/src/scripts/pyolian/testgenerator_suite.cs.template
@@ -1,6 +1,6 @@
1<!--(macro def_obj)-->${'.'.join(param.type.namespaces).lower()}$.${param.type.short_name}$ arg_${param.name}$ = null;<!--(end)--> 1<!--(macro def_obj)-->${'.'.join(param.type.namespaces).lower()}$.${param.type.short_name}$ arg_${param.name}$ = null;<!--(end)-->
2<!--(macro def_param)--> 2<!--(macro def_param)-->
3 <!--(if param.type.type == param.type.type.CLASS)-->${def_obj(param=param)}$<!--(else)-->${type_convert(param.type)}$ arg_${param.name}$ = default(${type_convert(param.type)}$);<!--(end)--> 3 <!--(if param.type.type == param.type.type.CLASS)-->${def_obj(param=param)}$<!--(else)-->${suite.type_convert(param.type)}$ arg_${param.name}$ = default(${suite.type_convert(param.type)}$);<!--(end)-->
4<!--(end)--> 4<!--(end)-->
5<!--(macro def_params)--> 5<!--(macro def_params)-->
6 <!--(for p in parameters)--> 6 <!--(for p in parameters)-->
@@ -65,7 +65,7 @@ ${def_params(parameters=func.parameters)}$
65${func.arg_init}$ 65${func.arg_init}$
66${func.init}$ 66${func.init}$
67 <!--(end)--> 67 <!--(end)-->
68 <!--(if func.method_return_type)-->var r = <!--(end)-->obj.${func.csname}$(${', '.join(['{} arg_{}'.format( param.direction.name.lower().replace('in', ''), param.name) for param in func.parameters])}$); 68 <!--(if func.method_return_type)-->var r = <!--(end)-->obj.${func.csname}$(${', '.join([ suite.print_arg(p) for p in func.parameters])}$);
69 <!--(if func.arg_shutdown or func.shutdown)--> 69 <!--(if func.arg_shutdown or func.shutdown)-->
70${func.arg_shutdown}$ 70${func.arg_shutdown}$
71${func.shutdown}$ 71${func.shutdown}$
@@ -91,7 +91,7 @@ ${func.get_init}$
91 <!--(if len(list(func.getter_values)) == 1)--> 91 <!--(if len(list(func.getter_values)) == 1)-->
92 var arg_${list(func.getter_values)[0].name}$ = obj.Get${func.csname}$(${', '.join(['arg_{}'.format(param.name) for param in func.getter_keys])}$); 92 var arg_${list(func.getter_values)[0].name}$ = obj.Get${func.csname}$(${', '.join(['arg_{}'.format(param.name) for param in func.getter_keys])}$);
93 <!--(else)--> 93 <!--(else)-->
94 obj.Get${func.csname}$(${', '.join(['arg_{}'.format(p.name) for p in func.getter_keys] + ['out arg_{}'.format(p.name) for p in func.getter_values])}$); 94 obj.Get${func.csname}$(${', '.join([suite.print_arg(p) for p in func.getter_keys] + ['out arg_{}'.format(p.name) for p in func.getter_values])}$);
95 <!--(end)--> 95 <!--(end)-->
96 <!--(if func.arg_get_shutdown or func.get_shutdown)--> 96 <!--(if func.arg_get_shutdown or func.get_shutdown)-->
97${func.arg_get_shutdown}$ 97${func.arg_get_shutdown}$
@@ -112,7 +112,7 @@ ${def_params(parameters=func.setter_keys)}$
112${func.arg_set_init}$ 112${func.arg_set_init}$
113${func.set_init}$ 113${func.set_init}$
114 <!--(end)--> 114 <!--(end)-->
115 obj.Set${func.csname}$(${', '.join(['arg_{}'.format(p.name) for p in list(func.setter_keys) + list(func.setter_values)])}$); 115 obj.Set${func.csname}$(${', '.join([suite.print_arg(p) for p in list(func.setter_keys) + list(func.setter_values)])}$);
116 <!--(if func.arg_set_shutdown or func.set_shutdown)--> 116 <!--(if func.arg_set_shutdown or func.set_shutdown)-->
117${func.arg_set_shutdown}$ 117${func.arg_set_shutdown}$
118${func.set_shutdown}$ 118${func.set_shutdown}$