# -*- coding: utf-8 -*- ########################################################################### # # Copyright (c) 2020-2022 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 test.py # # @author (last) Peter Lucia # @date (last) 22-Feb-2021 # @author (original) Behrouz NematiPour # @date (original) 01-May-2020 # ############################################################################ import names from dialin.ui import utils from dialin import HDSimulator hd_sim = HDSimulator() def gotoScreenNtest_Contains_DurationSection(): mouseClick(waitForObject(names.o_treatmentHome_startTreatment)) test.compare(waitForObjectExists(names.o_treatmentStart_shape_Shape).visible, True) def gotoScreenNTest_Adjustment(): mouseClick(waitForObject(names.o_treatmentStart_shape_Shape)) test.compare(waitForObjectExists(names.o_modalDialog).visible, True) def main(): utils.tstStart(__file__) startApplication(names.AUT_NAME) utils.waitForGUI(1) gotoScreenNtest_Contains_DurationSection() utils.waitForGUI(1) hd_sim.cmd_set_treatment_start_state() durationMin = 0 durationMax = 60 * 3 # 3h durationElapsed = 10 # 10m hd_sim.cmd_set_treatment_time(durationMax * 60, durationElapsed * 60) test.compare(str(waitForObjectExists(names.o_treatmentStart_TimeText_TimeText ).time), "02:50:00") test.compare(str(waitForObjectExists(names.o_treatmentStart_TimeText_hour_Text ).text), "02") test.compare(str(waitForObjectExists(names.o_treatmentStart_TimeText_minute_Text).text), "50") test.compare(str(waitForObjectExists(names.o_treatmentStart_TimeText_second_Text).text), "00") gotoScreenNTest_Adjustment() utils.waitForGUI(1) hd_sim.cmd_set_treatment_parameter_ranges(durationMin, durationMax, 0, 0, 0, 0) test.compare(waitForObjectExists(names.o_durationSlider_Slider).minimum, durationMin) test.compare(waitForObjectExists(names.o_durationSlider_Slider).maximum, durationMax) durationMin = 10 # 10m durationMax = 60 * 2 # 2h hd_sim.cmd_set_treatment_parameter_ranges(durationMin, durationMax, 0, 0, 0, 0) test.compare(waitForObjectExists(names.o_durationSlider_Slider).minimum, durationMin) test.compare(waitForObjectExists(names.o_durationSlider_Slider).maximum, durationMax) # the duration dialog should use the same value as the Treatment time test.compare(str(waitForObjectExists(names.o_TimeText_TimeText ).time), "00:10:00") test.compare(str(waitForObjectExists(names.o_TimeText_hour_Text ).text), "00") test.compare(str(waitForObjectExists(names.o_TimeText_minute_Text).text), "10") test.compare(str(waitForObjectExists(names.o_TimeText_second_Text).text), "00") # touch on the middle of the slider mouseClick(waitForObject(names.o_durationSlider_Slider), waitForObjectExists(names.o_durationSlider_Slider).width / 2, 5, Qt.LeftButton) # touch confirm # AdjustDurationReq mouseClick(waitForObjectExists(names.o_confirmButton)) # rejected 65, revert to 75 hd_sim.cmd_send_treatment_adjust_duration_response(0, 4, 75, 0) test.compare(str(waitForObjectExists(names.o_TimeText_hour_Text_2 ).text), "01") test.compare(str(waitForObjectExists(names.o_TimeText_minute_Text_2).text), "15") # rejected 65, revert to 75 # let's see if we got twice with no change do we still act the same hd_sim.cmd_send_treatment_adjust_duration_response(0, 4, 75, 0) test.compare(str(waitForObjectExists(names.o_TimeText_hour_Text_2 ).text), "01") test.compare(str(waitForObjectExists(names.o_TimeText_minute_Text_2).text), "15") test.compare(waitForObjectExists(names.o_modalDialog).visible, True) # accepted hd_sim.cmd_send_treatment_adjust_duration_response(1, 0, 45, 1000) test.compare(waitForObjectExists(names.o_treatmentStart_shape_Shape).visible, True) utils.tstDone()