aboutsummaryrefslogtreecommitdiffstats
path: root/tests/steps/initial_setup_steps.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/steps/initial_setup_steps.py')
-rw-r--r--tests/steps/initial_setup_steps.py138
1 files changed, 138 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()