Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r0d29de114c4155f07fc8c2d1c83544643a18a334 -r1da2d466f9f2501f10fd623cd48f3ae13e7c1faa --- shared/scripts/configuration/utility.py (.../utility.py) (revision 0d29de114c4155f07fc8c2d1c83544643a18a334) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 1da2d466f9f2501f10fd623cd48f3ae13e7c1faa) @@ -18,8 +18,13 @@ import squish from configuration import config from builtins import int as pyInt +import object +import time +from configuration.config import * + + def start_application(app_name): """ Function to start application and verify application status [running] @@ -132,4 +137,92 @@ except LookupError as _: test.passes("object is not present as expected") - squish.testSettings.objectNotFoundDebugging = True \ No newline at end of file + squish.testSettings.objectNotFoundDebugging = True + +def verify_countdown(screen_title, time_out, hd_simulator, dg_simulator): + """ + Method to verify the count down + time in application + @param screen_title - (str) current title of the screen + @param time_out - (int) time out duration in secs + @Param hd_simulator - Instance of class HDSimulator + @Param dg_simulator - Instance of class DGSimulator + """ + test.startSection("Verify the count down time in application") + for count_down in range(COUNT_DOWN_TIME_100, MINIMUM_COUNTDOWN_TIME-1, -1): + if screen_title == BEGIN_PRIME_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(time_out, count_down) + elif screen_title == PRIMING_TITLE: + hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(time_out, count_down) + elif screen_title == SYSTEM_SELF_TEST_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_no_cartridge_progress_data(time_out, count_down) + else: + dg_simulator.cmd_send_dg_pre_treatment_filter_flush_progress_data(time_out, count_down) + actual_time = get_time(screen_title) + expected_time = convert_seconds_into_min_and_sec(count_down) + test.compare(actual_time, expected_time, "Actual count down time: {} should be equal to expected count down time {}".format(actual_time, expected_time)) + verify_the_progress(count_down, screen_title, time_out) + test.endSection() + +def convert_seconds_into_min_and_sec(seconds): + min = time.strftime("%M", time.gmtime(seconds)) + sec = time.strftime("%S", time.gmtime(seconds)) + return min,sec + + + +def get_time(screen_title): + """ + Method to return the current count down + in the application + @param screen_title - (str) current title of the screen + """ + progress_circle_index = 4 + if screen_title == BEGIN_PRIME_TITLE or screen_title == PRIMING_TITLE: + parent_object = object.parent(squish.waitForObjectExists(self_test_dry_check_list_text(screen_title))) + elif screen_title == SYSTEM_SELF_TEST_TITLE: + parent_object = object.parent(squish.waitForObjectExists(names.o_system_self_test)) + else: + parent_object = object.parent(squish.waitForObjectExists(names.o_rinseack_title)) + progress_circle_index = 10 + time_parent_children = object.children(parent_object) + test.log(str(time_parent_children)) + progress_circle_parent = time_parent_children[progress_circle_index] + progress_circle_parent = object.children(progress_circle_parent) + test.log(str(progress_circle_parent)) + progress_circle_parent = progress_circle_parent[0] + test.log(str(progress_circle_parent)) + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_children = object.children(progress_circle_parent[0]) + test.log(str(progress_circle_children)) + time_text = progress_circle_children[0] + test.log(str(time_text)) + return time_text.time + + + +def verify_the_progress(count_down, screen_title, time_out): + """ + Method to verify the current progress + @param count_down - (int) current count down time + @param screen_title - (str) current title of the screen + @param time_out - (int) time out duration in secs + """ + test.startSection("Verifying the current progress") + if screen_title == BEGIN_PRIME_TITLE or screen_title == PRIMING_TITLE: + current_progress = (squish.waitForObjectExists(names.o_self_test_dry_progress)).progressValue + elif screen_title == SYSTEM_SELF_TEST_TITLE: + current_progress = (squish.waitForObjectExists(names.o_system_self_test_progress)).progressValue + else: + current_progress = (squish.waitForObjectExists(names.o_rinseback_setup_progress)).progressValue + #Since progress value is equal maximum count down value - current count down value + expected_progress = time_out - count_down + test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + test.endSection() + + + + + + + \ No newline at end of file