# Subject/Title: LDT -3016 End of Treatment - SW - 02 - Q&R - 15: SIT - Software Integration Tests - Squish Qt # # Functionalities: Testing all functionalities of End of Treatment # # Steps: # 1. Navigate to Create Rx page set all the values # 2. Validate and confirm all the values in create Rx page # 3. Navigate to Main treatment page # 4. In Main Treatment set the treatment state to TREATMENT_END_STATE from the simulator # 5. Verify Dialysis Treatment Complete popup is visible in main treatment page # 6. On Dialysis Treatment Complete popup Click on Stay on Treatment button # Verify the following: # a. New headerbar icon is available # b. Treatment time edit button is disabled # c. Saline Start Bolus edit button is enabled # d. Vitals button is enabled - Enter vitals values and check the values are displaying # e. Pressures edit button is enabled # f. Ultrafiltration edit button is enabled After click on edit icon # Only Isolated UF button is enabled and all other buttons are disabled # g.Treatment parameters Edit button is disabled # h. User can only edit bloodflow button # 7.Open the Dialysis Treatment complete popup and press end treatment # 8.Check request message from UI and change the treatment state to Rinseback state import names import can from leahi_dialin.ui import utils from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.ui.td_messaging import TD_Messaging from configuration import utility, config from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates from leahi_dialin.protocols import CAN td =TD_Messaging() endTreatmentState = "-1" def change_treatmentstates(state): """Method to change the treatment states to different sub state @return : Change the state from simulator """ test.startSection("Change the treatment parameter") td.td_tx_state( state, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0) test.endSection() def keyboard_object_map_helper(text): """ Method for setting custom object property's for keyboard keys @return: required object property's for keys """ if text is not None: names.keyboard_input["text"] = text return names.keyboard_input else: test.log("Invalid ",text," for object.") names.o_keyboard_input["text"] = "Q" def verify_valid_vitals_through_keypad(title_name,input_field_obj,expected_value, actual_value): """ Tests verifies valid patient id set through application keyboard setup . @return: N/A """ input_field = waitForObject(input_field_obj) mouseClick(input_field) #check the title title = waitForObjectExists(utility.setObjectText(text = title_name,obj =names.o_title_Text)) test.compare(title_name, title.text, "Title text should be -> "+ str(title_name)) for text in expected_value: keyboard_value = keyboard_object_map_helper(text) utils.waitForGUI(0.2) mouseClick(waitForObjectExists(keyboard_value)) utils.waitForGUI(0.2) test.compare(actual_value, (input_field.text), "Value should be -> "+ str(actual_value)) test.log("User successfully authenticated through patient id -> " + expected_value + "using keypad.") def handle_end_of_treatment_request( message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ message = message['message'] index = MsgFieldPositions.START_POS_FIELD_1 state,index = conversions.bytearray_to_integer( message, index) global endTreatmentState endTreatmentState = str(state) def verify_stay_treatment_state(): test.startSection("Check the UI behavior state when user is in stay on treatment") stay_on_treatment = waitForObject(names.o_cancelTouch_TouchRect) mouseClick(stay_on_treatment) complete_popup = waitForObject(names.o_treatmentCompleteButton_TreatmentCompleteButton) test.compare(complete_popup.visible,True, "Dialysis Treatment Complete popup is visible") treatment_time_edit = waitForObjectExists(names.o_treatmentHome_iconImage_Image) test.compare(not treatment_time_edit.enabled,True,"Treatment time edit is disabled") saline_edit =waitForObjectExists(names.o_treatmentHome_editButton_IconButton) test.compare(saline_edit.enabled,True,"Saline bolus edit button is enabled") patient_vitals =waitForObjectExists(names.o_vitalsButton_VitalsButton) test.compare(patient_vitals.enabled,True,"Patient vitals button is enabled") mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad(config.SYSTOLIC,names.o_bloodPressureSystolic_TextEntry,config.MIN_SYSTOLIC,config.MIN_SYSTOLIC) verify_valid_vitals_through_keypad(config.DIASTOLIC,names.o_bloodPressureDiastolic_TextEntry,config.MIN_DIASTOLIC,config.MIN_DIASTOLIC) verify_valid_vitals_through_keypad(config.HEARTRATE, names.o_heartRate_TextEntry, config.MIN_HEARTRATE, config.MIN_HEARTRATE) mouseClick(waitForObject(names.o_confirm_button)) blood_pressure = waitForObjectExists(names.o_treatmentHome_bloodPressure_LabelValue).topText test.compare(config.MIN_SYSTOLIC+"/"+config.MIN_DIASTOLIC, blood_pressure,"Blood pressure value should be ->"+str(config.MIN_SYSTOLIC+"/"+config.MIN_DIASTOLIC)) heart_rate = waitForObjectExists(names.o_treatmentHome_heartBeat_LabelValue).topText test.compare(config.MIN_HEARTRATE, heart_rate,"Heart Rate value should be ->"+str(config.MIN_HEARTRATE)) ultrafiltration_edit =waitForObjectExists(names.o_editButton_ultrafiltration_IconButton) test.compare(ultrafiltration_edit.enabled,True,"Ultrafiltration edit button is enabled") mouseClick(waitForObject(names.o_editButton_ultrafiltration_IconButton)) #check isolated,pause uf and edit uf button state isolateduf_button = waitForObjectExists(names.o_isolatedUfButton_TouchRect) test.compare(isolateduf_button.enabled,True,"Isolated UF button is enabled") edituf_button =waitForObjectExists(names.o_editButton_TouchRect) test.compare(not edituf_button.enabled,True,"Edit UF button is disabled") pauseuf_button = waitForObjectExists(names.o_pauseResumeButton_TouchRect) test.compare(not pauseuf_button.enabled,True,"Pause UF button is disabled") mouseClick(names.o_image_Image) treatment_parameters_edit = waitForObjectExists(names.o_treatmentHome_editButton_IconButton_2) test.compare(treatment_parameters_edit.enabled,True,"Treatment parameters edit button is disabled") td.td_treatment_set_points (blood_flow = 51, dialysate_flow = 0, dialysate_temp = 0) bloodflow_uparrow = waitForObjectExists(names.o_treatmentHome_upArrowIcon_ArrowButton) test.compare(bloodflow_uparrow.enabled,True,"Blood flow up arrow is enabled") bloodflow_downarrow = waitForObjectExists(names.o_treatmentHome_downArrowIcon_ArrowButton) test.compare(bloodflow_downarrow.enabled,True,"Blood flow down arrow is enabled") test.endSection() def main(): utils.tstStart(__file__) can_interface = td.can_interface global endTreatmentState # handle sent messages from UI if can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id message_id = MsgIds.MSG_ID_TD_END_TREATMENT_REQUEST.value can_interface.register_receiving_publication_function(channel_id, message_id, handle_end_of_treatment_request) startApplication(config.AUT_NAME) td.td_operation_mode(TDOpModes.MODE_STAN.value) # verify Standby screen test.verify(waitForObjectExists(names.o_standByScreen_MainHome), "In Standby") mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect)) td.td_operation_mode(TDOpModes.MODE_PRET.value) utility.verify_create_treatment_parameters() change_treatmentstates(TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value) change_treatmentstates(TDTreatmentStates.TREATMENT_END_STATE.value) verify_stay_treatment_state() test.startSection("Check the UI behavior when user in end treatment state") mouseClick(waitForObject(names.o_treatmentCompleteButton_TreatmentCompleteButton)) mouseClick(waitForObject(names.o_confirmTouch_ConfirmButton)) test.verify(waitFor("'endTreatmentState == 6'", 5000), "Testing UI -> TD message end state") change_treatmentstates(TDTreatmentStates.TREATMENT_RINSEBACK_STATE.value) test.endSection()