Index: suite_leahi/shared/scripts/configuration/config.py =================================================================== diff -u -r75e3ab588237239452761d2ec90e8b3aec6a916b -r8ac0eae52c22298abedaec3200ebd450888c3ac2 --- suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 75e3ab588237239452761d2ec90e8b3aec6a916b) +++ suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 8ac0eae52c22298abedaec3200ebd450888c3ac2) @@ -87,8 +87,13 @@ COMPLETE = 'Complete' HEPARIN = "Heparin" CREATERX = "Rx" -VALIDATE = "VALIDATE" -CONFIRM = "CONFIRM" +VALIDATE = "Validate" +CONFIRM = "Confirm" NEXT ="Next" +# Settings Service +DEFAULT_SERVICE_PASSWORD_RAW = "Atal.Matal.22leh" # TODO need to update if we ever change the default +#Feature Options +FEATURE_CONFIGURATIONS_SCREEN_TITLE_TEXT = "Feature Configurations" +FEATURE_CONFIGURATIONS_PARAMETERS_TEXTS = ["Integrated BP Cuff", "Heparin Syringe Pump", "Chemical Disinfection"] Index: suite_leahi/shared/scripts/configuration/navigation.py =================================================================== diff -u -rc7d96b722594bb29a7bbc3689715b90af6e3d616 -r8ac0eae52c22298abedaec3200ebd450888c3ac2 --- suite_leahi/shared/scripts/configuration/navigation.py (.../navigation.py) (revision c7d96b722594bb29a7bbc3689715b90af6e3d616) +++ suite_leahi/shared/scripts/configuration/navigation.py (.../navigation.py) (revision 8ac0eae52c22298abedaec3200ebd450888c3ac2) @@ -12,28 +12,52 @@ Method to navigate to "Service" screen """ td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value, 0) - settings_menu_object = utility.get_object_from_names( - names.o_Settings_Menu, - error_message="Settings menu object missing", - timeout_ms=1000, + headerbar_container = squish.waitForObject(names.o_mainMenu_MainMenu, 2000) + settings_menu_object = utility.findChildByText( + headerbar_container, "Settings" ) if settings_menu_object is not None: squish.mouseClick(settings_menu_object) - device_setting_screen_title_text = utility.get_object_from_names( - names.o_DeviceSettingsTitleText, - error_message="Device Settings Screen title text object missing", - timeout_ms=2000, + headerbar_container = squish.waitForObject(names.o_headerBar_HeaderBar, 2000) + device_setting_screen_headerbar_title_text = utility.findChildByText( + headerbar_container, "Device Settings" ) - if device_setting_screen_title_text is not None: + if device_setting_screen_headerbar_title_text is not None: test.compare( - device_setting_screen_title_text.text, + device_setting_screen_headerbar_title_text.text, config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Device Settings Screen Title text".format( config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT ), ) +def navigate_to_device_settings_using_service_password(): + td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) + grid_container = squish.waitForObject(names.o_DeviceSettingsGrid) + service_option = utility.findChildByText(grid_container, "Service") + + if service_option is not None: + squish.mouseClick(service_option) + + headerbar_container = squish.waitForObject(names.o_headerBar_HeaderBar) + service_screen_headerbar_title_text = utility.findChildByText( + headerbar_container, "Service" + ) + if service_screen_headerbar_title_text is not None: + test.compare( + service_screen_headerbar_title_text.text, + config.SERVICE_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Device Settings Screen Title text".format( + config.SERVICE_SCREEN_TITLE_TEXT + ), + ) + input_field = squish.waitForObject(names.o_userConfirmation_TextInput, 1000) + + squish.type(input_field, config.DEFAULT_SERVICE_PASSWORD_RAW) + confirm_button = squish.waitForObject(names.o_userConfirmation_ConfirmButton, 1000) + squish.mouseClick(confirm_button) + def navigation_pageIndicator_step(vStep_name): """ Navigate to the specified page using the step indicator component. @@ -45,16 +69,35 @@ """ test.startSection("Method to navigation in the pretreatment page ") + stepcount = squish.waitForObjectExists(names.o_preTreatmentStack_repeater_Repeater) + Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) + squish.mouseClick(squish.waitForObject(Nextbutton)) + autoLoadbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text ="Auto Load") + squish.mouseClick(squish.waitForObject(autoLoadbutton)) + td_simulator.td_blood_set_auto_load_response(vRejectionReason = 0) stepId = squish.waitForObjectExists(names.o_preTreatmentStack_stepIndicator_StepIndicator) values = utility.findAllObjectsById(stepId, "_text") - for index, input_field in enumerate(values[2:]): - test.log(str(index)); - test.log(str(input_field.text)) - if str(input_field.text) == vStep_name: - test.log("Reached the target step") - break - else: - Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) - squish.mouseClick(Nextbutton) + if stepcount.count == 9: + for input_field in values[3:]: + test.log(str(input_field.text)) + if str(input_field.text) == "Water Sample": + squish.mouseClick(squish.waitForObject(names.o_PreTreatmentSampleStack_button_TouchRect)) + if str(input_field.text) == vStep_name: + break + else: + Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) + squish.mouseClick(Nextbutton) + else: + for input_field in values[3:]: + test.log(str(input_field.text)) + if str(input_field.text) == "Water Sample": + squish.mouseClick(waitForObject(names.o_PreTreatmentSampleStack_button_TouchRect)) + + if str(input_field.text) == vStep_name: + break + else: + Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) + squish.mouseClick(Nextbutton) + test.endSection() \ No newline at end of file Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rc7d96b722594bb29a7bbc3689715b90af6e3d616 -r8ac0eae52c22298abedaec3200ebd450888c3ac2 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision c7d96b722594bb29a7bbc3689715b90af6e3d616) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 8ac0eae52c22298abedaec3200ebd450888c3ac2) @@ -5,10 +5,17 @@ from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates from configuration import config, navigation - -td =TD_Messaging() from leahi_dialin.ui import utils from builtins import int as pyInt + +td = TD_Messaging() + +def aut(*args): + """ + Joins the executable name and argument + into a single command string + """ + return " ".join(('leahi', *args)) def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -143,7 +150,7 @@ set_value_based_on_target(names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster,37.0) select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,config.DIALYZER_TYPE,2) set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 200) - select_different_dropdown(names.o_PreTreatment_vitalsCombobox_BaseCombobox,config.VITALS,1) + set_value_based_on_target(names.o_PreTreatmentCreate_bpMeasurementIntervalControl_ValueAdjusterCustom,5.0) select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,config.BICARBONATE,0) Validatebutton = setObjectText(obj = names.o_preTreatmentStack_Text, text =config.VALIDATE) squish.mouseClick(squish.waitForObject(Validatebutton)) @@ -163,14 +170,12 @@ vArterialPressureLimitWindowRejectReason = 0, vVenousPressureLimitWindowRejectReason = 0, vVenousPressureLimitAsymtrcRejectReason = 0, - vTransmembranePressureLimitWindowRejectReason = 0, + vTransmembranePressureLimitWindowRejectReason= 0, vDialysateTempRejectReason = 0, vHeparinDispensingRateRejectReason = 0, vHeparinBolusVolumeRejectReason = 0 ) - - confirmButton = setObjectText(obj = names.o_preTreatmentStack_Text,text = config.CONFIRM ) - squish.mouseClick(squish.waitForObject(confirmButton)) + squish.mouseClick(names.o_preTreatmentStack_confirmButton_ConfirmButton) test.endSection() def findAllObjectsById(parent, target_id): @@ -190,10 +195,6 @@ return results - - - - def set_value_with_slider(value_field_obj, slider_obj,parameter): """ Opens the slider and moves it gradually to the target value (step of 10). @@ -277,4 +278,20 @@ return squish.waitForObject(names_dict, timeout_ms).text except LookupError: test.fail("ERROR : " + error_message) - return None \ No newline at end of file + return None + +def findAllObjectsByText(parent, target_text): + """ + Recursively finds all child objects that have a 'text' property + matching the target_text. Returns a list of matches. + """ + results = [] + # Use hasattr to safely check for 'text' property before comparing + if hasattr(parent, 'text') and str(parent.text) == target_text: + results.append(parent) + + # Recurse through all children + for child in object.children(parent): + results.extend(findAllObjectsByText(child, target_text)) + + return results \ No newline at end of file Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -r0e16f6d7e1f8349a7ccf945c666f6fdab7752d16 -r8ac0eae52c22298abedaec3200ebd450888c3ac2 --- suite_leahi/shared/scripts/names.py (.../names.py) (revision 0e16f6d7e1f8349a7ccf945c666f6fdab7752d16) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision 8ac0eae52c22298abedaec3200ebd450888c3ac2) @@ -39,6 +39,8 @@ o_treatmentTimeNotificationBarSmall = {"container": mainTreatmentScreen, "objectName": "notification", "type": "NotificationBarSmall" } # settings_service_export_logs +o_mainMenu_MainMenu = {"container": o_Gui_MainView, "id": "_mainMenu", "type": "MainMenu", "unnamed": 1 } +o_headerBar_HeaderBar = {"container": o_Gui_MainView, "id": "_headerBar", "type": "HeaderBar", "unnamed": 1 } o_listView_ListView = {"container": o_Gui_MainView, "id": "_listView", "type": "ListView", "unnamed": 1 } o_listView_delegateControl = {"container": o_listView_ListView, "index": 2, "objectName": "delegateControl", "type": "Item" } o_Settings_Menu = {"container": o_listView_delegateControl, "objectName": "_touchRect2", "type": "TouchRect" } @@ -224,3 +226,21 @@ o_preTreatmentStack_Text = {"container": o_preTreatmentStack_PreTreatmentStack, "type": "Text", "unnamed": 1 } o_preTreatmentStack_stepIndicator_StepIndicator = {"container": o_preTreatmentStack_PreTreatmentStack, "id": "_stepIndicator", "type": "StepIndicator", "unnamed": 1 } +#Service +o_SettingsStack_SettingsStack = {"container": o_Gui_MainView, "objectName": "_SettingsStack", "type": "SettingsStack", } +o_UserConfirmation_SettingsServicePassword = {"container": o_SettingsStack_SettingsStack, "objectName": "UserConfirmation", "type": "SettingsServicePassword", } +o_userConfirmation_TextInput = {"container": o_UserConfirmation_SettingsServicePassword, "echoMode": 2, "id": "_input", "passwordCharacter": "•", "type": "TextInput", "unnamed": 1, } +o_userConfirmation_ConfirmButton = {"container": o_UserConfirmation_SettingsServicePassword, "objectName": "_confirmButton", "type": "ConfirmButton", } + +#Helpers +o_PreTreatmentSampleStack_PreTreatmentWaterSample = {"container": o_preTreatmentStack_PreTreatmentStack, "objectName": "_PreTreatmentSampleStack", "type": "PreTreatmentWaterSample", } +o_PreTreatmentSampleStack_button_TouchRect = {"container": o_PreTreatmentSampleStack_PreTreatmentWaterSample, "id": "_button", "type": "TouchRect", "unnamed": 1 } +o_preTreatmentStack_repeater_Repeater = {"container": o_preTreatmentStack_PreTreatmentStack, "id": "repeater", "type": "Repeater", "unnamed": 1 } + +# Feature Options +o_SettingsBase_SettingsFeatureConfigurations = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsFeatureConfigurations", } +o_SettingsBase_integratedBPCuffSwitch_BaseSwitch = {"checkable": True, "container": o_SettingsBase_SettingsFeatureConfigurations, "id": "_integratedBPCuffSwitch", "type": "BaseSwitch", "unnamed": 1 } +o_SettingsFeatureConfigurations_BackButton = {"container": o_SettingsBase_SettingsFeatureConfigurations, "objectName": "_backButton", "type": "BackButton", } +o_SettingsBase_heparinSyringePumpSwitch_BaseSwitch = {"checkable": True, "container": o_SettingsBase_SettingsFeatureConfigurations, "id": "_heparinSyringePumpSwitch", "type": "BaseSwitch", "unnamed": 1 } +o_vitalsButton_VitalsButton = {"container": o_Gui_MainView, "id": "_vitalsButton", "type": "VitalsButton", "unnamed": 1 } +o_vitalsPopup_Close_Image = {"container": o_Overlay, "id": "_image", "source": "qrc:/images/iClose", "type": "Image", "unnamed": 1 } Index: suite_leahi/tst_feature_options/test.py =================================================================== diff -u --- suite_leahi/tst_feature_options/test.py (revision 0) +++ suite_leahi/tst_feature_options/test.py (revision 8ac0eae52c22298abedaec3200ebd450888c3ac2) @@ -0,0 +1,324 @@ +# Subject/Title: Service - SW - 02 - Feature Configurations - Q&R +# +# Functionalities: Testing items of Service Feature Configurations feature +# +# Steps: +# 1 Start Leahi Application and simulate TD standby mode and navigate to the Device Settings screen +# and Navigate to Service screen, Enter Password and Click confirm Then Navigate to +# Feature Configurations Screen and compare Title Bar text, Verify the parameter under Feature Configurations screen +# Log Initial Integrated BP Cuff switch state: Unchecked and Enable it and Verify Enabled state then Click Back Button +# Navigate to Main Treatment Screen using navigate_to_main_treatment_screen_from_settings Function +# In Main Treatment Screen and Click Vitals Button and Verify that Measure Vitals button Enabled state in Vitals popup +# Close the Vitals popup and Navigate back to Feature Configurations Screen and Log Integrated BP Cuff switch state and +# Disable it and Verify Disable state then Click Back Button Navigate to Main Treatment Screen +# In Main Treatment Screen and Click Vitals Button and Verify that Measure Vitals button Enabled state in Vitals popup +# 2 Navigate back to Feature Configurations Screen and Log Initial Heparin Syringe Pump switch state: Unchecked +# Enable Switch and Verify Enabled state then Click Back Button and Navigate to Main Treatment Screen +# In Main Treatment Screen In HeaderBar Heparin is displayed and Navigate back to Feature Configurations Screen +# And Log Heparin Syringe Pump switch state and Disable it and Verify Disable state then Click Back Button +# Navigate to Main Treatment Screen In HeaderBar Heparin tab is not displayed + + +import names +from configuration import config, utility, navigation +from leahi_dialin.ui import utils +from leahi_dialin.ui.td_messaging import TD_Messaging +from leahi_dialin.common.td_defs import TDOpModes, TDTreatmentStates + +td_simulator = TD_Messaging() + + +def verify_integrated_bp_cuff_button_state(expected_state, message): + """Helper function to verify the enabled/disabled state using test.compare.""" + + overlay_container = waitForObject(names.o_Overlay, 2000) + integrated_bp_cuff_button = utility.findChildByText( + overlay_container, "Measure Vitals" + ) + current_state = integrated_bp_cuff_button.enabled + test.compare(current_state, expected_state, message) + + +def navigate_to_main_treatment_screen_from_settings(): + """Helper function to Navigate to Main Treatment screen from Device Settings""" + + main_menu_container = waitForObject(names.o_mainMenu_MainMenu, 2000) + settings_menu_object = utility.findChildByText(main_menu_container, "Treatment") + if settings_menu_object is not None: + mouseClick(settings_menu_object) + mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect, 3000)) + + td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value, 0) + td_simulator.td_operation_mode(TDOpModes.MODE_TREA.value, 0) + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) + blood_priming_screen = utility.findChildByText(headerbar_container, "Blood Priming") + if blood_priming_screen.visible: + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value,0,0,0,0,0,0,0,0,0, + ) + td_simulator.td_tx_state( + TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + + +def feature_configurations_screen(): + """Navigating to 'Feature Configurations' screen, Verifying Parameters, and Enable & Disable + Integrated BP Cuff switch and Verifying it in Main Treatment Screen""" + + test.startSection( + """Navigating to 'Feature Configurations' screen, Verifying Parameters, and Enable & Disable + Integrated BP Cuff switch & Verifying it in Main Treatment Screen """ + ) + grid_container = waitForObject(names.o_DeviceSettingsGrid) + feature_configurations_option = utility.findChildByText( + grid_container, "Feature Configurations" + ) + + if feature_configurations_option is not None: + mouseClick(feature_configurations_option) + + headerbar_container = waitForObject(names.o_headerBar_HeaderBar) + feature_configurations_title_text = utility.findChildByText( + headerbar_container, "Feature Configurations" + ) + if feature_configurations_title_text is not None: + test.compare( + feature_configurations_title_text.text, + config.FEATURE_CONFIGURATIONS_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Feature Configurations Screen Title text".format( + config.FEATURE_CONFIGURATIONS_SCREEN_TITLE_TEXT + ), + ) + + # Wait for the main grid/container + grid_container = waitForObject(names.o_SettingsBase_SettingsFeatureConfigurations) + + # Iterate through the list of expected texts from config + for ( + feature_configurations_parameter + ) in config.FEATURE_CONFIGURATIONS_PARAMETERS_TEXTS: + + # Finding any child within the container that matches this text + found_elements = utility.findAllObjectsByText( + grid_container, feature_configurations_parameter + ) + + # Verify that at least one such element was found + if found_elements: + # Take the first match found in the tree + matched_obj = found_elements[0] + + test.compare( + str(matched_obj.text), + feature_configurations_parameter, + f"'{feature_configurations_parameter}' found and verified in Feature Configurations Screen", + ) + + # Wait for the toggle Integrated BP Cuff switch object + integrated_bp_cuff_mode_switch = waitForObject( + names.o_SettingsBase_integratedBPCuffSwitch_BaseSwitch, 3000 + ) + + # Check current state and toggle Integrated BP Cuff and store the initial state + was_checked = integrated_bp_cuff_mode_switch.checked + + test.log( + f"Initial Integrated BP Cuff switch state: {'Checked' if was_checked else 'Unchecked'}" + ) + + if was_checked == config.DISABLED: + # Perform the toggle action + mouseClick(integrated_bp_cuff_mode_switch) + + # Verify the state + test.compare( + integrated_bp_cuff_mode_switch.checked, + config.ENABLED, + f"Verify Integrated BP Cuff switch is Enabled", + ) + + mouseClick(waitForObject(names.o_SettingsFeatureConfigurations_BackButton, 2000)) + main_menu_container = waitForObject(names.o_mainMenu_MainMenu, 2000) + prescriptions_menu_object = utility.findChildByText( + main_menu_container, "Prescriptions" + ) + if prescriptions_menu_object is not None: + mouseClick(prescriptions_menu_object) + td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value) + navigate_to_main_treatment_screen_from_settings() + mouseClick(waitForObjectExists(names.o_vitalsButton_VitalsButton, 2000)) + verify_integrated_bp_cuff_button_state( + config.ENABLED, "Comparison of Measure Vitals button Enabled state" + ) + mouseClick(waitForObjectExists(names.o_vitalsPopup_Close_Image, 2000)) + td_simulator.td_operation_mode(TDOpModes.MODE_INIT.value) + td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) + grid_container = waitForObject(names.o_DeviceSettingsGrid) + feature_configurations_option = utility.findChildByText( + grid_container, "Feature Configurations" + ) + + if feature_configurations_option is not None: + mouseClick(feature_configurations_option) + + # Wait for the toggle Integrated BP Cuff switch object + integrated_bp_cuff_mode_switch = waitForObject( + names.o_SettingsBase_integratedBPCuffSwitch_BaseSwitch, 3000 + ) + + # Check current state and toggle Integrated BP Cuff and store the initial state + was_checked = integrated_bp_cuff_mode_switch.checked + + test.log( + f"Integrated BP Cuff switch state: {'Checked' if was_checked else 'Unchecked'}" + ) + + if was_checked == config.ENABLED: + # Perform the toggle action + mouseClick(integrated_bp_cuff_mode_switch) + + # Verify the state + test.compare( + integrated_bp_cuff_mode_switch.checked, + config.DISABLED, + f"Verify Integrated BP Cuff switch is Disabled", + ) + mouseClick(waitForObject(names.o_SettingsFeatureConfigurations_BackButton, 2000)) + main_menu_container = waitForObject(names.o_mainMenu_MainMenu, 2000) + prescriptions_menu_object = utility.findChildByText( + main_menu_container, "Prescriptions" + ) + if prescriptions_menu_object is not None: + mouseClick(prescriptions_menu_object) + navigate_to_main_treatment_screen_from_settings() + + mouseClick(waitForObjectExists(names.o_vitalsButton_VitalsButton, 2000)) + verify_integrated_bp_cuff_button_state( + config.DISABLED, "Comparison of Measure Vitals button Disabled state" + ) + mouseClick(waitForObjectExists(names.o_vitalsPopup_Close_Image, 2000)) + td_simulator.td_operation_mode(TDOpModes.MODE_INIT.value) + td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) + test.endSection() + + +def enable_and_disable_heparin_and_verifing(): + """Enable & Disable Heparin Syringe Pump switch and Verifying it in Main Treatment Screen""" + + test.startSection( + "Enable & Disable Heparin Syringe Pump switch and Verifying it in Main Treatment Screen" + ) + grid_container = waitForObject(names.o_DeviceSettingsGrid) + feature_configurations_option = utility.findChildByText( + grid_container, "Feature Configurations" + ) + + if feature_configurations_option is not None: + mouseClick(feature_configurations_option) + + # Wait for the toggle Heparin Syringe Pump switch object + heparin_syringe_pump_mode_switch = waitForObject( + names.o_SettingsBase_heparinSyringePumpSwitch_BaseSwitch, 3000 + ) + + # Check current state and toggle Heparin Syringe Pump and store the initial state + was_checked = heparin_syringe_pump_mode_switch.checked + + test.log( + f"Initial Heparin Syringe Pump switch state: {'Checked' if was_checked else 'Unchecked'}" + ) + + if was_checked == config.DISABLED: + # Perform the toggle action + mouseClick(heparin_syringe_pump_mode_switch) + + # Verify the state + test.compare( + heparin_syringe_pump_mode_switch.checked, + config.ENABLED, + f"Verify Heparin Syringe Pump switch is Enabled", + ) + + mouseClick(waitForObject(names.o_SettingsFeatureConfigurations_BackButton, 2000)) + main_menu_container = waitForObject(names.o_mainMenu_MainMenu, 2000) + prescriptions_menu_object = utility.findChildByText( + main_menu_container, "Prescriptions" + ) + if prescriptions_menu_object is not None: + mouseClick(prescriptions_menu_object) + navigate_to_main_treatment_screen_from_settings() + + headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) + heparin_bar = utility.findChildByText(headerbar_container, "Heparin") + + if heparin_bar.visible: + test.log("In HeaderBar Heparin displayed and It is enabled") + test.compare( + heparin_bar.visible, + config.ENABLED, + f"Verify Heparin HeaderBar is Enabled and visible in screen", + ) + + td_simulator.td_operation_mode(TDOpModes.MODE_INIT.value) + td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) + grid_container = waitForObject(names.o_DeviceSettingsGrid) + feature_configurations_option = utility.findChildByText( + grid_container, "Feature Configurations" + ) + + if feature_configurations_option is not None: + mouseClick(feature_configurations_option) + + # Wait for the toggle Heparin Syringe Pump switch object + heparin_syringe_pump_mode_switch = waitForObject( + names.o_SettingsBase_heparinSyringePumpSwitch_BaseSwitch, 3000 + ) + + # Check current state and toggle Heparin Syringe Pump and store the initial state + was_checked = heparin_syringe_pump_mode_switch.checked + + test.log( + f"Heparin Syringe Pump switch state: {'Checked' if was_checked else 'Unchecked'}" + ) + + if was_checked == config.ENABLED: + # Perform the toggle action + mouseClick(heparin_syringe_pump_mode_switch) + + # Verify the state + test.compare( + heparin_syringe_pump_mode_switch.checked, + config.DISABLED, + f"Verify Heparin Syringe Pump switch is Disabled", + ) + + mouseClick(waitForObject(names.o_SettingsFeatureConfigurations_BackButton, 2000)) + main_menu_container = waitForObject(names.o_mainMenu_MainMenu, 2000) + prescriptions_menu_object = utility.findChildByText( + main_menu_container, "Prescriptions" + ) + if prescriptions_menu_object is not None: + mouseClick(prescriptions_menu_object) + navigate_to_main_treatment_screen_from_settings() + + headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) + heparin_bar = utility.findChildByText(headerbar_container, "Heparin") + if not heparin_bar.visible: + test.log("In HeaderBar Heparin is not displayed") + test.compare( + heparin_bar.visible, + config.DISABLED, + f"Verify Heparin in HeaderBar is not visible", + ) + + +def main(): + utils.tstStart(__file__) + startApplication(utility.aut("-q")) + navigation.navigate_to_device_settings_using_service_password() + feature_configurations_screen() + enable_and_disable_heparin_and_verifing() + test.endSection()