# 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 Trigger an alarm and Click Alarm list icon to navigate to Alarm list screen # 3 Generate alarms in batches of 10 from 1 to 160 # 4 Compare Number of Alarms displayed and Alarm IDs # 5 Compare of Alarm Reject Notification Text # 6 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 # 7 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 # 8 Set and Compare Alarm Dialog box color based on alarm priority # Compare of Alarm TitleBar Color, Compare of Alarm Bar Color After Alarm minimized 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) FLAG_MUTE = 512 FLAG_UNMUTE = 0 def minimize(): """ Method to minimize alarm dialog box @param N/A @output N/A """ mouseClick(waitForObject(names.o_AlarmButton_Minimize)) def maximize(): """ Method to maximize alarm dialog box @param N/A @output N/A """ mouseClick(waitForObject(names.o_AlarmButton_Maximize)) 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(names.o_AlarmsList_IconButton) # Generate alarms in batches of 10 from 1 to 160 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, ) # Get the alarm list grid and verify rows count alarm_grid = waitForObject(names.o_Alarm_List) # Verify 10 alarms are displayed using rows property test.compare(alarm_grid.rows, 10, "Comparison Number of Alarms displayed") test.startSection( f"Comparison Alarms ID from {batch_start} to { batch_start + 9 } " ) # 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_Reject_Notification_Description_Text ) 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).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).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).timeout, alarm_timeout, "Timeout delay for alarm", ) muted = v_flags == config.ALARM_MUTE_FLAG test.compare( waitForObjectExists(names.o_AlarmButton_Mute_Min).visible, muted, "Mute minutes button is visible", ) test.compare( waitForObjectExists(names.o_AlarmButton_Mute_Sec).visible, muted, "Mute seconds button is visible", ) muteTimeout_min, muteTimeout_sec = divmod(alarm_timeout, 60) if muted: test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Img).source.path), "/images/iBellOff", "Comparison of Alarm BellOff", ) test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Min).text), "{}".format(muteTimeout_min), "Comparison of Mute Minutes", ) test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Sec).text), "{0:02}".format(muteTimeout_sec), "Comparison of Mute seconds", ) minimize() test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Img).source.path), "/images/iBellOff", "Comparison of Alarm BellOff After minimized", ) test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Min).text), "{}".format(muteTimeout_min), "Comparison of Mute Minutes After minimized", ) test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Sec).text), "{0:02}".format(muteTimeout_sec), "Comparison of Mute seconds After minimized", ) else: test.compare( str(waitForObjectExists(names.o_AlarmButton_Mute_Img).source.path), "/images/iBellOn", "Comparison of Alarm BellOn", ) minimize() test.compare( str(waitForObjectExists(names.o_Alarm_Bar_Mute_Img).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=FLAG_MUTE, ) # 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)) alarm.cmd_activate_alarm_id( state=alarm_index, alarm=alarm_id, flags=FLAG_UNMUTE ) # 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 main(): utils.tstStart(__file__) startApplication(config.AUT_NAME_ONLY) test.startSection("Verification of General Alarm Requirements ") # test_send_active_list_response_batch_alarms() verification_of_alarm_parameters() test.endSection() utils.tstDone()