# -*- 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_In_treatment # date 2020/08/24 # author Joseph Varghese # # NOTE: # This test contradicts verification of Disinfection from Application UI # section import names from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from configuration import config from configuration import utility from dialin.common.dg_defs import DGHeatDisinfectStates, DGChemicalDisinfectStates, DGFlushStates from dialin.utils.conversions import integer_to_bytearray, unsigned_integer_to_bytearray from dialin.common.hd_defs import HDStandbyStates, HDOpModes from posix import utime DISINFECT_TREATMENT_OBJECT = { "Chemical" : names.o_DisinfectStack_disinfectChemical_TreatmentFlowBase, "Heat" : names.o_DisinfectStack_disinfectHeat_TreatmentFlowBase, "Flush" : names.o_DisinfectStack_disinfectFlush_TreatmentFlowBase } DISINFECT_NOTIFICATION_OBJECT = { "Chemical" : names.o_disinfectChemical_NotificationBar_NotificationBar, "Heat" : names.o_disinfectHeat_NotificationBar_NotificationBar, "Flush" : names.o_disinfectFlush_NotificationBar_NotificationBar } hd_simulator = HDSimulator() def verify_right_navigation_for_chemical_disinfection(num_of_instructions, indicator_object, left_arrow_object, right_arrow_object): """ 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 @param num_of_instructions (Int): Number of training screen - (it is dynamically figuring from Application) @param indicator_object (Dict): page step indicator object @param left_arrow_object (Dict): Object of left arrow from disinfection type @param right_arrow_object (Dict): Object of right arrow from disinfection type @returns : None """ test.startSection("Rightward navigation") test.verify(not object.exists(left_arrow_object), "The left navigation arrow should not be present on the first screen of instruction") child = object.children(waitForObject(indicator_object)) for indicator in range(num_of_instructions): if child[indicator].id != "_tailStepsRepeater": verify_bullet_navigation(num_of_instructions, indicator, indicator_object) if not object.exists(right_arrow_object): test.log("The right navigation arrow should not be present on the last screen of instruction") break mouseClick(waitForObject(right_arrow_object)) test.endSection() def verify_left_navigation_for_chemical_disinfection(num_of_instructions, indicator_object, left_arrow_object, right_arrow_object): """ 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 @param num_of_instructions (Int): Number of training screen - (it is dynamically figuring from Application) @param indicator_object (Dict): page step indicator object @param left_arrow_object (Dict): Object of left arrow from disinfection type @param right_arrow_object (Dict): Object of right arrow from disinfection type @returns : None """ test.startSection("Leftward instruction navigation") test.verify(not object.exists(right_arrow_object), "The right navigation arrow should not be present on the last screen of instruction") child = object.children(waitForObject(indicator_object)) for indicator in range(num_of_instructions, -1, -1): if child[indicator].id != "_tailStepsRepeater": verify_bullet_navigation(num_of_instructions, indicator, indicator_object) if not object.exists(left_arrow_object): test.log("The left navigation arrow should not be present on the last screen of instruction") break mouseClick(waitForObject(left_arrow_object)) test.endSection() def verify_bullet_navigation(num_of_instructions, indicator, indicator_object): """ This method verifies the properties of the bullets present in the instruction navigation screen. @param num_of_instructions (Int): Number of training screen - (it is dynamically figuring from Application) @param indicator_object (Dict): page step indicator(bullet) object @param indicator (Int): Current position index of indicator @returns : None """ test.startSection("Instruction bullet verification for screens " + str(indicator)) child = object.children(waitForObject(indicator_object)) 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(item): """ Method to verify rejection mode of create custom treatment. @param item (String): Disinfection type -(Flush,Heat or Chemical) @return: None """ 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) utils.waitForGUI(0.2) rejection_message = waitForObjectExists(DISINFECT_NOTIFICATION_OBJECT[item]) 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. @param : None @return: None """ test.log("Section to accept treatment response") hd_simulator.cmd_send_hd_disinfect_response(accepted = 1, reason = 0) def verify_disinfection_states(): """ Method to verify Disinfection Home page. This test covers the disinfection states. @param : None @return: None """ test.startSection("Section to verifies disinfection states") hd_simulator.cmd_send_hd_operation_mode(op_mode = 3, sub_mode = 1) standby_status = waitForObjectExists(names.o_MainHome_NotificationBar_NotificationBar) test.verify(standby_status.enabled, "Standby page should be displayed.") hd_simulator.cmd_send_hd_operation_mode(op_mode = 3, sub_mode = 2) test.log("verification of instruction navigation from Disinfection.") list_of_bullets = get_dynamic_bullet_count(names.o_disinfectHome_gridSteps_Grid) verify_right_navigation_for_chemical_disinfection(list_of_bullets, names.o_disinfectHome_gridSteps_Grid, names.o_disinfectHome_leftImage_Image, names.o_disinfectHome_rightImage_Image) verify_left_navigation_for_chemical_disinfection(list_of_bullets, names.o_disinfectHome_gridSteps_Grid, names.o_disinfectHome_leftImage_Image, names.o_disinfectHome_rightImage_Image) #NB: Disinfection states are yet to be added - Future development #verification of chemical disinfection states for chemical_mode_state in range(DGChemicalDisinfectStates.NUM_OF_DG_CHEM_DISINFECT_STATES.value): hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 1, flush_mode = 0, heat_mode = 0, chemical_mode = chemical_mode_state) #verification of heat disinfection states for heat_mode_state in range(DGHeatDisinfectStates.NUM_OF_DG_HEAT_DISINFECT_STATES.value): hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 1, flush_mode = 0, heat_mode = heat_mode_state, chemical_mode = 0) #verification of flush disinfection states for flush_mode_state in range(DGFlushStates.NUM_OF_DG_FLUSH_STATES.value): hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 1, flush_mode = flush_mode_state, heat_mode = 0, chemical_mode = chemical_mode_state) test.compare(waitForObjectExists(names.o_disinfectHome_Disinfection_Text).text, config.DISINFECT_TEXT, "Disinfection text is verified !") test.endSection() def get_dynamic_bullet_count(bullet_object): """ Method to get indicator count dynamically from application. @param bullet_object (Dict): Object of disinfection type. @return chemical_disinfect_count (Int): Number of page step indicator. """ chemical_disinfect_count = 0 child = object.children(waitForObject(bullet_object)) 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_disinfection_from_settings_path(): """ Method to verify Disinfection from Settings Path. @param : None @return: None """ test.startSection("Verification of Disinfection from settings path.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDStandbyStates.STANDBY_WAIT_FOR_TREATMENT_STATE.value) mouseClick(waitForObject(names.o_touchRect2_TouchRect)) test.log("User is navigated to DG Cleaning from settings") mouseClick(waitForObject(names.o_SettingsHome_DG_cleaning_button)) test.startSection("Section to verify rejection mode message from settings DG cleaning.") for rejection in range(1, config.NUM_OF_REQUEST_REJECT_REASONS + 1): hd_simulator.cmd_send_hd_general_response(message_id=155, accepted=0, reason=rejection, is_pure_data=False, has_parameters=False) utils.waitForGUI(0.1) rejection_message = waitForObjectExists(names.o_SettingsBase_NotificationBar_NotificationBarSmall) test.compare(rejection_message.text, config.REJECTION_REASON[rejection], "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection])) test.endSection() hd_simulator.cmd_send_hd_general_response(message_id=155, accepted=1, reason=0) test.log("verified DG cleaning acceptance condition.") mouseClick(waitForObject(names.o_SettingsBase_TouchRect)) test.log("User clicked on 'DG Cleaning' button -> Message ID : 154") mouseClick(waitForObject(names.o_SettingsBase_image_Image)) hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDStandbyStates.STANDBY_WAIT_FOR_DISINFECT_STATE.value) utils.waitForGUI(1) test.compare(waitForObject(names.o_disinfectHome_backButton_BackButton).text.text, config.BACK_TEXT, "Message : 154 is verified from UI to HD") mouseClick(waitForObject(names.o_disinfectHome_backButton_BackButton)) test.endSection() def verify_chemical_disinfect(): """ Method to verify Chemical Disinfect from Disinfection. @param : None @return: None """ test.startSection("Verification of chemical disinfection.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDStandbyStates.STANDBY_WAIT_FOR_DISINFECT_STATE.value) mouseClick(waitForObject(names.o_disinfectHome_Chemical_Disinfect)) utility.verify_page_step_indicator_for_disinfect(DISINFECT_TREATMENT_OBJECT['Chemical'], config.DISINFECT_TREATMENT_ID, 1, config.CHEMICAL_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.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(names.o_disinfectChemical_gridSteps_Grid) 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, names.o_disinfectChemical_gridSteps_Grid, names.o_disinfectChemical_leftImage_Image, names.o_disinfectChemical_rightImage_Image) test.verify(waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must be active") verify_left_navigation_for_chemical_disinfection(list_of_bullets, names.o_disinfectChemical_gridSteps_Grid, names.o_disinfectChemical_leftImage_Image, names.o_disinfectChemical_rightImage_Image) 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 right image arrow for the navigation -> "+str(right_arrow)) test.log("Verification of confirm button - Message : 127") mouseClick(waitForObject(names.o_disinfectChemical_confirmButton_TouchRect)) verify_request_rejection_mode("Chemical") verify_confirm_disinfect() mouseClick(waitForObject(names.o_disinfectChemical_back_navigation)) test.endSection() def verify_heat_disinfect(): """ Method to verify Heat Disinfect from Disinfection. @param : None @return: None """ test.startSection("Verification of heat disinfection.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDStandbyStates.STANDBY_WAIT_FOR_DISINFECT_STATE.value) mouseClick(waitForObject(names.o_disinfectHome_Heat_Disinfect)) utility.verify_page_step_indicator_for_disinfect(DISINFECT_TREATMENT_OBJECT['Heat'],config.DISINFECT_TREATMENT_ID, 1, config.HEAT_DISINFECT_TREATMENT_SCREENS) test.compare(waitForObjectExists(names.o_disinfectHeat_Heat_Disinfect_Text).text, config.HEAT_DISINFECT_TEXT, "Heat disinfect text should be visible") test.compare(waitForObjectExists(names.o_disinfectHeat_nextStepsBullet_StepBullet).text, config.HEAT_DISINFECT_TEXT, "Chemical disinfect indicator should be visible") test.compare(waitForObjectExists(names.o_disinfectHeat_headStepBullet_StepBullet).text, config.DISINFECT_TEXT, "Disinfection text should be visible") test.verify(waitForObjectExists(names.o_disinfectHeat_confirmButton_TouchRect).enabled, "confirm button must be active") test.log("Verification of confirm button - Message : 127") mouseClick(waitForObject(names.o_disinfectHeat_confirmButton_TouchRect)) verify_request_rejection_mode("Heat") verify_confirm_disinfect() mouseClick(waitForObject(names.o_disinfectHeat_backButton_BackButton)) test.endSection() def verify_water_flush(): """ Method to verify water Flush from Disinfection. @param : None @return: None """ test.startSection("Verification of Water Flush.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDStandbyStates.STANDBY_WAIT_FOR_DISINFECT_STATE.value) mouseClick(waitForObject(names.o_disinfectHome_TouchRect)) utility.verify_page_step_indicator_for_disinfect(DISINFECT_TREATMENT_OBJECT['Flush'],config.DISINFECT_TREATMENT_ID, 1, config.FLUSH_DISINFECT_TREATMENT_SCREENS) test.compare(waitForObjectExists(names.o_disinfectFlush_Water_Flush_Text).text, config.FLUSH_DISINFECT_TEXT, "Flush disinfect text should be visible") test.compare(waitForObjectExists(names.o_disinfectFlush_nextStepsBullet_StepBullet).text, config.FLUSH_DISINFECT_TEXT, "Flush disinfect indicator should be visible") test.compare(waitForObjectExists(names.o_disinfectFlush_headStepBullet_StepBullet).text, config.DISINFECT_TEXT, "Disinfection text should be visible") test.verify(waitForObjectExists(names.o_disinfectFlush_confirmButton_TouchRect).enabled, "confirm button must be active") test.log("Verification of confirm button - Message : 127") mouseClick(waitForObject(names.o_disinfectFlush_confirmButton_TouchRect)) verify_request_rejection_mode("Flush") verify_confirm_disinfect() mouseClick(waitForObject(names.o_disinfectFlush_backButton_BackButton)) test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) verify_chemical_disinfect() verify_heat_disinfect() verify_water_flush() # TODO need to figure out and add back # verify_disinfection_states() # verify_disinfection_from_settings_path() utils.tstDone()