Index: shared/scripts/configuration/utility.py =================================================================== diff -u -ra5b3fa865e8e6fd49d44820b8b834e531155c81a -r0f0f87cba116542a90079ea43d94393ef628cbb6 --- shared/scripts/configuration/utility.py (.../utility.py) (revision a5b3fa865e8e6fd49d44820b8b834e531155c81a) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 0f0f87cba116542a90079ea43d94393ef628cbb6) @@ -16,14 +16,16 @@ import object import squish import test +import time from builtins import int as pyInt from configuration import config from dialin.ui import utils from datetime import datetime +from dialin.common.hd_defs import HDOpModes from dialin.ui.hd_simulator import HDSimulator -hd = HDSimulator() +hd_simulator = HDSimulator() def color_verification(exp_val = "Red", act_val = "#c53b33"): @@ -36,7 +38,7 @@ handle the application for log """ test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) - + def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container @@ -491,3 +493,162 @@ test.compare(arterial_max, art_high, "Actual Arterial range maximum value: {} is equal to Expected value: {}".format(arterial_max, art_high)) test.endSection() + +def navigate_to_pretreatment_screen(mode): + """ + Method to navigate to sub mode under pre-treatment screen + @param mode - (int) pre treatment state + """ + hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_PRET.value,0) + hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=mode, water_sample_state=0, + consumables_self_test_state=0, no_cartridge_self_test_state=0, + installation_state=0, dry_self_test_state=0, prime_state=0, + recirculate_state=0, patient_connection_state=0) + + +def convert_seconds_into_min_and_sec(seconds): + min_and_sec = time.strftime("%M:%S", time.gmtime(seconds)) + return min_and_sec + + +def self_test_dry_check_list_text(text): + names.o_self_test_dry_check_list_text["text"] = text + return names.o_self_test_dry_check_list_text + + +def get_time(screen_title): + """ + Method to return the current count down + in the application + @param screen_title - (str) current title of the screen + """ + if screen_title == config.BEGIN_PRIME_TITLE or screen_title == config.PRIMING_TITLE: + parent_object = object.parent(squish.waitForObjectExists(self_test_dry_check_list_text(screen_title))) + elif screen_title == SYSTEM_SELF_TEST_TITLE: + parent_object = object.parent(squish.waitForObjectExists(names.o_system_self_test)) + else: + parent_object = object.parent(squish.waitForObjectExists(names.o_PreTreatmentBase_Filter_Flush_Text)) + time_parent_children = object.children(parent_object) + progress_circle_parent = time_parent_children[4] + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_parent = progress_circle_parent[0] + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_children = object.children(progress_circle_parent[0]) + time_text = progress_circle_children[1] + return time_text.time + + +def verify_countdown(screen_title): + """ + Method to verify the count down + time in application + @param screen_title - (str) current title of the screen + """ + test.startSection("Verify the count down time in application") + for count_down in range(config.COUNT_DOWN_TIME_100, config.MINIMUM_COUNTDOWN_TIME-1, -1): + if screen_title == config.BEGIN_PRIME_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(300, count_down) + elif screen_title == config.PRIMING_TITLE: + hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(300, count_down) + elif screen_title == config.SYSTEM_SELF_TEST_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_no_cartridge_progress_data(300, count_down) + else: + dg_simulator.cmd_send_dg_pre_treatment_filter_flush_progress_data(300, count_down) + actual_time = get_time(screen_title) + expected_time = convert_seconds_into_min_and_sec(count_down) + test.compare(actual_time, expected_time, "Actual count down time: {} should be equal to expected count down time {}".format(actual_time, expected_time)) + verify_the_progress(count_down, screen_title) + test.endSection() + + +def verify_the_progress(count_down, screen_title): + """ + Method to verify the current progress + @param count_down - (int) current count down time + @param screen_title - (str) current title of the screen + """ + test.startSection("Verifying the current progress") + if screen_title == config.BEGIN_PRIME_TITLE or screen_title == config.PRIMING_TITLE: + current_progress = (squish.waitForObjectExists(names.o_self_test_dry_progress)).progressValue + elif screen_title == config.SYSTEM_SELF_TEST_TITLE: + current_progress = (squish.waitForObjectExists(names.o_system_self_test_progress)).progressValue + else: + current_progress = (squish.waitForObjectExists(names.o_filter_flush_progress)).progressValue + #Since progress value is equal maximum count down value - current count down value + expected_progress = config.MAXIMUM_COUNTDOWN_TIME - count_down + test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + test.endSection() + + +def verify_page_step_indicator(screen_obj, pre_treatment_step): + """ + 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 : 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))) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + step_title = squish.waitForObjectExists(get_text_object(screen_obj, config.PRE_TREATMENT_SCREENS[page])) + + if page < pre_treatment_step: + test.log("To verify the step indicator of the completed pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) + test.compare(bullet_circle_color, config.COMPLETE_COLOR, " the bullet color must be " + str(config.COMPLETE_COLOR)) + test.compare(bullet_border_color, config.COMPLETE_COLOR," the bullet border color must be " + str(config.COMPLETE_COLOR)) + test.compare(step_title.color.name, config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) + + elif page == pre_treatment_step: + test.log("To verify the step indicators of the current pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) + test.verify(squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete) + test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) + test.compare(bullet_border_color,config.COMPLETE_COLOR, " the bullet border color must be " + str(config.COMPLETE_COLOR)) + test.compare(step_title.color.name,config.ENABLED_COLOR, " the text color must be " + str(config.ENABLED_COLOR)) + test.verify(step_title.font.bold, " the current text must be in bold") + + else: + test.log("To verify the step indicators of the remaining pre-treatment screen " + config.PRE_TREATMENT_SCREENS[page]) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).current,) + test.verify(not squish.waitForObjectExists(get_bullet_object(screen_obj, page)).complete,) + test.compare(step_title.color.name,config.INCOMPLETE_COLOR, " the text color must be " + str(config.INCOMPLETE_COLOR)) + test.compare(bullet_circle_color,config.CURRENT_COLOR," the bullet color must be " + str(config.CURRENT_COLOR)) + test.compare(bullet_border_color,config.INCOMPLETE_COLOR, " the bullet border color must be " + str(config.INCOMPLETE_COLOR)) + test.endSection() + +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 get_bullet_object(screen_obj, num): + """ + To obtain a bullet object based on occurrence provided. + @param screen_obj: provides the container on which the bullet must be present + @param num: provides the occurrence value + @returns a real name object + """ + names.o_bullet_object["container"] = screen_obj + names.o_bullet_object["occurrence"] = num + 1 + return names.o_bullet_object + +def get_indicators(screen_obj, txt): + """ + Verifying the busy indicators for BiCarb Pump Check and Acid Pump Check. + indicator object of expected txt + @param step - (str) expected txt + @return indicators - (obj) list of busy and check indicator + """ + parent_obj = object.parent(squish.waitForObjectExists(get_text_object(screen_obj,txt))) + children_obj = object.children(parent_obj) + indicator_parent = children_obj[2] + indicators = object.children(indicator_parent) + return indicators