Index: suite_leahi/shared/scripts/configuration/config.py =================================================================== diff -u -r4b929ef6eef32479f10e84325b0ad12173474a4d -r5a31e21e36f2652df87477d61a8b9f43f2bc89d2 --- suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 4b929ef6eef32479f10e84325b0ad12173474a4d) +++ suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 5a31e21e36f2652df87477d61a8b9f43f2bc89d2) @@ -210,3 +210,12 @@ "Install blood tubing set and dialyzer.", ] START_TREATMENT_REJECTION_NOTIFICATION = "[1] Request is not allowed in the current operating mode" + +#Recirculate +RECIRCULATE_SET_UP = "Recirculate Set Up" +RECIRCULATE_IN_PROGRESS = "Recirculate In Progress" +RECIRCULATION_COUNTDOWN_DESCRIPTION_TEXT = "Recirculation Time Elapsed:" +RECONNECT_TO_PATIENT = "Reconnect To Patient" +REJECTION_REASON = "[1] Request is not allowed in the current operating mode" +END_TREATMENT = "End Treatment" + Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -r4b929ef6eef32479f10e84325b0ad12173474a4d -r5a31e21e36f2652df87477d61a8b9f43f2bc89d2 --- suite_leahi/shared/scripts/names.py (.../names.py) (revision 4b929ef6eef32479f10e84325b0ad12173474a4d) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision 5a31e21e36f2652df87477d61a8b9f43f2bc89d2) @@ -328,3 +328,21 @@ o_PreTreatmentSampleStack_button_TouchRect = {"container": o_PreTreatmentSampleStack_PreTreatmentWaterSample, "id": "_button", "type": "TouchRect", "unnamed": 1 } o_preTreatmentStack_repeater_Repeater = {"container": o_preTreatmentStack_PreTreatmentStack, "id": "repeater", "type": "Repeater", "unnamed": 1 } +#Recirculate +o_recirculateRecirculateStack_EndTreatmentRecirculateStack = {"container": treatmentStack, "objectName": "_recirculateRecirculateStack", "type": "EndTreatmentRecirculateStack", } +o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase = {"container": o_recirculateRecirculateStack_EndTreatmentRecirculateStack, "objectName": "_EndTreatmentBase", "type": "EndTreatmentBase", } +o_EndTreatmentBase_NotificationBar_NotificationBarSmall = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase, "objectName": "NotificationBar", "type": "NotificationBarSmall", } +o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress= {"container": o_recirculateRecirculateStack_EndTreatmentRecirculateStack, "objectName": "_EndTreatmentBase", "type": "EndTreatmentRecirculateProgress", } +o_Recirculate_InProgress_Screen_NotificationBar = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress, "objectName": "NotificationBar", "type": "NotificationBarSmall", } +o_EndTreatmentBase_ButtonEndTreatment = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase, "type": "ButtonEndTreatment", "unnamed": 1 } +o_EndTreatmentBase_ButtonStartRecirculate = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase, "type": "ButtonStartRecirculate", "unnamed": 1 } +o_EndTreatmentBase_label_Text = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress, "objectName": "_label", "type": "Text", } +o_EndTreatmentBase_TimeText_minute_Text = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress, "objectName": "_TimeText_minute", "type": "Text", } +o_EndTreatmentBase_TimeText_second_Text = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress, "objectName": "_TimeText_second", "type": "Text", } +o_Recirculate_InProgress_Screen_ButtonEndTreatment = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress, "type": "ButtonEndTreatment", "unnamed": 1 } +o_EndTreatmentBase_ButtonResume = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentRecirculateProgress, "type": "ButtonResume", "unnamed": 1 } +o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase_2= {"container": o_recirculateRecirculateStack_EndTreatmentRecirculateStack, "objectName": "_EndTreatmentBase", "type": "EndTreatmentBase", "visible": True } +o_EndTreatmentBase_ButtonEndTreatment_2 = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase_2, "type": "ButtonEndTreatment", "unnamed": 1 } +o_EndTreatmentBase_NotificationBar_NotificationBarSmall_2 = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase_2, "objectName": "NotificationBar", "type": "NotificationBarSmall", } +o_EndTreatmentBase_ButtonResume_2 = {"container": o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase_2, "type": "ButtonResume", "unnamed": 1 } + Index: suite_leahi/tst_recirculate/test.py =================================================================== diff -u --- suite_leahi/tst_recirculate/test.py (revision 0) +++ suite_leahi/tst_recirculate/test.py (revision 5a31e21e36f2652df87477d61a8b9f43f2bc89d2) @@ -0,0 +1,260 @@ +# Subject/Title: Rinseback - SW - 02 - Recirculate - Q&R +# +# Functionalities: Testing of Rinseback Recirculate +# +# Steps: +# 1 Handle recirculateRequest sent messages messages from UI to FW +# 2 Start Leahi application and navigate to Main Treatment screen +# 3 Change Treatment sub mode to Recirculation State, Recirculations Sub State to DISCONNECT_PATIENT_STATE +# 4 Compare Recirculate Set Up Screen title text, Click on buttons verify FW received, Compare Rejection reason +# 5 Compare Recirculate In Progress title text, Click on buttons verify FW received, Compare Rejection reason +# 6 Compare Reconnect To Patient title text, Click on buttons verify FW received, Compare Rejection reason + + +import names +from configuration import config, utility +from leahi_dialin.ui import utils +from leahi_dialin.ui.td_messaging import TD_Messaging +from leahi_dialin.common.td_defs import TDOpModes, TDTreatmentStates, TDTreaRecircStates +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.protocols import CAN +from leahi_dialin.utils import conversions + +td_simulator = TD_Messaging() +can_interface = td_simulator.can_interface +recirculateRequest = None + + +# handler for messages from UI to FW +def handle_recirculate_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 recirculateRequest + recirculateRequest = state + + +def verify_screen_header(config_title): + """Verifies that the correct screen title is displayed in the header bar.""" + headerbar_container = utility.get_object_from_names(names.o_headerBar_HeaderBar) + title_obj = utility.findChildByText(headerbar_container, config_title) + if title_obj is not None: + test.compare( + title_obj.text, + config_title, + f"{config_title} screen is displayed and title text matches.", + ) + + +def click_and_verify_fw_request(button_name, expected_value, log_message): + """Clicks a button and waits for the firmware to receive the specific request value.""" + mouseClick(utility.get_object_from_names(button_name)) + test.verify( + waitFor(lambda: recirculateRequest == expected_value, 3000), + f"Testing FW received {log_message}", + ) + + +def verify_recirculation_rejection(): + """Comparison of Rejection Reason""" + + td_simulator.td_recirculate_cmd_response(0, 1) + rejectionReason = waitForObject( + utility.setObjectText( + text=config.REJECTION_REASON, + obj=names.o_EndTreatmentBase_NotificationBar_NotificationBarSmall, + ) + ) + test.compare( + rejectionReason.text, + config.REJECTION_REASON, + "Rejection Reason text should be :" + str(rejectionReason.text), + ) + + +def verify_recirculation_in_progress_screen_rejection(): + """Comparison of Rejection Reason""" + + td_simulator.td_recirculate_cmd_response(0, 1) + rejectionReason = waitForObject( + utility.setObjectText( + text=config.REJECTION_REASON, + obj=names.o_Recirculate_InProgress_Screen_NotificationBar, + ) + ) + test.compare( + rejectionReason.text, + config.REJECTION_REASON, + "Rejection Reason text should be :" + str(rejectionReason.text), + ) + + +def verify_reconnect_to_patient_screen_rejection(): + """Comparison of Rejection Reason""" + + td_simulator.td_recirculate_cmd_response(0, 1) + rejectionReason = waitForObject( + utility.setObjectText( + text=config.REJECTION_REASON, + obj=names.o_EndTreatmentBase_NotificationBar_NotificationBarSmall_2, + ) + ) + test.compare( + rejectionReason.text, + config.REJECTION_REASON, + "Rejection Reason text should be :" + str(rejectionReason.text), + ) + + +def recirculate_set_up_screen(): + test.startSection("Verify Recirculate Set Up Screen") + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_RECIRC_STATE.value, + 0, + 0, + 0, + 0, + 0, + TDTreaRecircStates.TREATMENT_RECIRC_DISCONNECT_PATIENT_STATE.value, + 0, + 0, + 0, + ) + + verify_screen_header(config.RECIRCULATE_SET_UP) + + click_and_verify_fw_request( + names.o_EndTreatmentBase_ButtonEndTreatment, 3, "End Treatment Button Value" + ) + verify_recirculation_rejection() + + click_and_verify_fw_request( + names.o_EndTreatmentBase_ButtonStartRecirculate, + 4, + "Start Recirculation Button Value", + ) + verify_recirculation_rejection() + test.endSection() + + +def recirculate_in_progress_screen(): + test.startSection("Verify Recirculate In Progress Screen") + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_RECIRC_STATE.value, + 0, + 0, + 0, + 0, + 0, + TDTreaRecircStates.TREATMENT_RECIRC_RECIRC_STATE.value, + 0, + 0, + 0, + ) + + verify_screen_header(config.RECIRCULATE_IN_PROGRESS) + + td_simulator.td_recirculate_progress(300, 270) + recirculation_desc = utility.get_object_from_names( + names.o_EndTreatmentBase_label_Text + ) + test.compare( + recirculation_desc.text, + config.RECIRCULATION_COUNTDOWN_DESCRIPTION_TEXT, + "Recirculation Countdown Description Text", + ) + + test.compare( + utility.get_object_from_names( + names.o_EndTreatmentBase_TimeText_minute_Text + ).text, + "04", + "Recirculation Countdown Minutes", + ) + test.compare( + utility.get_object_from_names( + names.o_EndTreatmentBase_TimeText_second_Text + ).text, + "30", + "Recirculation Countdown Seconds", + ) + + click_and_verify_fw_request( + names.o_Recirculate_InProgress_Screen_ButtonEndTreatment, + 3, + "End Treatment Button Value", + ) + verify_recirculation_in_progress_screen_rejection() + + click_and_verify_fw_request( + names.o_EndTreatmentBase_ButtonResume, 0, "Resume Button Value" + ) + verify_recirculation_in_progress_screen_rejection() + test.endSection() + + +def reconnect_to_patient_screen(): + test.startSection("Verify Reconnect To Patient Screen") + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_RECIRC_STATE.value, + 0, + 0, + 0, + 0, + 0, + TDTreaRecircStates.TREATMENT_RECIRC_RECONNECT_PATIENT_STATE.value, + 0, + 0, + 0, + ) + + verify_screen_header(config.RECONNECT_TO_PATIENT) + + click_and_verify_fw_request( + names.o_EndTreatmentBase_ButtonEndTreatment_2, 3, "End Treatment Button Value" + ) + + # mouseClick(waitForObject(utility.setObjectText(names.o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase_2, config.END_TREATMENT),3000)) + # recirculate_container = utility.get_object_from_names(names.o_recirculateRecirculateStack_EndTreatmentBase_EndTreatmentBase) + # end_treatment = utility.findChildByText(recirculate_container, config.END_TREATMENT) + # mouseClick(end_treatment) + # test.verify(waitFor( lambda: recirculateRequest == 3, 3000), "Testing FW received End Treatment Button Value") + + verify_reconnect_to_patient_screen_rejection() + + click_and_verify_fw_request( + names.o_EndTreatmentBase_ButtonResume_2, + 1, + "Start Resume Treatment Button Value", + ) + verify_reconnect_to_patient_screen_rejection() + test.endSection() + + +def main(): + utils.tstStart(__file__) + if can_interface is None: + test.fail("CAN Interface is not available. Stopping tests.") + return + + channel_id = CAN.DenaliChannels.ui_to_td_ch_id + + # Register Recirculate Request + message_id = MsgIds.MSG_ID_UI_RECIRCULATE_REQUEST.value + can_interface.register_receiving_publication_function( + channel_id, message_id, handle_recirculate_request + ) + + startApplication(utility.aut("-q")) + 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 + ) + recirculate_set_up_screen() + recirculate_in_progress_screen() + reconnect_to_patient_screen() + utils.tstDone()