uitest interpreter: some improvements
Change-Id: I7b768694ba5a82f7273fd7641fae5c3fc84233a6 Reviewed-on: https://gerrit.libreoffice.org/58340 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Jenkins
This commit is contained in:
@@ -16,14 +16,15 @@ def parse_line(line):
|
|||||||
This function parses a line from log file
|
This function parses a line from log file
|
||||||
and returns the parsed values as a python dictionary
|
and returns the parsed values as a python dictionary
|
||||||
"""
|
"""
|
||||||
if (line == "" or line.startswith("Action on element")):
|
if (line == ""):
|
||||||
return
|
return
|
||||||
dict = {}
|
dict = {}
|
||||||
if "{" in line:
|
if "{" in line:
|
||||||
start_index_of_parameters = line.find("{")
|
start_index_of_parameters = line.find("{")
|
||||||
end_index_of_parameters = line.find("}") + 1
|
end_index_of_parameters = line.find("}") + 1
|
||||||
parameters = line[start_index_of_parameters:end_index_of_parameters]
|
parameters = line[start_index_of_parameters:end_index_of_parameters]
|
||||||
dict["parameters"] = parameters
|
if parameters != "":
|
||||||
|
dict["parameters"] = parameters
|
||||||
line = line[:start_index_of_parameters-1]
|
line = line[:start_index_of_parameters-1]
|
||||||
word_list = line.split()
|
word_list = line.split()
|
||||||
dict["keyword"] = word_list[0]
|
dict["keyword"] = word_list[0]
|
||||||
@@ -54,7 +55,7 @@ def get_log_file(input_address):
|
|||||||
print("Use " + os.path.basename(sys.argv[0]) + " -h to get usage instructions")
|
print("Use " + os.path.basename(sys.argv[0]) + " -h to get usage instructions")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
content = [x.strip() for x in content]
|
content = [x.strip() for x in content if not x.startswith("Action on element")]
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def initiate_test_generation(address):
|
def initiate_test_generation(address):
|
||||||
@@ -65,6 +66,7 @@ def initiate_test_generation(address):
|
|||||||
print("Use " + os.path.basename(sys.argv[0]) + " -h to get usage instructions")
|
print("Use " + os.path.basename(sys.argv[0]) + " -h to get usage instructions")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
initial_text = \
|
initial_text = \
|
||||||
|
"# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-\n\n" + \
|
||||||
"from uitest.framework import UITestCase\n" + \
|
"from uitest.framework import UITestCase\n" + \
|
||||||
"from libreoffice.uno.propertyvalue import mkPropertyValues\n" + \
|
"from libreoffice.uno.propertyvalue import mkPropertyValues\n" + \
|
||||||
"import importlib\n\n" + \
|
"import importlib\n\n" + \
|
||||||
@@ -135,8 +137,18 @@ def get_test_line_from_one_log_line(log_line):
|
|||||||
test_line += ",tuple())\n"
|
test_line += ",tuple())\n"
|
||||||
return test_line
|
return test_line
|
||||||
elif action_dict["keyword"] == "CommandSent":
|
elif action_dict["keyword"] == "CommandSent":
|
||||||
test_line += "self.xUITest.executeCommand(\"" + \
|
if "parameters" not in action_dict:
|
||||||
action_dict["Name"] + "\")\n"
|
test_line += "self.xUITest.executeCommand(\"" + \
|
||||||
|
action_dict["Name"] + "\")\n"
|
||||||
|
return test_line
|
||||||
|
else:
|
||||||
|
test_line += "self.xUITest.executeCommandWithParameters(\"" + \
|
||||||
|
action_dict["Name"] + "\", mkPropertyValues(" + action_dict["parameters"] + \
|
||||||
|
"))\n"
|
||||||
|
return test_line
|
||||||
|
elif action_dict["keyword"] == "ModalDialogExecuted" or \
|
||||||
|
action_dict["keyword"] == "ModelessDialogConstructed":
|
||||||
|
test_line += action_dict["Id"] + " = " + "self.xUITest.getTopFocusWindow()\n"
|
||||||
return test_line
|
return test_line
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
@@ -187,6 +199,7 @@ def main():
|
|||||||
output_stream.write(test_line)
|
output_stream.write(test_line)
|
||||||
line_number += 2
|
line_number += 2
|
||||||
output_stream.write(" self.ui_test.close_doc()")
|
output_stream.write(" self.ui_test.close_doc()")
|
||||||
|
output_stream.write("\n\n# vim: set shiftwidth=4 softtabstop=4 expandtab:")
|
||||||
output_stream.close()
|
output_stream.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user