Index: tst_create_custom_treatment/test.py =================================================================== diff -u -rdaf16428627302767972a5525dd02b8303f9d39a -rb4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b --- tst_create_custom_treatment/test.py (.../test.py) (revision daf16428627302767972a5525dd02b8303f9d39a) +++ tst_create_custom_treatment/test.py (.../test.py) (revision b4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b) @@ -209,23 +209,46 @@ test.startSection("Verification of duration values") test.compare(waitForObject(names.o_PreTreatmentCreate_duration_SliderCreateTreatment).label, config.DURATION, "Parameter should be -> "+str(config.DURATION)) for duration in config.CREATE_TREATMENT_PARAMETER_RANGE[config.DURATION][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION) + """ + The function mocking the mouse click encounters a misstep when it comes to a "tight" slider + such as the duration slider, where the segments between ticks are small and causes a misstep. + Setting the x_mouselick_shift to correct the mouse click's x location to get correct values for + special cases: above 330 and at 480 (max value) + """ + x_shift_location = 5 + if duration >= 330 : + x_shift_location = -7 # correcting the automated mouse click + if duration == 480: + x_shift_location = -20 # mouse click was dropping off the slider + test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION, + x_mouseclick_shift=x_shift_location) test.endSection() #scroll the screen to the title heparin bolus volume parameter_object = set_parameter_type(text = config.HEPARIN_BOLUS_VOLUME) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) - test.startSection("Verification of heparin dispensing rate values") + test.startSection("verification of heparin dispensing rate values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinDispensingRate_SliderCreateTreatment).label, config.HEPARIN_DISPENSING_RATE, "Parameter should be -> "+str(config.HEPARIN_DISPENSING_RATE)) + utils.waitForGUI(1) for heparin_dispensing_rate in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_DISPENSING_RATE][::-1]: test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinDispensingRateSlider_Slider, heparin_dispensing_rate, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_dispensing_rate"], config.HEPARIN_DISPENSING_RATE) test.endSection() - test.startSection("Verification of heparin bolus volume values") + test.startSection("verification of heparin bolus volume values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinBolusVolume_SliderCreateTreatment).label, config.HEPARIN_BOLUS_VOLUME, "Parameter should be -> "+str(config.HEPARIN_BOLUS_VOLUME)) + mouseClick(names.o_PreTreatmentCreate_heparinBolusVolumeSwitch_Switch) + mouseClick(names.o_PreTreatmentCreate_heparinBolusVolumeSwitch_Switch) + utils.waitForGUI(1) for heparin_bolus_volume in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_BOLUS_VOLUME][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinBolusVolumeSlider_Slider, heparin_bolus_volume, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_bolus_volume"], config.HEPARIN_BOLUS_VOLUME) + # correcting the automated mouseClick x-location, this is needed for tighter set sliders (segments between ticks are small) + x_shift_location = 0 + if (heparin_bolus_volume == 50) or (heparin_bolus_volume == 20) or (heparin_bolus_volume == 10): + x_shift_location = 5 + + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinBolusVolumeSlider_Slider, heparin_bolus_volume, + config.CREATE_TREATMENT_SLIDER_VALUES["heparin_bolus_volume"], config.HEPARIN_BOLUS_VOLUME, + x_mouseclick_shift=x_shift_location) test.endSection() #scroll the screen to the title acid concentrate type @@ -235,7 +258,14 @@ test.startSection("Verification of heparin stop time values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinStopTime_SliderCreateTreatment).label, config.HEPARIN_STOP_TIME, "Parameter should be -> "+str(config.HEPARIN_STOP_TIME)) for heparin_stop_time in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_STOP_TIME][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) + # correcting the automated mouseClick x-location, this is needed for tighter set sliders (segments between ticks are small) + x_shift_location = 0 + if (heparin_stop_time == 50) or (heparin_stop_time == 20): + x_shift_location = 7 + if (heparin_stop_time == 10): + x_shift_location = 15 + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME, + x_mouseclick_shift=x_shift_location) test.endSection() test.startSection("Verification of saline bolus values") @@ -258,11 +288,25 @@ parameter_object = names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment#set_parameter_type(text = config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable, yDegreeScrollDisplace = 150) - test.startSection("Verification of blood pressure measurement interval values") + test.startSection("verification of blood pressure measurement interval values") + # TODO need to figure out if the switch should be OFF or on. based on application behavior, it stays on. + # off_label= utility.get_object_from_names(names.o_PreTreatmentCreate_BPInterval_OFF_Text, error_message = "off label object missing") + # if off_label is not None: + # test.compare(waitForObject(names.o_PreTreatmentCreate_BPInterval_OFF_Text).text,"OFF", "Text should be -> "+"OFF") + mouseClick(waitForObject(names.o_PreTreatmentCreate_BPInterval_Switch)) + mouseClick(names.o_PreTreatmentCreate_BPInterval_Switch) + utils.waitForGUI(1) test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) for blood_pressure_measurement_interval in config.CREATE_TREATMENT_PARAMETER_RANGE[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) - test.compare(config.OFF_TEXT, waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalValue_Text).text, "OFF text should display for value 0") + """ + The function mocking the mouse click encounters a misstep in traversing between tick marks, need to correct + """ + x_shift_location = 15 + if blood_pressure_measurement_interval >= 40 : + x_shift_location = 60 # correcting the automated mouse click + + test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, + x_mouseclick_shift=x_shift_location) test.endSection() test_continue_button() @@ -325,7 +369,7 @@ test.endSection() -def test_custom_treatment_slider(slider_object, value, slider_parameter, parameter): +def test_custom_treatment_slider(slider_object, value, slider_parameter, parameter, x_mouseclick_shift = 0): """ Method to set slider handle based on custom values @param slider_object : (dictionary) object of treatment parameters @@ -336,10 +380,9 @@ minimum_slider_value = slider_parameter[0] slider_buffer = slider_parameter[1] width_buffer = slider_parameter[2] - slider_width = ((value - minimum_slider_value)/slider_buffer) * width_buffer - utils.waitForGUI(0.2) + slider_width = ((value - minimum_slider_value)/slider_buffer) * width_buffer + x_mouseclick_shift mouseClick(waitForObjectExists(slider_object), float(slider_width) , 3, Qt.LeftButton) - + utils.waitForGUI(0.5) test.compare(waitForObjectExists(slider_object).value, value, str(parameter)+" slider value should set to " +str(value)) @@ -387,13 +430,13 @@ test.compare(waitForObject(names.o_PreTreatmentCreate_Create_a_Custom_Treatment_Text).text, config.TREATMENT_TITLE, "Title text should be -> "+str(config.TREATMENT_TITLE)) test.compare(waitForObject(names.o_PreTreatmentCreate_PRESCRIPTION_Text).text, config.PRESCRIPTION_TITLE, "Title text should be -> "+str(config.PRESCRIPTION_TITLE)) - #set custom values for parameters + # set custom values for parameters test.startSection("Verification of blood flow values") test.compare(waitForObject(names.o_PreTreatmentCreate_bloodFlowRate_SliderCreateTreatment).label, config.BLOOD_FLOW_RATE, "Parameter should be -> "+str(config.BLOOD_FLOW_RATE)) for blood_flow_rate in config.CREATE_TREATMENT_PARAMETER_RANGE[config.BLOOD_FLOW_RATE]: test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodFlowRateSlider_Slider, blood_flow_rate, config.CREATE_TREATMENT_SLIDER_VALUES["blood_flow_rate"], config.BLOOD_FLOW_RATE) test.endSection() - + test.startSection("Verification of dialysate flow values") test.compare(waitForObject(names.o_PreTreatmentCreate_dialysateFlowRate_SliderCreateTreatment).label, config.DIALYSATE_FLOW_RATE, "Parameter should be -> "+str(config.DIALYSATE_FLOW_RATE)) for dialysate_flow_rate in config.CREATE_TREATMENT_PARAMETER_RANGE[config.DIALYSATE_FLOW_RATE]: @@ -403,7 +446,20 @@ test.startSection("Verification of duration values") test.compare(waitForObject(names.o_PreTreatmentCreate_duration_SliderCreateTreatment).label, config.DURATION, "Parameter should be -> "+str(config.DURATION)) for duration in config.CREATE_TREATMENT_PARAMETER_RANGE[config.DURATION]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION) + """ + The function mocking the mouse click encounters a misstep when it comes to a "tight" slider + such as the duration slider, where the segments between ticks are small and causes a misstep. + Setting the x_mouselick_shift to correct the mouse click's x location to get correct values for + special cases: above 330 and at 480 (max value) + """ + x_shift_location = 5 + if duration >= 330 : + x_shift_location = -7 # correcting the automated mouse click + if duration == 480: + x_shift_location = -20 # mouse click was dropping off the slider + test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, + config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION, + x_mouseclick_shift=x_shift_location) test.endSection() #scroll the screen to the title heparin bolus volume @@ -439,7 +495,15 @@ test.startSection("Verification of heparin stop time values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinStopTime_SliderCreateTreatment).label, config.HEPARIN_STOP_TIME, "Parameter should be -> "+str(config.HEPARIN_STOP_TIME)) for heparin_stop_time in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_STOP_TIME]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) + # correcting the automated mouseClick x-location, this is needed for tighter set sliders (segments between ticks are small) + x_shift_location = 0 + if (heparin_stop_time == 50) or (heparin_stop_time == 20): + x_shift_location = 5 + if (heparin_stop_time == 10): + x_shift_location = 15 + + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME, + x_mouseclick_shift=x_shift_location) test.endSection() test.startSection("Verification of saline bolus values") @@ -540,8 +604,14 @@ utils.waitForGUI(1) test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) for blood_pressure_measurement_interval in config.CREATE_TREATMENT_PARAMETER_RANGE[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) - test.compare(config.OFF_TEXT, waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalValue_Text).text, "OFF text should display for value 0") + """ + The function mocking the mouse click encounters a misstep in traversing between tick marks, need to correct + """ + x_shift_location = 15 + if blood_pressure_measurement_interval >= 40 : + x_shift_location = 60 # correcting the automated mouse click + test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, + x_mouseclick_shift=x_shift_location) test.endSection() test.endSection() @@ -608,8 +678,12 @@ test_custom_treatment_slider(names.o_PreTreatmentCreate_dialysateTemperatureSlider_Slider, config.CREATE_CUSTOM_TREATMENT[config.DIALYSATE_TEMPERATURE], config.CREATE_TREATMENT_SLIDER_VALUES["dialysate_temperature"], config.DIALYSATE_TEMPERATURE) - #set custom values for parameters - test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, config.CREATE_CUSTOM_TREATMENT[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL], config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) + #set custom values for parameters + mouseClick(waitForObject(names.o_PreTreatmentCreate_BPInterval_Switch)) + mouseClick(names.o_PreTreatmentCreate_BPInterval_Switch) + utils.waitForGUI(1) + test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) + test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, config.CREATE_CUSTOM_TREATMENT[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL], config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, x_mouseclick_shift=25) test.endSection()