Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r7fb24046293d1d1f1c4dba5f0b679e403ac096db -rbf0f91cc77deda73a01e96768c76160d71e46ddf --- shared/scripts/configuration/utility.py (.../utility.py) (revision 7fb24046293d1d1f1c4dba5f0b679e403ac096db) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision bf0f91cc77deda73a01e96768c76160d71e46ddf) @@ -15,70 +15,30 @@ import builtins import names import pytz +import squish import sys import test -import squish from configuration import config from dialin.ui import utils from builtins import int as pyInt from datetime import datetime -from pytz import timezone -from squish import * -def start_application(app_name): - """ - Function to start application and verify application status [running] - If application does not start or running status is false, test stops - Argument: - @param app_name : (str) - Name of the application - @param app_executable : (str) - Actual application - @return: handle for the application if the application is in running state, - or error (exist the application) - """ - counter = 0 - while True: - try: - counter += 1 - test.log("Starting {}".format(app_name)) - squish.startApplication(app_name) - if counter == 1: - test.log("Application launched at the "+str(counter)+" st try.") - elif counter == 2: - test.log("Application launched at the "+str(counter)+" nd try.") - elif counter == 3: - test.log("Application launched at the "+str(counter)+" rd try.") - else: - test.log("Application launched at the "+str(counter)+" th try.") - break - except RuntimeError: - if counter == 1: - test.log("Application failed to launch after "+str(counter)+" try - Please refer logs") - elif counter == 20: - test.log("Exiting after "+str(counter)+ " tries..") - sys.exit(1) - else: - test.log("Application failed to launch after "+str(counter)+ " tries - Please refer logs") - except: - logErrorDetails("Failed to start the application") - sys.exit(1) - - def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container - @param obj - child UI object - @param container - container UI object + @param obj - (obj) child UI object + @param container - (obj) container UI object @return boolean true/false """ container = squish.findObject(container) - containerPos = container.mapToGlobal(squish.QPoint(0, 0)) + containerPos = container.mapToGlobal(QPoint(0, 0)) container_x, container_y = pyInt(containerPos.x), pyInt(containerPos.y) container_width, container_height = pyInt(container.width), pyInt(container.height) obj = squish.findObject(obj) - objPos = obj.mapToGlobal(squish.QPoint(0, 0)) + objPos = obj.mapToGlobal(QPoint(0, 0)) obj_x, obj_y = pyInt(objPos.x), pyInt(objPos.y) obj_width, obj_height = pyInt(obj.width), pyInt(obj.height) @@ -111,7 +71,7 @@ screenHeight = pyInt(ScreenObj.height) screenWidth = pyInt(ScreenObj.width) squish.mouseWheel(ScreenObj, screenWidth-1000, - screenHeight-10, 0, -50, squish.Qt.NoModifier) + screenHeight-10, 0, -50, Qt.NoModifier) raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") @@ -121,26 +81,22 @@ date_format='%Y/%b/%d - %H:%M' date = datetime.now() - - device_timezone=pytz.timezone('US/Pacific') - date = device_timezone.localize(date) date = date.astimezone(device_timezone) - return str(date.strftime(date_format)) def enter_keypad_value(entry): """ Method to enter user desired value using keypad - @param entry: User expected value + @param entry: (str) User expected value """ - test.startSection("Enter {entry}".format(entry=entry)) + test.startSection("Enter {}".format(entry)) for value in entry: value = builtins.int(value) - key_val = waitForObject(names.keypad_input(key_value=value)) + key_val = squish.waitForObject(names.keypad_input(key_value=value)) squish.mouseClick(key_val) utils.waitForGUI(1) test.endSection() @@ -149,18 +105,16 @@ def erase_entered_value(input_field): """ Method to erase the entered value - @param input_field - object of input field + @param input_field - (obj) object of input field """ test.startSection("Erasing value") - input_field= waitForObject(input_field) + input_field= squish.waitForObject(input_field) entered_value = input_field.text.toUtf8().constData() for value in entered_value: utils.waitForGUI(1) - squish.mouseClick(waitForObjectExists(names.o_back_space_key)) + squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) test.compare(input_field.text.toUtf8().constData(), "", "Input field should be empty") test.endSection() - - - - + + \ No newline at end of file