Index: suite_leahi/tst_service_export_logs/test.py =================================================================== diff -u -rc11f139f76c59b3e2f6a7c66c55f214b91dd73b4 -r0bb330c1823aad987899f72b12c302551d575c5a --- suite_leahi/tst_service_export_logs/test.py (.../test.py) (revision c11f139f76c59b3e2f6a7c66c55f214b91dd73b4) +++ suite_leahi/tst_service_export_logs/test.py (.../test.py) (revision 0bb330c1823aad987899f72b12c302551d575c5a) @@ -1,172 +1,252 @@ -import names -import os -import glob +# Subject/Title: LDT-1057 Device Settings - SW - 02 - Export Log - Q&R +# +# Functionalities: Testing all functionalities of Device Settings Export Log Screen +# +# Steps: +# 1. Export Application log files +# - Delete existing files from USB folders +# - Start Leahi Application +# - Navigate to Device Settings Screen +# - Navigate to Export logs Screen +# - Click on Export Button to transfer Application files from SD Card to USB +# - Compare Export Log Status "Application log export to USB is complete" +# - Check if the USB eject button enabled and Click on it +# - Close Application +# 2. Export Service log files +# - Start Leahi Application +# - Navigate to Device Settings Screen +# - Navigate to Export logs screen +# - Click on log type combo box and select a Service log type +# - Click on Export Button to transfer Service files from SD Card to USB +# - Compare Export In Progress Log Status "Service log export to USB in progress ... " +# - Check if the USB eject button enabled and Click on it +# - Close Application +# 3. Export Service log files +# - Delete existing files from USB folders +# - Start Leahi Application +# - Navigate to Device Settings Screen +# - Navigate to Export logs screen +# - Selects the first application log file that is currently displayed. +# - Click on Export Button to transfer Selected Application file from SD Card to USB +# - Compare Export Log Status "Application log export to USB is complete" +# - Check if the USB eject button enabled and Click on it +# - Close Application -from pathlib import Path +import names from configuration import application_init as application_init from configuration import config, utility from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates from leahi_dialin.ui import utils -td =TD_Messaging() +td_simulator = TD_Messaging() + def custom_object_for_export_log(text): """ - Method to set custom object property for export option - @param text : (string) parameter text - """ - names.optionComboBox["text"] = text - return names.optionComboBox + Method to set custom object property for export option + @param text : (string) parameter text + """ + names.o_OptionComboBox["text"] = text + return names.o_OptionComboBox -def service_text_obj(text): - names.serviceText["text"] = text - return names.serviceText def navigate_to_service_menu(): """ - Method to navigate to "Service" screen + Method to navigate to "Service" screen """ - test.startSection("Navigating to 'Service' menu") - td.td_operation_mode(op_mode=TDOpModes.MODE_SERV.value, sub_mode=TDStandbyStates.STANDBY_START_STATE.value) - service_screen_text = utility.get_object_from_names(service_text_obj(config.SERVICE_SCREEN_TITLE_TEXT), error_message="Service Screen title object missing", timeout_ms=2000) - if service_screen_text is not None: - test.compare(service_screen_text.text, config.SERVICE_SCREEN_TITLE_TEXT, "{} screen is displayed".format(config.SERVICE_SCREEN_TITLE_TEXT)) - test.endSection() - + td_simulator.td_operation_mode( + op_mode=TDOpModes.MODE_SERV.value, + sub_mode=TDStandbyStates.STANDBY_START_STATE.value, + ) + device_setting_screen_title_text = utility.get_object_from_names( + names.o_DeviceSettingsTitleText, + error_message="Device Settings Screen title text object missing", + timeout_ms=2000, + ) + if device_setting_screen_title_text is not None: + test.compare( + device_setting_screen_title_text.text, + config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Device Settings Screen Title text".format( + config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT + ), + ) + + def navigate_to_export_logs(): - test.startSection("Verifying the the export logs screen") - export_log_subscreen_menu_element = utility.get_object_from_names(names.settingsHomeExportLogs, error_message = "export log menu element object missing", timeout_ms=1000) + export_log_subscreen_menu_element = utility.get_object_from_names( + names.o_DeviceSettingsPageExportLogs, + error_message="export log menu element object missing", + timeout_ms=1000, + ) if export_log_subscreen_menu_element is not None: mouseClick(export_log_subscreen_menu_element) - - export_log_text = utility.get_object_from_names(names.exportLogsText, error_message = "export log text object missing", timeout_ms=1000) - if export_log_text is not None: - test.compare(export_log_text.text,config.EXPORT_LOG_TEXT,"{} should be under export logs screen ".format(config.EXPORT_LOG_TEXT)) - test.endSection() -def check_eject_usb_button(is_enabled, is_clicking_button = False): + export_log_screen_title_text = utility.get_object_from_names( + names.o_ExportLogsPageTitleText, + error_message="export log screen title text object missing", + timeout_ms=1000, + ) + if export_log_screen_title_text is not None: + test.compare( + export_log_screen_title_text.text, + config.EXPORT_LOG_TEXT, + "{} screen is displayed and Comparison of Export Log Screen Title text".format( + config.EXPORT_LOG_TEXT + ), + ) + + +def check_eject_usb_button(is_enabled, is_clicking_button=False): """ - For checking enabled/disabled state of the usb eject button + For checking enabled/disabled state of the usb eject button """ - eject_usb_button = utility.get_object_from_names(names.usbEjectButton, error_message="eject usb button object not found", timeout_ms=1000) + eject_usb_button = utility.get_object_from_names( + names.o_USBEjectButton, + error_message="eject usb button object not found", + timeout_ms=1000, + ) if eject_usb_button is not None: - test.compare(eject_usb_button.enabled, is_enabled, f"Check if the USB eject button enabled = {is_enabled}") + test.compare( + eject_usb_button.enabled, + is_enabled, + f"Check if the USB eject button enabled = {is_enabled}", + ) if is_clicking_button: mouseClick(eject_usb_button) -app_context = None; -def init_application_service_export_logs(): - """ - starts the application and traverse to the export log screen - """ - app_context = startApplication(config.AUT_NAME+ " -l") - - navigate_to_service_menu() - navigate_to_export_logs() -def stop_application(): - if app_context is not None: - app_context.detach() - def test_export_logs_eject_usb_case(): """ tests the case that the usb is ejected, requires restarting the application to get original state """ - init_application_service_export_logs() - - mouseClick(waitForObjectExists(names.exportButton)) - utils.waitForGUI(1) #This wait is to verify that the Application log export to USB is complete. Increase seconds in waitForGUI if the test compare fails. - export_log_status = utility.get_object_from_names(names.notificationBar, error_message = "export log status missing", timeout_ms = 3000) + mouseClick(waitForObjectExists(names.o_ExportButton)) + utils.waitForGUI( + 1 + ) # This wait is to verify that the Application log export to USB is complete. Increase seconds in waitForGUI if the test compare fails. + export_log_status = utility.get_object_from_names( + names.o_ExportLogsNotificationBar, + error_message="export log status missing", + timeout_ms=3000, + ) if export_log_status is not None: - test.compare(export_log_status.text,config.EXPORT_LOG_STATUS,"{}".format(config.EXPORT_LOG_STATUS)) + + test.compare( + export_log_status.text, + config.EXPORT_LOG_STATUS, + "Verification Export log status is 'Application log export to USB is complete'".format( + config.EXPORT_LOG_STATUS + ), + ) check_eject_usb_button(config.ENABLED, is_clicking_button=True) - stop_application() + def select_different_log_type(whichTypeIndex): - log_type_combo_box = utility.get_object_from_names(names.comboBox, error_message="Combo box object is missing") - if log_type_combo_box is not None: - mouseClick(waitForObjectExists(names.comboBox)) - log_type_option = utility.get_object_from_names(custom_object_for_export_log(config.EXPORT_LOGS_OPTIONS[whichTypeIndex]), error_message= f"Option {config.EXPORT_LOGS_OPTIONS[whichTypeIndex]} object is missing", timeout_ms = 500) + log_type_combo_box = utility.get_object_from_names( + names.o_LogTypeComboBox, error_message="Combo box object is missing" + ) + if log_type_combo_box is not None: + mouseClick(waitForObjectExists(names.o_LogTypeComboBox)) + log_type_option = utility.get_object_from_names( + custom_object_for_export_log( + config.EXPORT_LOGS_OPTIONS[whichTypeIndex]), + error_message=f"Option {config.EXPORT_LOGS_OPTIONS[whichTypeIndex]} object is missing", + timeout_ms=500, + ) if log_type_option is not None: - mouseClick(log_type_option) - combo_box_text = utility.get_object_from_names(names.comboBox, error_message = "unable to select from Combo Box", timeout_ms=1000) - test.compare(config.EXPORT_LOGS_OPTIONS[whichTypeIndex], combo_box_text.displayText, "User should able to select {}".format(config.EXPORT_LOGS_OPTIONS[whichTypeIndex])) + mouseClick(log_type_option) + combo_box_text = utility.get_object_from_names( + names.o_LogTypeComboBox, + error_message="unable to select from Combo Box", + timeout_ms=1000, + ) + test.compare( + config.EXPORT_LOGS_OPTIONS[whichTypeIndex], + combo_box_text.displayText, + "User should able to select {} log type".format( + config.EXPORT_LOGS_OPTIONS[whichTypeIndex] + ), + ) - export_button = utility.get_object_from_names(names.exportButton, error_message = "Export button was not enabled", timeout_ms=2000) + export_button = utility.get_object_from_names( + names.o_ExportButton, + error_message="Export button was not enabled", + timeout_ms=2000, + ) if export_button is not None: mouseClick(export_button) - - export_log_progress_status = utility.get_object_from_names(names.notificationBar, error_message = "export log progress status missing", timeout_ms=2000) + + export_log_progress_status = utility.get_object_from_names( + names.o_ExportLogsNotificationBar, + error_message="export log progress status missing", + timeout_ms=2000, + ) if export_log_progress_status is not None: - test.compare(export_log_progress_status.text,config.EXPORT_LOG_PROGRESS_STATUS,"{}".format(config.EXPORT_LOG_PROGRESS_STATUS)) - - usb_eject_button = utility.get_object_from_names(names.usbEjectButton, error_message = "USB eject button was not enabled", timeout_ms=2000) - if usb_eject_button is not None: - mouseClick(usb_eject_button) + test.compare( + export_log_progress_status.text, + config.EXPORT_LOG_PROGRESS_STATUS, + "Verification Export log status is 'Service log export to USB in progress ...'".format( + config.EXPORT_LOG_PROGRESS_STATUS + ), + ) + + check_eject_usb_button(config.ENABLED, is_clicking_button=True) return True - return False # default return if not successful + return False # default return if not successful + def select_a_log_file_and_export(): - test.startSection("Selecting a log file and exporting it") - - mouseClick(waitForObjectExists(names.progressRect)) - mouseClick(waitForObjectExists(names.exportButton)) - usb_eject_button = utility.get_object_from_names(names.usbEjectButton, error_message = "USB eject button not enabled", timeout_ms=2000) - if usb_eject_button is not None: - mouseClick(usb_eject_button) + + mouseClick(waitForObjectExists(names.o_ExportLogsProgressRect)) + mouseClick(waitForObjectExists(names.o_ExportButton)) + export_log_status = utility.get_object_from_names( + names.o_ExportLogsNotificationBar, + error_message="export log status missing", + timeout_ms=3000, + ) + if export_log_status is not None: + test.compare( + export_log_status.text, + config.EXPORT_LOG_STATUS, + "Verification Export log status is 'Application log export to USB is complete'".format( + config.EXPORT_LOG_STATUS + ), + ) + check_eject_usb_button(config.ENABLED, is_clicking_button=True) test.endSection() - -def delete_existing_files_usb_folders(): - - base_path = Path.home() / "Desktop/usb-disk" - - cleanup_targets = { - base_path / "log": ["*.log"], - base_path / "service": ["*.err"] - } - - for folder, extensions in cleanup_targets.items(): - if not folder.is_dir(): - test.log(f"Warning: Directory '{folder}' not found. Skipping.") - continue - - found = False - for ext in extensions: - for file_path in folder.glob(ext): - try: - os.remove(file_path) - found = True - except OSError as e: - test.log(f" Error deleting file {file_path}: {e}") - - if not found: - test.log("No matching files found.") - - test.log("Cleanup complete.") - + def main(): utils.tstStart(__file__) - + application_init.setup_post_log_successful_start() - - test.startSection("Export Application files") - - delete_existing_files_usb_folders() + + test.startSection("Export Application log files") + + application_init.delete_existing_files_usb_folders() + startApplication(config.AUT_NAME + "-q") + navigate_to_service_menu() + navigate_to_export_logs() test_export_logs_eject_usb_case() - closeWindow(names.o_Gui_MainView) + closeWindow(names.o_Gui_MainView) + test.endSection() - test.startSection("Export Service files") - - init_application_service_export_logs() - select_different_log_type(1) + test.startSection("Export Service log files") + + startApplication(config.AUT_NAME + "-q") + navigate_to_service_menu() + navigate_to_export_logs() + select_different_log_type(1) closeWindow(names.o_Gui_MainView) - + test.endSection() + test.startSection("Export single log file") - delete_existing_files_usb_folders() - init_application_service_export_logs() + + application_init.delete_existing_files_usb_folders() + startApplication(config.AUT_NAME + "-q") + navigate_to_service_menu() + navigate_to_export_logs() select_a_log_file_and_export() - + utils.tstDone() - \ No newline at end of file