Index: shared/scripts/configuration/config.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r262cc42e2b0a0044bc0c698249b0da502a31766f --- shared/scripts/configuration/config.py (.../config.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/config.py (.../config.py) (revision 262cc42e2b0a0044bc0c698249b0da502a31766f) @@ -32,3 +32,15 @@ BLOOD_PRIMING_TEXT = "Blood Priming" SALINE_UNIT = "mL" BLOOD_PRIMING_DEFAULT_VALUE = "0 mL" + +#pre-treatment_priming +NOT_VISIBLE = False +VISIBLE = True +FOCUS = True +NOT_IN_FOCUS = False +BUSY = "Busy" +CHECK = "Check" +BEGIN_PRIME_TITLE = "Begin Prime" +PRIMING_TITLE = "Priming" +MAXIMUM_COUNTDOWN_TIME = 300 +MINIMUM_COUNTDOWN_TIME = 0 Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r5fc2cf1333ef13de0a5b547e8b029f664b263941 -r262cc42e2b0a0044bc0c698249b0da502a31766f --- shared/scripts/configuration/utility.py (.../utility.py) (revision 5fc2cf1333ef13de0a5b547e8b029f664b263941) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 262cc42e2b0a0044bc0c698249b0da502a31766f) @@ -12,56 +12,19 @@ # ############################################################################ +import object import names import sys import time import test import squish -from configuration import config +from configuration.config import * from builtins import int as pyInt from dialin.ui.hd_simulator import HDSimulator -from cgitb import text hd_simulator = HDSimulator() -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 @@ -133,4 +96,62 @@ 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 \ No newline at end of file + 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 + @return time_text - (str) count down in the application + """ + if screen_title == BEGIN_PRIME_TITLE or screen_title == PRIMING_TITLE: + parent_object = object.parent(squish.waitForObjectExists(self_test_dry_check_list_text(screen_title))) + else: + parent_object = object.parent(squish.waitForObjectExists(system_self_test(screen_title))) + 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_the_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(MAXIMUM_COUNTDOWN_TIME, MINIMUM_COUNTDOWN_TIME-1, -1): + test.log(str(count_down)) + if screen_title == BEGIN_PRIME_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(total=300, countdown=count_down) + elif screen_title == PRIMING_TITLE: + hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(timeout=300, countdown=count_down) + elif screen_title == SYSTEM_SELF_TEST_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_no_cartridge_progress_data(total=300, countdown=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 + """ + test.startSection("Verifying the current progress") + if screen_title == BEGIN_PRIME_TITLE or screen_title == PRIMING_TITLE: + current_progress = (squish.waitForObjectExists(names.o_self_test_dry_progress)).progressValue + else: + current_progress = (squish.waitForObjectExists(names.o_system_self_test_progress)).progressValue + #Since progress value is equal maximum count down value - current count down value + expected_progress = MAXIMUM_COUNTDOWN_TIME - count_down + test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + test.endSection() \ No newline at end of file Index: shared/scripts/names.py =================================================================== diff -u -r5fc2cf1333ef13de0a5b547e8b029f664b263941 -r262cc42e2b0a0044bc0c698249b0da502a31766f --- shared/scripts/names.py (.../names.py) (revision 5fc2cf1333ef13de0a5b547e8b029f664b263941) +++ shared/scripts/names.py (.../names.py) (revision 262cc42e2b0a0044bc0c698249b0da502a31766f) @@ -59,7 +59,6 @@ o_self_test_dry_check_list_text = {"container": o_PreTreatmentPrimeStack_PreTreatmentBase_TreatmentFlowBase, "type": "Text", "unnamed": 1, "visible": True} #Priming title o_priming_title_text = {"container": o_PreTreatmentPrimeStack_PreTreatmentBase_TreatmentFlowBase, "text": "Priming", "type": "Text", "unnamed": 1, "visible": True} -#busy indicator -o_busy_indicator = {"container": o_PreTreatmentPrimeStack_PreTreatmentBase_TreatmentFlowBase, "id": "_busyIndicator", "source": "qrc:/images/iBusy", "type": "Image", "unnamed": 1, "visible": True} -#check mark -o_check_mark = {"container": o_PreTreatmentPrimeStack_PreTreatmentBase_TreatmentFlowBase, "id": "_checkIndicator", "occurrence": 2, "source": "qrc:/images/iBusyDone", "type": "Image", "unnamed": 1, "visible": True} \ No newline at end of file +#check_mark_parent_object +o_self_test_dry_progress_circle = {"container": o_PreTreatmentPrimeStack_PreTreatmentBase_TreatmentFlowBase, "id": "_progressCircle", "type": "ProgressCircle", "unnamed": 1, "visible": True} + Index: tst_pre_treatment_priming/test.py =================================================================== diff -u -r5fc2cf1333ef13de0a5b547e8b029f664b263941 -r262cc42e2b0a0044bc0c698249b0da502a31766f --- tst_pre_treatment_priming/test.py (.../test.py) (revision 5fc2cf1333ef13de0a5b547e8b029f664b263941) +++ tst_pre_treatment_priming/test.py (.../test.py) (revision 262cc42e2b0a0044bc0c698249b0da502a31766f) @@ -9,11 +9,15 @@ hd_simulator = HDSimulator() -BEGIN_PRIME_TITLE = "Begin Prime" -PRIMING_TITLE = "Priming" -MAXIMUM_COUNTDOWN_TIME = 300 -MINIMUM_COUNTDOWN_TIME = 0 - +SELF_TEST_DRY_STATES = {"DRY_SELF_TESTS_STATE" : 0, "DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE" : 1, + "DRY_SELF_TESTS_USED_CARTIDGE_CHECK_STATE": 2, "DRY_SELF_TESTS_OCCLUSION_SENSORS_STATE": 3, + "DRY_SELF_TESTS_PRESSURE_SENSORS_SETUP_STATE" : 4, "DRY_SELF_TESTS_PRESSURE_SENSORS_STATE" : 5, + "DRY_SELF_TESTS_PRESSURE_SENSORS_NORMAL_STATE" : 6, "DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE" : 7, + "DRY_SELF_TESTS_STOPPED_STATE" : 8, "DRY_SELF_TESTS_COMPLETE_STATE" : 9} +TEST_DRY_STEPS = ["Used Cartridge Check", "Occlusion Sensors Check", "Pressure Sensors Check", "Syringe Pump Check"] +SELF_TEST_COMPLETION_MSG = "Self Test Complete!" + + def navigate_self_test_dry_screen(): """ Method to navigate to self test dry @@ -40,65 +44,122 @@ test.endSection() -def get_time(screen_title): + + + +def verify_dry_states(): """ - Method to return the current count down - in the application - @return time_text - (str) count down in the application + Method to simulating different states + of self dry test and verify the busy and + check indicator """ - parent_object = object.parent(waitForObjectExists(self_test_dry_check_list_text(screen_title))) - 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 + test.startSection("Simulating different states of self dry test and verifying the busy and check indicator") + for state, index in SELF_TEST_DRY_STATES.items(): + test.startSection("Passing {} state".format(state)) + hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=5, water_sample_state=0, + consumables_self_test_state=0, no_cartridge_self_test_state=0, + installation_state=0, dry_self_test_state=index, prime_state=0, + recirculate_state=0, patient_connection_state=0) + if (state == "DRY_SELF_TESTS_STATE") or (state == "DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE"): + verify_the_indicators(indicator=None, steps=TEST_DRY_STEPS) + elif state == "DRY_SELF_TESTS_USED_CARTIDGE_CHECK_STATE": + verify_the_indicators(indicator=BUSY, steps="Used Cartridge Check") + elif state == "DRY_SELF_TESTS_OCCLUSION_SENSORS_STATE": + verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") + verify_the_indicators(indicator=BUSY, steps="Occlusion Sensors Check") + elif (state == "DRY_SELF_TESTS_PRESSURE_SENSORS_SETUP_STATE") or (state == "DRY_SELF_TESTS_PRESSURE_SENSORS_STATE") or (state == "DRY_SELF_TESTS_PRESSURE_SENSORS_NORMAL_STATE"): + verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") + verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") + verify_the_indicators(indicator=BUSY, steps= "Pressure Sensors Check") + elif state == "DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE": + verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") + verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") + verify_the_indicators(indicator=CHECK, steps="Pressure Sensors Check") + verify_the_indicators(indicator=BUSY, steps="Syringe Pump Check") + elif state == "DRY_SELF_TESTS_STOPPED_STATE": + verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") + verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") + verify_the_indicators(indicator=CHECK, steps="Pressure Sensors Check") + verify_the_indicators(indicator=CHECK, steps="Syringe Pump Check") + verify_completion_message_and_indicator(False) + else: + verify_the_indicators(indicator=CHECK, steps="Used Cartridge Check") + verify_the_indicators(indicator=CHECK, steps="Occlusion Sensors Check") + verify_the_indicators(indicator=CHECK, steps="Pressure Sensors Check") + verify_the_indicators(indicator=BUSY, steps="Syringe Pump Check") + verify_completion_message_and_indicator(True) + test.endSection() + test.endSection() + + +def get_indicators(step): + """ + Method to return the busy and check + indicator object of expected step + @param step - (str) expected step + """ + parent_obj = object.parent(waitForObjectExists(self_test_dry_check_list_text(step))) + children_obj = object.children(parent_obj) + indicator_parent = children_obj[2] + indicators = object.children(indicator_parent) + return indicators -def verify_the_countdown(screen_title): +def verify_the_indicators(indicator, steps): """ - Method to verify the count down - time in application + Method to verify the indicator + next to each check list steps + @param indicator - (str) expected indicator + @param steps - Expected steps """ - test.startSection("Verify the count down time in application") - for count_down in range(MINIMUM_COUNTDOWN_TIME, MAXIMUM_COUNTDOWN_TIME+1): - if screen_title == BEGIN_PRIME_TITLE: - hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(total=300, countdown=count_down) - else: - hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(timeout=300, countdown=count_down) - actual_time = get_time(screen_title) - expected_time = convert_seconds_into_min_and_sec(count_down) - if count_down > MAXIMUM_COUNTDOWN_TIME or count_down < MINIMUM_COUNTDOWN_TIME: - test.xcompare(actual_time, expected_time, "{} should not display on progress circle".format(expected_time)) - else: - 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) + test.startSection("Verify indicator is displayed for {}".format(steps)) + if indicator != None: + busy_indicator, check_indicator = get_indicators(steps) + if indicator is BUSY: + test.compare(busy_indicator.visible, VISIBLE, "{} indicator should display next to the {}".format(indicator, steps)) + elif indicator is CHECK: + test.compare(check_indicator.visible, VISIBLE, "{} indicator should display next to the {}".format(indicator, steps)) + else: + for step in steps: + busy_indicator, check_indicator = get_indicators(step) + test.compare(busy_indicator.visible, NOT_VISIBLE, "No indicator should display next to the {}".format(step)) + test.compare(check_indicator.visible, NOT_VISIBLE, "No indicator should display next to the {}".format(step)) + test.endSection() -def verify_the_progress(count_down): +def verify_completion_message_and_indicator(completed): + """ + Method to verify the 'Self Test Complete!' + is displayed + @param completed - (bool) True/False """ - Method to verify the current progress - """ - test.startSection("Verifying the current progress") - current_progress = (waitForObjectExists(names.o_self_test_dry_progress)).progressValue - #Since progress value is equal maximum count down value - current count down value - expected_progress = MAXIMUM_COUNTDOWN_TIME - count_down - test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + test.startSection("verify the 'Self Test Complete!' is displayed") + check_indicator = object.children(findObject(names.o_self_test_dry_progress_circle)) + check_indicator = objectMap.realName(check_indicator[2]) + if completed: + completion_msg = waitForObjectExists(self_test_dry_check_list_text(SELF_TEST_COMPLETION_MSG)) + test.compare(completion_msg.visible, VISIBLE, "{} message should be displayed".format(SELF_TEST_COMPLETION_MSG)) + test.compare(completion_msg.text, SELF_TEST_COMPLETION_MSG, "Completion message should be {}".format(SELF_TEST_COMPLETION_MSG)) + if object.exists(check_indicator): + test.passes("Check indicator should display on progress circle upon completion of 'Self test'") + else: + if object.exists(self_test_dry_check_list_text(SELF_TEST_COMPLETION_MSG)) is False: + test.passes("{} message should not display".format(SELF_TEST_COMPLETION_MSG)) test.endSection() + + def main(): utils.tstStart(__file__) startApplication(AUT_NAME) navigate_self_test_dry_screen() verify_the_countdown(BEGIN_PRIME_TITLE) - + verify_dry_states() + navigate_to_priming_screen() verify_the_countdown(PRIMING_TITLE) - snooze(20) # hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(self, timeout: int, countdown: int)