#-*- coding: utf-8 -*-" ## # Copyright (c) 2019-2020 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_date_and_time # date 05/26/2022 # author Papiya Mandal # author Amrita Debnath import names from configuration import config from dialin.ui.hd_simulator import HDSimulator from dialin.common.hd_defs import HDOpModes, HDStandbyStates from dialin.ui import utils from configuration import utility hd_simulator = HDSimulator() SERVICE_SCREEN_OPTIONS = ["Information", "Volume And Brightness", "Wi-Fi", "Bluetooth Cuff", "DG Cleaning", "Service", "Export Logs"] 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 settings_text_obj(text): """ Method to set custom object property for settings screen. @param text : (string) parameter text """ names.o_settings_home_text_obj["text"] = text return names.o_settings_home_text_obj def text_obj(text): """ Method to set custom object property for information screen. @param text : (string) parameter text """ names.o_SettingsBase_Information_Text["text"] = text return names.o_SettingsBase_Information_Text def navigate_to_settings_screen(): """ Method to navigate to "Settings" screen """ test.startSection("Navigating to 'Service' screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDStandbyStates.STANDBY_START_STATE.value) utils.waitForGUI(0.5) device_settings_text = waitForObjectExists(settings_text_obj(config.SERVICE_TEXT)) test.compare(device_settings_text.text, config.SERVICE_TEXT, "{} screen is displayed".format(config.SERVICE_TEXT)) test.endSection() def verify_settings_parameters(): """ Method to verify the parameters of 'Service' screen """ test.startSection("Verify the parameters of Service screen") for parameter in config.SERVICE_SCREEN_PARAMETER: parameter_text = waitForObjectExists(settings_text_obj(parameter)) test.compare(parameter_text.text, parameter, "{} should be available under 'Service' screen".format(parameter)) test.endSection() def verify_parameters_under_information(): """ Method to verify the parameter under 'Information' """ test.startSection("Verify the parameter under Information screen") test.log("Navigating to 'Information' screen") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_touchItem_TouchRect_service_information)) for title in config.INFORMATION_TITLES: title_text = waitForObjectExists(text_obj(title)) test.compare(title_text.text, title, "{} should be available".format(title)) for info_parameter in config.VERSION_PARAMETERS: info_parameter_text = waitForObjectExists(text_obj(info_parameter)) test.compare(info_parameter_text.text, info_parameter, "{} should be available under 'Information'".format(info_parameter)) test.log("Verifying services title and parameters") services_text = waitForObjectExists(text_obj(config.SERIVCES_TITLE)) test.compare(services_text.text, config.SERIVCES_TITLE, "Service title should be {}".format(config.SERIVCES_TITLE)) for services_parameter in config.SERVICES_PARAMETERS: services_par_text = waitForObjectExists(text_obj(services_parameter)) test.compare(services_par_text.text, services_parameter, "{} should be available under service tile".format(services_parameter)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsBase_backbutton_service_information_mouseArea_MouseArea_2)) test.endSection() def verify_volume_and_brightness_section(): """ Method to verify "Volume and Brightness" screen in service """ test.startSection("Verifying volume and brightness screen") test.log("Verifying the title text of 'Volume And Brightness' screen") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_mousearea_service_volume_and_brightness)) volume_and_brightness_text = waitForObjectExists(text_obj(config.VOLUME_AND_BRIGHTNESS_TEXT)) test.compare(volume_and_brightness_text.text, config.VOLUME_AND_BRIGHTNESS_TEXT, "Volume and Brightness text should be {}".format(config.VOLUME_AND_BRIGHTNESS_TEXT)) brightness_text = waitForObjectExists(text_obj(config.BRIGHTNESS_TEXT)) test.compare(brightness_text.text, config.BRIGHTNESS_TEXT,"Brightness title text should be {}".format(config.BRIGHTNESS_TEXT)) alarm_volume_text = waitForObjectExists(text_obj(config.ALARM_VOLUME_TEXT)) test.compare(alarm_volume_text.text, config.ALARM_VOLUME_TEXT,"Alarm Volume text should be {}".format(config.ALARM_VOLUME_TEXT)) # notification_text = waitForObjectExists(text_obj(config.NOTIFICATION_MESSAGE_TEXT)) # test.compare(notification_text.text, config.NOTIFICATION_MESSAGE_TEXT, "{} notification message is displayed and should be The response value is incorrect. [1007]".format(config.NOTIFICATION_MESSAGE_TEXT)) back_btn = waitForObjectExists(text_obj(config.BACK_TEXT)) test.compare(back_btn.enabled , True, "Back button should be enabled") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsBase_backbutton_service_vandb_mouseArea_MouseArea_3)) utils.waitForGUI(0.5) test.endSection() def verify_wifi_setting(): """ Method to verify "Wi-Fi" screen in service """ test.startSection("Verifying Wi-Fi setting") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_mousearea_service_wifi)) for services_parameter in config.WIFI_PARAMETERS_TEXTS: services_par_text = waitForObjectExists(text_obj(services_parameter)) test.compare(services_par_text.text, services_parameter, "{} should be available under Wi-Fi title".format(services_parameter)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsBase_service_wifi_scan_button_mouseArea_MouseArea_2)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_backbutton_mousearea_service_wifi)) test.endSection() def verify_bluetooth_cuff_setting(): """ Method to verify "Bluetooth Cuff" screen in service """ test.startSection("Verifying Bluetooth Cuff Setting") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_mousearea_service_bluetooth_cuff)) for services_parameter in config.BLUETOOTH_CUFF_PARAMETERS: services_par_text = waitForObjectExists(text_obj(services_parameter)) test.compare(services_par_text.text, services_parameter, "{} should be available under Bluetooth Cuff title".format(services_parameter)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsBase_service_bluetooth_cuff_scan_button_mouseArea_MouseArea_3)) mouseClick(waitForObjectExists(names.o_SettingsBase_service_bluetooth_cuff_scan_button_mouseArea_MouseArea_3)) mouseClick(waitForObjectExists(names.o_SettingsHome_backbutton_mousearea_service_bluetooth_cuff)) test.endSection() def verify_dg_cleaning_setting(): """ Method to verify "DG Cleaning" screen in service """ test.startSection("Verifying DG Cleaning setting") utils.waitForGUI(0.5) mouseClick(waitForObject(names.o_SettingsHome_mousearea_service_dg_cleaning)) for services_parameter in config.DG_CLEANING_PARAMETERS: services_par_text = waitForObjectExists(text_obj(services_parameter)) test.compare(services_par_text.text, services_parameter, "{} should be available under ".format(services_parameter)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_backbutton_mousearea_service_dg_cleaning)) test.endSection() def get_storage_data_status(file_name): """ Method to verify the storage data exported or not exported. @return: (bool) - True - if export data list is present in dash board, else return False """ test.log("verification of storage data before exporting the data") export_list = object.children(waitForObjectExists(file_name))[0] export_list_count = len(object.children(export_list)) if export_list_count >= 1: return True else: return False def verify_export_logs_screen(): """ Method to verify the export logs screen Note overall export log functionality is tested in tst_service_export_logs """ test.startSection("Verifying the the export logs screen") test.log("Navigating to service screen to export log screen") utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsHome_export_log_mouseArea_MouseArea)) test.compare(waitForObjectExists(names.o_export_logs_text).text,config.EXPORT_LOG_TEXT,"{} should be under export logs screen ".format(config.EXPORT_LOG_TEXT)) # TODO need to check whether these two verify checks are valid # log_status = get_storage_data_status(names.o_usb_folder_slider) # test.verify(log_status == False, "export data rectangles should not be filled with contents under USB drive.") # log_status = get_storage_data_status(names.o_SettingsBase_sdcFolderView_ListView) # test.verify(log_status == False, "export data rectangles should be not filled with contents under SD card.") for option in range(len(config.EXPORT_LOGS_OPTIONS)): utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_combo_box)) export_option = waitForObjectExists(custom_object_for_export_log(config.EXPORT_LOGS_OPTIONS[option])) utils.waitForGUI(2) mouseClick(export_option) test.compare(config.EXPORT_LOGS_OPTIONS[option], waitForObjectExists(names.o_combo_box ).displayText, "User should able to select {}".format(config.EXPORT_LOGS_OPTIONS[option])) utils.waitForGUI(1) test.endSection() def verify_export_functionality(): """ verify export log section before and after export button click. """ test.startSection("Verifying the the export button functionality") test.log("verification of progress bar color before exporting data") test.compare(waitForObjectExists(names.o_SettingsBase_progressCircle_ProgressCircle).color.name, config.RED_COLOR,"{} color progress bar is displayed for sd-card".format(config.RED_COLOR)) test.compare(waitForObjectExists(names.o_SettingsBase_progressCircle_ProgressCircle_2).color.name, config.GREEN_COLOR,"{} color progress bar is displayed for usb-drive".format(config.GREEN_COLOR)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsBase_export_button_mouseArea_MouseArea_2)) utils.waitForGUI(2) log_status = get_storage_data_status(names.o_usb_folder_slider) test.verify(log_status == True, "export data rectangles should NOT be empty after export button click under USB drive.") log_status = get_storage_data_status(names.o_SettingsBase_sdcFolderView_ListView) test.verify(log_status == False, "export data rectangles should be empty after export button click under SD card.") test.compare(waitForObjectExists(names.o_SettingsBase_progressCircle_ProgressCircle).color.name, config.RED_COLOR,"{} color progress bar is displayed for sd-card".format(config.RED_COLOR)) test.compare(waitForObjectExists(names.o_SettingsBase_progressCircle_ProgressCircle_2).color.name, config.GREEN_COLOR,"{} color progress bar is displayed for usb-drive".format(config.GREEN_COLOR)) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(names.o_SettingsBase_image_Image_export_log_eject_button )) test.compare(waitForObjectExists(names.o_export_btn).text, config.EXPORT_BUTTON_TEXT,"Export button text should be {}".format(config.EXPORT_BUTTON_TEXT)) test.compare(waitForObjectExists(names.o_export_btn).enabled, False, "Export button should be disabled") test.log("verification of progress bar color after exporting data") test.compare(waitForObjectExists(names.o_SettingsBase_progressCircle_ProgressCircle).color.name, config.RED_COLOR,"{} color progress bar is displayed for sd-card".format(config.RED_COLOR)) test.compare(waitForObjectExists(names.o_SettingsBase_progressCircle_ProgressCircle_2).color.name, config.RED_COLOR,"{} color progress bar is displayed for usb-drive".format(config.RED_COLOR)) mouseClick(waitForObjectExists(names.o_SettingsBase_backbutton_service_information_mouseArea_MouseArea_2)) test.endSection() def verify_water_input_subscreen(): expected_screen_title = "Water Input Mode" test.startSection("Navigating 'Water Input Mode' screen") utils.waitForGUI(0.5) service_subScreen_menu_element = utility.get_object_from_names(names.o_service_water_input_menu_element, 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(names.o_SettingsBase_Water_Input_Mode_Text, error_message=f"{expected_screen_title} object is missing") if subscreenTitle is not None: test.compare(subscreenTitle.text, expected_screen_title, "{} should be displayed when user is navigated to this screen".format(expected_screen_title)) pure_water_mode_switch = utility.get_object_from_names(names.o_SettingsBase_settingsRoInputSwitch_Switch, error_message = "RO Switch object not found") if pure_water_mode_switch is not None: 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") # done, go back to main screen back_button_obj = utility.get_object_from_names(names.o_SettingsBase_backbutton_service_information_mouseArea_MouseArea_2, error_message = "Water input screen back button object missing") if back_button_obj is not None: mouseClick(back_button_obj) utils.waitForGUI(0.5) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME+ " -l") navigate_to_settings_screen() verify_settings_parameters() verify_parameters_under_information() verify_volume_and_brightness_section() verify_wifi_setting() verify_bluetooth_cuff_setting() verify_dg_cleaning_setting() verify_export_logs_screen() verify_export_functionality() verify_water_input_subscreen() #Note the protected service menu items (factory reset, decommission, etc) are in tst_service_menu utils.tstDone()