# -*- 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_information # date 04/29/2022 # author Papiya Mandal # author Akshay Dhawan import builtins import datetime import names from configuration import config, utility from dialin.common.msg_ids import MsgIds from dialin.common import msg_defs from builtins import int as pyInt from dialin.utils.conversions import unsigned_integer_to_bytearray from dialin.ui.hd_simulator import HDSimulator from dialin.ui.dg_simulator import DGSimulator from dialin.common.hd_defs import HDOpModes from dialin.ui import utils from configuration.config import ALARM_VOLUME_TEXT hd_simulator = HDSimulator() dg_simulator = DGSimulator() DAY_3 = 3 DAY_25 = 25 DAY_12 = 12 DAY_30 = 30 MONTH_JAN = 1 MONTH_NOVEMBER = 11 MONTH_APRIL = 4 MONTH_AUGUST = 7 YEAR_2022 = 2022 YEAR_1977 = 1977 YEAR_2001 = 2001 YEAR_2045 = 2045 INTERVAL_DAYS_2_YEARS = 730 INTERVAL_DAYS_1_YEARS = 365 INTERVAL_DAYS_6_MONTHS = 180 INTERVAL_DAYS_10_MONTHS = 304 TOUCH_GRID_ITEM_NUMBER_5 = 5 GRID_ITEM_0 = 0 FIRST_PARAMETER_OBJECT_ITEM_POSITION_2 = 2 TITLE_ITEM_OBJECT_POSIITON_1 = 1 VERSION_ITEM_OBJECT_POSTION_3 = 3 BRIGHTNESS_BUFFER = 20 VOLUME_BUFFER = 20 VOLUME_RANGE = [80, 40, 20, 100, 60] def settings_text_obj(text): names.o_settings_home_text_obj["text"] = text return names.o_settings_home_text_obj def settings_base_text_obj(text): names.o_settings_base_text_obj["text"] = text return names.o_settings_base_text_obj def service_date_obj(text): names.o_service_date_obj["text"] = text return names.o_service_date_obj def volume_and_brightness_text_obj(text): names.o_SettingsBase_Volume_And_Brightness_Text["text"] = text return names.o_SettingsBase_Volume_And_Brightness_Text def verify_settings_parameters(): """ Method to verify the buttons and parameters of 'Device Settings screen """ test.startSection("Verify the buttons and parameters of 'Device Settings' screen") verify_export_button(config.ENABLED) mouseClick(waitForObjectExists(settings_text_obj(config.EXPORT_TEXT))) eject_btn = waitForObject(names.o_eject_btn) test.compare(eject_btn.enabled, config.ENABLED, "Eject button should be enabled") mouseClick(eject_btn) test.log("Verifying the state of 'Export' button after clicking on Eject button") verify_export_button(config.DISABLED) for parameter in config.DEVICE_SETTINGS_SCREEN_PARAMETER: parameter_text = waitForObjectExists(settings_text_obj(parameter)) test.compare(parameter_text.text, parameter, "{} should be available under 'Device Settings' screen".format(parameter)) test.endSection() def verify_parameters_under_information(): """ Method to verify the parameter under 'Information'\ and 'Services' """ test.startSection("Verify the parameter under 'Information' and 'Services'") test.log("Navigating to 'Information' screen") mouseClick(waitForObjectExists(names.o_arrow_btn)) for title in config.INFORMATION_TITLES: title_text = waitForObjectExists(settings_base_text_obj(title)) test.compare(title_text.text, title, "{} should be available".format(title)) for info_parameter in config.INFORMATION_PARAMETERS: info_parameter_text = waitForObjectExists(settings_base_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(settings_base_text_obj(config.SERIVCES_TITLE)) test.compare(services_text.text, config.SERIVCES_TITLE, "Services title should be {}".format(config.SERIVCES_TITLE)) for services_parameter in config.SERVICES_PARAMETERS: services_par_text = waitForObjectExists(settings_base_text_obj(services_parameter)) test.compare(services_par_text.text, services_parameter, "{} should be available under services".format(services_parameter)) test.endSection() def navigate_to_settings_screen(): """ Method to navigate to "Settings" screen """ test.startSection("Navigating to 'Device Settings' screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_STAN.value, sub_mode=HDOpModes.MODE_FAUL.value) utils.waitForGUI(1) mouseClick(waitForObjectExists(names.o_settings_Text)) device_settings_text = waitForObjectExists(settings_text_obj(config.DEVICE_SETTINGS_TEXT)) test.compare(device_settings_text.text, config.DEVICE_SETTINGS_TEXT, "{} screen is displayed".format(config.DEVICE_SETTINGS_TEXT)) test.endSection() def verify_hd_and_dg_versions(hd_major, hd_minor, hd_micro, hd_build, hd_fpga_id, hd_fpga_major, hd_fpga_minor, hd_fpga_lab, hd_compatibility_rev, hd_serial, dg_major, dg_minor, dg_micro, dg_build, dg_fpga_id, dg_fpga_major, dg_fpga_minor, dg_fpga_lab, dg_compatibility_rev, dg_serial): """ Method to verify the 'hd' and 'dg' version @param hd_major: (uint) - HD Major version number @param hd_minor: (uint) - HD Minor version number @param hd_micro: (uint) - HD Micro version number @param hd_build: (uint) - HD Build version number @param hd_fpga_id: (int) - HD FPGA id version number @param hd_fpga_major: (int) - HD FPGA Major version number @param hd_fpga_minor: (int) - HD FPGA Minor version number @param hd_fpga_lab: (int) - HD FPGA Lab version number @param dg_major: (uint) - DG Major version number @param dg_minor: (uint) - DG Minor version number @param dg_micro: (uint) - DG Micro version number @param dg_build: (uint) - DG Build version number @param dg_fpga_id: (int) - DG FPGA id version number @param dg_pga_major: (int) - DG FPGA Major version number @param dg__fpga_minor: (int) - DG FPGA Minor version number @param dg_fpga_lab: (int) - DG FPGA Lab version number @param compatibility_rev: (uint) - The FWs/UI compatibility revision """ test.startSection("Set 'HD' and 'DG' version and verify") hd_simulator.cmd_send_version_hd_data(major=hd_major, minor=hd_minor, micro=hd_micro, build=hd_build, fpga_id=hd_fpga_id, fpga_major=hd_fpga_major, fpga_minor=hd_fpga_minor, fpga_lab=hd_fpga_lab, compatibility_rev=hd_compatibility_rev) hd_simulator.cmd_send_serial_hd_data(hd_serial) dg_simulator.cmd_send_version_dg_data(major=dg_major, minor=dg_minor, micro=dg_micro, build=dg_build, fpga_id=dg_fpga_id, fpga_major=dg_fpga_major, fpga_minor=dg_fpga_minor, fpga_lab=dg_fpga_lab, compatibility_rev=dg_compatibility_rev) dg_simulator.cmd_send_serial_dg_data(dg_serial) version_details = {"HD Version": None, "HD FPGA Version": None, "HD Serial Number": None, "DG Version": None, "DG FPGA Version": None, "DG Serial Number": None} version_details["HD Serial Number"] = hd_serial version_details["DG Serial Number"] = dg_serial hd_version = "{hd_major}.{hd_minor}.{hd_micro}.{hd_build}.{hd_compatibility_rev}".format(hd_major=hd_major, hd_minor=hd_minor, hd_micro=hd_micro, hd_build=hd_build, hd_compatibility_rev=hd_compatibility_rev) version_details["HD Version"] = hd_version hd_fpga_version = "{hd_fpga_id}.{hd_fpga_major}.{hd_fpga_minor}.{hd_fpga_lab}".format(hd_fpga_id=hd_fpga_id, hd_fpga_major=hd_fpga_major, hd_fpga_minor=hd_fpga_minor, hd_fpga_lab=hd_fpga_lab) version_details["HD FPGA Version"] = hd_fpga_version dg_version = "{dg_major}.{dg_minor}.{dg_micro}.{dg_build}.{dg_compatibility_rev}".format(dg_major=dg_major, dg_minor=dg_minor, dg_micro=dg_micro, dg_build=dg_build, dg_compatibility_rev=dg_compatibility_rev) version_details["DG Version"] = dg_version dg_fpga_version = "{dg_fpga_id}.{dg_fpga_major}.{dg_fpga_minor}.{dg_fpga_lab}".format(dg_fpga_id=dg_fpga_id, dg_fpga_major=dg_fpga_major, dg_fpga_minor=dg_fpga_minor, dg_fpga_lab=dg_fpga_lab) version_details["DG FPGA Version"] = dg_fpga_version screen_parent_obj = object.parent(waitForObjectExists(settings_base_text_obj(("Information")))) screen_children_objs = object.children(screen_parent_obj) touch_grid = screen_children_objs[TOUCH_GRID_ITEM_NUMBER_5] touch_grid_child_obj = object.children(touch_grid) touch_grid_children_obj = object.children(touch_grid_child_obj[GRID_ITEM_0]) touch_grid_children_obj = touch_grid_children_obj[FIRST_PARAMETER_OBJECT_ITEM_POSITION_2:] count = 0 for title, version in version_details.items(): item_childrens = object.children(touch_grid_children_obj[count]) title_obj = item_childrens[TITLE_ITEM_OBJECT_POSIITON_1] count +=1 version_detail = item_childrens[VERSION_ITEM_OBJECT_POSTION_3] if (title_obj.text) == title: test.compare(title_obj.text, title, "{} title should be {}".format(title, title)) test.compare(version_detail.text, version, "{}'s version detail should be {}".format(title, version)) else: continue test.endSection() def verify_export_button(state): """ Method to verify the 'Export' button @param state - (bool) True/False state of the export button """ test.startSection("Verifying Export button") export_btn = waitForObjectExists(settings_text_obj(config.EXPORT_TEXT)) test.compare(export_btn.text, config.EXPORT_TEXT, "Export button text should be {}".format(config.EXPORT_TEXT)) if state == config.ENABLED: test.compare(export_btn.enabled, config.ENABLED, "Export button should be enabled") else: test.compare(export_btn.enabled, config.DISABLED, "Export button should be disabled") test.endSection() def verify_service_date(hd_day, hd_month, hd_year, hd_interval_days, dg_day, dg_month, dg_year, dg_interval_days): """ Method to simulate the 'HD last service date', 'HD next service date', 'DG next service date' and 'DG next service date' and verify the same is displayed on UI screen """ test.startSection("Verify 'HD last service date', 'HD next service date', 'DG next service date' and 'DG next service date' is displayed on UI screen") hd_epoch = builtins.int(datetime.datetime(hd_year, hd_month, hd_day).timestamp()) hd_interval = hd_interval_days * 86400 payload = unsigned_integer_to_bytearray(hd_epoch) payload += unsigned_integer_to_bytearray(hd_interval) hd_simulator.cmd_send_hd_general_response(message_id=138, accepted=0, reason=1, is_pure_data=False, has_parameters=True, parameters_payload=payload) utils.waitForGUI(1) hd_last_service_date = datetime.datetime(hd_year, hd_month, hd_day) hd_last_service_date = str(hd_last_service_date.strftime("%Y/%m/%02d")) hd_last_service_date_text = waitForObjectExists(service_date_obj(hd_last_service_date)) test.compare(hd_last_service_date_text.text, hd_last_service_date, "'HD last service date' should be {}".format(hd_last_service_date)) hd_next_service_date = datetime.datetime(hd_year, hd_month, hd_day) + datetime.timedelta(days=hd_interval_days) hd_next_service_date = str(hd_next_service_date.strftime("%Y/%m/%02d")) hd_next_service_date_text = waitForObjectExists(service_date_obj(hd_next_service_date)) test.compare(hd_next_service_date_text.text, hd_next_service_date, "'HD next service date' should be {}".format(hd_next_service_date)) dg_epoch = builtins.int(datetime.datetime(dg_year, dg_month, dg_day).timestamp()) dg_interval = dg_interval_days * 86400 payload = unsigned_integer_to_bytearray(dg_epoch) payload += unsigned_integer_to_bytearray(dg_interval) dg_simulator.cmd_send_dg_general_response(message_id=140, accepted=0, reason=1, is_pure_data=False, has_parameters=True, parameters_payload=payload) utils.waitForGUI(1) dg_last_service_date = datetime.datetime(dg_year, dg_month, dg_day) dg_last_service_date = str(dg_last_service_date.strftime("%Y/%m/%02d")) dg_last_service_date_text = waitForObjectExists(service_date_obj(dg_last_service_date)) test.compare(dg_last_service_date_text.text, dg_last_service_date, "'DG last service date' should be {}".format(dg_last_service_date)) dg_next_service_date = datetime.datetime(dg_year, dg_month, dg_day) + datetime.timedelta(days=dg_interval_days) dg_next_service_date = str(dg_next_service_date.strftime("%Y/%m/%02d")) dg_next_service_date_text = waitForObjectExists(service_date_obj(dg_next_service_date)) test.compare(dg_next_service_date_text.text, dg_next_service_date, "'DG last service date' should be {}".format(dg_next_service_date)) test.endSection() def verify_volume_and_brightness_section(): """ Method to verify "Volume and Brightness" screen """ test.startSection("Verifying volume and brightness screen") test.log("Verifying the title text of 'Volume And Brightness' screen") volume_and_brightness_text = waitForObjectExists(volume_and_brightness_text_obj(config.VOLUME_AND_BRIGHTNESS_TEXT)) test.compare(volume_and_brightness_text.text, config.VOLUME_AND_BRIGHTNESS_TEXT, "{} screen is displayed".format(config.VOLUME_AND_BRIGHTNESS_TEXT)) brightness_text = waitForObjectExists(volume_and_brightness_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(volume_and_brightness_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)) back_btn = waitForObjectExists(volume_and_brightness_text_obj(config.BACK_TEXT)) test.compare(back_btn.enabled , True, "Back button should be enabled") utils.waitForGUI(0.5) mouseClick(back_btn) utils.waitForGUI(0.5) mouseClick(waitForObjectExists(settings_text_obj(config.VOLUME_AND_BRIGHTNESS_TEXT))) utils.waitForGUI(1) test.endSection() def adjust_and_verify_alarm_volume(volume): """ Method to set the Alarm volume and verify the same @param volume - (int) User expected Alarm volume """ test.startSection("Set the Alarm Volume to {} and verify the current volume is {}".format(volume, volume)) alarm_volume_text = waitForObjectExists(volume_and_brightness_text_obj(config.ALARM_VOLUME_TEXT)) row_obj = object.parent(alarm_volume_text) alarm_volume_parent_object_index = 1 alarm_volume_parent_obj = object.children(row_obj) alarm_volume_parent_obj = alarm_volume_parent_obj[alarm_volume_parent_object_index] alarm_volume_parent_object = object.children(alarm_volume_parent_obj) MINIMUM_TEXT_INDEX = 0 MAXIMUM_TEXT_INDEX = 1 SLIDER_INDEX = -1 PROGRESS_OBJ_INDEX = 3 minimum_alarm_volume_value = alarm_volume_parent_object[MINIMUM_TEXT_INDEX] minimum_alarm_volume_value = minimum_alarm_volume_value.text maximum_alarm_volume_value = alarm_volume_parent_object[MAXIMUM_TEXT_INDEX] maximum_alarm_volume_value = maximum_alarm_volume_value.text slider_obj = alarm_volume_parent_object[SLIDER_INDEX] progress_parent = alarm_volume_parent_object[PROGRESS_OBJ_INDEX] progress_children = object.children(progress_parent) current_alarm_volume = progress_children[1] current_alarm_volume_val = builtins.int(str(current_alarm_volume.text)) width = pyInt(slider_obj.width) - 10 height = pyInt(slider_obj.height) - 20 if volume == current_alarm_volume_val: test.passes("Alarm volume value is already set to {}".format(volume)) elif volume < current_alarm_volume_val: while current_alarm_volume_val != volume: mouseDrag(slider_obj, -100, height, width, 0, Qt.NoModifier, Qt.LeftButton) current_alarm_volume_val -= VOLUME_BUFFER elif volume > current_alarm_volume_val: while current_alarm_volume_val != volume: mouseDrag(slider_obj, 50, height, width, 0, Qt.NoModifier, Qt.LeftButton) current_alarm_volume_val += VOLUME_BUFFER expected_alarm_volume = "{}{}".format(volume, config.UNIT_OF_VOLUME_AND_BRIGHTNESS) current_alarm_volume = progress_children[1] current_alarm_volume_val = "{}{}".format(current_alarm_volume.text, config.UNIT_OF_VOLUME_AND_BRIGHTNESS) test.compare(current_alarm_volume_val, expected_alarm_volume, "Current Alarm volume should be {}".format(expected_alarm_volume)) test.endSection() def verify_alarm_volume(): """ Method to loop through different alarm volume values and set the alarm volume in UI """ for volume in VOLUME_RANGE: adjust_and_verify_alarm_volume(volume) def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) navigate_to_settings_screen() verify_settings_parameters() verify_parameters_under_information() verify_hd_and_dg_versions(hd_major=10, hd_minor=20, hd_micro=30, hd_build=4000, hd_fpga_id=50, hd_fpga_major=60, hd_fpga_minor=70, hd_fpga_lab=80, hd_compatibility_rev=9999, hd_serial="HD1234567890123", dg_major=100, dg_minor=95, dg_micro=105, dg_build=1000, dg_fpga_id=124, dg_fpga_major=75, dg_fpga_minor=65, dg_fpga_lab=125, dg_compatibility_rev=4000, dg_serial="DG1234567890123") utils.waitForGUI(0.5) verify_hd_and_dg_versions(hd_major=12, hd_minor=25, hd_micro=32, hd_build=4100, hd_fpga_id=53, hd_fpga_major=66, hd_fpga_minor=72, hd_fpga_lab=84, hd_compatibility_rev=8888, hd_serial="HD9876543210123", dg_major=101, dg_minor=92, dg_micro=115, dg_build=1001, dg_fpga_id=121, dg_fpga_major=72, dg_fpga_minor=62, dg_fpga_lab=124, dg_compatibility_rev=3000, dg_serial="DG9876543210123") utils.waitForGUI(0.5) verify_hd_and_dg_versions(hd_major=91, hd_minor=33, hd_micro=42, hd_build=4240, hd_fpga_id=10, hd_fpga_major=50, hd_fpga_minor=10, hd_fpga_lab=20, hd_compatibility_rev=1234, hd_serial="HD1234512345123", dg_major=101, dg_minor=85, dg_micro=115, dg_build=1240, dg_fpga_id=122, dg_fpga_major=71, dg_fpga_minor=66, dg_fpga_lab=122, dg_compatibility_rev=4290, dg_serial="DG1234512345123") utils.waitForGUI(0.5) verify_hd_and_dg_versions(hd_major=40, hd_minor=30, hd_micro=33, hd_build=3210, hd_fpga_id=55, hd_fpga_major=68, hd_fpga_minor=71, hd_fpga_lab=88, hd_compatibility_rev=2345, hd_serial="HD09876543210987", dg_major=100, dg_minor=95, dg_micro=105, dg_build=1000, dg_fpga_id=124, dg_fpga_major=75, dg_fpga_minor=65, dg_fpga_lab=125, dg_compatibility_rev=4000, dg_serial="DG9876543210987") utils.waitForGUI(0.5) verify_service_date(hd_day=DAY_3, hd_month=MONTH_NOVEMBER, hd_year=YEAR_2022, hd_interval_days=INTERVAL_DAYS_2_YEARS, dg_day=DAY_25, dg_month=MONTH_JAN, dg_year=YEAR_1977, dg_interval_days=INTERVAL_DAYS_1_YEARS) utils.waitForGUI(0.5) verify_service_date(hd_day=DAY_25, hd_month=MONTH_JAN, hd_year=YEAR_1977, hd_interval_days=INTERVAL_DAYS_1_YEARS, dg_day=DAY_12, dg_month=MONTH_APRIL, dg_year=YEAR_2001, dg_interval_days=INTERVAL_DAYS_6_MONTHS) utils.waitForGUI(0.5) verify_service_date(hd_day=DAY_12, hd_month=MONTH_APRIL, hd_year=YEAR_2001, hd_interval_days=INTERVAL_DAYS_6_MONTHS, dg_day=DAY_30, dg_month=MONTH_AUGUST, dg_year=YEAR_2045, dg_interval_days=INTERVAL_DAYS_10_MONTHS) utils.waitForGUI(0.5) verify_service_date(hd_day=DAY_30, hd_month=MONTH_AUGUST, hd_year=YEAR_2045, hd_interval_days=INTERVAL_DAYS_10_MONTHS, dg_day=DAY_3, dg_month=MONTH_NOVEMBER, dg_year=YEAR_2022, dg_interval_days=INTERVAL_DAYS_2_YEARS) test.log("Navigating to 'Settings' screen") mouseClick(waitForObjectExists(service_date_obj(config.BACK_TEXT))) utils.waitForGUI(0.5) test.log("Navigating to 'Volume and Brightness' screen") mouseClick(waitForObjectExists(settings_text_obj(config.VOLUME_AND_BRIGHTNESS_TEXT))) verify_volume_and_brightness_section() verify_alarm_volume() utils.tstDone()