# -*- 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 dialin.ui.dg_simulator import DGSimulator from configuration import config from configuration import utility from dialin.common.dg_defs import DGHeatDisinfectStates, DGChemicalDisinfectStates, DGFlushStates from dialin.common.hd_defs import HDOpSubModes, HDOpModes 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() dg_simulator = DGSimulator() 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 @ """ 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 """ 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 """ 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 """ 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(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. """ test.startSection("Section to accept treatment response") hd_simulator.cmd_send_hd_disinfect_response(accepted = 1, reason = 0) test.endSection() def verify_disinfection_states(): 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): 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_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)) 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)) 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(): 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(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") 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(): test.startSection("Verification of Water Flush.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDOpSubModes.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") mouseClick(waitForObject(names.o_disinfectFlush_confirmButton_TouchRect)) verify_request_rejection_mode("Flush") verify_confirm_disinfect() test.endSection() def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) verify_chemical_disinfect() verify_heat_disinfect() verify_water_flush() verify_disinfection_states() utils.tstDone()