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

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/helpers/clock/__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:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
#
3
3
# Ubuntu System Tests
4
 
# Copyright (C) 2015 Canonical
 
4
# Copyright (C) 2015-2016 Canonical
5
5
#
6
6
# This program is free software: you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
#
 
19
 
 
20
from ubuntu_system_tests.helpers import autopilot
 
21
from ubuntu_system_tests.helpers import processes
 
22
from ubuntu_system_tests.helpers.scopes.apps import (
 
23
    launch_application_from_apps_scope
 
24
)
 
25
from ubuntu_system_tests.helpers.unity8 import close_app
 
26
from ubuntu_system_tests.helpers import wait_until
 
27
 
 
28
APP_NAME = 'Clock'
 
29
APP_WIN_ID = 'com.ubuntu.clock_clock'
 
30
QML = 'ubuntu-clock-app'
 
31
 
 
32
 
 
33
def launch_clock_app():
 
34
    """
 
35
    Launch the clock app from apps scope and return proxy object.
 
36
 
 
37
    :return: Proxy object for clock application.
 
38
 
 
39
    """
 
40
    launch_application_from_apps_scope(APP_NAME)
 
41
    wait_until(is_clock_app_running, period=0.5)
 
42
    return get_clock_app_proxy()
 
43
 
 
44
 
 
45
def close_clock_app():
 
46
    """ Close the calendar app using task switcher """
 
47
    if is_clock_app_running():
 
48
        close_app(APP_WIN_ID)
 
49
 
 
50
 
 
51
def is_clock_app_running():
 
52
    """ Indicate if the clock app is currently running """
 
53
    return processes.is_qmlscene_running_with_qmlfile(QML)
 
54
 
 
55
 
 
56
def get_clock_app_proxy():
 
57
    """
 
58
    Return clock app proxy object from existing process.
 
59
 
 
60
    :return: Proxy object for calendar application.
 
61
 
 
62
    """
 
63
    from ubuntu_system_tests.helpers.clock import _cpo  # NOQA
 
64
    proxy = autopilot.get_proxy_object_for_existing_qmlscene_process(QML)
 
65
    return proxy.main_view