# -*- 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_Ultrafiltration # date 2020/04/12 # author Behrouz NematiPour # import utils import denaliMessages from names import * eInvalid = 0 eIncrease = 1 eDecrease = 2 stringInvalid = "Invalid" stringInvalidTxt= "Due to out of range adjustment, this option\nis disabled." stringIncrease = "Increase" stringDecrease = "Decrease" stringIncreases = "increases" stringDecreases = "decreases" _Accepted = 0 _Reason = 0 _Volume = 0 _Duration = 0 _DurationDiff = 0 _Rate = 0 _RateDiff = 0 _RateOld = 0 def InDeCreaseS(vIncrease, vInvalid, vSingular): if vInvalid: return stringInvalid if vIncrease: if vSingular: return stringIncreases else: return stringIncrease else: if vSingular: return stringDecreases else: return stringDecrease return "" # --------------- Main Treatment def gotoScreenNtest_Contains_Ultrafiltration(): mouseClick(waitForObject(o_treatmentHome_startTreatment)) test.compare(waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).visible, True) def startNTestTreatmentUltrafiltration(vMinUF, vMaxUF): for i in range(vMinUF, vMaxUF+1, 10): denaliMessages.setTreatmentUltrafiltration(vMaxUF, i, 1, 1, 1, 1, 1) test.compare(utils.l2ml(waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).value), i) def gotoScreen_UltrafiltrationAdjustment(): # [Section Click] mouseClick(waitForObject(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration)) utils.waitForGUI(1) # --------------- Start Screen def testScreen_Start_Ultrafiltration(): # [Start Screen] test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_Screen ).visible , True ) ## Pause Button test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_PauseButton).text.text), "PAUSE ULTRAFILTRATION") def pause_Request(): # [Request Pause] mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationStart_PauseButton)) def pause_RejectNTest(): # [Reject Pause] denaliMessages.setTreatmentAdjustUltrafiltrationRejected() # [Reject Notification] test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_NotificationBar).text), "Unable to Pause Ultrafiltration or already paused") def pause_Accept(): # [Accept Pause] denaliMessages.setTreatmentAdjustUltrafiltrationAccepted() utils.waitForGUI(1) # --------------- Paused Screen def testScreen_Paused_Ultrafiltration(): # [Paused Screen] test.compare(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationPaused_Screen).visible, True) ## Edit Button test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationPaused_EditButton).text.text), "EDIT ULTRAFILTRATION VOLUME") ## Resume Button test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationPaused_ResumeButton).text.text), "RESUME ULTRAFILTRATION") ## Paused Notification test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationPaused_PausedText).text), "Ultrafiltration is paused.") def resume_Request(): # [Request Resume] mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationPaused_ResumeButton)) def resume_RejectNTest(): # [Reject Resume] denaliMessages.setTreatmentAdjustUltrafiltrationRejected() # [Reject Notification] test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationPaused_NotificationBar).text), "Unable to Resume Ultrafiltration or already running") def resume_Accept(): # [Accept Resume] denaliMessages.setTreatmentAdjustUltrafiltrationAccepted() utils.waitForGUI(1) def closeScreen(): mouseClick(waitForObject(o_closeButton)) utils.waitForGUI(1) def testScreen_Paused_Notification(): # [Section Paused Notification] test.compare(str(waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).notification.text), "Ultrafiltration Paused") def edit_Clicked(): mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationPaused_EditButton)) utils.waitForGUI(1) def testScreen_Edit_Ultrafiltration(): test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_NextButton).text.text), "NEXT") test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_PausedText).text), "Ultrafiltration is paused.") test.compare(str(waitForObjectExists(o_backButton).text.text), "BACK") def back_Clicked(): mouseClick(waitForObject(o_backButton)) def edit_RejectNTest(): denaliMessages.setTreatmentAdjustUltrafiltrationEditRejected(12) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_NotificationBar).visible, True) #this error message needs to be changed later when translated. test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_NotificationBar).text), "REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE") def updateNTest_Adjustment_Ranges(vMinUFVolume, vMaxUFVolume): # HD sends Ultrafiltration ranges denaliMessages.setTreatmentParamRanges(0, 0, vMinUFVolume, vMaxUFVolume, 0, 0) # Edit Screen updates Ultrafiltration ranges on Slider upon Receiving Ranges test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_VolumeSlider).minText.text), "{:.3f}".format(utils.ml2l(vMinUFVolume))) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_VolumeSlider).maxText.text), "{:.3f}".format(utils.ml2l(vMaxUFVolume))) def user_Adjusted(): # Edit Screen updated the adjusted Ultrafiltration value mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationEdit_VolumeSlider), 430, 1, Qt.LeftButton) def next_Clicked(): mouseClick(waitForObject(names.o_treatmentAdjustmentUltrafiltrationEdit_NextButton)) def adjustmentResponse(): denaliMessages.setTreatmentAdjustUltrafiltrationEditResponse(_Accepted, _Reason, _Volume, _Duration, _DurationDiff, _Rate, _RateDiff, _RateOld) def next_Accepted(vVolume, vRateState, vDurationState): global _Accepted, _Reason, _Volume, _Duration, _DurationDiff, _Rate, _RateDiff, _RateOld _Accepted = 1; _Reason = 0; _RateOld = 10; _Volume = vVolume mDurationOld = 60 # minute if vRateState == eIncrease: _Rate = 30 # mL/Min _RateDiff = _Rate - _RateOld if vRateState == eDecrease: _Rate = 5 # mL/Min _RateDiff = _Rate - _RateOld if vRateState == eInvalid: _Rate = 0 _RateDiff = 0 if vDurationState == eIncrease: _Duration = 1800 # minute _DurationDiff = _Duration - mDurationOld if vDurationState == eDecrease: _Duration = 30 # minute _DurationDiff = _Duration - mDurationOld if vDurationState == eInvalid: _Duration = 0 _DurationDiff = 0 adjustmentResponse () testScreen_Confirm_Ultrafiltration() testScreen_Confirm_OptionRate (vRateState ) testScreen_Confirm_OptionDuration (vDurationState) def testScreen_Confirm_Ultrafiltration(): #[Confrim Screen] test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_Screen).visible, True) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_PausedText).text), "Ultrafiltration is paused.") test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_ConfirmButton).text.text), "CONFIRM") test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_ConfirmButton).disabled, True) test.compare(str(waitForObjectExists(o_backButton).text.text), "BACK") #[Confirm Title / Ultrafiltration Volume] test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_Title ).text), "To confirm new UF Volume ({:.3f}),\nselect a treatment adjustment:".format(utils.ml2l(_Volume))) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate ).selected , False) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).selected , False) def testScreen_Confirm_OptionRate(vIncrease): # Rate Option mInvalid = _Rate == 0 and _RateDiff == 0 mIncrease = _RateDiff > 0 mInDeCrease = InDeCreaseS(mIncrease, mInvalid, False) mInDeCreases = InDeCreaseS(mIncrease, mInvalid, True ) test.compare(mIncrease, vIncrease == eIncrease) test.compare(mInvalid , vIncrease == eInvalid ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).visible , True ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).disabled , mInvalid) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).isIncrease , mIncrease) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate_Title ).visible , True) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).title ), "{} UF Rate".format(mInDeCrease)) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate_Description ).visible , True) if mInvalid: test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).description ),stringInvalidTxt) else: test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).description ), "The rate {} by {} mL/min,\nthe treatment duration remains the same.".format(mInDeCreases, abs(_RateDiff))) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate).valueText ), "UF Rate : {} mL/min".format(_Rate)) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate_DiffImageWave ).visible , not mInvalid) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate_DiffImageWave ).isIncrease , mIncrease) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate_DiffImageClock).visible , False) def testScreen_Confirm_OptionDuration(vIncrease): mInvalid = _Duration == 0 and _DurationDiff == 0 mIncrease = _DurationDiff > 0 mInDeCrease = InDeCreaseS(mIncrease, mInvalid, False) mInDeCreases = InDeCreaseS(mIncrease, mInvalid, True ) test.compare(mIncrease, vIncrease == eIncrease) test.compare(mInvalid , vIncrease == eInvalid ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).visible , True ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).disabled , mInvalid) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).isIncrease , mIncrease ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration_Title ).visible , True ) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).title ), "{} Treatment Duration".format(mInDeCrease)) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration_Description ).visible , True ) if mInvalid: test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).description ),stringInvalidTxt) else: test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).description ), "The rate remains, the treatment\nduration {} by {} minutes.".format(mInDeCreases, abs(_DurationDiff))) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration).valueText ), "UF Rate : {} mL/min".format(_RateOld)) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration_DiffImageClock).visible , not mInvalid ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration_DiffImageClock).isIncrease, mIncrease ) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration_DiffImageWave ).visible , False) def confirm_Request_Rate(): mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate)) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_ConfirmButton).disabled, False) mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationConfirm_ConfirmButton)) def confirm_Request_Duration(): mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration)) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_ConfirmButton).disabled, False) mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationConfirm_ConfirmButton)) def confirm_RejectNTest(): denaliMessages.setTreatmentAdjustUltrafiltrationConfirmRejected(2) test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_NotificationBar).visible, True) test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_NotificationBar).text ), "REQUEST_REJECT_REASON_TIMEOUT_WAITING_FOR_USER_CONFIRM") def confirm_Accept(vVolume, vDuration, vRate): denaliMessages.setTreatmentAdjustUltrafiltrationConfirmResponse(1, 0, vVolume, vDuration, vRate) def main(): utils.tstStart() startApplication("denaliSquish") # denaliSquish utils.waitForGUI(1) gotoScreenNtest_Contains_Ultrafiltration() utils.waitForGUI(1) gotoScreen_UltrafiltrationAdjustment() # Start Screen upon User touch while IS NOT PAUSED testScreen_Start_Ultrafiltration() closeScreen() # Back to main gotoScreen_UltrafiltrationAdjustment() testScreen_Start_Ultrafiltration() pause_Request() pause_RejectNTest() # Test Notification pause_Accept() # Paused Screen upon Pause accepted testScreen_Paused_Ultrafiltration() closeScreen() # Back to main # Main Treatment Paused Notification upon Pause accepted testScreen_Paused_Notification() # Paused Screen upon User touch while IS PAUSED gotoScreen_UltrafiltrationAdjustment() testScreen_Paused_Ultrafiltration() resume_Request() resume_RejectNTest() resume_Accept() # Paused Screen upon User touch while IS PAUSED gotoScreen_UltrafiltrationAdjustment() # Start Screen upon User touch while IS NOT PAUSED testScreen_Start_Ultrafiltration() pause_Request() pause_Accept() testScreen_Paused_Notification() # Edit Screen upon Used Edit Button edit_Clicked() # Edit Screen testScreen_Edit_Ultrafiltration() # Back to Paused Screen from Edit Screen back_Clicked() # Paused Screen upon User Back Button from Edit Screen testScreen_Paused_Ultrafiltration() # Edit Screen upon Used Edit Button edit_Clicked() updateNTest_Adjustment_Ranges(600, 2400) updateNTest_Adjustment_Ranges(100, 4800) user_Adjusted() next_Accepted(2400, eIncrease, eIncrease) back_Clicked() # Edit Rejected edit_RejectNTest() # Some of this test may never happen but GUI should work as developed # So Volume is not necessarily correct # ----- Rate Inv next_Accepted( 0, eInvalid , eIncrease) back_Clicked() next_Accepted( 20, eInvalid , eDecrease) back_Clicked() next_Accepted( 40, eInvalid , eInvalid ) back_Clicked() # ----- Rate Inc next_Accepted(1200, eIncrease, eIncrease) back_Clicked() next_Accepted(1800, eIncrease, eDecrease) back_Clicked() next_Accepted(2400, eIncrease, eInvalid ) back_Clicked() # ----- Rate Dec next_Accepted( 300, eDecrease, eIncrease) back_Clicked() next_Accepted( 400, eDecrease, eDecrease) back_Clicked() next_Accepted( 500, eDecrease, eInvalid ) back_Clicked() # ----- Duration Inv next_Accepted( 0, eIncrease, eInvalid ) back_Clicked() next_Accepted( 20, eDecrease, eInvalid ) back_Clicked() next_Accepted( 40, eInvalid , eInvalid ) # ----- Duration Inc next_Accepted(1200, eIncrease, eIncrease) back_Clicked() next_Accepted(1800, eDecrease, eIncrease) back_Clicked() next_Accepted(2400, eInvalid , eIncrease) back_Clicked() # ----- Duration Dec next_Accepted( 300, eIncrease, eDecrease) back_Clicked() next_Accepted( 400, eDecrease, eDecrease) back_Clicked() next_Accepted( 500, eInvalid , eDecrease) back_Clicked() # options request next_Accepted(3600, eIncrease, eIncrease) confirm_Request_Rate() confirm_RejectNTest() # options request next_Accepted(4800, eIncrease, eIncrease) confirm_Request_Duration() confirm_RejectNTest() confirm_Accept(1200, 2 *60, 20) utils.tstDone()