summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uitest/ui_logger_dsl/UI_Object_commands.tx18
-rw-r--r--uitest/ui_logger_dsl/dsl_core.py50
-rw-r--r--vcl/source/uitest/logger.cxx67
-rw-r--r--vcl/source/uitest/uiobject.cxx51
4 files changed, 166 insertions, 20 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"):
diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx
index 36a6c7340add..0ecd673f9879 100644
--- a/vcl/source/uitest/logger.cxx
+++ b/vcl/source/uitest/logger.cxx
@@ -20,6 +20,49 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <memory>
+namespace{
+
+bool isDialogWindow(vcl::Window const * pWindow)
+{
+ WindowType nType = pWindow->GetType();
+ // DIALOG to MODALDIALOG
+ if (nType >= WindowType::DIALOG && nType <= WindowType::MODALDIALOG)
+ return true;
+
+ // MESSBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
+ if (nType >= WindowType::MESSBOX && nType <= WindowType::QUERYBOX)
+ return true;
+
+ if (nType == WindowType::TABDIALOG)
+ return true;
+
+ return false;
+}
+
+bool isTopWindow(vcl::Window const * pWindow)
+{
+ WindowType eType = pWindow->GetType();
+ if (eType == WindowType::FLOATINGWINDOW)
+ {
+ return pWindow->GetStyle() & WB_SYSTEMFLOATWIN;
+ }
+ return false;
+}
+
+vcl::Window* get_top_parent(vcl::Window* pWindow)
+{
+ if (isDialogWindow(pWindow) || isTopWindow(pWindow))
+ return pWindow;
+
+ vcl::Window* pParent = pWindow->GetParent();
+ if (!pParent)
+ return pWindow;
+
+ return get_top_parent(pParent);
+}
+
+
+}
UITestLogger::UITestLogger():
maStream(),
mbValid(false)
@@ -216,7 +259,17 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
OUString aContent;
if(pUIObject->get_type()=="EditUIObject"){
- aContent = "Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+ if(aParentID=="")
+ {
+ VclPtr <vcl::Window> pParent_top = get_top_parent(xUIElement);
+ aParentID= pParent_top->get_id();
+ }
+ if(aParentID==""){
+ aContent = aContent+"Type on '" + rID + "' " + aKeyCode;
+ }
+ else{
+ aContent = aContent+"Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+ }
}
else if(pUIObject->get_type()=="SwEditWinUIObject" && rID=="writer_edit"){
aContent = "Type on writer " + aKeyCode ;
@@ -234,7 +287,17 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
aContent = "Type on draw " + aKeyCode ;
}
else{
- aContent = "Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+ if(aParentID=="")
+ {
+ VclPtr <vcl::Window> pParent_top = get_top_parent(xUIElement);
+ aParentID= pParent_top->get_id();
+ }
+ if(aParentID==""){
+ aContent = "Type on '" + rID + "' " + aKeyCode ;
+ }
+ else{
+ aContent = "Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+ }
}
maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8));
}
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 1919da040f1f..d26072cd05a9 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -622,6 +622,10 @@ OUString ButtonUIObject::get_action(VclEventId nEvent) const
return "Start database" ;
}
else{
+ if (get_top_parent(mxButton)->get_id()==""){
+ //This part because if we don't have parent
+ return "Click on '" + mxButton->get_id() ;
+ }
return "Click on '" + mxButton->get_id() + "' from "+
get_top_parent(mxButton)->get_id();
}
@@ -747,6 +751,14 @@ OUString EditUIObject::get_action(VclEventId nEvent) const
const Selection& rSelection = mxEdit->GetSelection();
long nMin = rSelection.Min();
long nMax = rSelection.Max();
+ if(get_top_parent(mxEdit)->get_id()==""){
+ //This part because if we don't have parent
+ return "Select in '" +
+ mxEdit->get_id() +
+ "' {\"FROM\": \"" + OUString::number(nMin) + "\", \"TO\": \"" +
+ OUString::number(nMax) + "\"}"
+ ;
+ }
return "Select in '" +
mxEdit->get_id() +
"' {\"FROM\": \"" + OUString::number(nMin) + "\", \"TO\": \"" +
@@ -868,6 +880,10 @@ OUString CheckBoxUIObject::get_action(VclEventId nEvent) const
{
if (nEvent == VclEventId::CheckboxToggle)
{
+ if(get_top_parent(mxCheckBox)->get_id()==""){
+ //This part because if we don't have parent
+ return "Toggle '" + mxCheckBox->get_id() + "' CheckBox";
+ }
return "Toggle '" + mxCheckBox->get_id() + "' CheckBox from " +
get_top_parent(mxCheckBox)->get_id();
}
@@ -918,6 +934,10 @@ OUString RadioButtonUIObject::get_action(VclEventId nEvent) const
{
if (nEvent == VclEventId::RadiobuttonToggle)
{
+ if(get_top_parent(mxRadioButton)->get_id()==""){
+ //This part because if we don't have parent
+ return "Select '" + mxRadioButton->get_id() + "' RadioButton";
+ }
return "Select '" + mxRadioButton->get_id() + "' RadioButton from " +
get_top_parent(mxRadioButton)->get_id();
}
@@ -1024,11 +1044,21 @@ OUString ListBoxUIObject::get_action(VclEventId nEvent) const
if (nEvent == VclEventId::ListboxSelect)
{
sal_Int32 nPos = mxListBox->GetSelectedEntryPos();
+ if(get_top_parent(mxListBox)->get_id()==""){
+ //This part because if we don't have parent
+ return "Select element with position " + OUString::number(nPos) +
+ " in '" + mxListBox->get_id();
+ }
return "Select element with position " + OUString::number(nPos) +
" in '" + mxListBox->get_id() +"' from" + get_top_parent(mxListBox)->get_id() ;
}
else if (nEvent == VclEventId::ListboxFocus)
{
+ if(get_top_parent(mxListBox)->get_id()=="")
+ {
+ //This part because if we don't have parent
+ return this->get_type() + " Action:FOCUS Id:" + mxListBox->get_id();
+ }
return this->get_type() + " Action:FOCUS Id:" + mxListBox->get_id() +
" Parent:" + get_top_parent(mxListBox)->get_id();
}
@@ -1099,6 +1129,11 @@ OUString ComboBoxUIObject::get_action(VclEventId nEvent) const
if (nEvent == VclEventId::ComboboxSelect)
{
sal_Int32 nPos = mxComboBox->GetSelectedEntryPos();
+ if (get_top_parent(mxComboBox)->get_id()==""){
+ //This part because if we don't have parent
+ return "Select in '" + mxComboBox->get_id() +
+ "' ComboBox item number " + OUString::number(nPos);
+ }
return "Select in '" + mxComboBox->get_id() +
"' ComboBox item number " + OUString::number(nPos) +
" from " + get_top_parent(mxComboBox)->get_id();
@@ -1214,11 +1249,21 @@ OUString SpinFieldUIObject::get_action(VclEventId nEvent) const
{
if (nEvent == VclEventId::SpinfieldUp)
{
+ if(get_top_parent(mxSpinField)->get_id()=="")
+ {
+ //This part because if we don't have parent
+ return "Increase '" + mxSpinField->get_id();
+ }
return "Increase '" + mxSpinField->get_id() +
"' from " + get_top_parent(mxSpinField)->get_id();
}
else if (nEvent == VclEventId::SpinfieldDown)
{
+ if(get_top_parent(mxSpinField)->get_id()=="")
+ {
+ //This part because if we don't have parent
+ return "Decrease '" + mxSpinField->get_id();
+ }
return "Decrease '" + mxSpinField->get_id() +
"' from " + get_top_parent(mxSpinField)->get_id();
}
@@ -1282,6 +1327,12 @@ OUString TabControlUIObject::get_action(VclEventId nEvent) const
if (nEvent == VclEventId::TabpageActivate)
{
sal_Int32 nPageId = mxTabControl->GetCurPageId();
+
+ if(get_top_parent(mxTabControl)->get_id()==""){
+ //This part because if we don't have parent
+ return "Choose Tab number " + OUString::number(mxTabControl->GetPagePos(nPageId)) +
+ " in '" + mxTabControl->get_id();
+ }
return "Choose Tab number " + OUString::number(mxTabControl->GetPagePos(nPageId)) +
" in '" + mxTabControl->get_id()+
"' from " + get_top_parent(mxTabControl)->get_id() ;