Kaydet (Commit) db68a9c0 authored tarafından Saurav Chirania's avatar Saurav Chirania

uitest interpreter: some improvements

Change-Id: I7b768694ba5a82f7273fd7641fae5c3fc84233a6
Reviewed-on: https://gerrit.libreoffice.org/58340Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Jenkins
üst 00f6bec6
......@@ -16,14 +16,15 @@ def parse_line(line):
This function parses a line from log file
and returns the parsed values as a python dictionary
"""
if (line == "" or line.startswith("Action on element")):
if (line == ""):
return
dict = {}
if "{" in line:
start_index_of_parameters = line.find("{")
end_index_of_parameters = line.find("}") + 1
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]
word_list = line.split()
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")
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
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")
sys.exit(1)
initial_text = \
"# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-\n\n" + \
"from uitest.framework import UITestCase\n" + \
"from libreoffice.uno.propertyvalue import mkPropertyValues\n" + \
"import importlib\n\n" + \
......@@ -135,8 +137,18 @@ def get_test_line_from_one_log_line(log_line):
test_line += ",tuple())\n"
return test_line
elif action_dict["keyword"] == "CommandSent":
test_line += "self.xUITest.executeCommand(\"" + \
action_dict["Name"] + "\")\n"
if "parameters" not in action_dict:
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 ""
......@@ -187,6 +199,7 @@ def main():
output_stream.write(test_line)
line_number += 2
output_stream.write(" self.ui_test.close_doc()")
output_stream.write("\n\n# vim: set shiftwidth=4 softtabstop=4 expandtab:")
output_stream.close()
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment