~canonical-platform-qa/ubuntu-system-tests/trunk

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/helpers/gallery/__init__.py

  • Committer: Tarmac
  • Author(s): Sergio Cazzolato
  • Date: 2016-02-10 14:20:31 UTC
  • mfrom: (277.4.26 base_test_refactor)
  • Revision ID: tarmac-20160210142031-j2py2zg1d6yi4tdg
Refactoring base test class and autopilot helpers. The idea is to reduce the tests/base and autopilot.py files length.

First step is implemented. For that different methods were move mainly to autopilot helper and this helper was split in different files.

The second part which is pushed and within it all the methods to launch and close apps are moved to the helpers.

Approved by PS Jenkins bot, Richard Huddie.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
#
4
4
# Ubuntu System Tests
5
 
# Copyright (C) 2015 Canonical
 
5
# Copyright (C) 2015-2016 Canonical
6
6
#
7
7
# This program is free software: you can redistribute it and/or modify
8
8
# it under the terms of the GNU General Public License as published by
17
17
# You should have received a copy of the GNU General Public License
18
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
#
 
20
 
 
21
from ubuntu_system_tests.helpers import autopilot
 
22
from ubuntu_system_tests.helpers import click
 
23
from ubuntu_system_tests.helpers import processes
 
24
from ubuntu_system_tests.helpers.scopes.apps import (
 
25
    launch_application_from_apps_scope
 
26
)
 
27
from ubuntu_system_tests.helpers.unity8 import (
 
28
    close_app, launch_application_from_launcher
 
29
)
 
30
 
 
31
APP = 'gallery-app'
 
32
APP_NAME = 'Gallery'
 
33
APP_WIN_ID = 'com.ubuntu.gallery_gallery'
 
34
APP_CLICK = 'com.ubuntu.gallery'
 
35
 
 
36
 
 
37
def launch_gallery_app():
 
38
    """
 
39
    Launch the gallery app from apps scope and return proxy object.
 
40
 
 
41
    :return: Proxy object for gallery application.
 
42
 
 
43
    """
 
44
    from ubuntu_system_tests.helpers.gallery._cpo import EventsView
 
45
    launch_application_from_apps_scope(APP_NAME)
 
46
    return EventsView(get_gallery_app_proxy())
 
47
 
 
48
 
 
49
def close_gallery_app():
 
50
    """ Close the gallery app using task switcher """
 
51
    if is_gallery_app_running():
 
52
        close_app(APP_WIN_ID)
 
53
 
 
54
 
 
55
def is_gallery_app_running():
 
56
    """ Indicate if the gallery app is currently running """
 
57
    return processes.is_process_running(APP)
 
58
 
 
59
 
 
60
def get_gallery_app_proxy():
 
61
    """
 
62
    Return gallery app proxy object from existing process.
 
63
 
 
64
    :return: Proxy object for gallery application.
 
65
 
 
66
    """
 
67
    proxy = autopilot.get_proxy_object_for_existing_app(
 
68
        APP, cleanup_process=click.get_click_app_identifier(APP_CLICK))
 
69
    return proxy
 
70
 
 
71
 
 
72
def get_gallery_events_view():
 
73
    """Return a gallery_app EventsView custom proxy object."""
 
74
    from ubuntu_system_tests.helpers.gallery._cpo import EventsView
 
75
    return EventsView(get_gallery_app_proxy())
 
76
 
 
77
 
 
78
def get_gallery_photo_viewer():
 
79
    """Return a gallery_app PhotoViewer custom proxy object."""
 
80
    from ubuntu_system_tests.helpers.gallery._cpo import PhotoViewer
 
81
    return PhotoViewer(get_gallery_app_proxy())
 
82
 
 
83
 
 
84
def launch_gallery_app_from_launcher():
 
85
    """Drag out the launcher and tap the gallery app icon to start it."""
 
86
    launch_application_from_launcher(APP_WIN_ID)
 
87
    return get_gallery_app_proxy()