Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r9498ba0c5cd12801de49e3eda26d9b3a8dfc4e55 -r2961accdbc24fa832a3c6fa3f12fa52ce7938124 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 9498ba0c5cd12801de49e3eda26d9b3a8dfc4e55) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 2961accdbc24fa832a3c6fa3f12fa52ce7938124) @@ -13,92 +13,14 @@ ############################################################################ import names -import sys import test import squish -from configuration import config -from builtins import int as pyInt import object import time +from configuration.utility import * from configuration.config import * - -def scroll_to_zone(zone=None, screen_object=None): - - """ - scroll to the numeric if object is hidden - @param zone - UI object - @param screen_object - UI object (UI Home screen = waveforms + numerics) - @return boolean true/false - """ - counter = 0 - while counter <= 100: - try: - counter += 1 - squish.findObject(zone) - squish.snooze(0.5) - if check_if_object_is_within_the_container(obj=zone, container=screen_object): - return True - else: - raise RuntimeError - except RuntimeError: - ScreenObj = squish.waitForObject(screen_object) - screenHeight = pyInt(ScreenObj.height) - screenWidth = pyInt(ScreenObj.width) - squish.mouseWheel(ScreenObj, screenWidth-1000, screenHeight-10, 0, -50, squish.Qt.NoModifier) - - raise LookupError("zone object is not in view to the user after trying 100 times") - - -def check_if_object_is_within_the_container(obj=None, container=None): - """ - check if an object is inside a container - @param obj - child UI object - @param container - container UI object - @return boolean true/false - """ - container = squish.findObject(container) - containerPos = container.mapToGlobal(squish.QPoint(0, 0)) - container_x, container_y = pyInt(containerPos.x), pyInt(containerPos.y) - container_width, container_height = pyInt(container.width), pyInt(container.height) - - obj = squish.findObject(obj) - objPos = obj.mapToGlobal(squish.QPoint(0, 0)) - obj_x, obj_y = pyInt(objPos.x), pyInt(objPos.y) - obj_width, obj_height = pyInt(obj.width), pyInt(obj.height) - - if obj_x >= container_x and obj_y >= container_y: - if (obj_x + obj_width) <= (container_x + container_width) and (obj_y + obj_height) <= (container_y + container_height): - return True - - return False - -def scroll_to_zone(zone=None, screen_object=None): - """ - scroll to the numeric if object is hidden - @param zone - UI object - @param screen_object - UI object (UI Home screen = waveforms + numerics) - @return boolean true/false - """ - counter = 0 - while counter <= 100: - try: - counter += 1 - squish.findObject(zone) - squish.snooze(0.5) - if check_if_object_is_within_the_container(obj=zone, container=screen_object): - return True - else: - raise RuntimeError - except RuntimeError: - ScreenObj = squish.waitForObject(screen_object) - screenHeight = pyInt(ScreenObj.height) - screenWidth = pyInt(ScreenObj.width) - squish.mouseWheel(ScreenObj, screenWidth-1000, - screenHeight-10, 0, -50, squish.Qt.NoModifier) - - raise LookupError("zone object is not in view to the user after " + \ - "trying 100 times") - +from configuration import config + def get_bullet_object(screen_obj, num): """ To obtain a bullet object based on occurrence provided. @@ -123,83 +45,42 @@ test.passes("object is not present as expected") squish.testSettings.objectNotFoundDebugging = True + -def verify_countdown(screen_title, time_out, hd_simulator, dg_simulator): +def convert_seconds_into_min_and_sec(seconds, time_format="%M:%S"): """ - 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 + Method to convert seconds into minute format. + @param seconds - time in seconds. + @param time_format (str) - time format. + @return (int) - minute time """ - 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 + seconds = int(seconds) + min_and_sec = time.strftime(time_format, time.gmtime(seconds)) + return min_and_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): +def verify_bullet_navigation(num, num_of_instructions, screen_obj): """ - 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 + Method to verify status of bullets based + on number of instruction screen + @param num - (int) number of indicator + @param num_of_instructions- (int) count the number of instructions + @param object - screen_obj - (str) Screen object """ - 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() + test.startSection("instruction bullet verification for screens") + for instruction in range(1, num_of_instructions): + bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj,(0 + instruction) - 1))) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + if instruction <= num: + test.compare(bullet_circle_color, config.COMPLETE_COLOR) + test.compare(bullet_border_color,config.COMPLETE_COLOR) + test.log(str(instruction) + " Complete bullet") + else: + test.compare(bullet_circle_color, config.CURRENT_COLOR) + test.compare(bullet_border_color,config.INCOMPLETE_COLOR) + test.log(str(instruction) + " Incomplete bullet") + test.endSection() def rinseback_rejection_msg(text): names.o_rinseback_rejection_msg["text"] = text