# Subject/Title: LDT-1802 General Alarm Requirements - SW - 02 - Instructions with new design - Q&R # # Functionalities: Testing all items of General Alarm Requirements # # Steps: # 1 Start Leahi Application # 2 Set and Compare Alarm Mute condition and timeouts - Compare Timeout delay for alarm, # Compare Mute minutes button is visible, Compare Mute seconds button is visible, # Compare of Alarm BellOff, Compare Mute Minutes, Mute seconds, # Compare Alarm BellOff After minimized, Compare Mute Minutes After minimized and # Compare Mute seconds After minimized # 3 Set and Compare Alarm UnMute condition and timeouts - Compare Timeout delay for alarm, # Compare Mute minutes button is visible, Compare Mute seconds button is visible, # Compare of Alarm BellOn, Compare Alarm BellOn After minimized, # Compare Mute Minutes After minimized and Compare Mute seconds After minimized # 4 Set and Compare Alarm Dialog box color based on alarm priority # Compare of Alarm TitleBar Color, Compare of Alarm Bar Color After Alarm minimized # 5 Simulate Ok Button and Compare Alarm Ok Button visible, Compare Alarm Resume Button visible # Compare Alarm Rinseback Button visible, Compare Alarm End Treatment Button visible, # Compare Alarm Mute Silenced visible, Compare Minimize Button not visible # 6 Trigger an alarm and Click Alarm list icon to navigate to Alarm list screen # 7 Generate alarms in batches of 10 from 1 to 160 # 8 Compare Number of Alarms displayed and Alarm IDs # 9 Compare of Alarm Reject Notification Text import names import re from leahi_dialin.ui import utils from configuration import config, utility from leahi_dialin.ui.td_messaging_alarms import TD_Messaging_Alarms alarm = TD_Messaging_Alarms() ALARM_ID_COMBINATION = (2, 3, 5, 7, 10, 15, 20, 25, 30, 50) ALARM_EXPIRES_TIME = (0, 10, 20, 30, 30, 100) alarm_flags = { "flags": 0, "system_fault": 1, "stop": 2, "no_clear": 4, "no_resume": 8, "no_rinseback": 16, "no_end_treatment": 32, "no_new_treatment": 64, "user_must_ack": 128, "alarms_to_escalate": 256, "alarms_silenced": 512, "lamp_on": 1024, "unused_1": 2048, "unused_2": 4096, "unused_3": 8192, "no_minimize": 16384, "top_condition": 32768, } def minimize(): """ Method to minimize alarm dialog box @param N/A @output N/A """ mouseClick(waitForObject(names.o_AlarmButton_Minimize, 2000)) def maximize(): """ Method to maximize alarm dialog box @param N/A @output N/A """ mouseClick(waitForObject(names.o_AlarmButton_Maximize, 2000)) def findChildByText(parent_object, target_text): """Recursively finds a child object by its text property.""" for child in object.children(parent_object): if hasattr(child, "text") and str(child.text) == target_text: return child found = findChildByText(child, target_text) if found: return found return None def test_send_active_list_response_batch_alarms(): alarm.cmd_activate_alarm_id(state=1, alarm=1, silence_expires=0, flags=0) mouseClick(waitForObject(names.o_AlarmsList_IconButton, 2000)) # Generate alarms in batches of 10 from 1 to 160s count = 0 for batch_start in range(1, 161, 10): count += 1 alarm.cmd_send_active_list_response( True, 0, batch_start, batch_start + 1, batch_start + 2, batch_start + 3, batch_start + 4, batch_start + 5, batch_start + 6, batch_start + 7, batch_start + 8, batch_start + 9, ) test.startSection( f"Comparison Alarms ID from {batch_start} to { batch_start + 9 } " ) # Get the alarm list grid and verify rows count alarm_grid = waitForObject(names.o_Alarm_List, 2000) # Verify 10 alarms are displayed using rows property test.compare(alarm_grid.rows, 10, "Comparison Number of Alarms displayed") # Verify each alarm ID in the batch for i in range(10): expected_alarm_id = str(batch_start + i) # Using the findChildByText function to find the text object containing the expected alarm ID # within the alarm grid container. text_object = findChildByText(alarm_grid, expected_alarm_id) if text_object: test.compare( text_object.text, expected_alarm_id, f"Comparison Alarms ID { expected_alarm_id } ", ) # Finding and Comparison Alarm Reject Notification text alarm.cmd_send_active_list_response(accept=0, reason=count) alarm_reject_notification = utility.get_object_from_names( names.o_AlarmReject_Notification_Description_Text, timeout_ms=3000 ) alarm_reject_notification_text = str(alarm_reject_notification.text) trimmed_alarm_reject_notification_text = re.sub( r"\n", " ", alarm_reject_notification_text ) trimmed_alarm_reject_notification_text = re.sub( r"\].*", "]", trimmed_alarm_reject_notification_text ) test.compare( trimmed_alarm_reject_notification_text, config.ALARM_REJECT_NOTIFICATION_TEMPLATE.format(count), "Comparison of Alarm Reject Notification Text", ) test.endSection() def test_color_based_on_alarm_priority(alarm_priority): """ Method to verify alarm dialog box color based on alarm priority @param alarm_priority - (int) alarm priority level @output N/A """ test.startSection( "verification of alarm dialog box color based on alarm priority -> " + str(alarm_priority) ) test.compare( str(waitForObjectExists(names.o_Alarm_Dialog_TitleBar, 2000).color.name), config.ALARMS_COLORS_HEADER[(config.ALARM_PRIORITY_OPTIONS[alarm_priority])], "Comparison of Alarm TitleBar Color", ) minimize() test.compare( str(waitForObject(names.o_Alarm_Bar, 2000).color.name), config.ALARMS_COLORS_HEADER[(config.ALARM_PRIORITY_OPTIONS[alarm_priority])], "Comparison of Alarm Bar Color After Alarm minimized", ) maximize() test.endSection() def test_verify_alarm_mute(alarm_timeout=0, v_flags=0, alarm_status="Mute"): """ Method to verify alarm mute and unmute characteristics. @param alarm_timeout - (int) timeout delay for alarm @param alarm_status - (str) status of alarm @param v_flag - (int) flag for mute and unmute operation. @output N/A """ test.startSection( "verification of alarm " + str(alarm_status) + " condition for timeout " + str(alarm_timeout) ) test.compare( waitForObjectExists(names.o_AlarmButton_Mute, 2000).timeout, alarm_timeout, "Timeout delay for alarm", ) muted = v_flags == config.ALARM_MUTE_FLAG test.compare( waitForObjectExists(names.o_AlarmButton_Mute_Min, 2000).visible, muted, "Mute minutes is visible", ) test.compare( waitForObjectExists(names.o_AlarmButton_Mute_Sec, 2000).visible, muted, "Mute seconds is visible", ) muteTimeout_min, muteTimeout_sec = divmod(alarm_timeout, 60) if muted: test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Img, 2000).source.path), "/images/iBellOff", "Comparison of Alarm BellOff", ) test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Min, 2000).text), "{}".format(muteTimeout_min), "Comparison of Mute Minutes", ) test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Sec, 2000).text), "{0:02}".format(muteTimeout_sec), "Comparison of Mute seconds", ) minimize() test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Img, 2000).source.path), "/images/iBellOff", "Comparison of Alarm BellOff After minimized", ) test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Min, 2000).text), "{}".format(muteTimeout_min), "Comparison of Mute Minutes After minimized", ) test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Sec, 2000).text), "{0:02}".format(muteTimeout_sec), "Comparison of Mute seconds After minimized", ) else: test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Img, 2000).source.path), "/images/iBellOn", "Comparison of Alarm BellOn", ) minimize() test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Img, 2000).source.path), "/images/iBellOn", "Comparison of Alarm BellOn After minimized", ) maximize() test.endSection() def verification_of_alarm_parameters(): """ Method to verify parameters of the alarm @param N/A @output N/A """ test.startSection("Verification of alarm parameters") for alarm_id in ALARM_ID_COMBINATION: for alarm_index in range(config.NUM_OF_ALARM_PRIORITIES): alarm.cmd_activate_alarm_id( state=alarm_index, alarm=alarm_id, silence_expires=ALARM_EXPIRES_TIME[alarm_index], flags=alarm_flags["alarms_silenced"], ) # verify mute feature in application. test_verify_alarm_mute( alarm_timeout=ALARM_EXPIRES_TIME[alarm_index], v_flags=config.ALARM_MUTE_FLAG, alarm_status="Mute", ) mouseClick(waitForObjectExists(names.o_AlarmButton_Mute, 2000)) alarm.cmd_activate_alarm_id( state=alarm_index, alarm=alarm_id, flags=alarm_flags["flags"] ) # verify un-mute feature in application. test_verify_alarm_mute( v_flags=config.ALARM_UNMUTE_FLAG, alarm_status="UnMute" ) # verify coloring based on priority. test_color_based_on_alarm_priority(alarm_index) test.endSection() def verification_of_alarm_flag(): """ Method to verify alarm flag @param N/A @output N/A """ test.startSection("Verification of Alarm flags") flag_status = alarm_flags["user_must_ack"] alarm.cmd_activate_alarm_id(1, 1, 0, flags=flag_status) ok_button = waitForObjectExists(names.o_Alarm_Ok_Button) if ok_button.visible == True: mouseClick(ok_button) test.compare( waitForObjectExists(names.o_Alarm_Ok_Button, 2000).visible, True, "Alarm Ok Button visible", ) resume_button = waitForObjectExists(names.o_Alarm_Resume_Button, 2000) if resume_button.visible == True: mouseClick(resume_button) test.compare( waitForObjectExists(names.o_Alarm_Resume_Button, 2000).visible, True, "Alarm Resume Button visible", ) rinseback_button = waitForObjectExists(names.o_Alarm_Rinseback_Button) if rinseback_button.visible == True: mouseClick(rinseback_button) test.compare( waitForObjectExists(names.o_Alarm_Rinseback_Button, 2000).visible, True, "Alarm Rinseback Button visible", ) end_treatment_button = waitForObjectExists(names.o_Alarm_End_Treatment_Button, 2000) if end_treatment_button.visible == True: mouseClick(end_treatment_button) test.compare( waitForObjectExists(names.o_Alarm_End_Treatment_Button, 2000).visible, True, "Alarm End Treatment Button visible", ) flag_status = alarm_flags["alarms_silenced"] alarm.cmd_activate_alarm_id(1, 1, 0, flags=flag_status) alarm_silenced = waitForObjectExists(names.o_AlarmButton_Mute) if alarm_silenced.visible == True: test.compare( waitForObjectExists(names.o_AlarmButton_Mute, 2000).visible, True, "Alarm Mute Button Silenced visible", ) flag_status = alarm_flags["no_minimize"] alarm.cmd_activate_alarm_id(1, 1, 0, flags=flag_status) minimize_buttonn = waitForObjectExists(names.o_AlarmButton_Minimize, 2000) if minimize_buttonn.visible is not True: test.compare( waitForObjectExists(names.o_AlarmButton_Minimize, 2000).visible, False, "Alarm Minimize Button not visible", ) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME_ONLY) verification_of_alarm_parameters() verification_of_alarm_flag() test_send_active_list_response_batch_alarms() utils.tstDone()