aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Kroemeke <skroemeke@luxoft.com>2019-02-13 09:51:14 +0100
committerBramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>2019-02-14 09:52:11 +0000
commite3d2c0d35f4f1b1182536c8366ca2eb7f6a86be5 (patch)
tree3cce19d6c37c48d637ab7386c42ed58121dce694
parent00a63effbb97a69e1653ebcd40d2e6bec659fe35 (diff)
[squish] connect to squish-appman-hook, little clean-up
Appman hook will be soon present, and in order to use it, the AUT must get the '-c' parameter pointing to the squish-appman-hook.yaml. It will be located in the install (root) folder, so that is where it points to. Clean-up was needed to remove unnecessary parts and overcomplicated sections. Change-Id: I7ca33b9fa1d57a30fc3d14fb5470e508be641e3e Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
-rw-r--r--squishtests/suite_neptune3/shared/scripts/bdd_hooks.py173
-rw-r--r--squishtests/suite_neptune3/shared/scripts/common/app.py46
-rw-r--r--squishtests/suite_neptune3/shared/steps/essential.py32
3 files changed, 83 insertions, 168 deletions
diff --git a/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py b/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
index caa4d94f..01f85cbe 100644
--- a/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
+++ b/squishtests/suite_neptune3/shared/scripts/bdd_hooks.py
@@ -48,8 +48,6 @@ import test
# waiting time to let all windows to arrange at start-up
STARTUP_ARRANGE_TIME_SEC = 2
-STARTUP_RETRIES = 0
-STARTUP_RETRIES_WAIT_SEC = 2
END_DEARRANGE_TIME_SEC = 3
@@ -70,71 +68,69 @@ def start_neptune_ui_app_w_focus(window):
'dashboard' : dashboard view focused
"""
- def repeater(tries):
- """ Inside repeater function for de-coupling and allowing retries """
+ test.log("Found dbus environment")
+ test.log("DBUS_SESSION_BUS_ADDRESS with '"
+ + os.environ.get('DBUS_SESSION_BUS_ADDRESS')
+ + "'")
+ test.log("DBUS_SESSION_BUS_PID now is '"
+ + os.environ.get('DBUS_SESSION_BUS_PID')
+ + "'")
- # DBUS MUST NOT be started from within neptune3ui otherwise
- # squish will not start correctly with the squish attach to subprocess
- # option.
- command_line_options = "-r"
- command_line = settings.G_AUT_MAIN + " " + command_line_options
+ # DBUS MUST NOT be started from within neptune3ui otherwise
+ # squish will not start correctly with the squish attach to subprocess
+ # option.
+ command_line_options = ("-r"
+ + " -c am-config-neptune.yaml"
+ + " -c squish-appman-hook.yaml")
- test.log("command_line: " + command_line)
+ command_line = settings.G_AUT_MAIN + " " + command_line_options
- try:
- # try to start application
- app_context = squish.startApplication(command_line)
- except Exception as e:
- test.fail("direct command line call didn't work:", str(e))
- return False
+ test.log("command_line: " + command_line)
- test.log("Started applicationContext: '" + app_context.name + "' ("
- + str(app_context.pid) + ", #" + str(app_context.port)
- + ") is running!")
+ try:
+ # try to start application
+ app_context = squish.startApplication(command_line)
+ except Exception as e:
+ test.fail("direct command line call didn't work:", str(e))
+ return False
- # this snooze is really needed, VERY IMPORTANT
- squish.snooze(STARTUP_ARRANGE_TIME_SEC)
+ test.log("Started applicationContext: '" + app_context.name + "' ("
+ + str(app_context.pid) + ", #" + str(app_context.port)
+ + ") is running!")
- try:
- # update to catch all AUT instances
- app.update_all_contexts()
+ # this snooze is really needed, VERY IMPORTANT
+ squish.snooze(STARTUP_ARRANGE_TIME_SEC)
- app_now = squish.currentApplicationContext()
- test.log("Current app: '" + str(app_now.commandLine) + "'")
+ # try to register all already connected AUTs
+ # especially from appman
+ app.update_all_contexts()
- # wait for windows to arrange
- test.log("Started up application with: '" + command_line + "'!")
+ # to be able to focus window we need the neptune main app
+ app.switch_to_main_app()
- # to be able to focus window we need the neptune main app
- app.switch_to_main_app()
- worked, window_obj = get_focus_window(window)
+ try:
+ worked, window_obj = get_focus_window(window)
- if not worked:
- return False
- except Exception as e:
- if tries > 0:
- test.log("retrying to start AUT '" + settings.G_AUT_MAIN + "'!")
- squish.snooze(STARTUP_RETRIES_WAIT_SEC)
- return repeater(tries - 1)
- else:
- test.fail("Window not found after " + str(STARTUP_RETRIES)
- + " retries!!:" + str(e))
- return False
- # only for console so far
- test.log("Window size is : " + str(window_obj.width)
- + "x" + str(window_obj.height))
- test.log("Window pos is : " + str(window_obj.x)
- + "," + str(window_obj.y))
-
- # look for center console
- try:
- console_obj = squish.waitForObject(
- names.neptune_3_UI_Center_Console_centerConsole_CenterConsole,
- 500)
- except Exception:
- test.fail("Could not find console window!!!")
+ if not worked:
+ return False
+ except Exception as e:
+ test.fail("Window not found!! (" + str(e) + ")")
return False
+ # only for console so far
+ test.log("Window size is : " + str(window_obj.width)
+ + "x" + str(window_obj.height))
+ test.log("Window pos is : " + str(window_obj.x)
+ + "," + str(window_obj.y))
+
+ # look for center console
+ try:
+ console_obj = squish.waitForObject(
+ names.neptune_3_UI_Center_Console_centerConsole_CenterConsole,
+ 500)
+ except Exception:
+ test.fail("Could not find console window!!!")
+ else:
# look also into
# https://doc.froglogic.com/squish/latest/rgs-squish.html#rgss-screen-object
test.log("----------------------")
@@ -157,38 +153,6 @@ def start_neptune_ui_app_w_focus(window):
# from https://kb.froglogic.com/display/KB/Problem+-+Bringing+window+to+foreground+%28Qt%29
window_obj.show()
getattr(window_obj, "raise")()
- #not needed any more??? o.activateWindow()
- return True
- # run here
- test.log("Found dbus environment")
- test.log("DBUS_SESSION_BUS_ADDRESS with '"
- + os.environ.get('DBUS_SESSION_BUS_ADDRESS')
- + "'")
- # start dbus here
- #start_dbus()
- #
- # THERE IS A BIG DBUS issue: if started from IDE, in the
- # shell which started the IDE, a dbus session must be existent
- # beforehand. From inside (maybe it is also a configuration issue on the
- # test computer!) a valid dbus-session could yet not be established.
- #
- # To start a working and then being used dbus session from the
- # test script here would be the best solution but yet
- # it cannot be solved.
- # It's either a test machine issue (configuration, permissions,
- # dbus configuration), or dbus API must be used instead of
- # subprocess python module. For python dbus module API squish must be
- # extended to use not only build-in python scripts but system's
- # python installation.
- test.log("DBUS_SESSION_BUS_ADDRESS now is '"
- + os.environ.get('DBUS_SESSION_BUS_ADDRESS')
- + "'")
- #test.log("DBUS_SESSION_BUS_PID now is '"
- # + os.environ.get('DBUS_SESSION_BUS_PID')
- # + "'")
-
- repeater(STARTUP_RETRIES)
- test.log("leaving start_neptune_ui_app_w_focus")
def get_focus_window(window):
@@ -295,38 +259,3 @@ def get_position_item(itemObjectOrName):
return False, QPoint(0, 0)
worked, pos = recursive_go_deep(item)
return worked, pos
-
-
-# doesn't work, but I will leave it, maybe something else is terribly wrong
-def mouseMoveLinear(obj, x, y, time_sec):
- step_size = 30
- time_p_step = float(time_sec) / float(step_size)
-
- dx = float(x) / step_size
- dy = float(y) / step_size
- sx = float(0.0)
- sy = float(0.0)
-
- old_x = __builtin__.int(0)
- old_y = __builtin__.int(0)
-
- for _ss in range(step_size):
- draw_x = __builtin__.int(sx)
- draw_y = __builtin__.int(sy)
-
- step_x = draw_x - old_x
- step_y = draw_y - old_y
-
- if step_x != 0 or step_y != 0:
- mouseMove(step_x, step_y)
-
- #test.log(" (" + str(draw_x) + ":" + str(draw_y) + ") "
- # + str(step_x) + ":" + str(step_y))
-
- old_x = __builtin__.int(draw_x)
- old_y = __builtin__.int(draw_y)
-
- sx += dx
- sy += dy
- # wait milliseconds
- snooze(time_p_step)
diff --git a/squishtests/suite_neptune3/shared/scripts/common/app.py b/squishtests/suite_neptune3/shared/scripts/common/app.py
index 3fa245cb..6273e4a0 100644
--- a/squishtests/suite_neptune3/shared/scripts/common/app.py
+++ b/squishtests/suite_neptune3/shared/scripts/common/app.py
@@ -52,7 +52,6 @@ def register_main(app):
def register_app(app):
"""Registers an app into settings.G_APP_HANDLE, if this app is known."""
good = False
- result = None
app_url = os.path.basename(os.path.normpath(app.cwd))
app_array = filter(lambda x, app_url=app_url: x[1] == app_url,
@@ -70,10 +69,9 @@ def register_app(app):
+ "' to be usable in squish!")
else:
test.log("App '" + app_name + "' is already registered!")
- result = app
else:
test.fail("The app with path '" + app.cwd + "' is not known!")
- return good, result
+ return good
def switch_to_main_app():
@@ -90,10 +88,19 @@ def switch_to_main_app():
def switch_to_app(app_name):
"""Switch context to the given app, to act in its process."""
+
+ # do this always upfront, because an app
+ # might have been connected in the meanwhile
+ # and must be updated before trying to possibly
+ # change to it.
+ update_all_contexts()
+
good = False
if app_name in settings.G_APP_HANDLE.keys():
switch_to_app = settings.G_APP_HANDLE[app_name]
if switch_to_app is not None:
+ test.log("Trying to switch to registered app '"
+ + app_name + "'!")
squish.snooze(settings.G_WAIT_SWITCH_APP_CONTEXT)
squish.setApplicationContext(switch_to_app)
test.log("Switched to registered app '" + app_name + "'!")
@@ -113,19 +120,30 @@ def get_app_id(app_name):
return False, ""
+def register(app):
+ """
+ Register an app or main app (input: by instance)
+ to known apps.
+ """
+ worked = True
+
+ app_name = str(app)
+ if app_name == settings.G_AUT_MAIN:
+ register_main(app)
+ elif app_name == settings.G_AUT_APPMAN:
+ register_app(app)
+ elif app_name == settings.G_AUT_REMOTE:
+ test.log("app '" + app_name + "' is found, all right!")
+ else:
+ test.warning("app '" + app_name + "' with path '"
+ + a.cwd + "' is yet not known!")
+ worked = False
+ return worked
+
+
def update_all_contexts():
"""Update application contexts, each possible app has to be registered
before using!"""
app_list = squish.applicationContextList()
for a in app_list:
- # distinguish apps
- app_name = str(a)
- if app_name == settings.G_AUT_MAIN:
- register_main(a)
- elif app_name == settings.G_AUT_APPMAN:
- register_app(a)
- elif app_name == settings.G_AUT_REMOTE:
- test.log("app '" + app_name + "' is found, all right!")
- else:
- test.warning("app '" + app_name + "' with path '"
- + a.cwd + "' is yet not known!")
+ register(a)
diff --git a/squishtests/suite_neptune3/shared/steps/essential.py b/squishtests/suite_neptune3/shared/steps/essential.py
index 0aa4201e..7b95483b 100644
--- a/squishtests/suite_neptune3/shared/steps/essential.py
+++ b/squishtests/suite_neptune3/shared/steps/essential.py
@@ -41,38 +41,6 @@ import common.qml_names as qml
from math import sin, cos, floor
-def coord_up_px(in_pix):
- up = QPoint(0, -in_pix)
- transf = coord_transform2DReal(up)
- return transf
-
-
-def coord_down_px(in_pix):
- return coord_up_px(-in_pix)
-
-
-def coord_right_px(in_pix):
- right = QPoint(in_pix, 0)
- transf = coord_transform2DReal(right)
- return transf
-
-
-def coord_left_px(in_pix):
- return coord_right_px(-in_pix)
-
-
-def coord_addQPoints(a, b):
- return QPoint(a.x + b.x, a.y + b.y)
-
-
-def coord_transform2DReal(src_point):
- ti = QPoint(src_point.x, src_point.y)
- if settings.SCREEN_LANDSCAPE:
- ti.x = -src_point.x
- ti.y = src_point.y
- return ti
-
-
def coord_transform2D(src_point):
ti = QPoint(0, 0)