Index: shared/scripts/configuration/config.py =================================================================== diff -u --- shared/scripts/configuration/config.py (revision 0) +++ shared/scripts/configuration/config.py (revision 8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6) @@ -0,0 +1,27 @@ + +########################################################################### +# +# Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. +# +# 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 utils.py +# +# @author (last) Joseph varghese +# @date (last) 18-Jan-2022 +# +############################################################################ + +import os + +Application_name = "denaliSquish" + +COMMON_PATH = f"{os.environ['HOME']}/Projects" + + +COLOR_CODES = {"Aqua": "#81ffff", "Blue": "#017dea", "Blue 2": "#1090d5", "Green": "#29fd2d", "Grey": "#d3d3d3", + "Lavender": "#db98f5", "Light Blue": "#acd7f1", "Light Teal": "#29f1da","Lime": "#b7fc36", + "Magenta":"#fd28fd", "Orange": "#f2721c", "Peach":"#f1979a", "Red": "#c53b33", "Rose":"#fc178d", + "Slate blue":"#7f7ffa", "Violet": "#6435c9", "White": "#ffffff", "Yellow": "#fcfc4d"} + Fisheye: Tag 8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6 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 -r8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 325957ecac9491e749ae3330c8ede80adb70a1df) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6) @@ -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: @@ -63,27 +61,71 @@ 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/searchImages/Rinseback_flow_rate.png =================================================================== diff -u Binary files differ Index: shared/searchImages/aterial_pressure_high_limit.png =================================================================== diff -u Binary files differ Index: shared/searchImages/aterial_pressure_low_limit.png =================================================================== diff -u Binary files differ Index: shared/searchImages/blood.png =================================================================== diff -u Binary files differ Index: shared/searchImages/blood_pressure_measurement_interval.png =================================================================== diff -u Binary files differ Index: shared/searchImages/dialysate.png =================================================================== diff -u Binary files differ Index: shared/searchImages/dialysate_temperature.png =================================================================== diff -u Binary files differ Index: shared/searchImages/duration.png =================================================================== diff -u Binary files differ Index: shared/searchImages/heparin_bolus_volume.png =================================================================== diff -u Binary files differ Index: shared/searchImages/heparin_dispensing_rate.png =================================================================== diff -u Binary files differ Index: shared/searchImages/heparin_stop_time.png =================================================================== diff -u Binary files differ Index: shared/searchImages/saline_bolus.png =================================================================== diff -u Binary files differ Index: shared/searchImages/venous_pressure_high_limits.png =================================================================== diff -u Binary files differ Index: shared/searchImages/venous_pressure_low_limits.png =================================================================== diff -u Binary files differ Index: tst_create_custom_treatment/test.py =================================================================== diff -u --- tst_create_custom_treatment/test.py (revision 0) +++ tst_create_custom_treatment/test.py (revision 8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6) @@ -0,0 +1,202 @@ +# -*- 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 2020/01/27 +# author Joseph varghese +# + +# NOTE: +# This test is intended to be used to verify custom treatment in application . + +import names +import time +import test +from dialin.ui import utils +from dialin.ui import unittests + +from builtins import str as pyStr +from configuration import utility +from dialin.common.msg_defs import RequestRejectReasons +from dialin.ui.hd_simulator import HDSimulator + + +PATIENT_ID = "id" +HEPARIN_TYPE = "UFH 1,000 IU/mL" +ACID_CONCENTRATE = ["Fres. Naturalyte", "08-1251-1", "08-2251-0", "08-3251-9"] +BICARBONATE_CONCENTRATE = "Fres. Centrisol" +DIALYZER_TYPE = ["BB Diacap Pro 13H", "BB Diacap Pro 16H", "BB Diacap Pro 19H", "F Optiflux F160NRe", "F Optiflux F180NRe"] + + +def treatment_create_flickable(x_axis =0, y_axis = 0): + + mouseWheel(waitForObject(names.treatment_create_flickable), + 1184, 107, x_axis, y_axis, Qt.NoModifier) + + +def set_heparin_type(text): + if isinstance(text, pyStr): + names.operating_parameters["text"] = text + return names.operating_parameters + else: + test.log(f"Invalid \"text\": {text} for object.") + names.keyboard_input["text"] = "UFH 1,000 IU/mL" + + +def set_acid_concentrate(text): + if isinstance(text, pyStr): + names.operating_parameters["text"] = text + return names.operating_parameters + else: + test.log(f"Invalid \"text\": {text} for object.") + names.keyboard_input["text"] = "Fres.Naturalyte" + + +def set_bicarbonate_concentrate(text): + if isinstance(text, pyStr): + names.operating_parameters["text"] = text + return names.operating_parameters + else: + test.log(f"Invalid \"text\": {text} for object.") + names.keyboard_input["text"] = "Fres.Centrisol" + + +def set_dialyzer_type(text): + if isinstance(text, pyStr): + names.operating_parameters["text"] = text + return names.operating_parameters + else: + test.log(f"Invalid \"text\": {text} for object.") + names.keyboard_input["text"] = "BB Diacap Pro 13H" + + +def set_operating_parameters(heparin_type, acid_concentrate, bicarbonate_concentrate, dialyzer_type): + """ + Tests that all possible non-slider options are shown. + + @return: None + """ + treatment_create_flickable(y_axis = -120) + heparin_box_obj = set_heparin_type(text = heparin_type) + tapObject(waitForObject(heparin_box_obj)) + + acid_concentrate_box_obj = set_acid_concentrate(text = acid_concentrate) + tapObject(waitForObject(acid_concentrate_box_obj)) + treatment_create_flickable(y_axis = -80) + + bicarbonate_concentrate_box_obj = set_bicarbonate_concentrate(text = bicarbonate_concentrate) + tapObject(waitForObject(bicarbonate_concentrate_box_obj)) + treatment_create_flickable(y_axis = -120) + + dialyzer_type_box_obj = set_dialyzer_type(text = dialyzer_type) + tapObject(waitForObject(dialyzer_type_box_obj)) + treatment_create_flickable(y_axis = -80) + + +def verify_request_rejection_mode(hd_simulator): + + reject_reasons = [ + RequestRejectReasons.REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE + ] * hd_simulator.NUM_TREATMENT_PARAMETERS + + treatment_status = hd_simulator.cmd_send_treatment_parameter_validation_response(reject_reasons) + test.compare(True, treatment_status) + test.log("custom treatment should be rejected") + + +def test_sliders(): + """ + Tests that all sliders have the correct min / max values and that the selected value is displayed correctly. + + @return: None + """ + + sliders = { + "_bloodFlowRate": {"min": 100 , "max": 500, "units": "mL/min", "title": "Blood Flow Rate"}, + "_dialysateFlowRate": {"min":100 , "max": 600, "units": "__ mL/min", "title": "Dialysate Flow Rate"}, + "_duration": {"min": 60, "max": 480, "units": "__ min", "title": "Duration"}, + "_heparinDispensingRate": {"min": 0, "max": 1, "units": "__ mL/hr", "title": "Heparin Dispensing Rate" }, + "_heparinBolusVolume": {"min": 0, "max": 2, "units": "__ mL", "title": "Heparin Bolus Volume" }, + "_heparinStopTime": {"min": 0, "max": 470, "units": "__ min", "title": "Heparin Stop Time" }, + "_salineBolus": {"min": 100, "max": 300, "units": "__ mL", "title": "Saline Bolus"}, + "_dialysateTemperature": {"min": 35, "max": 38, "units": "__ °C", "title": "Dialysate Temperature"}, + "_bloodPressureMeasurementInterval": {"min": 0, "max": 60, "units": "__ min", "title": "Blood Pressure Measurements Interval"}, + "_rinsebackFlowRate": {"min": 50, "max": 150, "units": "__ mL/min", "title": "Rinseback Flow Rate"}, + } + + + +def create_custom_treatment_record(): + + custom_treatment = waitForObject(names.custom_treatment) + test.compare("Create a Custom Treatment", custom_treatment.text) + test.log(f"user successfully authenticated.") + + mouseClick(waitForImage("blood",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("dialysate",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("duration",{ "tolerant": True, "threshold": 99.999 })) + treatment_create_flickable(y_axis = -100) + mouseClick(waitForImage("heparin_dispensing_rate",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("heparin_bolus_volume",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("heparin_stop_time",{ "tolerant": True, "threshold": 99.999 })) + treatment_create_flickable(y_axis = -65) + mouseClick(waitForImage("saline_bolus",{ "tolerant": True, "threshold": 99.999 })) + + set_operating_parameters(heparin_type = HEPARIN_TYPE, + acid_concentrate = ACID_CONCENTRATE[0], + bicarbonate_concentrate = BICARBONATE_CONCENTRATE, + dialyzer_type = DIALYZER_TYPE[0]) + + treatment_create_flickable(y_axis = -65) + mouseClick(waitForImage("dialysate_temperature",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("aterial_pressure_low_limit",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("aterial_pressure_high_limit",{ "tolerant": True, "threshold": 99.999 })) + treatment_create_flickable(y_axis = -150) + mouseClick(waitForImage("venous_pressure_low_limits",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("venous_pressure_high_limits",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("blood_pressure_measurement_interval",{ "tolerant": True, "threshold": 99.999 })) + mouseClick(waitForImage("Rinseback_flow_rate",{ "tolerant": True, "threshold": 99.999 })) + test.log("User successfully selected values for treatment items") + +def main(): + + utils.tstStart("tst_create_custom_treatment") + utility.start_application("Create custom treatment for a patient") + + hd = HDSimulator() + + unittests.test_python_version() + + mouseClick(waitForObject(names.input_patient_id)) + type(waitForObject(names.input_patient_id), PATIENT_ID) + mouseClick(waitForObject(names.confirm_button)) + + create_custom_treatment_record() + #verify_request_rejection_mode(hd) + #set_operating_parameters(heparin_type = HEPARIN_TYPE, + # acid_concentrate = ACID_CONCENTRATE[1], + # bicarbonate_concentrate = BICARBONATE_CONCENTRATE, + # dialyzer_type = DIALYZER_TYPE[1]) + treatment_create_flickable(y_axis = -65) + #hd.cmd_send_pre_treatment_patient_connection_confirm_response(accepted = 1, reason = 1) + #hd.cmd_send_pre_treatment_prime_start_response(accepted = 1, reason = 1) + #hd.cmd_send_pre_treatment_continue_to_treament_response( accepted=1, reason= 0) + hd.cmd_initiate_treatment_response(response= 1, reason=0) + time.sleep(2) + #hd.cmd_send_pre_treatment_patient_connection_confirm_response(accepted = 1, reason = 0) + #hd.simulator.cmd_send_treatment_parameter_validation_response(19) + #hd.cmd_initiate_treatment_response(response=1, reason=0) + #hd.cmd_send_treatment_parameter_validation_response(self, rejections: List[RequestRejectReasons]) + + + time.sleep(20) + + + utils.tstDone() +