Index: tst_Treatment_Adjustment_Ultrafiltration/test.py =================================================================== diff -u -rb795e6250294344ef7b0396bae4648fb2aa306b3 -r59636301fab15c81ae50b7ea7546b79e494189f8 --- tst_Treatment_Adjustment_Ultrafiltration/test.py (.../test.py) (revision b795e6250294344ef7b0396bae4648fb2aa306b3) +++ tst_Treatment_Adjustment_Ultrafiltration/test.py (.../test.py) (revision 59636301fab15c81ae50b7ea7546b79e494189f8) @@ -12,99 +12,240 @@ # author Behrouz NematiPour # -import names +import squish +import test + import utils -import denaliMessages +import denaliMessages +from names import * + +eInvalid = 0 +eIncrease = 1 +eDecrease = 2 +stringInvalid = "Invalid" +stringInvalidDetail = "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 "" + + def gotoScreenNtest_Contains_Ultrafiltration(): - mouseClick(waitForObject(names.o_treatmentHome_startTreatment)) - test.compare(waitForObjectExists(names.o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).visible, True) + squish.mouseClick(squish.waitForObject(o_treatmentHome_startTreatment)) + test.compare(squish.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(names.o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).value), i) + test.compare(utils.l2ml(squish.waitForObjectExists(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration).value), i) + def gotoScreen_UltrafiltrationAdjustment(): # [Section Click] - mouseClick(waitForObject(names.o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration)) + squish.mouseClick(squish.waitForObject(o_treatmentStart_ultrafiltrationTouchArea_TreatmentUltrafiltration)) utils.waitForGUI(1) - + + def testScreen_Start_Ultrafiltration(): - # [Start Screen] + # [Start Screen] + test.compare(squish.waitForObjectExists(o_treatmentAdjustmentUltrafiltrationStart_Screen).visible, True) ## Pause Button - test.compare(str(waitForObjectExists(names.o_pauseButton_TouchRect).text.text), "PAUSE ULTRAFILTRATION") + test.compare(str(squish.waitForObjectExists(o_pauseButton_TouchRect).text.text), "PAUSE ULTRAFILTRATION") + def pause_Request(): # [Request Pause] - mouseClick(waitForObject(names.o_pauseButton_TouchRect)) + squish.mouseClick(squish.waitForObject(o_pauseButton_TouchRect)) + def pause_RejectNTest(): # [Reject Pause] denaliMessages.setTreatmentAdjustUltrafiltrationRejected() + # [Reject Notification] - test.compare(str(waitForObjectExists(names.notificationBar_NotificationBar).text), "Unable to Pause Ultrafiltration or already paused") + test.compare(str(squish.waitForObjectExists(notificationBar_NotificationBar).text), "Unable to Pause Ultrafiltration or already paused") + def pause_Accept(): # [Accept Pause] denaliMessages.setTreatmentAdjustUltrafiltrationAccepted() utils.waitForGUI(1) + def testScreen_Paused_Ultrafiltration(): - # [Paused Screen] - ## Edit Button - test.compare(str(waitForObjectExists(names.o_editButton_TouchRect).text.text), "EDIT ULTRAFILTRATION VOLUME") - ## Resume Button - test.compare(str(waitForObjectExists(names.o_resumeButton_TouchRect).text.text), "RESUME ULTRAFILTRATION") - ## Paused Notification - test.compare(str(waitForObjectExists(names.o_pauseNotificationBar_NotificationBar).text), "Ultrafiltration is paused.") + # [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.") + def resume_Request(): # [Request Resume] - mouseClick(waitForObject(names.o_resumeButton_TouchRect)) + mouseClick(waitForObject(o_resumeButton_TouchRect)) + def resume_RejectNTest(): # [Reject Resume] denaliMessages.setTreatmentAdjustUltrafiltrationRejected() # [Reject Notification] - test.compare(str(waitForObjectExists(names.notificationBar_NotificationBar).text), "Unable to Resume Ultrafiltration or already running") + test.compare(str(waitForObjectExists(notificationBar_NotificationBar).text), "Unable to Resume Ultrafiltration or already running") + def resume_Accept(): # [Accept Resume] denaliMessages.setTreatmentAdjustUltrafiltrationAccepted() utils.waitForGUI(1) - + + def closeScreen(): - mouseClick(waitForObject(names.o_closeButton)) + mouseClick(waitForObject(o_closeButton)) utils.waitForGUI(1) - + + def testScreen_Paused_Notification(): # [Section Paused Notification] - test.compare(str(waitForObjectExists(names.o_treatmentStart_NotificationBar_NotificationBar).text), "Ultrafiltration Paused") - test.compare(str(waitForObjectExists(names.o_treatmentStart_0_000_Text).color.name), "#696969") + test.compare(str(waitForObjectExists(o_treatmentStart_NotificationBar_NotificationBar).text), "Ultrafiltration Paused") + test.compare(str(waitForObjectExists(o_treatmentStart_0_000_Text).color.name), "#696969") + def edit_Clicked(): - mouseClick(waitForObject(names.o_editButton_TouchRect)) + mouseClick(waitForObject(o_editButton_TouchRect)) + utils.waitForGUI(1) + def testScreen_Edit_Ultrafiltration(): - test.compare(str(waitForObjectExists(names.o_nextButton_TouchRect).text.text), "NEXT") - test.compare(str(waitForObjectExists(names.notificationBar_NotificationBar).text), "Ultrafiltration is paused.") - test.compare(str(waitForObjectExists(names.o_backButton_BackButton).text.text), "BACK") + 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") + def back_Clicked(): - mouseClick(waitForObject(names.o_backButton_BackButton)) + mouseClick(waitForObject(o_backButton_BackButton)) + +def edit_RejectNTest(): + denaliMessages.setTreatmentAdjustUltrafiltrationEditRejected(12) + test.compare(waitForObjectExists(notificationBar_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") + + +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 + denaliMessages.setTreatmentAdjustUltrafiltrationEditResponse(_Accepted, _Reason, _Volume, _Duration, _DurationDiff, _Rate, _RateDiff, _RateOld) + + +def testScreen_Confirm_Ultrafiltration(): + test.compare( waitForObjectExists(o_treatmentAdjustmentUltrafiltrationConfirm_Screen).visible, True) + #[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(): + # Rate Option + mInvalid = _Rate == 0 and _RateDiff == 0 + mIncrease = _RateDiff > 0 + mInDeCrease = InDeCreaseS(mIncrease, mInvalid, False) + mInDeCreases = InDeCreaseS(mIncrease, mInvalid, True ) + + 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) + 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(): + mInvalid = _Duration == 0 and _DurationDiff == 0 + mIncrease = _DurationDiff > 0 + mInDeCrease = InDeCreaseS(mIncrease, mInvalid, False) + mInDeCreases = InDeCreaseS(mIncrease, mInvalid, True ) + + 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) + 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 main(): utils.tstStart() - + startApplication("denali") utils.waitForGUI(1) gotoScreenNtest_Contains_Ultrafiltration() utils.waitForGUI(1) - + gotoScreen_UltrafiltrationAdjustment() - + # Start Screen upon User touch while IS NOT PAUSED testScreen_Start_Ultrafiltration() pause_Request() @@ -117,11 +258,11 @@ # 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() @@ -134,37 +275,77 @@ 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() - + # HD sends Ultrafiltration ranges denaliMessages.setTreatmentParamRanges(0, 0, 100, 4800, 0, 0) # Edit Screen updates Ultrafiltration ranges on Slider upon Receiving Ranges - test.compare(str(waitForObjectExists(names.o_volumeSlider_Slider).minText.text), "0.100") - test.compare(str(waitForObjectExists(names.o_volumeSlider_Slider).maxText.text), "4.800") + test.compare(str(waitForObjectExists(o_volumeSlider_Slider).minText.text), "0.100") + test.compare(str(waitForObjectExists(o_volumeSlider_Slider).maxText.text), "4.800") - mouseClick(waitForObject(names.o_volumeSlider_Slider), 404, 1, Qt.LeftButton) - test.compare(str(waitForObjectExists(names.o2_300_Text).text), "2.300") - mouseClick(waitForObject(names.o_nextButton_TouchRect)) + # Edit Screen updated the adjusted Ultrafiltration value + mouseClick(waitForObject(o_volumeSlider_Slider), 430, 1, Qt.LeftButton) - # HD Response - # ----------- + test.compare(str(waitForObjectExists(o_textVolume_Text).text), "2.400") + mouseClick(waitForObject(o_nextButton_TouchRect)) + + # Edit Rejected + edit_RejectNTest() + + + # 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 () - utils.tstDone() + 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 () + 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 () + back_Clicked() + + # 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_Clicked() + + utils.tstDone() + +