18
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
import unityclickscope
24
This file should be used to import the helpers from unityclickscope, rather
25
than importing unityclickscope directly.
27
Any CPOs written should derive from the classes defined in this file rather
28
than directly from unityclickscope.
30
It is required to over-ride the imported classes to ensure they cannot be
31
instantiated directly. Otherwise this can cause Autopilot CPO errors.
36
class ClickScope(unityclickscope.ClickScope):
39
def validate_dbus_object(cls, path, state):
40
"""This class can never be selected."""
44
class StoreScope(unityclickscope.StoreScope):
47
def validate_dbus_object(cls, path, state):
48
"""This class can never be selected."""
52
class Preview(unityclickscope.Preview):
55
def validate_dbus_object(cls, path, state):
56
"""This class can never be selected."""
24
from gi.repository import Accounts, GLib
25
from autopilot.exceptions import StateNotFoundError
27
from ubuntu_system_tests.helpers.input_manager import input_manager
28
from ubuntu_system_tests.helpers.scopes.base import (
29
Preview as PreviewBase
32
logger = logging.getLogger(__name__)
35
class Preview(PreviewBase):
38
def validate_dbus_object(cls, path, state):
39
"""This class can never be selected."""
42
def get_details(self):
43
"""Return the details of the application whose preview is open."""
44
header_widget = self.select_single('PreviewWidget', objectName='hdr')
45
title_label = header_widget.select_single(
46
'Label', objectName='titleLabel')
47
subtitle_label = header_widget.select_single(
48
'Label', objectName='subtitleLabel')
50
title=title_label.text, subtitle=subtitle_label.text)
53
install_button = self.select_single(
54
'PreviewActionButton', objectName='buttoninstall_click')
55
input_manager.pointer.click_object(install_button)
57
def is_progress_bar_visible(self):
59
self.select_single('ProgressBar', objectName='progressBar')
61
except StateNotFoundError:
65
class AccountManager(object):
68
self.manager = Accounts.Manager()
70
def _start_main_loop(self):
72
self._main_loop = GLib.MainLoop()
73
self._main_loop_thread = threading.Thread(
74
target=self._main_loop.run)
75
self._main_loop_thread.start()
77
def delete_account(self, account):
78
self._start_main_loop()
80
account.store(self._on_account_deleted, None)
81
self._join_main_loop()
83
def _join_main_loop(self):
84
self._main_loop_thread.join()
85
if self.error is not None:
86
raise Exception(self.error.message)
88
def _on_account_deleted(self, account, error, userdata):
91
self._main_loop.quit()