# Subject/Title: Misc SW Enhancements - SW - 02 - General Aesthetics - 02-S24 - Q&R # # Functionalities: Testing items of Main Treatment Screen # # Steps: # 1 Start Leahi Application # 2 Verify that the vitals dialog numpad text turns red when the entered value is out of range. # 3 Verifying New Treatment Duration in Main Treatment Screen # 4 Comparison of'Total Fluid Delivered' and 'Delivering Fluid' texts # 5 Comparison of Ultrafiltration Paused State and Ultrafiltration Complete State texts # 6 Comparison of the Ultrafiltration Edit Button state is disabled import names from configuration import config, utility, navigation from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates, TDTreatmentStates from leahi_dialin.common.ui_defs import TXStates from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.utils import conversions from leahi_dialin.protocols import CAN td_simulator = TD_Messaging() can_interface = td_simulator.can_interface newTreatmentDuration = None def handle_new_treatment_duration_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 newTreatmentDuration newTreatmentDuration = state def check_bp_cuff_enabled(): integrated_bp_value = navigation.get_ini_value( "/home/denali/Public/luis/config/configurations/Settings/System.conf", section="Feature Configurations", key="IntegratedBPCuff", ) if integrated_bp_value == "0": navigation.navigate_to_device_settings_using_service_password() device_settings_grid = waitForObject(names.o_DeviceSettingsGrid) mouseClick( utility.findChildByText(device_settings_grid, config.FEATURE_CONFIGURATIONS) ) integrated_bp_cuff_mode_switch = waitForObject( names.o_SettingsBase_integratedBPCuffSwitch_BaseSwitch, 3000 ) mouseClick(integrated_bp_cuff_mode_switch) test.log("Initial Integrated BP Cuff switch is enabled state") 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 vitals_popup(): """ Verify that the vitals dialog numpad text turns red when the entered value is out of range. """ test.startSection( "Verify that the vitals dialog numpad text turns red when the entered value is out of range." ) mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad( config.SYSTOLIC, names.o_bloodPressureSystolic_TextEntry, config.SYSTOLIC_59, config.SYSTOLIC_59, ) parent_obj = waitForObject(names.o_numRect_Rectangle, 3000) value_object = utility.findObjectById(parent_obj, "_valueLabel") test.compare( utility.findObjectById(parent_obj, "_valueLabel").color.name, config.RED_COLOR, "Comparison of Vitals dialog numpad text turns red when it is less than Minimum Systolic range", ) verify_valid_vitals_through_keypad( config.DIASTOLIC, names.o_bloodPressureDiastolic_TextEntry, config.DIASTOLIC_39, config.DIASTOLIC_39, ) parent_obj = waitForObject(names.o_numRect_Rectangle, 3000) value_object = utility.findObjectById(parent_obj, "_valueLabel") test.compare( utility.findObjectById(parent_obj, "_valueLabel").color.name, config.RED_COLOR, "Comparison of Vitals dialog numpad text turns red when it is less than Minimum Diastolic range", ) verify_valid_vitals_through_keypad( config.HEARTRATE, names.o_heartRate_TextEntry, config.HEARTRATE_39, config.HEARTRATE_39, ) parent_obj = waitForObject(names.o_numRect_Rectangle, 3000) value_object = utility.findObjectById(parent_obj, "_valueLabel") test.compare( utility.findObjectById(parent_obj, "_valueLabel").color.name, config.RED_COLOR, "Comparison of Vitals dialog numpad text turns red when it is less than Minimum Heart Rate range", ) verify_valid_vitals_through_keypad( config.SYSTOLIC, names.o_bloodPressureSystolic_TextEntry, config.SYSTOLIC_251, config.SYSTOLIC_251, ) parent_obj = waitForObject(names.o_numRect_Rectangle, 3000) value_object = utility.findObjectById(parent_obj, "_valueLabel") test.compare( utility.findObjectById(parent_obj, "_valueLabel").color.name, config.RED_COLOR, "Comparison of Vitals dialog numpad text turns red when it is more than Maximum Systolic range", ) verify_valid_vitals_through_keypad( config.DIASTOLIC, names.o_bloodPressureDiastolic_TextEntry, config.DIASTOLIC_201, config.DIASTOLIC_201, ) parent_obj = waitForObject(names.o_numRect_Rectangle, 3000) value_object = utility.findObjectById(parent_obj, "_valueLabel") test.compare( utility.findObjectById(parent_obj, "_valueLabel").color.name, config.RED_COLOR, "Comparison of Vitals dialog numpad text turns red when it is more than Maximum Diastolic range", ) verify_valid_vitals_through_keypad( config.HEARTRATE, names.o_heartRate_TextEntry, config.HEARTRATE_181, config.HEARTRATE_181, ) parent_obj = waitForObject(names.o_numRect_Rectangle, 3000) value_object = utility.findObjectById(parent_obj, "_valueLabel") test.compare( utility.findObjectById(parent_obj, "_valueLabel").color.name, config.RED_COLOR, "Comparison of Vitals dialog numpad text turns red when it is more than Maximum Heart Rate range", ) mouseClick(waitForObject(names.o_Vitals_Popup_CloseButton, 3000)) test.endSection() def edit_treatment_duration(): """ Verifying New Treatment Duration in Main Treatment Screen """ test.startSection("Verifying New Treatment Duration in Main Treatment Screen") td_simulator.td_treatment_time(tx_duration_s=51, tx_elapsed_s=5, tx_remaining_s=6) td_simulator.td_ultrafiltration(10, 0.53, 0.37, 0) td_simulator.td_param_ranges( min_tx_time_s=50, max_tx_time_s=300, min_uf_volume_mL=0.0, max_uf_volume_mL=1790, min_dial_rate_mLH=0, max_dial_rate_mLH=0, ) treatmentEdit = waitForObject(names.o_treatment_duration) treatmentEditbutton = utility.findObjectById(treatmentEdit, "_editTimeIcon") mouseClick(treatmentEditbutton) if can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id message_id = MsgIds.MSG_ID_UI_DURATION_VALIDATE_REQUEST.value can_interface.register_receiving_publication_function( channel_id, message_id, handle_new_treatment_duration_request ) utility.set_value_based_on_target(names.o_newTreatmentDuration_ValueAdjuster, 60) mouseClick(waitForObject(names.o_continueButton_TouchRect, 3000)) test.verify( waitFor(lambda: newTreatmentDuration == 60, 10000), "Verifying FW received New Treatment Duration", ) td_simulator.td_duration_validate_response(0, 60, 0, 0) parent_object = waitForObject(names.o_newTreatmentDuration, 3000) newTreatmentDuration_value_object = utility.findObjectById(parent_object, "_value") test.log(str(newTreatmentDuration_value_object.text)) parent_object = waitForObject(names.o_ufVolumeGoal, 3000) ufVolumeGoal_value_object = utility.findObjectById(parent_object, "_value") test.log(str(ufVolumeGoal_value_object.text)) parent_object = waitForObject(names.o_ufRate, 3000) ufRate_value_object = utility.findObjectById(parent_object, "_value") test.log(str(ufRate_value_object.text)) mouseClick(waitForObject(names.o_confirmButton_TouchRect, 3000)) mouseClick(waitForObject(names.o_Vitals_Popup_CloseButton, 3000)) test.endSection() def main_treatment_fluid_delivery(): """ Comparison of'Total Fluid Delivered' and 'Delivering Fluid' texts """ test.startSection( "Comparison of'Total Fluid Delivered' and 'Delivering Fluid' texts" ) salineTextObj = waitForObject(names.salineDeliveredText) test.compare( salineTextObj.text, config.TOTAL_FLUID_DELIVERED, "Comparison of'Total Fluid Delivered' text", ) # change state to in progress td_simulator.td_tx_state( TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, TXStates.SALINE_BOLUS_STATE_IN_PROGRESS, # saline in progess 0, ) salineTextObj = waitForObject(names.salineDeliveredText) test.compare( salineTextObj.text, config.DELIVERING_FLUID, "Comparison of Delivering Fluid text", ) test.endSection() def main_treatment_screen_paused_completed_state(): """ Comparison of Ultrafiltration Paused State and Ultrafiltration Complete State texts """ test.startSection( "Comparison of Ultrafiltration Paused State and Ultrafiltration Complete State texts" ) mouseClick(waitForObject(names.o_editButton_ultrafiltration_IconButton, 2000)) mouseClick(waitForObject(names.o_ultrafiltration_pauseResumeButton_TouchRect, 2000)) td_simulator.td_ultrafiltration(10, 0.53, 0.37, 1) notification_row_object = waitForObjectExists(names.o_PopupItem, 3000) ultrafiltration_paused_state = utility.findChildByText( notification_row_object, config.ULTRAFILTRATION_PAUSED_STATE ) test.compare( ultrafiltration_paused_state.text, config.ULTRAFILTRATION_PAUSED_STATE, "Comparison Ultrafiltration Paused State text in Ultrafiltration popup", ) mouseClick(waitForObject(names.o_Vitals_Popup_CloseButton, 3000)) ultrafiltration_status_object = waitForObjectExists( names.o_treatmentHome_ultrafiltration_status, 3000 ) ultrafiltration_paused_state = utility.findChildByText( ultrafiltration_status_object, config.ULTRAFILTRATION_PAUSED_STATE ) test.compare( ultrafiltration_paused_state.text, config.ULTRAFILTRATION_PAUSED_STATE, "Comparison Ultrafiltration Paused State text in Main Treatment Screen", ) td_simulator.td_ultrafiltration(10, 0.53, 10, 0) ultrafiltration_status_object = waitForObjectExists( names.o_treatmentHome_ultrafiltration_status, 3000 ) ultrafiltration_complete_state = utility.findChildByText( ultrafiltration_status_object, config.ULTRAFILTRATION_COMPLETE_STATE ) test.compare( ultrafiltration_complete_state.text, config.ULTRAFILTRATION_COMPLETE_STATE, "Comparison Ultrafiltration Complete State text in Main Treatment Screen", ) test.endSection() def end_of_treatment(): """ Comparison of the Ultrafiltration Edit Button state is disabled """ test.startSection("Comparison of the Ultrafiltration Edit Button state is disabled") td_simulator.td_tx_state( TDTreatmentStates.TREATMENT_END_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) mouseClick(waitForObject(names.o_treatmentCompleteButton_TreatmentCompleteButton)) mouseClick(waitForObject(names.o_confirmTouch_ConfirmButton)) ultrafiltration_edit_button = waitForObjectExists( names.o_editButton_ultrafiltration_IconButton, 2000 ) if not ultrafiltration_edit_button.enabled: test.compare( ultrafiltration_edit_button.enabled, config.DISABLED, f"Comparison of the Ultrafiltration Edit Button state is disabled = {config.DISABLED}", ) test.endSection() def main(): utils.tstStart(__file__) startApplication(utility.aut("-q")) check_bp_cuff_enabled() td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value) mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect, 5000)) td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value, 0) utility.verify_create_treatment_parameters() mouseClick(waitForObject(utility.setObjectText(names.o_preTreatmentStack_Text, config.START), 3000)) td_simulator.td_operation_mode(TDOpModes.MODE_TREA.value, 0) td_simulator.td_tx_state( TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) vitals_popup() edit_treatment_duration() main_treatment_fluid_delivery() main_treatment_screen_paused_completed_state() end_of_treatment() utils.tstDone()