From b5fa637570b348339015fdc0857dec74bf703314 Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Wed, 25 May 2011 18:10:52 +0300 Subject: [PATCH] Changes: Adding wait for the application to raise for the failing test RevBy: TrustMe --- tests/harmattan/functests/tests.xml | 3 -- tests/harmattan/red-tests/tests.xml | 3 ++ .../testscripts/test-single-instance.py | 28 +++++++++++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/harmattan/functests/tests.xml b/tests/harmattan/functests/tests.xml index 2b0683e..07d4af6 100644 --- a/tests/harmattan/functests/tests.xml +++ b/tests/harmattan/functests/tests.xml @@ -258,9 +258,6 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-single-instance.py test_single_instance_abnormal_lock_release_with_invoker - - source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-single-instance.py test_single_instance_window_raise_with_script - true true diff --git a/tests/harmattan/red-tests/tests.xml b/tests/harmattan/red-tests/tests.xml index a690e05..a0d7a8a 100644 --- a/tests/harmattan/red-tests/tests.xml +++ b/tests/harmattan/red-tests/tests.xml @@ -101,6 +101,9 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-boot-mode.py test_boot_mode_and_normal_mode + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-single-instance.py test_single_instance_window_raise_with_script + true diff --git a/tests/harmattan/testscripts/test-single-instance.py b/tests/harmattan/testscripts/test-single-instance.py index 3dcc631..d234392 100644 --- a/tests/harmattan/testscripts/test-single-instance.py +++ b/tests/harmattan/testscripts/test-single-instance.py @@ -166,6 +166,30 @@ class SingleInstanceTests(unittest.TestCase): return None + def wait_for_app(self, app = None, timeout = 10, sleep = 1): + """ + Waits for an application to start. Checks periodically if + the app is running for a maximum wait set in timeout. + + Returns the pid of the application if it was running before + the timeout finished, otherwise None is returned. + """ + + pid = None + start = time.time() + + while pid == None and time.time() < start + timeout: + pid = self.get_pid_full(app) + + if pid != None: + break + + debug("waiting %s secs for %s" % (sleep, app)) + + time.sleep(sleep) + + return pid + def single_instance_window_raise_with_script(self, si_cmd): # For Bug#250404 # 1. Start the multi-instance application from script @@ -187,7 +211,7 @@ class SingleInstanceTests(unittest.TestCase): time.sleep(4) # get pid - pid1 = self.get_pid_full('/usr/bin/python /usr/bin/fala_focus') + pid1 = self.wait_for_app('/usr/bin/python /usr/bin/fala_focus') self.assert_(pid1 != None, "%s was not started") wid = self.minimize(app) @@ -200,7 +224,7 @@ class SingleInstanceTests(unittest.TestCase): time.sleep(4) # check that there's only one instance running - pids = self.get_pid_full('/usr/bin/python /usr/bin/fala_focus') + pids= self.wait_for_app('/usr/bin/python /usr/bin/fala_focus') st, op = commands.getstatusoutput("xprop -id %s | awk '/window state/ {print $3}'" %wid) self.assert_(op == 'Normal', "%s was not raised" % app)