# -*- 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_Treatment_Adjustment_Pressures # date 2020/11/04 # author Behrouz NematiPour # from dialin.common import Ranges from dialin.squish import utils, denaliMessages import names inrangeColor = "#ffffff" def gotoScreenNtest_Contains_PressuresSection(): """ clicks on the start treatment to go to the in-treatment screen and make sure the pressures section is present """ mouseClick (waitForObjectExists(names.o_treatmentHome_startTreatment)) utils.waitForGUI(1) test.compare(waitForObjectExists(names.o_treatmentStart_pressureTouchArea_TreatmentPressure).visible, True) def gotoScreenNTest_Adjustment(): """ clicks on the in-treatment pressures section and checks the Pressure adjustment screen pops up and checks some items exist on the screen. """ mouseClick ( waitForObjectExists(names.o_treatmentStart_pressureTouchArea_TreatmentPressure)) utils.waitForGUI(1) test.compare( waitForObjectExists(names.o_treatmentAdjustmentPressures_Screen ).visible , True ) test.compare(str(waitForObjectExists(names.o_treatmentAdjustmentPressures_Screen_Title ).text ), "PRESSURES" ) test.compare( waitForObjectExists(names.o_arterial_progress ).visible , True ) test.compare(str(waitForObjectExists(names.o_arterial_range_slider ).titleText), "Arterial" ) test.compare( waitForObjectExists(names.o_arterial_slider ).visible , True ) test.compare(str(waitForObjectExists(names.o_venous_range_slider ).titleText), "Venous" ) def test_pressure_limits_constants(): """ Checks for the PRS constant values that should have never change during application life cycle. """ test.compare( waitForObjectExists(names.o_arterial_range_slider ).minimum , Ranges.ARTERIAL_PRESSURE_MINIMUM ) test.compare(str(waitForObjectExists(names.o_arterial_progress_textMinimum ).text ), str(Ranges.ARTERIAL_PRESSURE_MINIMUM)) test.compare( waitForObjectExists(names.o_arterial_range_slider ).maximum , Ranges.ARTERIAL_PRESSURE_MAXIMUM ) test.compare(str(waitForObjectExists(names.o_arterial_progress_textMaximum ).text ), str(Ranges.ARTERIAL_PRESSURE_MAXIMUM)) test.compare( waitForObjectExists(names.o_venous_range_slider ).minimum , Ranges.VENOUS_PRESSURE_MINIMUM ) test.compare(str(waitForObjectExists(names.o_venous_progress_textMinimum ).text ), str(Ranges.VENOUS_PRESSURE_MINIMUM)) test.compare( waitForObjectExists(names.o_venous_range_slider ).maximum , Ranges.VENOUS_PRESSURE_MAXIMUM ) test.compare(str(waitForObjectExists(names.o_venous_progress_textMaximum ).text ), str(Ranges.VENOUS_PRESSURE_MAXIMUM)) def setNTest_Pressures_ValueColors(vArterial, vVenous): """ Checks the Pressures Values on each parameter change passed to the function """ denaliMessages.setPressureOcclusionData(vArterial, vVenous, 0, 0, 0) arterial_value = waitForObjectExists(names.o_arterial_marker ).value venous_value = waitForObjectExists(names.o_venous_marker ).value # get current limits to check the text value color. arterial_limit_min = waitForObjectExists(names.o_arterial_limitbar).minimum arterial_limit_max = waitForObjectExists(names.o_arterial_limitbar).maximum venous_limit_min = waitForObjectExists(names.o_venous_limitbar ).minimum venous_limit_max = waitForObjectExists(names.o_venous_limitbar ).maximum # arterial test.compare( waitForObjectExists(names.o_arterial_range_slider ).value, vArterial) test.compare(str(waitForObjectExists(names.o_arterial_progress_textValue).text), str(vArterial)) if arterial_limit_min <= arterial_value <= arterial_limit_max: # checked in range white since the out of range may be subject to change test.compare(waitForObjectExists(names.o_arterial_progress_textValue).color.name, inrangeColor) # venous test.compare( waitForObjectExists(names.o_venous_range_slider ).value, vVenous ) test.compare(str(waitForObjectExists(names.o_venous_progress_textValue ).text), str(vVenous)) if venous_limit_min <= venous_value <= venous_limit_max: # checked in range white since the out of range may be subject to change test.compare(waitForObjectExists(names.o_venous_progress_textValue).color.name, inrangeColor) def test_pressure_limits(vArterialLow, vArterialHigh, vVenousLow, vVenousHigh): """ Checks the Pressures Limits on each parameter change passed to the function """ # arterial arterial_limit_min_text = str(waitForObjectExists(names.o_arterial_limitbar_textMinimum).text) arterial_limit_min_value = waitForObjectExists(names.o_arterial_limitbar).minimum arterial_limit_max_text = str(waitForObjectExists(names.o_arterial_limitbar_textMaximum).text) arterial_limit_max_value = waitForObjectExists(names.o_arterial_limitbar).maximum #venous venous_limit_min_text = str(waitForObjectExists(names.o_venous_limitbar_textMinimum ).text) venous_limit_min_value = waitForObjectExists(names.o_venous_limitbar ).minimum venous_limit_max_text = str(waitForObjectExists(names.o_venous_limitbar_textMaximum ).text) venous_limit_max_value = waitForObjectExists(names.o_venous_limitbar ).maximum test.compare(arterial_limit_min_text , str(vArterialLow )) test.compare(arterial_limit_min_value , vArterialLow ) test.compare(arterial_limit_max_text , str(vArterialHigh )) test.compare(arterial_limit_max_value , vArterialHigh ) test.compare(venous_limit_min_text , str(vVenousLow )) test.compare(venous_limit_min_value , vVenousLow ) test.compare(venous_limit_max_text , str(vVenousHigh )) test.compare(venous_limit_max_value , vVenousHigh ) def setNTest_Pressures_Limits(vArterialLow, vArterialHigh, vVenousLow, vVenousHigh): """ uses the pressures limits and checks if they change correctly by using the function test_pressure_limits """ # arterial constants shall never change regarding the PRS # it has to be set to reject otherwise the dialog is closed. # the accept and dialog close has been tested somewhere else. denaliMessages.sendTreatmentAdjustPressuresLimitsResponse(False, 0, vArterialLow, vArterialHigh, vVenousLow, vVenousHigh) test_pressure_limits(vArterialLow, vArterialHigh, vVenousLow, vVenousHigh) def confirm_accept(): """ checks if confirm touched and accepted response received it closes the adjustment dialog. """ arterialLow = Ranges.ARTERIAL_PRESSURE_LOW_DEF arterialHigh = Ranges.ARTERIAL_PRESSURE_HIGH_DEF venousLow = Ranges.VENOUS_PRESSURE_LOW_DEF venousHigh = Ranges.VENOUS_PRESSURE_HIGH_DEF test.compare(waitForObjectExists(names.o_treatmentAdjustmentPressures_Screen).visible, True) denaliMessages.sendTreatmentAdjustPressuresLimitsResponse( True, 0, arterialLow , arterialHigh , venousLow , venousHigh ) utils.waitForGUI(1) test.compare(utils.isVisible(object, names.o_treatmentAdjustmentPressures_Screen), False) def confirm_request(): mouseClick ( waitForObjectExists(names.o_confirmButton)) def main(): utils.tstStart(__file__) startApplication(names.AUT_NAME + " -q") utils.waitForGUI(1) gotoScreenNtest_Contains_PressuresSection() gotoScreenNTest_Adjustment() test_pressure_limits_constants() # checking the on going values of the pressures. # checks the initial values of zero setNTest_Pressures_ValueColors(0, 0) #checks the ranges of values. for arterial in range(Ranges.ARTERIAL_PRESSURE_MINIMUM , Ranges.ARTERIAL_PRESSURE_MAXIMUM + Ranges.PRESSURE_STEPS, Ranges.PRESSURE_STEPS * 10): setNTest_Pressures_ValueColors(arterial, 0 ) for venous in range(Ranges.VENOUS_PRESSURE_MINIMUM , Ranges.VENOUS_PRESSURE_MAXIMUM + Ranges.PRESSURE_STEPS, Ranges.PRESSURE_STEPS * 10): setNTest_Pressures_ValueColors(0 , venous) # checking the limit change setNTest_Pressures_Limits(#-300, +100, -100, +400 Ranges.ARTERIAL_PRESSURE_LOW_DEF , Ranges.ARTERIAL_PRESSURE_HIGH_DEF , Ranges.VENOUS_PRESSURE_LOW_DEF , Ranges.VENOUS_PRESSURE_HIGH_DEF ) # changed the ranges setNTest_Pressures_Limits( -200, -100, +200, +500 ) # same ranges should not change the ranges setNTest_Pressures_Limits( -200, -100, +200, +500 ) # checks the ranges of values. for arterial in range(Ranges.ARTERIAL_PRESSURE_MINIMUM , Ranges.ARTERIAL_PRESSURE_MAXIMUM + Ranges.PRESSURE_STEPS, Ranges.PRESSURE_STEPS * 10): setNTest_Pressures_ValueColors(arterial, 0 ) for venous in range(Ranges.VENOUS_PRESSURE_MINIMUM , Ranges.VENOUS_PRESSURE_MAXIMUM + Ranges.PRESSURE_STEPS, Ranges.PRESSURE_STEPS * 10): setNTest_Pressures_ValueColors(0 , venous) # changed the ranges setNTest_Pressures_Limits( -100, +200, 0, +300 ) # checks the ranges of values. for arterial in range(Ranges.ARTERIAL_PRESSURE_MINIMUM , Ranges.ARTERIAL_PRESSURE_MAXIMUM + Ranges.PRESSURE_STEPS, Ranges.PRESSURE_STEPS * 10): setNTest_Pressures_ValueColors(arterial, 0 ) for venous in range(Ranges.VENOUS_PRESSURE_MINIMUM , Ranges.VENOUS_PRESSURE_MAXIMUM + Ranges.PRESSURE_STEPS, Ranges.PRESSURE_STEPS * 10): setNTest_Pressures_ValueColors(0 , venous) confirm_request() confirm_accept() utils.tstDone()