# -*- 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_time_duration # @author (last) Amol Shinde # @author (last) Sai Chaitanya Ela # @date (last) 04-03-2022 import names from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from configuration import config, utility from dialin.ui.utils import waitForGUI from dialin.common.hd_defs import TreatmentStates, UFStates, SalineBolusStates, HeparinStates, TreatmentRinsebackStates, TreatmentRecircStates, TreatmentBloodPrimeStates, TreatmentEndStates, TreatmentStopStates, TreatmentDialysisStates, BloodLeakZeroingStates MIN_TIME_RANGE = 60 MAX_TIME_RANGE = 480 #FTo optimize the Test Execution time we are passing two specific seconds values for verification total_time_list = [90,120] hd_simulator = HDSimulator() def start_treatment_time_verification(vTotal): """ Method to verify Actual time in seconds to Time appear on UI Screen in seconds. Also it compare the Progress bar value in seconds @param vTotal: (int) Total time in seconds """ for count in range(0,vTotal+1): hd_simulator.cmd_set_treatment_time(vTotal, count, vTotal - count) utils.waitForGUI(0.5) test.compare(waitForObjectExists(names.o_treatment_duration).progressValue, count, "progress value should be {}".format(count)) test.compare(waitForObjectExists(names.o_treatment_duration).timeTextValue, vTotal - count, "Expected Time on UI should be in seconds {}".format(vTotal - count)) def get_slider_time_obj(): """ Method to get the time duartion pop up slider time obj @return slider_time - (obj) op up slider time obj """ pop_up_screen_children_objs = object.children(waitForObjectExists(names.o_pop_screen)) treatment_obj = pop_up_screen_children_objs[2] treatment_children_obj = object.children(treatment_obj) slider_parent = treatment_children_obj[2] slider_parent = object.children(slider_parent) duration_slider_parent = slider_parent[1] duration_slider = object.children(duration_slider_parent) time_obj = duration_slider[-1] return time_obj def open_time_duration_pop_up(): test.log("Opening time duration pop up") mouseClick(waitForObject(names.o_treatmentHome_time_duration_mouseArea_MouseArea)) mouseClick(waitForObject(names.o_time_duration_confirmButton_TouchRect_2)) def close_time_duration_pop_up(): test.log("Closing time duration pop up") mouseClick(waitForObjectExists(names.o_pop_up_close_button)) def reset_treatment_time_verification(vTotal): """ Method to reset and verify Actual time in seconds to Maximum & Minimum values on UI screen in seconds @param vTotal: (int) Total time in seconds """ hd_simulator.cmd_set_treatment_time(vTotal, 0, vTotal) test.compare(waitForObjectExists(names.o_treatment_duration).maximum, vTotal, "Reset maximum value and compare it expected value {}".format(vTotal)) test.compare(waitForObjectExists(names.o_treatment_duration).minimum, 0, "Reset minimum value and compare it expected value {}".format(0)) def verify_time_remaining_start_time_and_pop_up_slider_val(vTotal): """ Method to verify the time remaining and time duration pop up slider values are equal """ test.startSection("Verify Time remaining and pop up slider cal") hd_simulator.cmd_set_treatment_time(vTotal, 0, vTotal) waitForGUI(1) current_time = utility.convert_seconds_into_min_and_sec(vTotal, "%H:%M") open_time_duration_pop_up() current_slider_val = get_slider_time_obj() test.compare(current_slider_val.time, current_time, "Time remaining and pop up slider value should be {}".format(vTotal)) close_time_duration_pop_up() test.endSection() def verify_pause_treatment_text(): """ Method to verify 'Treatment Paused' text is displayed """ test.log("Verifying the text 'Treatment Paused'") test.compare(str(waitForObjectExists(names.o_Treatment_Paused).text), config.TREATMENT_PAUSED_TEXT, "{} should display Main treatment's remain time section".format(config.TREATMENT_PAUSED_TEXT)) def treatment_time_verification(total): test.startSection("Verify the seconds values inside Progress bar and on timer 'Time in seconds'") reset_treatment_time_verification(total) start_treatment_time_verification(total) test.endSection() def verify_pop_up(): """ Method to pass slider value and and verify the same on time duration pop screen """ test.startSection("Verify the slider values") open_time_duration_pop_up() start_treatment_time_verification(60) for duration in range(61): hd_simulator.cmd_set_treatment_parameter_ranges(min_treatment_duration = duration, max_treatment_duration = 61, min_uf_volume = 0.0, max_uf_volume = 0.0, min_dialysate_flow_rate = 0, max_dialysate_flow_rate = 0) utils.waitForGUI(0.1) hd_simulator.cmd_send_treatment_adjust_duration_response(accepted = True, reason = 0, duration = 100, ultrafiltration = 60) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) #navigate to dialysis state hd_simulator.cmd_set_treatment_states_data(sub_mode= TreatmentStates.TREATMENT_DIALYSIS_STATE.value, uf_state= UFStates.UF_PAUSED_STATE.value, saline_state=SalineBolusStates.SALINE_BOLUS_STATE_IDLE.value, heparin_state= HeparinStates.HEPARIN_STATE_OFF.value, rinseback_state= TreatmentRinsebackStates.RINSEBACK_STOP_INIT_STATE.value, recirculate_state= TreatmentRecircStates.TREATMENT_RECIRC_RECIRC_STATE.value, blood_prime_state= TreatmentBloodPrimeStates.BLOOD_PRIME_RAMP_STATE.value, treatment_end_state= TreatmentEndStates.TREATMENT_END_WAIT_FOR_RINSEBACK_STATE.value, treatment_stop_state= TreatmentStopStates.TREATMENT_STOP_RECIRC_STATE.value, dialysis_state=TreatmentDialysisStates.DIALYSIS_START_STATE.value, bloodLeakZeoringState = BloodLeakZeroingStates.BLD_ZEROING_IDLE_STATE.value) utils.waitForGUI(1) verify_pop_up() #Calculating total seconds into minutes and passing to treatment time verification for value in total_time_list: verify_time_remaining_start_time_and_pop_up_slider_val(value) treatment_time_verification(value) #Give treatment stop response to pause remain time hd_simulator.cmd_set_treatment_states_data(sub_mode= TreatmentStates.TREATMENT_START_STATE.value, uf_state= UFStates.UF_PAUSED_STATE.value, saline_state=SalineBolusStates.SALINE_BOLUS_STATE_IDLE.value, heparin_state= HeparinStates.HEPARIN_STATE_OFF.value, rinseback_state= TreatmentRinsebackStates.RINSEBACK_STOP_INIT_STATE.value, recirculate_state= TreatmentRecircStates.TREATMENT_RECIRC_RECIRC_STATE.value, blood_prime_state= TreatmentBloodPrimeStates.BLOOD_PRIME_RAMP_STATE.value, treatment_end_state= TreatmentEndStates.TREATMENT_END_WAIT_FOR_RINSEBACK_STATE.value, treatment_stop_state= TreatmentStopStates.TREATMENT_STOP_NO_RECIRC_STATE.value, dialysis_state=TreatmentDialysisStates.DIALYSIS_START_STATE.value, bloodLeakZeoringState = BloodLeakZeroingStates.BLD_ZEROING_IDLE_STATE.value) #verify treatment pause state verify_pause_treatment_text() utils.tstDone()