12
12
from autopilot.input import Mouse, Touch, Pointer
13
13
from autopilot.platform import model
14
14
from autopilot.matchers import Eventually
15
from subprocess import Popen
16
15
from testtools.matchers import Contains, Equals, NotEquals, GreaterThan
17
16
from time import sleep
18
17
import BaseHTTPServer, SimpleHTTPServer, SocketServer, ssl, cgi
20
19
import oauth.oauth as oauth
23
21
from online_accounts_ui.emulators.items import EmulatorBase
260
258
self.pointer = Pointer(self.input_device_class.create())
261
# Increase the timeout of online-accounts-ui, to make sure it won't
262
# quit before the system settings panel asks it to open.
263
self.patch_environment('OAU_DAEMON_TIMEOUT', '120')
264
self.app = self.launch_test_application('online-accounts-ui',
265
'--desktop_file_hint=/usr/share/applications/online-accounts-ui.desktop',
259
self.app = self.launch_test_application('system-settings', 'online-accounts',
260
'--desktop_file_hint=/usr/share/applications/ubuntu-system-settings.desktop',
267
262
emulator_base=EmulatorBase,
268
263
capture_output=True)
269
self.system_settings = Popen(['system-settings', 'online-accounts',
270
'--desktop_file_hint=/usr/share/applications/ubuntu-system-settings.desktop'])
272
264
self.window = self.app.select_single("QQuickView")
273
265
self.assertThat(self.window.visible, Eventually(Equals(True)))
276
super(OnlineAccountsUiTests, self).tearDown()
277
self.system_settings.terminate()
279
267
def test_title(self):
280
268
""" Checks whether the Online Accounts window title is correct """
281
269
# On the phone, this fails because of https://bugs.launchpad.net/bugs/1252294
299
287
provider_item = self.app.select_single('Standard', text=provider)
300
288
self.assertThat(provider_item, NotEquals(None))
302
def test_create_account_with_form(self):
303
""" Test the creation of an account using a username/password form"""
304
page = self.app.select_single('NoAccountsPage')
305
self.assertThat(page, NotEquals(None))
307
provider_item = self.app.select_single('Standard', text='TestLogin')
308
self.assertThat(provider_item, NotEquals(None))
310
# Depending on the number of installed providers, it may be that our
311
# test provider is not visible; in that case, scroll the page
312
self.pointer.move_to_object(page)
313
(page_center_x, page_center_y) = self.pointer.position()
314
page_bottom = page.globalRect[1] + page.globalRect[3]
315
while provider_item.center[1] > page_bottom - 20:
316
self.pointer.move(page_center_x, page_center_y)
318
self.pointer.move(page_center_x, page_center_y - provider_item.height * 2)
319
# wait some time before releasing, to avoid a flick
321
self.pointer.release()
322
self.pointer.move_to_object(provider_item)
325
# Move to the username field
326
username_field = self.app.select_single('TextField', objectName='usernameField')
327
self.pointer.move_to_object(username_field)
329
self.keyboard.type('pinkuser')
330
self.keyboard.press_and_release('Tab')
331
self.keyboard.type('lolcat')
333
continue_btn = self.app.select_single('Button', objectName='continueButton')
334
self.pointer.move_to_object(continue_btn)
337
# The account should be created shortly
339
account_item = self.app.select_single('AccountItem', text='TestLogin')
340
self.assertThat(account_item, NotEquals(None))
341
self.assertThat(account_item.subText, Equals('pinkuser'))
344
self.pointer.move_to_object(account_item)
348
edit_page = self.app.select_single('AccountEditPage')
349
self.assertThat(edit_page, NotEquals(None))
350
remove_button = edit_page.select_single('Button')
351
self.assertThat(remove_button, NotEquals(None))
352
self.pointer.move_to_object(remove_button)
356
removal_page = self.app.select_single('RemovalConfirmation')
357
self.assertThat(removal_page, NotEquals(None))
358
remove_button = removal_page.select_single('Button', text='Remove')
359
self.assertThat(remove_button, NotEquals(None))
360
self.pointer.move_to_object(remove_button)
363
# Check that the account has been deleted
364
sleep(2) # weird: with 1 second only, org.freedesktop.DBus.Error.NoReply is received
365
account_item = self.app.select_single('AccountItem', text='TestLogin')
366
self.assertThat(account_item, Equals(None))
368
290
def test_create_oauth1_account(self):
369
291
""" Test the creation of an OAuth 1.0 account """
370
292
# On the phone, this fails because of https://bugs.launchpad.net/bugs/1231968