# -*- 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_audio_and_brightness # date 11/16/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() SERVICE_SCREEN_OPTIONS = ["Information", "Volume And Brightness", "Wi-Fi", "Bluetooth Cuff", "DG Cleaning", "Set Date And Time", "Export Logs" ] EMPTY_INPUT_FIELD = "" SET_DATE_AND_TIME_TEXT = "Set Date And Time" 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 date_time_screen_text_obj(text): names.o_settings_date_and_time_text["text"] = text return names.o_settings_date_and_time_text 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)) mouseClick(waitForObjectExists(names.o_service_show_password)) test.log("Verifying the entered password") password = str((waitForObjectExists(names.o_password_text_field)).text) test.compare(password, str(password), "Entered password should be {}".format(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_set_date_and_time(): """ Method to navigate to set date and time screen and verify its title 'Set Date And Time' """ test.startSection("Navigating 'Set Date And Time' screen") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_mouseArea_MouseArea_2_set_date_time)) set_date_and_time_title = waitForObjectExists(settings_text_obj(SET_DATE_AND_TIME_TEXT)) test.compare(set_date_and_time_title.text, SET_DATE_AND_TIME_TEXT, "{} should be displayed when user is navigated to 'Set Date And Time' screen".format(SET_DATE_AND_TIME_TEXT)) test.endSection() def verify_back_btn(): """ Method to verify the back button and click """ test.startSection("Verify the 'BACK' button") test.compare(str(waitForObjectExists(settings_text_obj(config.BACK_TEXT)).text), config.BACK_TEXT,"'BACK' button text should be {}".format(config.BACK_TEXT)) utils.waitForGUI(0.1) test.compare(waitForObjectExists(settings_text_obj(config.BACK_TEXT)).enabled , True, "'BACK' button should be enabled") mouseClick(waitForObjectExists(names.o_SettingsDateTime_mouseArea_MouseArea_2)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_mouseArea_MouseArea_2_set_date_time)) test.endSection() def verify_confirm_btn(valid_parameter_passed): """ Method to verify the status of confirm button and click on confirm button @param valid_paramter_passed - (bool) True/False whether hour/minute/day/month/year is valid """ test.startSection("Verify the status of confirm button and click on confirm button") if valid_parameter_passed is config.VALID: if object.exists(date_time_screen_text_obj(text=config.CONFIRM_TEXT)): confirm_btn = waitForObjectExists(date_time_screen_text_obj(text=config.CONFIRM_TEXT)) test.compare(confirm_btn.enabled, config.ENABLED, "Confirm Button should be enabled") mouseClick(confirm_btn) confirm_msg = waitForObjectExists(settings_text_obj(CONFIRMATION_MESSAGE)) test.compare(confirm_msg.visible, config.VISIBLE, "{} message should be displayed".format(CONFIRMATION_MESSAGE)) else: if not(object.exists(date_time_screen_text_obj(text=config.CONFIRM_TEXT))): test.passes("Confirm button is not available") test.endSection() def main(): utils.tstStart(__file__) application_init.setup_post_log_successful_start() startApplication(config.AUT_NAME+ " -l") navigate_to_service_menu() navigate_to_set_date_and_time() utils.tstDone()