[gnome-logs/wip/test: 22/33] Run gnome-logs-test for the search test
- From: Rashi Aswani <aswanirashi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs/wip/test: 22/33] Run gnome-logs-test for the search test
- Date: Wed, 19 Aug 2015 05:50:38 +0000 (UTC)
commit 6a007d07fa52b8141b516594496c5900aee01df9
Author: Rashi Aswani <aswanirashi19 gmail com>
Date: Tue Jul 21 19:24:42 2015 +0530
Run gnome-logs-test for the search test
tests/common_steps.py | 75 +++++++++-------------------------------------
tests/general.feature | 8 ++--
tests/gnome-logs-test.c | 5 ++-
tests/steps/general.py | 20 ++++++------
4 files changed, 32 insertions(+), 76 deletions(-)
---
diff --git a/tests/common_steps.py b/tests/common_steps.py
index a82a0f0..803fbff 100644
--- a/tests/common_steps.py
+++ b/tests/common_steps.py
@@ -1,5 +1,5 @@
# -*- coding: UTF-8 -*-
-from dogtail.utils import isA11yEnabled, enableA11y
+from dogtail.utils import isA11yEnabled, enableA11y, run
if isA11yEnabled() is False:
enableA11y(True)
@@ -22,74 +22,18 @@ class dummy(TestCase):
def runTest(self): # pylint: disable=R0201
assert True
-
-def wait_until(my_lambda, element, timeout=30, period=0.25):
- """
- This function keeps running lambda with specified params until the result is True
- or timeout is reached
- Sample usages:
- * wait_until(lambda x: x.name != 'Loading...', context.app)
- Pause until window title is not 'Loading...'.
- Return False if window title is still 'Loading...'
- Throw an exception if window doesn't exist after default timeout
-
- * wait_until(lambda element, expected: x.text == expected, element, ('Expected text'))
- Wait until element text becomes the expected (passed to the lambda)
-
- """
- exception_thrown = None
- mustend = int(time()) + timeout
- while int(time()) < mustend:
- try:
- if my_lambda(element):
- return True
- except Exception as e:
- # If lambda has thrown the exception we'll re-raise it later
- # and forget about if lambda passes
- exception_thrown = e
- sleep(period)
- if exception_thrown:
- raise exception_thrown
- else:
- return False
-
-
class TimeoutError(Exception):
"""
Timeout exception class for limit_execution_time_to function
"""
pass
-
-def limit_execution_time_to(
- seconds=10, error_message=strerror(errno.ETIME)):
- """
- Decorator to limit function execution to specified limit
- """
- def decorator(func):
- def _handle_timeout(signum, frame):
- raise TimeoutError(error_message)
-
- def wrapper(*args, **kwargs):
- signal(SIGALRM, _handle_timeout)
- alarm(seconds)
- try:
- result = func(*args, **kwargs)
- finally:
- alarm(0)
- return result
-
- return wraps(func)(wrapper)
-
- return decorator
-
-
class App(object):
"""
This class does all basic events with the app
"""
def __init__(
- self, appName, shortcut='<Control><Q>', a11yAppName=None,
+ self, appName, shortcut='<Control><Q>', a11yAppName="None",
forceKill=True, parameters='', recordVideo=False):
"""
Initialize object App
@@ -174,6 +118,17 @@ class App(object):
assert not self.isRunning(), "Application cannot be stopped"
- step(u'Start a new Logs instance')
-def start_new_logs_instance(context):
+ step(u'Make sure that gnome-logs-test is running')
+def ensure_app_running(context):
context.app = context.app_class.startViaCommand()
+
+def cleanup():
+ # Remove cached data and settings
+ folders = ['~/.local/share/gnome-logs-test', '~/.cache/gnome-logs/test', '~/.config/gnome-logs-test']
+ for folder in folders:
+ system("rm -rf %s > /dev/null" % folder)
+
+ # Reset GSettings
+ schemas = [x for x in Gio.Settings.list_schemas() if 'gnome-logs-test' in x.lower()]
+ for schema in schemas:
+ system("gsettings reset-recursively %s" % schema)
diff --git a/tests/general.feature b/tests/general.feature
index e7ec4e7..0794ed4 100644
--- a/tests/general.feature
+++ b/tests/general.feature
@@ -1,9 +1,9 @@
Feature: General
- Background:
- * Make sure that gnome-logs is running
+Background:
+ * Make sure that gnome-logs-test is running
@start_logs
- Scenario: Start logs directly
- * Click on search
+ Scenario: Search
+ * Click on Search
Then all selection toolbar buttons are sensitive
diff --git a/tests/gnome-logs-test.c b/tests/gnome-logs-test.c
index ca60090..260277a 100644
--- a/tests/gnome-logs-test.c
+++ b/tests/gnome-logs-test.c
@@ -60,6 +60,7 @@ main (int argc, char** argv)
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/util/check_log_message", check_log_message);
g_object_unref (application);
-
- return g_test_run ();
+ //g_application_quit (G_APPLICATION (application));
+
+ return g_test_run ();
}
diff --git a/tests/steps/general.py b/tests/steps/general.py
index afcc8ad..55720bc 100644
--- a/tests/steps/general.py
+++ b/tests/steps/general.py
@@ -5,22 +5,22 @@ from pyatspi import STATE_SENSITIVE
from time import sleep
from common_steps import App
- step(u'Make sure that gnome-logs is running')
-def make_sure_gnome_logs_is_running(context):
- system("gnome-logs --force-shutdown 2&> /dev/null")
+ step(u'Run gnome-logs-test')
+def run_gnome_logs_test(context):
+ system("./gnome-logs-test --force-shutdown 2&> /dev/null")
context.execute_steps(u'* Start a new Logs instance')
@step(u'Click on search')
def click_on_search(context):
- app.child('Search').click()
+ context.app.child('Search').parent.click()
@then(u'all selection toolbar buttons are sensitive')
def all_selection_toolbar_buttons_sensitive(context):
sleep(0.5)
- assert app.child(translate('Important')).sensitive
- assert app.child(translate('All')).sensitive
- assert app.child(translate('Applications')).sensitive
- assert app.child(translate('System')).sensitive
- assert app.child(translate('Security')).sensitive
- assert app.child(translate('Hardware')).sensitive
+ assert context.app.child(translate('Important')).sensitive
+ assert context.app.child(translate('All')).sensitive
+ assert context.app.child(translate('Applications')).sensitive
+ assert context.app.child(translate('System')).sensitive
+ assert context.app.child(translate('Security')).sensitive
+ assert context.app.child(translate('Hardware')).sensitive
sleep(0.5)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]