/usr/lib/python3/dist-packages/online_accounts_ui/__init__.py is in ubuntu-system-settings-online-accounts-autopilot 0.7+16.04.20160322-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Copyright (C) 2013, 2014 Canonical Ltd.
#
# This file is part of ubuntu-system-settings-online-accounts.
#
# ubuntu-system-settings-online-accounts is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; version 3.
#
# ubuntu-system-settings-online-accounts is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
# TODO This is a workaround for bug #1327325 that will make phabet-test-run
# fail if something is printed to stdout. --elopio - 2014-07-03
logging.basicConfig(filename='warning.log', level=logging.WARNING)
import autopilot.logging
import ubuntuuitoolkit
logger = logging.getLogger(__name__)
class OnlineAccountsUIException(ubuntuuitoolkit.ToolkitException):
"""Exception raised when there is a problem with Online Accounts UI."""
class OnlineAccountsUI():
"""Autopilot helper for the Online Accounts UI."""
def __init__(self, application_proxy):
super().__init__()
self.application_proxy = application_proxy
self.main_view = self.application_proxy.wait_select_single(MainWindow)
class MainWindow(ubuntuuitoolkit.MainView):
"""Autopilot helper for the Main View."""
@property
def no_accounts_page(self):
page = self.select_single(NoAccountsPage)
try:
page.visible.wait_for(True)
return page
except AssertionError:
raise OnlineAccountsUIException(
'The No Accounts page is not visible.')
@property
def accounts_page(self):
page = self.select_single(AccountsPage)
try:
page.visible.wait_for(True)
return page
except AssertionError:
raise OnlineAccountsUIException('The Accounts page is not visible')
@autopilot.logging.log_action(logger.info)
def add_test_login_account(self, user_name, password):
account_creation_page = self.no_accounts_page.go_to_add_account(
'TestLogin')
account_creation_page.create_new_account(user_name, password)
return self.accounts_page
class NoAccountsPage(ubuntuuitoolkit.QQuickFlickable):
"""Autopilot helper for the No Accounts Page."""
def get_providers(self):
"""Return the list of account providers."""
provider_plugin_list = self._get_provider_plugin_list()
provider_items = provider_plugin_list.select_many(
ubuntuuitoolkit.listitems.Standard)
# sort by y
provider_items = sorted(
provider_items,
key=lambda item: (item.globalRect.y, item.globalRect.x))
result = []
for item in provider_items:
result.append(item.text)
return result
def _get_provider_plugin_list(self):
return self.select_single(ProviderPluginList)
class ProviderPluginList(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
"""Autopilot helper for the Provider Plugin list."""
@autopilot.logging.log_action(logger.debug)
def click_provider(self, name):
"""Click a provider item.
:param name: The name of the provider to click.
"""
provider_item = self.select_single(
ubuntuuitoolkit.listitems.Standard, text=name)
provider_item.swipe_into_view()
self.pointing_device.click_object(provider_item)
class NewAccount(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
"""Autopilot helper for the New Account form."""
@autopilot.logging.log_action(logger.debug)
def fill(self, user_name, password):
"""Fill the form.
:param user_name: The user name of the account.
:param password: The password of the account.
"""
username_text_field = self.select_single(
ubuntuuitoolkit.TextField, objectName='usernameField')
username_text_field.write(user_name)
password_text_field = self.select_single(
ubuntuuitoolkit.TextField, objectName='passwordField')
password_text_field.write(password)
self._click_continue()
@autopilot.logging.log_action(logger.debug)
def _click_continue(self):
continue_button = self.select_single(
'Button', objectName='continueButton')
self.pointing_device.click_object(continue_button)
class AccountsPage(ubuntuuitoolkit.QQuickFlickable):
"""Autopilot helper for the Accounts Page."""
def get_accounts(self):
"""Return the list of accounts."""
account_items = self.select_many(AccountItem)
# sort by y
account_items = sorted(
account_items,
key=lambda item: (item.globalRect.y, item.globalRect.x))
result = []
for item in account_items:
result.append(item.get_information())
return result
@autopilot.logging.log_action(logger.info)
def delete_account(self, provider_name, user_name):
account_item = self.select_single(
AccountItem, text=provider_name, subText=user_name)
self.pointing_device.click_object(account_item)
account_edit_page = self.get_root_instance().select_single(
AccountEditPage)
account_edit_page.visible.wait_for(True)
account_edit_page.remove_account()
account_item.wait_until_destroyed()
class AccountItem(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
"""Autopilot helper for the Account item."""
def get_information(self):
"""Return the information of the account.
:return: A tuple with the provider name and the user name.
"""
return self.text, self.subText
class AccountEditPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
"""Autopilot helper for the Account Edit page."""
@autopilot.logging.log_action(logger.debug)
def remove_account(self):
remove_account_button = self.select_single('Button')
self.pointing_device.click_object(remove_account_button)
self._confirm_removal()
def _confirm_removal(self):
removal_dialog = self.get_root_instance().select_single(
'RemovalConfirmation')
remove_button = removal_dialog.select_single('Button', text='Remove')
self.pointing_device.click_object(remove_button)
|