# -*- coding: utf-8 -*-" ## # Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_settings_information # date 10/07/2023 # author Vy Duong ### ## Tests for the service menu section that is password protected ### import builtins import names from configuration import application_init as application_init from configuration import config, utility from dialin.ui.hd_simulator import HDSimulator from dialin.common.hd_defs import HDOpModes, HDStandbyStates from dialin.ui import utils from calendar import isleap hd_simulator = HDSimulator() def custom_object_for_export_log(text): """ Method to set custom object property for export option @param text : (string) parameter text """ names.o_option_combo_box["text"] = text return names.o_option_combo_box def service_text_obj(text): names.o_service_home_text_obj["text"] = text return names.o_service_home_text_obj def navigate_to_service_menu(): """ Method to navigate to "Service" screen """ test.startSection("Navigating to 'Service' menu") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDStandbyStates.STANDBY_START_STATE.value) utils.waitForGUI(0.5) service_screen_text = utility.get_object_from_names(service_text_obj(config.SERVICE_SCREEN_TITLE_TEXT), error_message="Service Screen title object missing") 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() def navigate_to_subscreen(whichScreenKey, expectedScreenTitle, titleObject): """ Method to navigate to the water input mode screen @param whichScreenEnum : SERVICE_SCREEN_SUBSCREEN_INDEX """ test.startSection(f"Navigating '{expectedScreenTitle}' screen") names.o_serviceScreen_subscreen_menu["occurrence"] = whichScreenKey service_subScreen_menu_element = utility.get_object_from_names(names.o_serviceScreen_subscreen_menu, error_message="subscreen menu element not found") if service_subScreen_menu_element is not None: mouseClick(service_subScreen_menu_element) utils.waitForGUI(0.5) subscreenTitle = utility.get_object_from_names(titleObject, error_message=f"{expectedScreenTitle} object is missing") if subscreenTitle is not None: test.compare(subscreenTitle.text, expectedScreenTitle, "{} should be displayed when user is navigated to this screen".format(expectedScreenTitle)) test.endSection() def navigate_to_export_logs(): test.startSection("Verifying the the export logs screen") export_log_subscreen_menu_element = utility.get_object_from_names(names.o_SettingsHome_export_log_mouseArea_MouseArea, error_message = "export log menu element object missing") if export_log_subscreen_menu_element is not None: mouseClick(export_log_subscreen_menu_element) utils.waitForGUI(1) export_log_text = utility.get_object_from_names(names.o_export_logs_text, error_message = "export log text object missing") 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 select_different_log_type(whichTypeIndex): log_type_combo_box = utility.get_object_from_names(names.o_combo_box, error_message="Combo box object is missing") if log_type_combo_box is not None: mouseClick(waitForObjectExists(names.o_combo_box)) 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) utils.waitForGUI(2) test.compare(config.EXPORT_LOGS_OPTIONS[whichTypeIndex], waitForObjectExists(names.o_combo_box ).displayText, "User should able to select {}".format(config.EXPORT_LOGS_OPTIONS[whichTypeIndex])) utils.waitForGUI(1) return True return False # default return if not successful def check_eject_usb_button(is_enabled, is_clicking_button = False): """ For checking enabled/disabled state of the usb eject button """ eject_usb_button = utility.get_object_from_names(names.o_SettingsBase_image_Image_export_log_eject_button, error_message="eject usb button object not found") 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}") if is_clicking_button: utils.waitForGUI(0.5) mouseClick(eject_usb_button) utils.waitForGUI(0.5) 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() check_eject_usb_button(config.ENABLED, is_clicking_button=True) utils.waitForGUI(1) # check_eject_usb_button(config.DISABLED) stop_application() def main(): utils.tstStart(__file__) test.log("TODO test case incomplete, need script call handling in the APP to complete", "Need to add an option to the application to allow mocked-script calls") application_init.setup_post_log_successful_start() test_export_logs_eject_usb_case() # select_different_log_type(1) # TODO need to select the logs and click export utils.tstDone()