Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r5fc2cf1333ef13de0a5b547e8b029f664b263941 -r262cc42e2b0a0044bc0c698249b0da502a31766f --- shared/scripts/configuration/utility.py (.../utility.py) (revision 5fc2cf1333ef13de0a5b547e8b029f664b263941) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 262cc42e2b0a0044bc0c698249b0da502a31766f) @@ -12,56 +12,19 @@ # ############################################################################ +import object import names import sys import time import test import squish -from configuration import config +from configuration.config import * from builtins import int as pyInt from dialin.ui.hd_simulator import HDSimulator -from cgitb import text hd_simulator = HDSimulator() -def start_application(app_name): - """ - Function to start application and verify application status [running] - If application does not start or running status is false, test stops - Argument: - @param app_name : (str) - Name of the application - @param app_executable : (str) - Actual application - @return: handle for the application if the application is in running state, - or error (exist the application) - """ - counter = 0 - while True: - try: - counter += 1 - test.log("Starting {}".format(app_name)) - squish.startApplication(app_name) - if counter == 1: - test.log("Application launched at the "+str(counter)+" st try.") - elif counter == 2: - test.log("Application launched at the "+str(counter)+" nd try.") - elif counter == 3: - test.log("Application launched at the "+str(counter)+" rd try.") - else: - test.log("Application launched at the "+str(counter)+" th try.") - break - except RuntimeError: - if counter == 1: - test.log("Application failed to launch after "+str(counter)+" try - Please refer logs") - elif counter == 20: - test.log("Exiting after "+str(counter)+ " tries..") - sys.exit(1) - else: - test.log("Application failed to launch after "+str(counter)+ " tries - Please refer logs") - except: - logErrorDetails("Failed to start the application") - sys.exit(1) - - + def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container @@ -133,4 +96,62 @@ def self_test_dry_check_list_text(text): names.o_self_test_dry_check_list_text["text"] = text - return names.o_self_test_dry_check_list_text \ No newline at end of file + return names.o_self_test_dry_check_list_text + +def get_time(screen_title): + """ + Method to return the current count down + in the application + @param screen_title - (str) current title of the screen + @return time_text - (str) count down in the application + """ + 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))) + else: + parent_object = object.parent(squish.waitForObjectExists(system_self_test(screen_title))) + time_parent_children = object.children(parent_object) + progress_circle_parent = time_parent_children[4] + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_parent = progress_circle_parent[0] + progress_circle_parent = object.children(progress_circle_parent) + progress_circle_children = object.children(progress_circle_parent[0]) + time_text = progress_circle_children[1] + return time_text.time + + +def verify_the_countdown(screen_title): + """ + Method to verify the count down + time in application + @param screen_title - (str) current title of the screen + """ + test.startSection("Verify the count down time in application") + for count_down in range(MAXIMUM_COUNTDOWN_TIME, MINIMUM_COUNTDOWN_TIME-1, -1): + test.log(str(count_down)) + if screen_title == BEGIN_PRIME_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_dry_progress_data(total=300, countdown=count_down) + elif screen_title == PRIMING_TITLE: + hd_simulator.cmd_send_pre_treatment_disposables_prime_progress_data(timeout=300, countdown=count_down) + elif screen_title == SYSTEM_SELF_TEST_TITLE: + hd_simulator.cmd_send_pre_treatment_self_test_no_cartridge_progress_data(total=300, countdown=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) + test.endSection() + + +def verify_the_progress(count_down, screen_title): + """ + Method to verify the current progress + @param count_down - (int) current count down time + """ + 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 + else: + current_progress = (squish.waitForObjectExists(names.o_system_self_test_progress)).progressValue + #Since progress value is equal maximum count down value - current count down value + expected_progress = MAXIMUM_COUNTDOWN_TIME - count_down + test.compare(current_progress, expected_progress, "{} should be the current progress".format(expected_progress)) + test.endSection() \ No newline at end of file