# -*- coding: utf-8 -*-" import names from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from dialin.ui.dg_simulator import DGSimulator from configuration import config from configuration import utility from dialin.utils.conversions import integer_to_bytearray, float_to_bytearray, short_to_bytearray, unsigned_integer_to_bytearray, integer_to_bit_array, unsigned_short_to_bytearray, unsigned_byte_to_bytearray, unsigned_byte_to_bytearray from dialin.common.hd_defs import HDOpModes, HDOpSubModes from dateutil.tz._common import ZERO hd_simulator = HDSimulator() dg_simulator = DGSimulator() def verify_right_navigation_for_chemical_disinfection(num_of_instructions): """ The method is used to verify the functionality of the right arrow in the disinfection navigation, as well as the visibility of the two arrows """ test.startSection("Rightward navigation") test.verify(not object.exists(names.o_disinfectChemical_leftImage_Image), "The left navigation arrow should not be present on the first screen of instruction") child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) for indicator in range(num_of_instructions): if child[indicator].id != "_tailStepsRepeater": verify_bullet_navigation(num_of_instructions, indicator) if not object.exists(names.o_disinfectChemical_rightImage_Image): test.log("The right navigation arrow should not be present on the last screen of instruction") break mouseClick(waitForObject(names.o_disinfectChemical_rightImage_Image)) test.endSection() def verify_left_navigation_for_chemical_disinfection(num_of_instructions): """ The method is used to verify the functionality of the left arrow in the instruction navigation, as well as the visibility of the two arrows """ test.startSection("Leftward instruction navigation") test.verify(not object.exists(names.o_disinfectChemical_rightImage_Image), "The right navigation arrow should not be present on the last screen of instruction") child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) for indicator in range(num_of_instructions, -1, -1): if child[indicator].id != "_tailStepsRepeater": verify_bullet_navigation(num_of_instructions, indicator) if not object.exists(names.o_disinfectChemical_leftImage_Image): test.log("The left navigation arrow should not be present on the last screen of instruction") break mouseClick(waitForObject(names.o_disinfectChemical_leftImage_Image)) test.endSection() def verify_bullet_navigation(num_of_instructions, indicator): """ This method verifies the properties of the bullets present in the instruction navigation screen """ test.startSection("Instruction bullet verification for screens " + str(indicator)) child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) for instruction in range(num_of_instructions): if child[instruction].id == "_tailStepsRepeater": continue bullet_children = object.children(child[instruction]) bullet_circle_color = bullet_children[0].color.name bullet_border_color = bullet_children[0].border.color.name if instruction <= indicator: test.compare(bullet_circle_color, config.COMPLETE_COLOR) test.log("The bullet " + str(instruction+1) + " must be a complete bullet") else: test.compare(bullet_circle_color, config.INCOMPLETE_COLOR) test.compare(bullet_border_color,config.CURRENT_COLOR) test.log("The bullet " + str(instruction+1) + " must be a incomplete bullet") test.endSection() def verify_request_rejection_mode(): """ Method to verify rejection mode of create custom treatment """ test.startSection("Section to verify rejection mode of create custom treatment") for rejection in range(1, config.NUM_OF_REQUEST_REJECT_REASONS + 1): hd_simulator.cmd_send_hd_disinfect_response(accepted = 0, reason = rejection) rejection_message = waitForObjectExists(names.o_disinfectChemical_NotificationBar_NotificationBar) test.compare(rejection_message.text, config.REJECTION_REASON[rejection], "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection])) test.endSection() def verify_confirm_disinfect(): """ Method to accept treatment response. """ test.startSection("Section to accept treatment response") hd_simulator.cmd_send_hd_disinfect_response(accepted = 1, reason = 0) def verify_disinfection_states(): hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 0, flush_mode = 0, heat_mode = 0, chemical_mode = 1) def get_dynamic_bullet_count(): chemical_disinfect_count = 0 child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) for dynamic_indicator_count in range (len(child)): if child[dynamic_indicator_count].id != "_tailStepsRepeater": chemical_disinfect_count+=1 if chemical_disinfect_count != 0: return chemical_disinfect_count def verify_chemical_disinfect(): test.startSection("Verification of chemical disinfection.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDOpSubModes.STANDBY_WAIT_FOR_DISINFECT_STATE.value) mouseClick(waitForObject(names.o_disinfectHome_Chemical_Disinfect)) test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect text should be visible") test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect indicator should be visible") test.verify(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).font.bold, "Chemical disinfect text from page step indicator should be bold") test.compare(waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).text, config.DISINFECT_TEXT, "Disinfection text should be visible") test.verify(not waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).font.bold, "disinfect text from page step indicator should not be bold") test.log("verification of instruction navigation from chemical disinfection.") list_of_bullets = get_dynamic_bullet_count() test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must not be active") verify_right_navigation_for_chemical_disinfection(list_of_bullets) test.verify(waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must be active") verify_left_navigation_for_chemical_disinfection(list_of_bullets) test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled ,"confirm button must not be active") for right_arrow in range(list_of_bullets-1): mouseClick(waitForObject(names.o_disinfectChemical_rightImage_Image)) test.log("user clicked on tight image arrow for the iteration -> "+str(right_arrow)) mouseClick(waitForObject(names.o_disinfectChemical_confirmButton_TouchRect)) verify_request_rejection_mode() verify_confirm_disinfect() mouseClick(waitForObject(names.o_disinfectChemical_back_navigation)) test.endSection() def verify_heat_disinfect(): test.startSection("Verification of heat disinfection.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDOpSubModes.STANDBY_WAIT_FOR_DISINFECT_STATE.value) mouseClick(waitForObject(names.o_disinfectHome_Heat_Disinfect)) utility.verify_page_step_indicator_for_disinfect(config.DISINFECT_TREATMENT_ID, 1, config.HEAT_DISINFECT_TREATMENT_SCREENS) test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect text should be visible") test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect indicator should be visible") test.verify(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).font.bold, "Chemical disinfect text from page step indicator should be bold") test.compare(waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).text, config.DISINFECT_TEXT, "Disinfection text should be visible") test.verify(not waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).font.bold, "disinfect text from page step indicator should not be bold") test.log("verification of instruction navigation from chemical disinfection.") list_of_bullets = get_dynamic_bullet_count() test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must not be active") verify_right_navigation_for_chemical_disinfection(list_of_bullets) test.verify(waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must be active") verify_left_navigation_for_chemical_disinfection(list_of_bullets) test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled ,"confirm button must not be active") for right_arrow in range(list_of_bullets-1): mouseClick(waitForObject(names.o_disinfectChemical_rightImage_Image)) test.log("user clicked on tight image arrow for the iteration -> "+str(right_arrow)) mouseClick(waitForObject(names.o_disinfectChemical_confirmButton_TouchRect)) verify_request_rejection_mode() verify_confirm_disinfect() test.endSection() def verify_water_flush(): pass def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) #verify_disinfection_states() verify_chemical_disinfect() verify_heat_disinfect() verify_water_flush() """ hd_simulator.cmd_send_hd_disinfection_state(self, sub_mode: int, flush_mode: int, heat_mode: int,chemical_mode: int) hd_simulator.cmd_send_hd_disinfect_response(self, accepted: bool, reason: int) hd_simulator.cmd_send_hd_disinfect_chemical_confirm(self, accepted: bool, reason: int) dg_simulator.cmd_send_dg_disinfect_progress_time_flush(self, total: int, countdown: int) dg_simulator.cmd_send_dg_disinfect_progress_time_heat(self, total: int, countdown: int) # hd_simulator.cmd_send_hd_disinfect_response(accepted = True, reason =1) #payload = integer_to_bytearray(1) #payload += unsigned_integer_to_bytearray(4) #hd_simulator.cmd_send_hd_general_response(message_id=155, accepted=1, reason=1, is_pure_data=False, has_parameters=True, parameters_payload=payload) snooze(5) #hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 0, flush_mode = 0, heat_mode = 0, chemical_mode = 1) #snooze(5) #dg_simulator.cmd_send_dg_disinfect_progress_time_flush(total = 120, countdown = 45) """ utils.waitForGUI(2) utils.tstDone()