# 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_post # @author (last) Papiya Mandal # @date (last) 27-Jan-2022 # # NOTE: # This test is a demo and is intended to be used as an example on how to call the dialin API within SquishQt. import names from dialin.ui import utils from builtins import int as pyInt from dialin.ui.hd_simulator import HDSimulator from dialin.ui.dg_simulator import DGSimulator POST_ITEMS_COUNT = 20 + 1 # Python not including the last hd = HDSimulator() dg = DGSimulator() def get_progress(): """ Method to obtain progress @return: Progress value """ progress_bar = object.parent(waitForObjectExists(names.progress_bar)) progress_bar_children = object.children(progress_bar) progress_bar_val_parent = progress_bar_children[3] progress_bar_val_parents_children = object.children(progress_bar_val_parent) progress_bar_val = progress_bar_val_parents_children[1] return progress_bar_val.text.toUtf8().constData() def verify_the_progress(item) -> None: """ Method to verify the progress @param item: (int) single message post item @param is_final: (bool) if this is the final post message(True/False) """ progress = pyInt(get_progress()) test.compare(item, progress, "Single post message item {item} expected to reflect on progress bar, got {progress}" .format(item=item, progress=progress)) def verify_final_message_posted(is_passed: bool = False, is_final: bool = False) -> None: """ method to verify the indication of final message posted @param is_passed: (bool) final message result (passed,failed) @param is_final: (bool) if this is the final post message(True/False) @return: None """ if is_final == False: if object.exists(names.busy_indicator): busy_indicator = waitForObject(names.busy_indicator) test.compare(busy_indicator.enabled, True, "Waiting for a value") if is_final == True and is_passed == True: if object.exists(names.done_indicator): done_indicator = waitForObject(names.done_indicator) test.compare(done_indicator.enabled, True, "Done, Final value passed") if is_final == True and is_passed == False: if object.exists(names.fail_indicator): fail_indicator = waitForObject(names.fail_indicator) test.compare(fail_indicator.enabled, True, "Failed, Final value not passed") def post_a_message_and_verify_progress_and_completion(item: int, is_passed: bool, is_final: bool = False): """ method to post a message and verify the progress bar and @param item: (int) single message post item @param is_passed: (bool) final message result (passed,failed) @param is_final: (bool) if this is the final post message(True/False) """ hd.cmd_send_hd_post(item, is_passed, is_final) dg.cmd_send_dg_post(item, is_passed, is_final) if not is_final: verify_the_progress(item) verify_final_message_posted(is_passed, is_final) def main(): utils.tstStart(__file__) startApplication(names.AUT_NAME) hd.cmd_send_power_on_self_test_version_request() for item in range(POST_ITEMS_COUNT): post_a_message_and_verify_progress_and_completion(item, True , False) # single passed post_a_message_and_verify_progress_and_completion(item, False, False) # single failed for item in range(POST_ITEMS_COUNT): post_a_message_and_verify_progress_and_completion(item, False, True ) # Final passed post_a_message_and_verify_progress_and_completion(item, True , True ) # Final failed utils.tstDone()