# -*- 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 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 service_text_obj(text): names.o_service_home_text_obj["text"] = text return names.o_service_home_text_obj def settings_text_obj(text): names.o_set_date_and_time_text_obj["text"] = text return names.o_set_date_and_time_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 = waitForObjectExists(service_text_obj(config.SERVICE_SCREEN_TITLE_TEXT)) test.compare(service_screen_text.text, config.SERVICE_SCREEN_TITLE_TEXT, "{} screen is displayed".format(config.SERVICE_SCREEN_TITLE_TEXT)) test.compare(waitForObjectExists(names.o_service_text).text,config.SERVICE_TEXT, "{} screen is displayed".format(config.SERVICE_TEXT)) mouseClick(waitForObjectExists(names.o_service_text)) services_password_title = (waitForObjectExists(names.o_service_text_title).text) test.compare(services_password_title, config.SERVICES_TITLE_TEXT, "{} should display once user is navigated to services password screen".format(config.SERVICES_TITLE_TEXT)) utils.waitForGUI(0.5) #enter the password to access screen test.log("Clicking on password entry field") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_password_text_field)) mouseClick(waitForObjectExists(names.o_switch_keyboard_to_keypad)) password = config.DEFAULT_SERVICE_PASSWORD_RAW type(waitForObject(names.o_password_text_field), str(password)) confirm_button = (waitForObjectExists(names.o_service_confirm_btn).text) test.compare(confirm_button, config.CONFIRM_TEXT, "Button text should be {}".format(config.CONFIRM_TEXT)) mouseClick(waitForObjectExists(names.o_service_confirm_btn)) utils.waitForGUI(0.5) # HD response to advance to the service menu hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDStandbyStates.STANDBY_START_STATE.value) 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("Navigating 'Set Date And Time' screen") utils.waitForGUI(0.5) names.o_serviceScreen_subscreen_menu["occurrence"] = whichScreenKey mouseClick(waitForObjectExists(names.o_serviceScreen_subscreen_menu)) subscreenTitle = waitForObjectExists(titleObject) test.compare(subscreenTitle.text, expectedScreenTitle, "{} should be displayed when user is navigated to 'Set Date And Time' screen".format(expectedScreenTitle)) test.endSection() def navigate_back_to_service_main_screen(): test.startSection("Return to Service Screens") mouseClick(waitForObject(names.o_SettingsBase_backbutton_service_information_mouseArea_MouseArea_2)) utils.waitForGUI(0.5) test.endSection() def test_water_input_subscreen(): test.startSection("Navigating 'Set Date And Time' screen") navigate_to_subscreen(config.SERVICE_SCREEN_SUBSCREEN_INDEX["WATER_INPUT_MODE_SUBSCREEN"], "Water Input Mode", names.o_SettingsBase_Water_Input_Mode_Text) pure_water_mode_switch = waitForObject(names.o_SettingsBase_settingsRoInputSwitch_Switch) test.compare(pure_water_mode_switch.checked, False, "Pure water mode switch value should be False") utils.waitForGUI(0.5) mouseClick(pure_water_mode_switch) utils.waitForGUI(0.5) test.compare(pure_water_mode_switch.checked, True, "Pure water mode switch value should be True") navigate_back_to_service_main_screen() test.endSection() def test_enable_root_ssh_screen(): test.startSection(f"Navigating {config.SERVICES_ENABLE_ROOT_SSH_TITLE} screen") navigate_to_subscreen(config.SERVICE_SCREEN_SUBSCREEN_INDEX["ENABLE_ROOT_SUBSCREEN"], config.SERVICES_ENABLE_ROOT_SSH_TITLE, names.o_SettingsBase_Enable_Root_SSH_Text) enable_root_ssh_options=[{"option_label": "Enable SSH Login", "option_switch": names.o_SettingsBase_settingsRootSSHAccess_SSHDSwitch_Switch}, {"option_label": "Enable Root Login", "option_switch": names.o_SettingsBase_settingsRootSSHAccess_RootSwitch_Switch}] #traverse the options available to enable/disable on the "enable root ssh" screen for index in range(0,len(enable_root_ssh_options), 1): option_text = enable_root_ssh_options[index]["option_label"] names.o_SettingsBase_Enable_Root_SSH_Screen_Text["text"] = option_text try: # option label text object option_label_text_object = waitForObject(names.o_SettingsBase_Enable_Root_SSH_Screen_Text) test.compare(option_label_text_object, option_text, f"{option_text} incorrect") utils.waitForGUI(0.5) try: option_switch_object = waitForObject(enable_root_ssh_options[index]["option_switch"]) test.compare(option_switch_object.checked, False, f"{option_text} switch value should be False") utils.waitForGUI(0.5) mouseClick(option_switch_object) utils.waitForGUI(0.5) test.compare(option_switch_object.checked, True, f"{option_text} switch value should be True") except LookupError: test.fail(f"FAIL : Switch object for {option_text} not found") except LookupError: test.fail(f"FAIL : Object for {option_text} not found") navigate_back_to_service_main_screen() test.endSection() def main(): utils.tstStart(__file__) # TODO need to replace real scripts with mock scripts to get behavior application_init.setup_post_log_successful_start() startApplication(config.AUT_NAME+ " -l") navigate_to_service_menu() # test the subscreens test_water_input_subscreen() test_enable_root_ssh_screen() utils.tstDone()