Index: shared/scripts/configuration/config.py =================================================================== diff -u -rbb798f36abcf369278c91d168e16c35003d0b55a -r9b83f12cc68db53745c55d7317a6b364a00241d1 --- shared/scripts/configuration/config.py (.../config.py) (revision bb798f36abcf369278c91d168e16c35003d0b55a) +++ shared/scripts/configuration/config.py (.../config.py) (revision 9b83f12cc68db53745c55d7317a6b364a00241d1) @@ -15,7 +15,7 @@ import os -Application_name = "denaliSquish" +APPLICATION_NAME = "denaliSquish" COMMON_PATH = f"{os.environ['HOME']}/Projects" Fisheye: Tag 9b83f12cc68db53745c55d7317a6b364a00241d1 refers to a dead (removed) revision in file `shared/scripts/configuration/sim_setup.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r325957ecac9491e749ae3330c8ede80adb70a1df -r9b83f12cc68db53745c55d7317a6b364a00241d1 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 325957ecac9491e749ae3330c8ede80adb70a1df) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 9b83f12cc68db53745c55d7317a6b364a00241d1) @@ -14,16 +14,14 @@ import sys -import os import test import squish -from dialin.ui import utils +from configuration import config +from builtins import int as pyInt +from builtins import str as pyStr +from builtins import float as pyFloat -Application_name = "denaliSquish" - -COMMON_PATH = f"{os.environ['HOME']}/Projects" - def start_application(app_name): """ @@ -40,7 +38,7 @@ try: counter += 1 test.log("Starting {}".format(app_name)) - squish.startApplication(Application_name) + squish.startApplication(config.APPLICATION_NAME) if counter == 1: test.log(f"Application launched at the {counter}'st try.") elif counter == 2: @@ -49,7 +47,6 @@ test.log(f"Application launched at the {counter}'rd try.") else: test.log(f"Application launched at the {counter}'th try.") - squish.snooze(20) break except RuntimeError: if counter == 1: @@ -63,27 +60,70 @@ logErrorDetails("Failed to start the application") sys.exit(1) - -def launch_application(test_name): + +def color_verification(exp_val = "Red", act_val = "#c53b33"): """ - Method to enables simulator and launch application - @param test_name: (str) name of the test case - @return: None, print out in the console + Function to verify item color verification + Argument: + exp_val - Expected required value + act_val - Color displayed on UI + Return: + handle the application for log """ + test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) - test.log("Launching a new instance of Firmware Simulator") - #cleanup() - try: - os.chdir(f"{COMMON_PATH}/testsuites/shared/scripts/configuration") - #out = os.system("sudo chmod 777 sim_setup.sh") - res = os.system("./sim_setup.sh") - utils.waitForGUI(delay_s = 5) - if (res != 0) and (res != 256): - raise Exception("Wrong path to the simulator executable was given. Script not executed") - except Exception as msg: - test.log(str(msg)) - test.log("Launched Simulator......") - start_application("Denali Application") - - +def check_if_object_is_within_the_container(obj=None, container=None): + """ + check if an object is inside a container + Arguments: + obj - child UI object + container - container UI object + Return: + bool + """ + container = squish.findObject(container) + containerPos = container.mapToGlobal(squish.QPoint(0, 0)) + container_x, container_y = pyInt(containerPos.x), pyInt(containerPos.y) + container_width, container_height = pyInt(container.width), pyInt(container.height) + + obj = squish.findObject(obj) + objPos = obj.mapToGlobal(squish.QPoint(0, 0)) + obj_x, obj_y = pyInt(objPos.x), pyInt(objPos.y) + obj_width, obj_height = pyInt(obj.width), pyInt(obj.height) + + if obj_x >= container_x and obj_y >= container_y: + if (obj_x + obj_width) <= (container_x + container_width) and (obj_y + obj_height) <= (container_y + container_height): + return True + + return False + + +def scroll_to_zone(zone=None, screen_object=None): + """ + scroll to the numeric if object is hidden + Arguments: + zone - UI object + screen_object - UI object (UI Home screen = waveforms + numerics) + Return: + bool + """ + counter = 0 + while counter <= 100: + try: + counter += 1 + squish.findObject(zone) + squish.snooze(0.5) + if check_if_object_is_within_the_container(obj=zone, container=screen_object): + return True + else: + raise RuntimeError + except RuntimeError: + ScreenObj = squish.waitForObject(screen_object) + screenHeight = pyInt(ScreenObj.height) + screenWidth = pyInt(ScreenObj.width) + squish.mouseWheel(ScreenObj, screenWidth-1000, + screenHeight-10, 0, -50, squish.Qt.NoModifier) + + raise LookupError("zone object is not in view to the user after " + \ + "trying 100 times") Index: shared/scripts/names.py =================================================================== diff -u -rcea2e793ece38bca22959780b1bb9947a5b47b9c -r9b83f12cc68db53745c55d7317a6b364a00241d1 --- shared/scripts/names.py (.../names.py) (revision cea2e793ece38bca22959780b1bb9947a5b47b9c) +++ shared/scripts/names.py (.../names.py) (revision 9b83f12cc68db53745c55d7317a6b364a00241d1) @@ -56,6 +56,7 @@ fluid_text = {"container": treatmentStack_treatmentHome_TreatmentHome, "text": "Volume Delivered", "type": "Text", "unnamed": 1, "visible": True} cumulative_fluid_text = {"container": treatmentStack_treatmentHome_TreatmentHome, "text": "Cumulative Delivered", "type": "Text", "unnamed": 1, "visible": True} + #authentication confirm_button = {"container": o_PreTreatmentCreateStack_PreTreatmentBase_TreatmentFlowBase, "text": "CONFIRM", "type": "Text", "unnamed": 1, "visible": True} back_button ={"container": o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_image", "source": "qrc:/images/iBack", "type": "Image", "unnamed": 1, "visible": True} @@ -69,6 +70,8 @@ o_PreTreatmentBase_confirmButton_TouchRect_2 = {"container": o_PreTreatmentCreateStack_PreTreatmentBase_TreatmentFlowBase, "gradient": 0, "objectName": "_confirmButton", "type": "TouchRect", "visible": True} o_PreTreatmentCreate_heparinDispensingRate_SliderCreateTreatment = {"container": o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, "gradient": 0, "objectName": "_heparinDispensingRate", "type": "SliderCreateTreatment", "visible": True} o_PreTreatmentBase_backgroundRect_Rectangle_2 = {"container": o_PreTreatmentCreateStack_PreTreatmentBase_TreatmentFlowBase, "gradient": 0, "id": "_backgroundRect", "type": "Rectangle", "unnamed": 1, "visible": True} +keyboard_switch = {"container": o_Gui_MainView, "id": "shiftKeyIcon", "source": "qrc:/QtQuick/VirtualKeyboard/content/styles/default/images/shift-868482.svg", "type": "Image", "unnamed": 1, "visible": True} +keyboard_switch_2 = {"container": o_Gui_MainView, "id": "shiftKeyIcon", "source": "qrc:/QtQuick/VirtualKeyboard/content/styles/default/images/shift-80c342.svg", "type": "Image", "unnamed": 1, "visible": True} Fisheye: Tag 9b83f12cc68db53745c55d7317a6b364a00241d1 refers to a dead (removed) revision in file `tst_authentication/test.py'. Fisheye: No comparison available. Pass `N' to diff? Index: tst_patient_id/test.py =================================================================== diff -u --- tst_patient_id/test.py (revision 0) +++ tst_patient_id/test.py (revision 9b83f12cc68db53745c55d7317a6b364a00241d1) @@ -0,0 +1,197 @@ +# -*- 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_create_patient_ID +# date 2022/01/18 +# author Joseph varghese +# + +# NOTE: +# This test is intended to be used to verify patient id in application. . + +import names +import time +import string +from dialin.ui import utils +from dialin.ui.hd_simulator import HDSimulator +from dialin.ui import unittests + +from builtins import str as pyStr +from configuration import utility + + +CHARACTER_PATIENT_ID = ["qwerty","sampleid","abcdefghijklmnop","patientid", "username"] +ALPHANUMERIC_PATIENT_ID = ["sA@MpLE#123", "A@BH&321","5432@qwerty"] +KEYBOARD_SWITCH = ["ABC", "&123"] + + +def keyboard_object_map_helper(text): + """ + Method for setting custom object property's for keyboard keys + + @return: required object property's for keys + """ + if text is not None: + names.keboard_input["text"] = text + return names.keboard_input + else: + test.log(f"Invalid \"text\": {text} for object.") + names.keyboard_input["text"] = "Q" + + +def keyboard_switching_section(text): + """ + Tests to automate keyboard based on user input + + @return: key text (text displayed on keyboard) + """ + keyboard_value = keyboard_object_map_helper(text) + object_status = object.exists(keyboard_value) + if object_status is True: + return text + else: + #Tests to get status of keys in keyboard layout + object_status = object.exists(keyboard_object_map_helper(KEYBOARD_SWITCH[1])) + if object_status is True: + keyboard_value = keyboard_object_map_helper(KEYBOARD_SWITCH[1]) + utils.waitForGUI(.3) + mouseClick(waitForObject(keyboard_value)) + keyboard_value = keyboard_object_map_helper(text) + object_status = object.exists(keyboard_value) + if object_status is True: + return text + object_status = object.exists(keyboard_object_map_helper(KEYBOARD_SWITCH[0])) + if object_status is True: + keyboard_value = keyboard_object_map_helper(KEYBOARD_SWITCH[0]) + mouseClick(waitForObject(keyboard_value)) + keyboard_value = keyboard_object_map_helper(text) + object_status = object.exists(keyboard_value) + if object_status is True: + return text + object_status = object.exists(names.keyboard_switch) + if object_status is True: + keyboard_value = waitForObject(names.keyboard_switch) + mouseClick(keyboard_value) + text = text.lower() + keyboard_value = keyboard_object_map_helper(text) + object_status = object.exists(keyboard_value) + if object_status is True: + return text + object_status = object.exists(names.keyboard_switch2) + if object_status is True: + keyboard_value = waitForObject(names.keyboard_switch_2) + mouseClick(keyboard_value) + text = text.lower() + keyboard_value = keyboard_object_map_helper(text) + object_status = object.exists(keyboard_value) + if object_status is True: + return text + + +def user_input_clear_option(): + """ + Tests to clear retained patient id + + @return: N/A + """ + patient_id_input = waitForObject(names.input_patient_id) + patient_id = str(patient_id_input.text) + patient_id_length = len(patient_id) + while (patient_id_length != 0): + type(waitForObject(names.input_patient_id), "") + type(waitForObject(names.input_patient_id), "") + patient_id_length = patient_id_length - 1 + + +def validation_of_valid_patient_id_through_keypad(expected_value): + """ + Tests verifies valid patient id set through application keyboard setup . + + @return: N/A + """ + patient_id_input = waitForObject(names.input_patient_id) + mouseClick(patient_id_input) + patient_id = list(expected_value) + for text in patient_id: + keyword_state = keyboard_switching_section(text) + if keyword_state is not None: + keyboard_value = keyboard_object_map_helper(keyword_state) + mouseClick(waitForObject(keyboard_value)) + utils.waitForGUI(.2) + + test.compare(expected_value, (patient_id_input.text)) + test.log(f"Patient id should be -> {expected_value}") + + mouseClick(waitForObject(names.confirm_button)) + + custom_treatment = waitForObject(names.custom_treatment) + test.compare("Create a Custom Treatment", custom_treatment.text) + test.log(f"user successfully authenticated through patient id -> {expected_value} using keypad.") + + mouseClick(waitForObject(names.back_button)) + + +def validation_of_valid_patient_id_through_user_input(expected_value): + """ + Tests verifies valid patient id set through user's input. + + @return: N/A + """ + patient_id_input = waitForObject(names.input_patient_id) + mouseClick(waitForObject(patient_id_input)) + type(waitForObject(names.input_patient_id), expected_value) + test.compare(expected_value, (patient_id_input.text)) + test.log(f"Patient id should be -> {expected_value}") + + mouseClick(waitForObject(names.confirm_button)) + + custom_treatment = waitForObject(names.custom_treatment) + test.compare("Create a Custom Treatment", custom_treatment.text) + test.log(f"user successfully authenticated through patient id -> {expected_value}.") + + mouseClick(waitForObject(names.back_button)) + + +def validation_of_invalid_patient_id_through_user_input(expected_value): + """ + Tests verifies invalid patient id set through user's input. + + @return: N/A + """ + patient_id_input = waitForObject(names.input_patient_id) + mouseClick(waitForObject(patient_id_input)) + type(waitForObject(names.input_patient_id), expected_value) + if expected_value is not patient_id_input.text or patient_id_input.text is None: + test.passes(f"Patient ID -> {expected_value} should be invalid") + else: + test.xfail(f"Patient ID {expected_value} is valid") + user_input_clear_option() + + +def main(): + + utils.tstStart("tst_patient_id") + utility.start_application("validation of patient ID") + utils.waitForGUI(2) + + hd = HDSimulator() + + hd._handler_ui_first_check_in(message = None) + + mouseClick(waitForObject(names.input_patient_id)) + for patient_id in CHARACTER_PATIENT_ID: + validation_of_valid_patient_id_through_keypad(patient_id) + validation_of_valid_patient_id_through_user_input(patient_id) + + for patient_id in ALPHANUMERIC_PATIENT_ID: + validation_of_valid_patient_id_through_keypad(patient_id) + validation_of_valid_patient_id_through_user_input(patient_id) + + utils.tstDone() +