Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r325957ecac9491e749ae3330c8ede80adb70a1df -r8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 325957ecac9491e749ae3330c8ede80adb70a1df) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 8fe36cf3dde9429e91c1497af8bf7eac2a9a10e6) @@ -14,16 +14,14 @@ import sys -import os import test import squish -from dialin.ui import utils +from configuration import config +from builtins import int as pyInt +from builtins import str as pyStr +from builtins import float as pyFloat -Application_name = "denaliSquish" - -COMMON_PATH = f"{os.environ['HOME']}/Projects" - def start_application(app_name): """ @@ -40,7 +38,7 @@ try: counter += 1 test.log("Starting {}".format(app_name)) - squish.startApplication(Application_name) + squish.startApplication(config.Application_name) if counter == 1: test.log(f"Application launched at the {counter}'st try.") elif counter == 2: @@ -63,27 +61,71 @@ logErrorDetails("Failed to start the application") sys.exit(1) - -def launch_application(test_name): + +def color_verification(exp_val = "Red", act_val = "#c53b33"): """ - Method to enables simulator and launch application - @param test_name: (str) name of the test case - @return: None, print out in the console + Function to verify item color verification + Argument: + exp_val - Expected required value + act_val - Color displayed on UI + Return: + handle the application for log """ + test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) - test.log("Launching a new instance of Firmware Simulator") - #cleanup() - try: - os.chdir(f"{COMMON_PATH}/testsuites/shared/scripts/configuration") - #out = os.system("sudo chmod 777 sim_setup.sh") - res = os.system("./sim_setup.sh") - utils.waitForGUI(delay_s = 5) - if (res != 0) and (res != 256): - raise Exception("Wrong path to the simulator executable was given. Script not executed") - except Exception as msg: - test.log(str(msg)) - test.log("Launched Simulator......") - start_application("Denali Application") - - +def check_if_object_is_within_the_container(obj=None, container=None): + """ + check if an object is inside a container + Arguments: + obj - child UI object + container - container UI object + Return: + bool + """ + 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 + Arguments: + zone - UI object + screen_object - UI object (UI Home screen = waveforms + numerics) + Return: + bool + """ + 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")