Index: tst_Treatment_Adjustment_Ultrafiltration/test.py =================================================================== diff -u -r59636301fab15c81ae50b7ea7546b79e494189f8 -r92a813d62f26a3e5ddf77b3b58b5c965fadeffb5 --- tst_Treatment_Adjustment_Ultrafiltration/test.py (.../test.py) (revision 59636301fab15c81ae50b7ea7546b79e494189f8) +++ tst_Treatment_Adjustment_Ultrafiltration/test.py (.../test.py) (revision 92a813d62f26a3e5ddf77b3b58b5c965fadeffb5) @@ -12,33 +12,30 @@ # author Behrouz NematiPour # -import squish -import test - import utils import denaliMessages from names import * -eInvalid = 0 -eIncrease = 1 -eDecrease = 2 -stringInvalid = "Invalid" -stringInvalidDetail = "Due to out of range adjustment, this option\nis disabled." +eInvalid = 0 +eIncrease = 1 +eDecrease = 2 +stringInvalid = "Invalid" +stringInvalidTxt= "Due to out of range adjustment, this option\nis disabled." -stringIncrease = "Increase" -stringDecrease = "Decrease" +stringIncrease = "Increase" +stringDecrease = "Decrease" stringIncreases = "increases" stringDecreases = "decreases" -_Accepted = 0 -_Reason = 0 -_Volume = 0 -_Duration = 0 -_DurationDiff = 0 -_Rate = 0 -_RateDiff = 0 -_RateOld = 0 +_Accepted = 0 +_Reason = 0 +_Volume = 0 +_Duration = 0 +_DurationDiff = 0 +_Rate = 0 +_RateDiff = 0 +_RateOld = 0 def InDeCreaseS(vIncrease, vInvalid, vSingular): if vInvalid: @@ -55,42 +52,42 @@ return stringDecrease return "" - +# --------------- Main Treatment def gotoScreenNtest_Contains_Ultrafiltration(): - squish.mouseClick(squish.waitForObject(o_treatmentHome_startTreatment)) - test.compare(squish.waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).visible, True) + 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(squish.waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).value), i) + test.compare(utils.l2ml(waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).value), i) - + def gotoScreen_UltrafiltrationAdjustment(): # [Section Click] - squish.mouseClick(squish.waitForObject(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration)) + mouseClick(waitForObject(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration)) utils.waitForGUI(1) +# --------------- Start Screen def testScreen_Start_Ultrafiltration(): # [Start Screen] - test.compare(squish.waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_Screen).visible, True) + test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_Screen ).visible , True ) ## Pause Button - test.compare(str(squish.waitForObjectExists(o_pauseButton_TouchRect).text.text), "PAUSE ULTRAFILTRATION") + test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_PauseButton).text.text), "PAUSE ULTRAFILTRATION") - + def pause_Request(): # [Request Pause] - squish.mouseClick(squish.waitForObject(o_pauseButton_TouchRect)) + mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationStart_PauseButton)) def pause_RejectNTest(): # [Reject Pause] denaliMessages.setTreatmentAdjustUltrafiltrationRejected() - # [Reject Notification] - test.compare(str(squish.waitForObjectExists(notificationBar_NotificationBar).text), "Unable to Pause Ultrafiltration or already paused") + test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_NotificationBar).text), "Unable to Pause Ultrafiltration or already paused") def pause_Accept(): @@ -99,26 +96,28 @@ utils.waitForGUI(1) +# --------------- Paused Screen def testScreen_Paused_Ultrafiltration(): # [Paused Screen] - # # Edit Button - test.compare(str(squish.waitForObjectExists(o_editButton_TouchRect).text.text), "EDIT ULTRAFILTRATION VOLUME") - # # Resume Button - test.compare(str(waitForObjectExists(o_resumeButton_TouchRect).text.text), "RESUME ULTRAFILTRATION") - # # Paused Notification - test.compare(str(waitForObjectExists(o_pauseNotificationBar_NotificationBar).text), "Ultrafiltration is paused.") + 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_resumeButton_TouchRect)) + mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationPaused_ResumeButton)) def resume_RejectNTest(): # [Reject Resume] denaliMessages.setTreatmentAdjustUltrafiltrationRejected() # [Reject Notification] - test.compare(str(waitForObjectExists(notificationBar_NotificationBar).text), "Unable to Resume Ultrafiltration or already running") + test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationPaused_NotificationBar).text), "Unable to Resume Ultrafiltration or already running") def resume_Accept(): @@ -134,75 +133,115 @@ def testScreen_Paused_Notification(): # [Section Paused Notification] - test.compare(str(waitForObjectExists(o_treatmentStart_NotificationBar_NotificationBar).text), "Ultrafiltration Paused") - test.compare(str(waitForObjectExists(o_treatmentStart_0_000_Text).color.name), "#696969") + test.compare(str(waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).notification.text), "Ultrafiltration Paused") def edit_Clicked(): - mouseClick(waitForObject(o_editButton_TouchRect)) + mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationPaused_EditButton)) utils.waitForGUI(1) def testScreen_Edit_Ultrafiltration(): - test.compare(str(waitForObjectExists(o_nextButton_TouchRect).text.text), "NEXT") - test.compare(str(waitForObjectExists(notificationBar_NotificationBar).text), "Ultrafiltration is paused.") - test.compare(str(waitForObjectExists(o_backButton_BackButton).text.text), "BACK") + 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_BackButton)) + mouseClick(waitForObject(o_backButton)) def edit_RejectNTest(): denaliMessages.setTreatmentAdjustUltrafiltrationEditRejected(12) - test.compare(waitForObjectExists(notificationBar_NotificationBar).visible, True) + test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_NotificationBar).visible, True) #this error message needs to be changed later when translated. - test.compare(str(waitForObjectExists(notificationBar_NotificationBar).text), "REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE") + test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_NotificationBar).text), "REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE") -def next_Clicked(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld): - global _Accepted - global _Reason - global _Volume - global _Duration - global _DurationDiff - global _Rate - global _RateDiff - global _RateOld - _Accepted = vAccepted - _Reason = vReason - _Volume = vVolume - _Duration = vDuration - _DurationDiff = vDurationDiff - _Rate = vRate - _RateDiff = vRateDiff - _RateOld = vRateOld +def update_Adjustment_Ranges(): + # HD sends Ultrafiltration ranges + denaliMessages.setTreatmentParamRanges(0, 0, 100, 4800, 0, 0) + + +def user_Adjusted(): + # Edit Screen updates Ultrafiltration ranges on Slider upon Receiving Ranges + test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_VolumeSlider).minText.text), "0.100") + test.compare(str(waitForObjectExists(o_treatmentAdjustmentUltrafiltrationEdit_VolumeSlider).maxText.text), "4.800") + # Edit Screen updated the adjusted Ultrafiltration value + mouseClick(waitForObject(o_treatmentAdjustmentUltrafiltrationEdit_VolumeSlider), 430, 1, Qt.LeftButton) + + +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(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(): +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 ),stringInvalidDetail) + 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))) @@ -212,20 +251,23 @@ test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonRate_DiffImageClock).visible , False) -def testScreen_Confirm_OptionDuration(): +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 ),stringInvalidDetail) + 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))) @@ -235,10 +277,20 @@ test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_AdjustmentButtonDuration_DiffImageWave ).visible , False) +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("denali") + startApplication("denali") # denaliSquish utils.waitForGUI(1) gotoScreenNtest_Contains_Ultrafiltration() @@ -248,6 +300,11 @@ # 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() @@ -293,58 +350,86 @@ # Edit Screen upon Used Edit Button edit_Clicked() - # HD sends Ultrafiltration ranges - denaliMessages.setTreatmentParamRanges(0, 0, 100, 4800, 0, 0) + update_Adjustment_Ranges() + + user_Adjusted() - # Edit Screen updates Ultrafiltration ranges on Slider upon Receiving Ranges - test.compare(str(waitForObjectExists(o_volumeSlider_Slider).minText.text), "0.100") - test.compare(str(waitForObjectExists(o_volumeSlider_Slider).maxText.text), "4.800") + next_Accepted(2400, eIncrease, eIncrease) + back_Clicked() - # Edit Screen updated the adjusted Ultrafiltration value - mouseClick(waitForObject(o_volumeSlider_Slider), 430, 1, Qt.LeftButton) - - test.compare(str(waitForObjectExists(o_textVolume_Text).text), "2.400") - mouseClick(waitForObject(o_nextButton_TouchRect)) - # Edit Rejected edit_RejectNTest() + # Some of this test may never happen but GUI should work as developed + # So Volume is not necessarily correct - # Rate : Increate , Durtation : Increate - # Edit Accepted - next_Clicked(1, 0, 2400, 3 * 60, 2 * 60, 30, 20, 10) - testScreen_Confirm_Ultrafiltration() - testScreen_Confirm_OptionRate () - testScreen_Confirm_OptionDuration () - + + # ----- Rate Inc + next_Accepted(2400, eIncrease, eIncrease) back_Clicked() - # Rate : Decrease , Durtation : Decrease - # Edit Accepted - next_Clicked(1, 0, 300, 30, -30, 5, -5, 10) - testScreen_Confirm_Ultrafiltration() - testScreen_Confirm_OptionRate () - testScreen_Confirm_OptionDuration () - + next_Accepted(2400, eIncrease, eDecrease) back_Clicked() - # Rate : Disable , Durtation : Increase - # Edit Accepted - next_Clicked(1, 0, 4800, 8 * 60, 7 * 60, 0, 0, 10) - testScreen_Confirm_Ultrafiltration() - testScreen_Confirm_OptionRate () - testScreen_Confirm_OptionDuration () - + next_Accepted(2400, eIncrease, eInvalid ) back_Clicked() + + # ----- Rate Dec + next_Accepted( 300, eDecrease, eIncrease) + back_Clicked() + + next_Accepted( 300, eDecrease, eDecrease) + back_Clicked() + + next_Accepted( 300, eDecrease, eInvalid ) + back_Clicked() + + # ----- Rate Inv + next_Accepted( 0, eInvalid , eIncrease) + back_Clicked() + + next_Accepted( 0, eInvalid , eDecrease) + back_Clicked() + + next_Accepted( 0, eInvalid , eInvalid ) + back_Clicked() + + # ----- Coverage - Duration Duplicate + next_Accepted(2400, eIncrease, eIncrease) + back_Clicked() + + # ----- Duration Inc + next_Accepted(2400, eIncrease, eIncrease) + back_Clicked() + + next_Accepted(2400, eDecrease, eIncrease) + back_Clicked() + + next_Accepted(2400, eInvalid , eIncrease) + back_Clicked() + + # ----- Duration Dec + next_Accepted( 300, eIncrease, eDecrease) + back_Clicked() + + next_Accepted( 300, eDecrease, eDecrease) + back_Clicked() + + next_Accepted( 300, eInvalid , eDecrease) + back_Clicked() + + # ----- Duration Inv + next_Accepted( 0, eIncrease, eInvalid ) + back_Clicked() + + next_Accepted( 0, eDecrease, eInvalid ) + back_Clicked() + + next_Accepted( 0, eInvalid , eInvalid ) - # Rate : Disable , Durtation : Increase - # Edit Accepted - next_Clicked(1, 0, 2400, 0, 0, 30, 20, 10) - testScreen_Confirm_Ultrafiltration() - testScreen_Confirm_OptionRate () - testScreen_Confirm_OptionDuration () + confirm_RejectNTest() - #confirm_Clicked() + confirm_Accept(1200, 2 *60, 20) utils.tstDone()