Index: shared/scripts/configuration/config.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -re722325d02c51abd72e9215a56f4623f3b1334c5 --- shared/scripts/configuration/config.py (.../config.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/config.py (.../config.py) (revision e722325d02c51abd72e9215a56f4623f3b1334c5) @@ -32,3 +32,30 @@ BLOOD_PRIMING_TEXT = "Blood Priming" SALINE_UNIT = "mL" BLOOD_PRIMING_DEFAULT_VALUE = "0 mL" + + +#Setting +CLEAR_ALARM_CONDITION_TEXT = "Clear Alarm Condition" +EXPORT_TEXT ="Export" +DEVICE_SETTINGS_TEXT = "Device Settings" +DEVICE_SETTINGS_SCREEN_PARAMETER = ["Information", "Volume And Brightness", "Wi-Fi", "Bluetooth Cuff", "Dialysate Generator Settings", "Services"] +SettingsHome_Treatment_Text = "Treatment" +SettingsHome_Manager_Text = "Manager" +SettingsHome_Settings_Text = "Settings" + +#Information + +INFORMATION_TITLES = ["Information", "Versions"] +INFORMATION_PARAMETERS = ["Information", "UI Version", "HD Version", "HD FPGA Version", "HD Serial Number", "DG Version", "DG FPGA Version", "DG Serial Number"] +SERIVCES_TITLE = "Services" +SERVICES_PARAMETERS = ["HD Last Service Date", "HD Next Service Date", "DG Last Service Date", "DG Next Service Date"] + +ENABLED = True +DISABLED = False + +#services +PASSWORD = 123 +CONFIRM_TEXT = "CONFIRM" + +OUT_OF_RANGE_COLOR = "#c53b33" +IN_RANGE_COLOR = "#fcfcfc" Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -re722325d02c51abd72e9215a56f4623f3b1334c5 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision e722325d02c51abd72e9215a56f4623f3b1334c5) @@ -12,52 +12,14 @@ # ############################################################################ - +import names import sys import test import squish from configuration import config from builtins import int as pyInt - +from dialin.ui import utils -def start_application(app_name): - """ - Function to start application and verify application status [running] - If application does not start or running status is false, test stops - Argument: - @param app_name : (str) - Name of the application - @param app_executable : (str) - Actual application - @return: handle for the application if the application is in running state, - or error (exist the application) - """ - counter = 0 - while True: - try: - counter += 1 - test.log("Starting {}".format(app_name)) - squish.startApplication(app_name) - if counter == 1: - test.log("Application launched at the "+str(counter)+" st try.") - elif counter == 2: - test.log("Application launched at the "+str(counter)+" nd try.") - elif counter == 3: - test.log("Application launched at the "+str(counter)+" rd try.") - else: - test.log("Application launched at the "+str(counter)+" th try.") - break - except RuntimeError: - if counter == 1: - test.log("Application failed to launch after "+str(counter)+" try - Please refer logs") - elif counter == 20: - test.log("Exiting after "+str(counter)+ " tries..") - sys.exit(1) - else: - test.log("Application failed to launch after "+str(counter)+ " tries - Please refer logs") - except: - logErrorDetails("Failed to start the application") - sys.exit(1) - - def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container @@ -108,3 +70,57 @@ raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") + + +def keyboard_input(key_value): + names.o_keyboard_object["text"] = key_value + return names.o_keyboard_object + +def enter_keyboard_numeric_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + for value in entry: + value = pyInt(value) + key_val = squish.waitForObject(keyboard_input(value)) + squish.mouseClick(key_val) + utils.waitForGUI(1) + test.endSection() + +def keypad_input(key_value): + names.o_keypad_input["text"] = key_value + return names.o_keypad_input + +def enter_keypad_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + for value in entry: + value = pyInt(value) + key_val = squish.waitForObject(keypad_input(value)) + squish.mouseClick(key_val) + utils.waitForGUI(1) + test.endSection() + + +def erase_entered_value(input_field): + """ + Method to erase the entered value + @param input_field - (obj) object of input field + """ + test.startSection("Erasing value") + input_field= squish.waitForObject(input_field) + entered_value = str(input_field.text) + for value in range(len(entered_value)+1): + utils.waitForGUI(1) + squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) + + test.compare(str(input_field.text), "", "Input field should be empty") + test.endSection() + Index: shared/scripts/names.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -re722325d02c51abd72e9215a56f4623f3b1334c5 --- shared/scripts/names.py (.../names.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/names.py (.../names.py) (revision e722325d02c51abd72e9215a56f4623f3b1334c5) @@ -48,6 +48,29 @@ o_cumulative_fluid_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Cumulative Delivered", "type": "Text", "unnamed": 1, "visible": True} +#settings_Home +o_settings_Text = {"container": o_Gui_MainView, "text": "Settings", "type": "Text", "unnamed": 1, "visible": True} +o_SettingsHome_SettingsHome = {"container": o_Gui_MainView, "objectName": "_SettingsHome", "type": "SettingsHome", "visible": True} +o_settings_home_text_obj = {"container": o_SettingsHome_SettingsHome, "type": "Text", "unnamed": 1, "visible": True} +o_eject_btn = {"container": o_SettingsHome_SettingsHome, "id": "_image", "source": "qrc:/images/iEject", "type": "Image", "unnamed": 1, "visible": True} +o_arrow_btn = {"container": o_SettingsHome_SettingsHome, "id": "_image", "source": "qrc:/images/iArrowRight", "type": "Image", "unnamed": 1, "visible": True} +o_SettingsBase_SettingsBase = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsBase", "visible": True} +o_settings_base_text_obj = {"container": o_SettingsBase_SettingsBase, "type": "Text", "unnamed": 1, "visible": True} +o_userConfirmation_UserConfirmation = {"container": o_Gui_MainView, "objectName": "UserConfirmation", "type": "UserConfirmation", "visible": True} +o_services_screen_text_obj = {"container": o_userConfirmation_UserConfirmation, "type": "Text", "unnamed": 1, "visible": True} +o_password_text_field = {"container": o_userConfirmation_UserConfirmation, "echoMode": 2, "id": "_input", "passwordCharacter": "•", "type": "TextInput", "unnamed": 1, "visible": True} +o_show_password = {"container": o_userConfirmation_UserConfirmation, "id": "_showPassword", "source": "qrc:/images/iEye", "type": "Image", "unnamed": 1, "visible": True} +#object on keyboard to switch to keypad +o_switch_keyboard_to_keypad = {"container": o_Gui_MainView, "text": "&123", "type": "Text", "unnamed": 1, "visible": True} +o_keyboard_object = {"container": o_Gui_MainView, "type": "Text", "unnamed": 1, "visible": True} +o_SettingsBase_SettingsDateTime = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsDateTime", "visible": True} +o_settings_date_and_time_text = {"container": o_SettingsBase_SettingsDateTime, "type": "Text", "unnamed": 1, "visible": True} +o_date_time_container = {"container": o_SettingsBase_SettingsDateTime, "id": "_container", "type": "Column", "unnamed": 1, "visible": True} +#virtal keypad input field +o_keypad_input = {"container": o_Gui_MainView, "id": "_keyText", "type": "Text", "unnamed": 1, "visible": True} +#virtal keypad back space key +o_back_space_key = {"container": o_Gui_MainView, "id": "_backspaceKeyIcon", "source": "qrc:/plugins/QtQuick/VirtualKeyboard/Styles/denali/images/iBackspace.svg", "type": "Image", "unnamed": 1, "visible": True} + Index: tst_settings_date_and_time/test.py =================================================================== diff -u --- tst_settings_date_and_time/test.py (revision 0) +++ tst_settings_date_and_time/test.py (revision e722325d02c51abd72e9215a56f4623f3b1334c5) @@ -0,0 +1,215 @@ +# -*- 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/15/2022 +# author Papiya Mandal + +import builtins +import names + +from configuration import config, utility +from dialin.ui.hd_simulator import HDSimulator +from dialin.common.hd_defs import HDOpModes +from dialin.ui import utils + + +hd_simulator = HDSimulator() + +SERVICES_TITLE_TEXT = "Please Enter The Service Password" +SET_DATE_AND_TIME_TEXT = "Set Date And Time" +TIME_TITLE = "Time (HH:MM)" +DATE_TITLE_TEXT = "Date (MM/DD/YYYY)" +HOUR_TEXT = "Hour" +MINUTE_TEXT = "Minute" +DAY_TEXT = "Day" +MONTH_TEXT = "Month" +YEAR_TEXT = "Year" +HOUR_UPPER_LIMIT = 23 +HOUR_LOWER_LIMIT = 0 +MINUTE_LOWER_LIMIT = 0 +MINUTE_UPPER_LIMIT = 59 +DAY_UPPER_LIMIT = 31 +DAY_LOWER_LIMIT = 1 +MONTH_UPPER_LIMIT = 12 +MONTH_LOWER_LIMIT = 1 +YEAR_UPPER_LIMIT = 2100 +YEAR_LOWER_LIMIT = 1970 + +def settings_text_obj(text): + names.o_settings_home_text_obj["text"] = text + return names.o_settings_home_text_obj + +def services_screen_text_obj(text): + names.o_services_screen_text_obj["text"] = text + return names.o_services_screen_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_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 navigate_to_services_password_screen_and_enter_password(): + """ + Method to navigate to services screen + and verify the "Please Enter The Service Password" + title is displayed and enter password, verify the + password and click on confirm button + """ + test.startSection("Navigating to 'services password' screen and enter password") + mouseClick(waitForObjectExists(settings_text_obj(config.SERIVCES_TITLE))) + services_password_title = waitForObjectExists(services_screen_text_obj(SERVICES_TITLE_TEXT)) + test.compare(services_password_title.text, SERVICES_TITLE_TEXT, "{} should display once user is navigated to services password screen".format(SERVICES_TITLE_TEXT)) + test.log("Clicking on password entry field") + utils.waitForGUI(0.3) + mouseClick(waitForObjectExists(names.o_switch_keyboard_to_keypad)) + mouseClick(waitForObjectExists(names.o_password_text_field)) + utility.enter_keyboard_numeric_value(entry=str(config.PASSWORD)) + mouseClick(waitForObjectExists(names.o_show_password)) + test.log("Verifying the entered password") + password = str((waitForObjectExists(names.o_password_text_field)).text) + test.compare(password, str(config.PASSWORD), "Entered password should be {}".format(config.PASSWORD)) + mouseClick(waitForObjectExists(services_screen_text_obj(config.CONFIRM_TEXT))) + 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(settings_text_obj(SET_DATE_AND_TIME_TEXT))) + set_date_and_time_title = waitForObjectExists(date_time_screen_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_entered_date_and_time(hour, min, day, month, year): + """ + Method to enter date and time and verify the + valid and invalid entries and click on confirm + button + """ + date_time_column = waitForObjectExists(names.o_date_time_container) + date_time_column_children = object.children(date_time_column) + time_row = date_time_column_children[0] + date_row = date_time_column_children[1] + time_row_children = object.children(time_row) + date_row_children = object.children(date_row) + time_title_text = time_row_children[0] + date_title_text = date_row_children[0] + test.log("Verifying time title text") + test.compare(time_title_text.text, TIME_TITLE, "{} shoule be the time title text".format(TIME_TITLE)) + test.log("Verifying date title text") + test.compare(date_title_text.text, DATE_TITLE_TEXT, "{} should be the date title text".format(DATE_TITLE_TEXT)) + hour_parent = time_row_children[1] + hour_parent_children = object.children(hour_parent) + hour_input_field = hour_parent_children[1] + minute_parent = time_row_children[-1] + minute_parent_children = object.children(minute_parent) + minute_input_field = minute_parent_children[1] + test.log("Entering hour") + utility.erase_entered_value(hour_input_field) + utility.enter_keypad_value(hour) + test.compare(hour_input_field.text, hour, "Hour value should be {}".format(hour)) + verify_color_of_entry(entry=hour, date_time_parameter=HOUR_TEXT, input_field=hour_input_field) + test.log("Entering minute") + mouseClick(minute_input_field) + utility.erase_entered_value(minute_input_field) + utility.enter_keypad_value(min) + test.compare(minute_input_field.text, min, "Minute value should be {}".format(min)) + verify_color_of_entry(entry=min, date_time_parameter=MINUTE_TEXT, input_field=minute_input_field) + month_parent = date_row_children[1] + month_input_field = month_parent[1] + day_parent = date_row_children[3] + day_input_field = day_parent[1] + year_parent = date_row_children[-1] + year_input_field = year_parent[1] + test.log("Entering Month") + mouseClick(month_input_field) + utility.erase_entered_value(month_input_field) + utility.enter_keypad_value(month) + test.compare(month_input_field.text, month, "Month value should be {}".format(month)) + verify_color_of_entry(entry=month, date_time_parameter=MONTH_TEXT, input_field=month_input_field) + test.log("Entering Day") + mouseClick(day_input_field) + utility.erase_entered_value(day_input_field) + utility.enter_keypad_value(day) + test.compare(day_input_field.text, day, "Day value should be {}".format(day)) + verify_color_of_entry(entry=day, date_time_parameter=DAY_TEXT, input_field=day_input_field) + test.log("Entering Year") + mouseClick(year_input_field) + utility.erase_entered_value(year_input_field) + utility.enter_keypad_value(year) + test.compare(year_input_field.text, year, "Year value should be {}".format(year)) + verify_color_of_entry(entry=year, date_time_parameter=YEAR_TEXT, input_field=year_input_field) + + +def verify_color_of_entry(entry, date_time_parameter, input_field): + """ + Method to verify the color of entry + of date and time + @param entry: (int) user user entered value + @param date_time_parameter - (str) parameter name under which user is entering value (hour/minute/day/month/year) + @param input_field - (obj) object of input field + """ + test.startSection("Verify the color of {} value {}".format(date_time_parameter, entry)) + input_field_color = input_field.color.name + entry = builtins.int(entry) + if date_time_parameter is HOUR_TEXT: + if (entry < HOUR_LOWER_LIMIT) or (entry > HOUR_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Hour value {} is out of range, hour value should be in range of {} and {}".format(entry, HOUR_LOWER_LIMIT, HOUR_UPPER_LIMIT)) + elif (entry >= HOUR_LOWER_LIMIT) and (entry <= HOUR_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "Hour value {} is in range of {} and {}".format(entry, HOUR_LOWER_LIMIT, HOUR_UPPER_LIMIT)) + elif date_time_parameter is MINUTE_TEXT: + if (entry < MINUTE_LOWER_LIMIT) or (entry > MINUTE_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Minute value {} is out of range, minute value should be in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) + elif (entry >= MINUTE_LOWER_LIMIT) and (entry <= MINUTE_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) + elif date_time_parameter is DAY_TEXT: + if (entry < DAY_LOWER_LIMIT) or (entry > DAY_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Day value {} is out of range, Day value should be in range of {} and {}".format(entry, DAY_LOWER_LIMIT, DAY_UPPER_LIMIT)) + elif (entry >= DAY_LOWER_LIMIT) and (entry <= DAY_UPPER_LIMIT): + test.compare(input_field_color,config.IN_RANGE_COLOR, "Day value {} is in range of {} and {}".format(entry, DAY_LOWER_LIMIT, DAY_UPPER_LIMIT)) + elif date_time_parameter is MONTH_TEXT: + if (entry < MONTH_LOWER_LIMIT) or (entry > MONTH_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Month value {} is out of range, Month value should be in range of {} and {}".format(entry, MONTH_LOWER_LIMIT, MONTH_UPPER_LIMIT)) + elif (entry >= MONTH_LOWER_LIMIT) and (entry <= MONTH_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "Month value {} is in range of {} and {}".format(entry, MONTH_LOWER_LIMIT, MONTH_UPPER_LIMIT)) + elif date_time_parameter is YEAR_TEXT: + if (entry < YEAR_LOWER_LIMIT) or (entry > YEAR_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Year value {} is out of range, Year value should be in range of {} and {}".format(entry, YEAR_LOWER_LIMIT, YEAR_UPPER_LIMIT)) + elif (entry >= YEAR_LOWER_LIMIT) and (entry <= YEAR_UPPER_LIMIT): + test.compare(input_field_color, config.IN_RANGE_COLOR, "Year value {} is in range of {} and {}".format(entry, YEAR_LOWER_LIMIT, YEAR_UPPER_LIMIT)) + test.endSection() + + + +def main(): + + utils.tstStart(__file__) + startApplication(config.AUT_NAME) + + navigate_to_settings_screen() + navigate_to_services_password_screen_and_enter_password() + navigate_to_set_date_and_time() + verify_entered_date_and_time(hour="12", min="33", day="1", month="3", year="2022") + + +