summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorAhmed ElShreif <aelshreif7@gmail.com>2019-08-09 23:23:11 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2019-08-19 22:56:39 +0800
commite72ae01b906455524a1d4a615ab1a0efb94a6f11 (patch)
treef9dc6e523d1cfd133cd445424a891c8645dbebd1 /uitest
parent99bedce928c33e8cb607f1d3f3c09feebaeb3c6b (diff)
uitest: solve problem with un-named parents
1) Add recursively query for the parent until find an parent with a name. 2) Remove the parent part "from xxxxxx" from the log statment if there is un-named parent 3) Update the compiler to use the most top parent if there is command with no un-named parent Change-Id: Id7dd5092bc995312494b5536720141908e73af9a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/ui_logger_dsl/UI_Object_commands.tx18
-rw-r--r--uitest/ui_logger_dsl/dsl_core.py50
2 files changed, 50 insertions, 18 deletions
diff --git a/uitest/ui_logger_dsl/UI_Object_commands.tx b/uitest/ui_logger_dsl/UI_Object_commands.tx
index fbdab9c4e6ca..9b25e09c6efc 100644
--- a/uitest/ui_logger_dsl/UI_Object_commands.tx
+++ b/uitest/ui_logger_dsl/UI_Object_commands.tx
@@ -19,31 +19,29 @@ UIObjectCommand:
;
ButtonUIObject:
- 'Click on' ui_button=STRING 'from' parent_id=ID
+ 'Click on' ui_button=STRING ('from' parent_id=ID)?
;
CheckBoxUIObject:
- 'Toggle' Check_box_id=STRING 'CheckBox' 'from' parent_id=ID
+ 'Toggle' Check_box_id=STRING 'CheckBox' ('from' parent_id=ID)?
;
RadioButtonUIObject:
- 'Select' Radio_button_id=STRING 'RadioButton' 'from' parent_id=ID
+ 'Select' Radio_button_id=STRING 'RadioButton' ('from' parent_id=ID)?
;
ComboBoxUIObject:
- 'Select in' Combo_box_id=STRING 'ComboBox' 'item number' item_num=INT 'from' parent_id=ID
+ 'Select in' Combo_box_id=STRING 'ComboBox' 'item number' item_num=INT ('from' parent_id=ID)?
;
TabControlUIObject:
- 'Choose Tab number' tab_page_number=INT 'in' tab_id=STRING 'from' parent_id=ID
+ 'Choose Tab number' tab_page_number=INT 'in' tab_id=STRING ('from' parent_id=ID)?
;
-
EditUIObject:
- action=action_on_UIObject 'from' parent_id=ID
+ action=action_on_UIObject ('from' parent_id=ID)?
;
SpinFieldUIObject:
- change=increase_or_ecrease Spin_id=STRING 'from' parent_id=ID
+ change=increase_or_ecrease Spin_id=STRING ('from' parent_id=ID)?
;
ListBoxUIObject:
- 'Select element with position ' POS=INT 'in' list_id=STRING 'from' parent_id=ID
+ 'Select element with position ' POS=INT 'in' list_id=STRING ('from' parent_id=ID)?
;
-
//=============================================================
//hellper grammer for EditUIObject
action_on_UIObject:
diff --git a/uitest/ui_logger_dsl/dsl_core.py b/uitest/ui_logger_dsl/dsl_core.py
index 827f2ca45b20..a1d1da8b60a2 100644
--- a/uitest/ui_logger_dsl/dsl_core.py
+++ b/uitest/ui_logger_dsl/dsl_core.py
@@ -27,6 +27,9 @@ class ul_Compiler:
variables=[]
objects = dict()
current_app=""
+ parent_hierarchy_count=0
+ last_parent=[]
+
def __init__(self , input_address , output_address):
self.ui_dsl_mm = metamodel_from_file('ui_logger_dsl_grammar.tx')
self.output_stream=self.initiate_test_generation(output_address)
@@ -44,6 +47,7 @@ class ul_Compiler:
return content
def initiate_test_generation(self,output_address):
+ self.last_parent.append("MainWindow")
try:
f = open(output_address,"w")
except IOError as err:
@@ -195,6 +199,8 @@ class ul_Compiler:
self.variables.append(old_line)
line = "\t\t" + DialogCommand.dialog_name + " = self.xUITest.getTopFocusWindow()\n"
self.variables.append(line)
+ self.last_parent.append(DialogCommand.dialog_name)
+ self.parent_hierarchy_count=self.parent_hierarchy_count+1
elif (DialogCommand.__class__.__name__ == "OpenModelessDialog"):
old_line = self.variables.pop()
@@ -209,6 +215,8 @@ class ul_Compiler:
self.variables.append(old_line)
line = "\t\t" + DialogCommand.dialog_name + " = self.xUITest.getTopFocusWindow()\n"
self.variables.append(line)
+ self.last_parent.append(DialogCommand.dialog_name)
+ self.parent_hierarchy_count=self.parent_hierarchy_count+1
elif (DialogCommand.__class__.__name__ == "CloseDialog"):
if (self.prev_command.__class__.__name__ == "ButtonUIObject"):
@@ -216,12 +224,17 @@ class ul_Compiler:
line="\t\tself.ui_test.close_dialog_through_button("+\
self.prev_command.ui_button+")\n"
self.variables.append(line)
+ self.last_parent.pop()
+ self.parent_hierarchy_count=self.parent_hierarchy_count-1
self.prev_command=DialogCommand
def handle_button(self, ButtonUIObject):
- self.init_Object(ButtonUIObject.ui_button,ButtonUIObject.parent_id)
+ if ButtonUIObject.parent_id == "" :
+ self.init_Object( ButtonUIObject.ui_button , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(ButtonUIObject.ui_button,ButtonUIObject.parent_id)
self.write_line_without_parameters(ButtonUIObject.ui_button,"CLICK","tuple")
@@ -229,7 +242,10 @@ class ul_Compiler:
def handle_check_box(self, CheckBoxUIObject):
- self.init_Object(CheckBoxUIObject.Check_box_id,CheckBoxUIObject.parent_id)
+ if CheckBoxUIObject.parent_id == "" :
+ self.init_Object( CheckBoxUIObject.Check_box_id , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(CheckBoxUIObject.Check_box_id,CheckBoxUIObject.parent_id)
self.write_line_without_parameters(CheckBoxUIObject.Check_box_id,"CLICK","tuple")
@@ -237,7 +253,10 @@ class ul_Compiler:
def handle_tab(self, TabControlUIObject):
- self.init_Object(TabControlUIObject.tab_id,TabControlUIObject.parent_id)
+ if TabControlUIObject.parent_id == "" :
+ self.init_Object( TabControlUIObject.tab_id , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(TabControlUIObject.tab_id,TabControlUIObject.parent_id)
self.write_line_with_one_parameters(TabControlUIObject.tab_id,"SELECT","POS",TabControlUIObject.tab_page_number)
@@ -245,7 +264,10 @@ class ul_Compiler:
def handle_Combo_box(self, ComboBoxUIObject):
- self.init_Object(ComboBoxUIObject.Combo_box_id,ComboBoxUIObject.parent_id)
+ if ComboBoxUIObject.parent_id == "" :
+ self.init_Object( ComboBoxUIObject.Combo_box_id , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(ComboBoxUIObject.Combo_box_id,ComboBoxUIObject.parent_id)
self.write_line_with_one_parameters(ComboBoxUIObject.Combo_box_id,"SELECT","POS",ComboBoxUIObject.item_num)
@@ -253,7 +275,10 @@ class ul_Compiler:
def handle_Radio_button(self,RadioButtonUIObject):
- self.init_Object(RadioButtonUIObject.Radio_button_id,RadioButtonUIObject.parent_id)
+ if RadioButtonUIObject.parent_id == "" :
+ self.init_Object( RadioButtonUIObject.Radio_button_id , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(RadioButtonUIObject.Radio_button_id,RadioButtonUIObject.parent_id)
self.write_line_without_parameters(RadioButtonUIObject.Radio_button_id,"CLICK","tuple")
@@ -261,7 +286,10 @@ class ul_Compiler:
def handle_List_box(self, ListBoxUIObject):
- self.init_Object(ListBoxUIObject.list_id,ListBoxUIObject.parent_id)
+ if ListBoxUIObject.parent_id == "" :
+ self.init_Object( ListBoxUIObject.list_id , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(ListBoxUIObject.list_id,ListBoxUIObject.parent_id)
self.write_line_with_one_parameters(ListBoxUIObject.list_id,"SELECT","POS",ListBoxUIObject.POS)
@@ -269,7 +297,10 @@ class ul_Compiler:
def handle_spin_field(self,SpinFieldUIObject):
- self.init_Object(SpinFieldUIObject.Spin_id,SpinFieldUIObject.parent_id)
+ if SpinFieldUIObject.parent_id == "" :
+ self.init_Object( SpinFieldUIObject.Spin_id , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(SpinFieldUIObject.Spin_id,SpinFieldUIObject.parent_id)
if(SpinFieldUIObject.change=="Increase"):
self.write_line_without_parameters(SpinFieldUIObject.Spin_id,"UP","tuple")
@@ -279,7 +310,10 @@ class ul_Compiler:
def handle_Edit_uiObject(self,EditUIObject):
- self.init_Object(EditUIObject.action.edit_button,EditUIObject.parent_id)
+ if EditUIObject.parent_id == "" :
+ self.init_Object( EditUIObject.action.edit_button , self.last_parent[self.parent_hierarchy_count] )
+ else:
+ self.init_Object(EditUIObject.action.edit_button,EditUIObject.parent_id)
if(EditUIObject.action.__class__.__name__ =="Type_action"):