Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r3a3129a66d9d1382afc332bc1a14eaaf0d98a62d --- shared/scripts/configuration/utility.py (.../utility.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 3a3129a66d9d1382afc332bc1a14eaaf0d98a62d) @@ -14,50 +14,12 @@ import sys +import time import test import squish from configuration import config from builtins import int as pyInt - -def start_application(app_name): - """ - Function to start application and verify application status [running] - If application does not start or running status is false, test stops - Argument: - @param app_name : (str) - Name of the application - @param app_executable : (str) - Actual application - @return: handle for the application if the application is in running state, - or error (exist the application) - """ - counter = 0 - while True: - try: - counter += 1 - test.log("Starting {}".format(app_name)) - squish.startApplication(app_name) - if counter == 1: - test.log("Application launched at the "+str(counter)+" st try.") - elif counter == 2: - test.log("Application launched at the "+str(counter)+" nd try.") - elif counter == 3: - test.log("Application launched at the "+str(counter)+" rd try.") - else: - test.log("Application launched at the "+str(counter)+" th try.") - break - except RuntimeError: - if counter == 1: - test.log("Application failed to launch after "+str(counter)+" try - Please refer logs") - elif counter == 20: - test.log("Exiting after "+str(counter)+ " tries..") - sys.exit(1) - else: - test.log("Application failed to launch after "+str(counter)+ " tries - Please refer logs") - except: - logErrorDetails("Failed to start the application") - sys.exit(1) - - def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container @@ -108,3 +70,8 @@ raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") + + +def convert_seconds_into_min_and_sec(seconds): + min_and_sec = time.strftime("%M:%S", time.gmtime(seconds)) + return min_and_sec Index: shared/scripts/names.py =================================================================== diff -u -r890bc526cefea044d6900937daf51903a985ab9e -r3a3129a66d9d1382afc332bc1a14eaaf0d98a62d --- shared/scripts/names.py (.../names.py) (revision 890bc526cefea044d6900937daf51903a985ab9e) +++ shared/scripts/names.py (.../names.py) (revision 3a3129a66d9d1382afc332bc1a14eaaf0d98a62d) @@ -51,6 +51,7 @@ #main treatment time duration o_QQuickView = { "type": "QQuickView"} o_Gui_MainView = {"type": "Gui::MainView", "unnamed": 1, "visible": True} +o_pop_screen = {"container": o_Overlay, "type": "PopupItem", "unnamed": 1, "visible": True} o_treatmentHome = {"container": o_QQuickView , "id": "_treatmentHome" , "type": "TreatmentHome", "unnamed": 1, "visible": True} o_Treatment_Paused = {"container": o_treatmentHome, "text": "Treatment Paused", "type": "Text", "unnamed": 1, "visible": True} o_Overlay = {"container": o_Gui_MainView, "type": "Overlay", "unnamed": 1, "visible": True} Index: tst_time_duration/test.py =================================================================== diff -u -rdfbfb692b941ab983d31fc9a735a82bb0b18adf8 -r3a3129a66d9d1382afc332bc1a14eaaf0d98a62d --- tst_time_duration/test.py (.../test.py) (revision dfbfb692b941ab983d31fc9a735a82bb0b18adf8) +++ tst_time_duration/test.py (.../test.py) (revision 3a3129a66d9d1382afc332bc1a14eaaf0d98a62d) @@ -14,7 +14,7 @@ import names from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator -from configuration import config +from configuration import config, utility from random import randint from dialin.ui.utils import waitForGUI @@ -31,12 +31,35 @@ """ for i in range(0,vTotal+1): - + hd_simulator.cmd_set_treatment_time(vTotal, i, vTotal - i) test.compare(waitForObjectExists(names.o_treatment_duration).progressValue, i, "progress value should be {}".format(i)) test.compare(waitForObjectExists(names.o_treatment_duration).timeTextValue, vTotal - i, "Expected Time on UI should be in seconds {}".format(vTotal - i)) - +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_Remaining_Text)) + +def close_time_duration_pop_up(): + mouseClick(waitForObjectExists(names.o_confirm_button)) + test.log("Confirm button is clicked") + def reset_treatment_time_verification(vTotal): """ Method to reset and verify Actual time in seconds @@ -47,8 +70,15 @@ 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): + hd_simulator.cmd_set_treatment_time(vTotal, 0, vTotal) + current_time = utility.convert_seconds_into_min_and_sec(vTotal) + 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() + def verify_pause_treatment_text(): """ Method to verify 'Treatment Paused' text is displayed @@ -81,21 +111,16 @@ return totaltime_list def verify_pop_up(): - test.log("Pop up of time duration") - mouseClick(waitForObject(names.o_treatmentHome_Time_Remaining_Text)) + open_time_duration_pop_up() #FIXME: If we not use specified value then it will take minimum one and maximum 8 hours. - #treatment_time_verification(60) start_treatment_time_verification(60) - for duration in range(60): - hd_simulator.cmd_set_treatment_parameter_ranges(min_treatment_duration = duration, max_treatment_duration = 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) waitForGUI(0.1) hd_simulator.cmd_send_treatment_adjust_duration_response(True, 0, 100, 60) - - test.verify(waitForObjectExists(names.o_confirm_button).enabled, "'Confirm' button should be enabled") - mouseClick(waitForObjectExists(names.o_confirm_button)) - test.log("Confirm button is clicked") + close_time_duration_pop_up() def main(): utils.tstStart(__file__) @@ -105,12 +130,13 @@ hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0, dialysis_state=0) - snooze(3) + snooze(1) verify_pop_up() #Calculating total seconds into minutes and passing to treatment time verification total_time_list = total_time() for value in total_time_list: + verify_time_remaining_start_time_and_pop_up_slider_val(value) treatment_time_verification(value*60) #Give treatment stop response to pause remain time