Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r6d646586c7bf81465255281cb3698b8a0cd25998 -r03b5230f7cecbb728de9357e4582cf381b24cba2 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 6d646586c7bf81465255281cb3698b8a0cd25998) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 03b5230f7cecbb728de9357e4582cf381b24cba2) @@ -18,10 +18,12 @@ import time import test +from builtins import str as pyStr from builtins import int as pyInt from configuration import config from dialin.ui import utils from datetime import datetime +from dialin.ui import utils from dialin.common.hd_defs import HDOpModes from dialin.ui.hd_simulator import HDSimulator from dialin.ui.dg_simulator import DGSimulator @@ -578,7 +580,7 @@ """ Method to verify the Page Step indicators [the object on top of the screen which indicates the steps passed, current, remained] @param pre_treatment_step : (int) indicates the Current pre-treatment step - """ + """ test.startSection("verification of page step indicators") for page in range(len(config.PRE_TREATMENT_SCREENS)): bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj, page))) @@ -624,10 +626,43 @@ squish.testSettings.objectNotFoundDebugging = True def get_text_object(screen_obj, txt): + """ + To obtain a text object based on text provided + @param screen_obj: provides the container on which the txt must be present + @returns a real name object + """ names.o_text_object["container"] = screen_obj names.o_text_object["text"] = txt return names.o_text_object +def verify_color_of_entry(entry, vital_parameter, input_field): + """ + Method to verify the color of entry + of systolic, diastolic and heart rate + @param entry: (int) user user entered value + @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) + @param input_field - (obj) object of input field + """ + test.startSection("Verify the color of {} value {}".format(vital_parameter, entry)) + input_field_color = input_field.color.name + entry = pyInt(entry) + if vital_parameter is config.SYSTOLIC_TEXT: + if (entry < config.SYSTOLIC_LOWER_LIMIT) or (entry > config.SYSTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + elif (entry >= config.SYSTOLIC_LOWER_LIMIT) and (entry <= config.SYSTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + elif vital_parameter is config.DIASTOLIC_TEXT: + if (entry < config.DIASTOLIC_LOWER_LIMIT) or (entry > config.DIASTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + elif (entry >= config.DIASTOLIC_LOWER_LIMIT) and (entry <= config.DIASTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + elif vital_parameter is config.HEART_RATE_TITLE: + if (entry < config.HEART_RATE_LOWER_LIMIT) or (entry > config.HEART_RATE_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) + elif (entry >= config.HEART_RATE_LOWER_LIMIT) and (entry <= config.HEART_RATE_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) + test.endSection() + def get_bullet_object(screen_obj, num): """ To obtain a bullet object based on occurrence provided. @@ -638,4 +673,46 @@ names.o_bullet_object["container"] = screen_obj names.o_bullet_object["occurrence"] = num + 1 return names.o_bullet_object - \ No newline at end of file + +def keypad_input(key_value): + """ + Method to enter values using application UI keyboard + @param key_value: (str) User expected value + """ + if key_value is not None: + names.o_keypad_input["text"] = key_value + return names.o_keypad_input + else: + test.log("Invalid text for object.") + names.o_keypad_input["text"] = None + + +def enter_keypad_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + entry = pyStr(entry) #type casted into string format + for value in entry: + squish.mouseClick(squish.waitForObject(keypad_input(value))) + 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 range(len(entered_value)+1): + 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() + + \ No newline at end of file