~feng-kylin/unity8/OpenUrlInIndicator

« back to all changes in this revision

Viewing changes to tests/autopilot/unity8/indicators_client/tests/__init__.py

  • Committer: Tarmac
  • Author(s): Nick Dedekind, Launchpad Translations on behalf of unity-team
  • Date: 2013-07-11 19:50:27 UTC
  • mfrom: (2.5.114 indicators-client)
  • Revision ID: tarmac-20130711195027-yheu3w2oc42c1h7s
Moved indicators-client code into unity8. Fixes: https://bugs.launchpad.net/bugs/1191132, https://bugs.launchpad.net/bugs/1191822.

Approved by PS Jenkins bot, Michał Sawicz, Nicolas d'Offay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
# Copyright 2013 Canonical
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
 
6
# by the Free Software Foundation.
 
7
 
 
8
"""qml-phone-shell autopilot tests."""
 
9
 
 
10
import os.path
 
11
 
 
12
from autopilot.input import Mouse, Touch, Pointer
 
13
from autopilot.testcase import AutopilotTestCase
 
14
from autopilot.matchers import Eventually
 
15
from autopilot.platform import model
 
16
from testtools.matchers import Equals
 
17
 
 
18
from unity8.indicators_client.emulators.main_window import MainWindow
 
19
from logging import getLogger
 
20
import sys
 
21
from time import sleep
 
22
 
 
23
log = getLogger(__name__)
 
24
 
 
25
class FormFactors(object):
 
26
    Phone, Tablet, Desktop = range(3)
 
27
 
 
28
class IndicatorsTestCase(AutopilotTestCase):
 
29
 
 
30
    """A common test case class that provides several useful methods for indicator tests."""
 
31
 
 
32
    if model() == 'Desktop':
 
33
        scenarios = [
 
34
        ('with mouse', dict(input_device_class=Mouse)),
 
35
        ]
 
36
    else:
 
37
        scenarios = [
 
38
        ('with touch', dict(input_device_class=Touch)),
 
39
        ]
 
40
 
 
41
    def setUp(self, geometry, grid_size):
 
42
        self.pointing_device = Pointer(self.input_device_class.create())
 
43
        super(IndicatorsTestCase, self).setUp()
 
44
        if grid_size != "0":
 
45
            os.environ['GRID_UNIT_PX'] = grid_size
 
46
            self.grid_size = int(grid_size)
 
47
        else:
 
48
            self.grid_size = int(os.environ['GRID_UNIT_PX'])
 
49
 
 
50
        if os.path.realpath(__file__).startswith("/usr/"):
 
51
            self.launch_test_installed(geometry)
 
52
        else:
 
53
            self.launch_test_local(geometry)
 
54
 
 
55
    def launch_test_local(self, geometry):
 
56
        if geometry != "0x0":
 
57
            self.app = self.launch_test_application("../../builddir/src/Panel/Indicators/client/indicators-client",
 
58
                "-geometry", geometry, app_type='qt')
 
59
        else:
 
60
            self.app = self.launch_test_application("../../builddir/src/Panel/Indicators/client/indicators-client",
 
61
                app_type='qt')
 
62
 
 
63
    def launch_test_installed(self, geometry):
 
64
        if geometry != "0x0":
 
65
            self.app = self.launch_test_application("indicators-client", "-geometry", geometry, app_type='qt')
 
66
        else:
 
67
            self.app = self.launch_test_application("indicators-client", app_type='qt')
 
68
 
 
69
    def skipWrapper(*args, **kwargs):
 
70
        pass
 
71
 
 
72
    def form_factor(self):
 
73
        return FormFactors.Desktop
 
74
 
 
75
    def __getattribute__(self, attr_name):
 
76
        attr = object.__getattribute__(self, attr_name);
 
77
        if attr_name.startswith("test_"):
 
78
            try:
 
79
                if self.form_factor() in attr.blacklist:
 
80
                    return self.skipWrapper
 
81
            except:
 
82
                pass
 
83
        return attr
 
84
 
 
85
    @property
 
86
    def main_window(self):
 
87
        return MainWindow(self.app)