aboutsummaryrefslogtreecommitdiffstats
path: root/tests/steps
diff options
context:
space:
mode:
authorVadim Rutkovsky <vrutkovs@redhat.com>2014-03-21 23:15:00 +0800
committerVadim Rutkovsky <vrutkovs@redhat.com>2014-03-25 16:46:23 +0800
commit399b1a6fc593a9c5e692923120346e0386f578e5 (patch)
tree0ce0730706208dfb3f34cd2c4b7335aa3872491f /tests/steps
parenta9b96e5ae15d13d204e7bef5da283bb34154d9c8 (diff)
downloadgsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.tar
gsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.tar.gz
gsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.tar.bz2
gsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.tar.lz
gsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.tar.xz
gsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.tar.zst
gsoc2013-evolution-399b1a6fc593a9c5e692923120346e0386f578e5.zip
Add installed tests using --enable-installed-tests switch
https://bugzilla.gnome.org/show_bug.cgi?id=726832
Diffstat (limited to 'tests/steps')
-rw-r--r--tests/steps/initial_setup_steps.py138
-rw-r--r--tests/steps/steps.py122
2 files changed, 260 insertions, 0 deletions
diff --git a/tests/steps/initial_setup_steps.py b/tests/steps/initial_setup_steps.py
new file mode 100644
index 0000000000..ec97e455e4
--- /dev/null
+++ b/tests/steps/initial_setup_steps.py
@@ -0,0 +1,138 @@
+# -*- coding: UTF-8 -*-
+from behave import step
+
+from common_steps import wait_until, check_for_errors
+from dogtail.tree import root
+from os import system
+from pyatspi import STATE_SENSITIVE
+from time import sleep
+
+
+@step(u'Open Evolution and setup fake account')
+def open_evolution_and_setup_fake_account(context):
+ system("evolution --force-shutdown 2&> /dev/null")
+ context.execute_steps(u'* Start a new Evolution instance')
+ window = context.app.child(roleName='frame')
+ if window.name == 'Evolution Account Assistant':
+ context.execute_steps(u"""
+ * Complete Welcome dialog in Evolution Account Assistant
+ * Complete Restore from Backup dialog in Evolution Account Assistant
+ * Complete Identity dialog setting name to "GNOME QE User" and email address to "test@test"
+ * Wait for account is being looked up dialog in Evolution Account Assistant
+ * Complete Receiving Email dialog of Evolution Account Assistant setting
+ | Field | Value |
+ | Server Type: | None |
+ * Complete Sending Email dialog of Evolution Account Assistant setting
+ | Field | Value |
+ | Server Type: | Sendmail |
+ * Complete Account Summary in Evolution Account Assistant
+ * Complete Done dialog in Evolution Account Assistant
+ """)
+ # Evo doesn't create default addressbook immidiately
+ # We should restart it
+ system("evolution --force-shutdown 2&> /dev/null")
+ context.execute_steps(u'* Start a new Evolution instance')
+
+
+@step(u'Complete Receiving Options in Evolution Account Assistant')
+@step(u'Complete Account Summary in Evolution Account Assistant')
+@step(u'Complete Restore from Backup dialog in Evolution Account Assistant')
+@step(u'Complete Welcome dialog in Evolution Account Assistant')
+def evo_account_assistant_dummy_dialogs(context):
+ # nothing to do here, skip it
+ window = context.app.child('Evolution Account Assistant')
+ click_continue(window)
+
+
+@step(u'Complete Identity dialog setting name to "{name}" and email address to "{email}"')
+def evo_account_assistant_identity_dialog(context, name, email):
+ # nothing to do here, skip it
+ window = context.app.child('Evolution Account Assistant')
+ window.childLabelled("Full Name:").text = name
+ window.childLabelled("Email Address:").text = email
+ click_continue(window)
+
+
+@step(u"Wait for account is being looked up dialog in Evolution Account Assistant")
+def wait_for_account_to_be_looked_up(context):
+ window = context.app.child('Evolution Account Assistant')
+ skip_lookup = window.findChildren(lambda x: x.name == 'Skip Lookup')
+ visible_skip_lookup = [x for x in skip_lookup if x.showing]
+ if len(visible_skip_lookup) > 0:
+ visible_skip_lookup = visible_skip_lookup[0]
+ assert wait_until(lambda x: not x.showing, visible_skip_lookup),\
+ "Skip Lookup button didn't dissappear"
+
+
+def click_continue(window):
+ # As initial wizard dialog creates a bunch of 'Continue' buttons
+ # We have to click to the visible and enabled one
+ button = None
+ for attempt in xrange(0, 10):
+ btns = window.findChildren(lambda x: x.name == 'Continue')
+ visible_and_enabled = [x for x in btns if x.showing and STATE_SENSITIVE in x.getState().getStates()]
+ if visible_and_enabled == []:
+ sleep(0.1)
+ continue
+ else:
+ button = visible_and_enabled[0]
+ break
+ button.click()
+
+
+@step(u'Complete {sending_or_receiving} Email dialog of Evolution Account Assistant setting')
+def evo_account_assistant_receiving_email_dialog_from_table(context, sending_or_receiving):
+ window = context.app.child('Evolution Account Assistant')
+ for row in context.table:
+ label = str(row['Field'])
+ value = str(row['Value'])
+ filler = window.child(roleName='filler', name='%s Email' % sending_or_receiving)
+ widgets = filler.findChildren(lambda x: x.showing)
+ visible_widgets = [x for x in widgets if x.labeller and x.labeller.name == label]
+ if len(visible_widgets) == 0:
+ raise RuntimeError("Cannot find visible widget labelled '%s'" % label)
+ widget = visible_widgets[0]
+ if widget.roleName == 'combo box':
+ if label != 'Port:':
+ widget.click()
+ widget.menuItem(value).click()
+ else:
+ # Port is a combobox, but you can type your port there
+ widget.textentry('').text = value
+ widget.textentry('').grab_focus()
+ widget.textentry('').keyCombo("<Enter>")
+ if widget.roleName == 'text':
+ widget.text = value
+
+ # Check for password here and accept self-generated certificate (if appears)
+ btns = window.findChildren(lambda x: x.name == 'Check for Supported Types')
+ visible_btns = [w for w in btns if w.showing]
+ if visible_btns == []:
+ click_continue(window)
+ return
+ visible_btns[0].click()
+
+ # Confirm all certificates by clicking 'Accept Permanently' until dialog is visible
+ apps = [x.name for x in root.applications()]
+ if 'evolution-user-prompter' in apps:
+ prompter = root.application('evolution-user-prompter')
+ dialog = prompter.child(roleName='dialog')
+ while dialog.showing:
+ if prompter.findChild(lambda x: x.name == 'Accept Permanently', retry=False, requireResult=False):
+ prompter.button('Accept Permanently').click()
+ else:
+ sleep(0.1)
+
+ # Wait until Cancel button disappears
+ cancel = filler.findChildren(lambda x: x.name == 'Cancel')[0]
+ while cancel.showing:
+ sleep(0.1)
+ check_for_errors(context)
+ click_continue(window)
+
+
+@step(u'Complete Done dialog in Evolution Account Assistant')
+def evo_account_assistant_done_dialog(context):
+ # nothing to do here, skip it
+ window = context.app.child('Evolution Account Assistant')
+ window.button('Apply').click()
diff --git a/tests/steps/steps.py b/tests/steps/steps.py
new file mode 100644
index 0000000000..dac984f5dc
--- /dev/null
+++ b/tests/steps/steps.py
@@ -0,0 +1,122 @@
+# -*- coding: UTF-8 -*-
+from behave import step, then
+from common_steps import wait_until
+from dogtail.tree import root
+from dogtail.rawinput import keyCombo
+from time import sleep
+from os import system
+
+
+@step(u'Help section "{name}" is displayed')
+def help_is_displayed(context, name):
+ try:
+ context.yelp = root.application('yelp')
+ frame = context.yelp.child(roleName='frame')
+ wait_until(lambda x: x.showing, frame)
+ sleep(1)
+ context.assertion.assertEquals(name, frame.name)
+ finally:
+ system("killall yelp")
+
+
+@step(u'Evolution has {num:d} window opened')
+@step(u'Evolution has {num:d} windows opened')
+def evolution_has_num_windows_opened(context, num):
+ windows = context.app.findChildren(lambda x: x.roleName == 'frame')
+ context.assertion.assertEqual(len(windows), num)
+
+
+@step(u'Preferences dialog is opened')
+def preferences_dialog_opened(context):
+ context.app.window('Evolution Preferences')
+
+
+@step(u'"{name}" view is opened')
+def view_is_opened(context, name):
+ if name != 'Mail':
+ window_name = context.app.children[0].name
+ context.assertion.assertEquals(window_name, "%s - Evolution" % name)
+ else:
+ # A special case for Mail
+ context.assertion.assertTrue(context.app.menu('Message').showing)
+
+
+@step(u'Open "{section_name}" section')
+def open_section_by_name(context, section_name):
+ context.app.menu('View').click()
+ context.app.menu('View').menu('Window').point()
+ context.app.menu('View').menu('Window').menuItem(section_name).click()
+
+
+@step(u'"{name}" menu is opened')
+def menu_is_opened(context, name):
+ sleep(0.5)
+ menu = context.app.menu(name)
+ children_displayed = [x.showing for x in menu.children]
+ context.assertion.assertTrue(True in children_displayed, "Menu '%s' is not opened" % name)
+
+
+@step(u'Press "{sequence}"')
+def press_button_sequence(context, sequence):
+ keyCombo(sequence)
+ sleep(0.5)
+
+
+@then(u'Evolution is closed')
+def evolution_is_closed(context):
+ assert wait_until(lambda x: x.dead, context.app),\
+ "Evolution window is opened"
+ context.assertion.assertFalse(context.app_class.isRunning(), "Evolution is in the process list")
+
+
+@step(u'Message composer with title "{name}" is opened')
+def message_composer_is_opened(context, name):
+ context.app.composer = context.app.window(name)
+
+
+@then(u'Contact editor window with title "{title}" is opened')
+def contact_editor_with_label_is_opened(context, title):
+ context.app.contact_editor = context.app.dialog(title)
+ context.assertion.assertIsNotNone(
+ context.app.contact_editor, "Contact Editor was not found")
+ context.assertion.assertTrue(
+ context.app.contact_editor.showing, "Contact Editor didn't appear")
+
+
+@then(u'Contact editor window is opened')
+def contact_editor_is_opened(context):
+ context.execute_steps(u'Then Contact editor window with title "Contact Editor" is opened')
+
+
+@then(u'Contact List editor window is opened')
+def contact_list_editor_is_opened(context):
+ context.execute_steps(
+ u'Then Contact List editor window with title "Contact List Editor" is opened')
+
+
+@then(u'Contact List editor window with title "{name}" is opened')
+def contact_list_editor__with_name_is_opened(context, name):
+ context.app.contact_list_editor = context.app.dialog(name)
+
+
+@step(u'Memo editor with title "{name}" is opened')
+def memo_editor_is_opened(context, name):
+ context.execute_steps(u'* Task editor with title "%s" is opened' % name)
+
+
+@step(u'Shared Memo editor with title "{name}" is opened')
+def shared_memo_editor_is_opened(context, name):
+ context.execute_steps(u'* Task editor with title "%s" is opened' % name)
+
+
+@step(u'Task editor with title "{title}" is opened')
+def task_editor_with_title_is_opened(context, title):
+ context.app.task_editor = context.app.window(title)
+ # Spoof event_editor for assigned tasks
+ if 'Assigned' in title:
+ context.app.event_editor = context.app.task_editor
+
+
+@step(u'Event editor with title "{name}" is displayed')
+def event_editor_with_name_displayed(context, name):
+ context.app.event_editor = context.app.window(name) \ No newline at end of file