Index: shared/scripts/configuration/utility.py =================================================================== diff -u -re3c3fa195b5f07e20c1e9a274e55a834dcd093a9 -r549e92960cbce36d7be3fc981fd41d99bf73e016 --- shared/scripts/configuration/utility.py (.../utility.py) (revision e3c3fa195b5f07e20c1e9a274e55a834dcd093a9) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 549e92960cbce36d7be3fc981fd41d99bf73e016) @@ -137,74 +137,4 @@ raise LookupError("zone object is not in view to the user after " + \ "trying 100 times") - - -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(value) -> None: - """ - Method to verify the progress - @param value: int single message - """ - progress = pyInt(get_progress()) - test.compare(progress-1, value, - f"Single value {value} is updated in 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 - """ - item = 0 - 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) - if item < (len(msgs_and_conditions)-1): - verify_the_progress(value=msg) - verify_final_message_posted(final_msg=final_msg, final_msg_posted=final_msg_posted) - item += 1 - else: - test.log("Final message won't posted on progress bar") - 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 - """ - 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") + \ No newline at end of file Index: shared/scripts/names.py =================================================================== diff -u -rac1a9cbe15494e819b721e40626dc066d5b70a7a -r549e92960cbce36d7be3fc981fd41d99bf73e016 --- shared/scripts/names.py (.../names.py) (revision ac1a9cbe15494e819b721e40626dc066d5b70a7a) +++ shared/scripts/names.py (.../names.py) (revision 549e92960cbce36d7be3fc981fd41d99bf73e016) @@ -62,4 +62,4 @@ busy_indicator = {"container": o_initialModeScreen_ScreenItem, "id": "_busyIndicator", "source": "qrc:/images/iBusy", "type": "Image", "unnamed": 1, "visible": True} done_indicator = {"container": o_initialModeScreen_ScreenItem, "id": "_checkIndicator", "source": "qrc:/images/iBusyDone", "type": "Image", "unnamed": 1, "visible": True} fail_indicator = {"container": o_initialModeScreen_ScreenItem, "id": "_checkIndicator", "source": "qrc:/images/iBusyFail", "type": "Image", "unnamed": 1, "visible": True} -progress_bar = {"container": o_initialModeScreen_ScreenItem, "id": "_textMaximum", "type": "Text", "unnamed": 1, "visible": False} +progress_bar = {"container": o_initialModeScreen_ScreenItem, "id": "_textMaximum", "type": "Text", "unnamed": 1, "visible": False} \ No newline at end of file Index: suite.conf =================================================================== diff -u -r5900c4bf715431eaa6acb03a6a4963bd8918f987 -r549e92960cbce36d7be3fc981fd41d99bf73e016 --- suite.conf (.../suite.conf) (revision 5900c4bf715431eaa6acb03a6a4963bd8918f987) +++ suite.conf (.../suite.conf) (revision 549e92960cbce36d7be3fc981fd41d99bf73e016) @@ -1,6 +1,6 @@ AUT=denaliSquish LANGUAGE=Python OBJECTMAPSTYLE=script -TEST_CASES=tst_post_failure tst_patientID_UI tst_standbymode tst_pre_treatment tst_case2 tst_post_done +TEST_CASES=tst_patientID_UI tst_standbymode tst_pre_treatment tst_case2 tst_post VERSION=3 WRAPPERS=Qt Index: tst_post/test.py =================================================================== diff -u -r8d2a8febaa162cfabc7fff3807d4ec8618b37016 -r549e92960cbce36d7be3fc981fd41d99bf73e016 --- tst_post/test.py (.../test.py) (revision 8d2a8febaa162cfabc7fff3807d4ec8618b37016) +++ tst_post/test.py (.../test.py) (revision 549e92960cbce36d7be3fc981fd41d99bf73e016) @@ -1,67 +1,113 @@ -# -*- 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 -# date 2020/12/27 -# author Behrouz NematiPour +# @author (last) Papiya Mandal, Sai Chaitainya Ela +# @date (last) 21-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 time import sleep from dialin.ui import utils -from dialin.ui import unittests +# from dialin.ui import unittests +from builtins import int as pyInt +from configuration.utility import * from dialin.ui.hd_simulator import HDSimulator # from dialin.ui.dg_simulator import DGSimulator # from dialin.ui.hd_simulator_alarms import HDAlarmsSimulator -ITEM_INDICES = [5, 10, 2, 15, 8, 19, 11, 20] +MSGS_AND_CONDITIONS = { 5: [True, False], 10: [True, False], 2: [True, False], + 18: [True, True], 7: [False, True], + } + +hd = HDSimulator() +#dg = DGSimulator() - -def main(): +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() - utils.tstStart("demo") - startApplication("denaliSquish") - hd = HDSimulator() - #dg = DGSimulator() - - hd.cmd_send_power_on_self_test_version_request() - hd.cmd_send_hd_operation_mode(0, 0) +def verify_the_progress(value) -> None: + """ + Method to verify the progress + @param value: int single message + """ + progress = pyInt(get_progress()) + test.compare(progress-1, value, + f"Single value {value} is updated in Progress bar") -def post_a_message_and_verify_progress_and_completion(): - - for index in ITEM_INDICES: - hd.cmd_send_hd_post(index, False, True) +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) + if final_msg_posted != True: + verify_the_progress(value=msg) + verify_final_message_posted(final_msg=final_msg, final_msg_posted=final_msg_posted) + else: + test.log("Final message won't posted on progress bar") + verify_final_message_posted(final_msg=final_msg, final_msg_posted=final_msg_posted) -def verify_progress_and_completion_upon_sending_the_message(final_msg=None, done=None) -> None: +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(): - - - -# for i in range(20): -# hd.cmd_send_hd_post(i, True, False) -# snooze(0.1) -# hd.cmd_send_hd_post(0, True, True) -# -# -# unittests.test_python_version() -# unittests.test_crc8() -# unittests.test_can0() + utils.tstStart("tst_post_done") + startApplication("denaliSquish") + hd.cmd_send_power_on_self_test_version_request() + post_a_message_and_verify_progress_and_completion(MSGS_AND_CONDITIONS) + utils.tstDone() -