Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r7ca7f96e85f513986b5eeef60916500b84879c36 -r31bdd04017bc17ca8697dea8f78268382184d5f0 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 7ca7f96e85f513986b5eeef60916500b84879c36) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 31bdd04017bc17ca8697dea8f78268382184d5f0) @@ -7,18 +7,25 @@ # # @file utils.py # +# @author (last) Papiya Mandal +# @date (last) 21-Jan-2022 # @author (last) Joseph varghese # @date (last) 15-Jan-2022 # ############################################################################ - - + +import names +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 dialin.ui.hd_simulator import HDSimulator + - def start_application(app_name): """ Function to start application and verify application status [running] @@ -55,22 +62,22 @@ 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 - @return boolean true/false + @return boolean true and 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) @@ -79,8 +86,7 @@ return True return False - - + def scroll_to_zone(zone=None, screen_object=None): """ scroll to the numeric if object is hidden @@ -103,7 +109,96 @@ 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") + + +def pressure_pop_up_text_obj(text): + names.o_pop_up_pressure_text_obj["text"] = text + return names.o_pop_up_pressure_text_obj + +def pressure_text_obj(text): + names.o_pressure_text_obj["text"] = text + return names.o_pressure_text_obj + +def get_current_date_and_time(): + + date_format='%Y/%b/%d - %H:%M' + date = datetime.now() + return str(date.strftime(date_format)) + +def enter_keypad_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + for value in entry: + value = pyInt(value) + key_val = squish.waitForObject(keypad_input(value)) + squish.mouseClick(key_val) + utils.waitForGUI(1) + test.endSection() + +def erase_entered_value(input_field): + """ + Method to erase the entered value + @param input_field - (obj) object of input field + """ + test.startSection("Erasing value") + input_field= squish.waitForObject(input_field) + entered_value = str(input_field.text) + for value in entered_value: + utils.waitForGUI(1) + squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) + + test.compare(str(input_field.text), "", "Input field should be empty") + test.endSection() + +def vitals_reading_obj(reading): + names.o_vitals_reading["text"] = reading + return names.o_vitals_reading + +def keypad_input(key_value): + names.o_keypad_input["text"] = key_value + return names.o_keypad_input + + +def scroll_to_value_on_pop_up(value=None, container=None): + """ + scroll to the to the value if object is hidden + @param value - value object + @param container - Container of the value + @return boolean true and false + """ + counter = 0 + while counter <= 100: + try: + counter += 1 + squish.findObject(value) + squish.snooze(0.5) + if check_if_object_is_within_the_container(obj=value, container=container): + return True + else: + raise RuntimeError + except RuntimeError: + ScreenObj = squish.waitForObject(container) + screenHeight = pyInt(ScreenObj.height) + screenWidth = pyInt(ScreenObj.width) + squish.mouseWheel(ScreenObj, screenWidth//2, + screenHeight//2, 0, -50, squish.Qt.NoModifier) + + raise LookupError("value object is not in view to the user after " + \ + "trying 100 times") + +def get_alarm_id_obj(id): + names.o_alarm_id["text"] = id + return names.o_alarm_id + +def get_alarm_msg_obj(msg): + names.o_alarm_message["text"] = msg + return names.o_alarm_message +