Index: tst_post/test.py =================================================================== diff -u -rf8943fd4831755c59de02301e92eed5e2dc6eee5 -raec87c936c1a1a5aa06c5b18c417115e208f69ba --- tst_post/test.py (.../test.py) (revision f8943fd4831755c59de02301e92eed5e2dc6eee5) +++ tst_post/test.py (.../test.py) (revision aec87c936c1a1a5aa06c5b18c417115e208f69ba) @@ -1,100 +1,44 @@ +# -*- 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_post -# @author (last) Papiya Mandal -# @date (last) 27-Jan-2022 +# date 2020/12/27 +# author Behrouz NematiPour # # 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 time import sleep from dialin.ui import utils from dialin.ui import unittests from dialin.ui.hd_simulator import HDSimulator -MSGS_AND_CONDITIONS = { 5: [True, False], 10: [True, False], 2: [True, False], - 18: [True, True], 7: [False, True], - } - -hd = HDSimulator() - -def verify_the_progress(value, final_msg_posted) -> None: - """ - Method to verify the progress - @param value: int single message - """ - progress = pyInt(get_progress())-1 - if final_msg_posted is True: - assertion.are_not_equal(expected_value=value, - actual_value=progress, - message=f"Final value {value} should " + - "not reflect on the progress bar") - elif final_msg_posted is False: - assertion.are_equal(expected_value=value, - actual_value=progress, - message=f"{value} should reflect "+ - "on progress bar") - - -def post_a_message_and_verify_progress_and_completion(msgs_and_conditions): - """ - method to post a message and verify the progress bar and - if final message is posted - """ - for msg, conditions in msgs_and_conditions.items(): - final_msg = conditions[0] - final_msg_posted = conditions[1] - hd.cmd_send_hd_post(msg, final_msg, final_msg_posted) - snooze(2) - verify_the_progress(value=msg, final_msg_posted=final_msg_posted) - verify_final_message_posted(final_msg=final_msg, final_msg_posted=final_msg_posted) - - -def verify_final_message_posted(final_msg=None, final_msg_posted=None) -> None: - """ - method to verify the indication of final - message posted - @param final_msg: bool final message(True/False) - @param final_msg_posted: bool if this is the final post message(True/False) - @return: None - """ - test.startSection("Verifying the status") - if final_msg == True and final_msg_posted == True: - - if object.exists(names.done_indicator): - done_indicator = waitForObject(names.done_indicator) - test.compare(done_indicator.enabled, True, "Done, Final value passed") - - elif (final_msg == False and final_msg_posted == True) \ - or (final_msg == False and final_msg_posted == False): - - if object.exists(names.fail_indicator): - fail_indicator = waitForObject(names.fail_indicator) - test.compare(fail_indicator.enabled, True, "Failed, Final value not passed") - - elif (final_msg == True and final_msg_posted == False): - - if object.exists(names.busy_indicator): - busy_indicator = waitForObject(names.busy_indicator) - test.compare(busy_indicator.enabled, True, "Waiting for a value") - test.endSection() - - def main(): - - utils.tstStart("tst_post") + utils.tstStart("demo") startApplication("denaliSquish") + hd = HDSimulator() + + hd.cmd_send_power_on_self_test_version_request() - post_a_message_and_verify_progress_and_completion(MSGS_AND_CONDITIONS) + for i in range(20): + hd.cmd_send_hd_post(i, True, False) + sleep(0.1) + hd.cmd_send_hd_post(0, True, True) + hd.cmd_send_hd_operation_mode(4, 0) + unittests.test_python_version() + unittests.test_crc8() + unittests.test_can0() + utils.tstDone() +