~mzanetti/unity8/fix-left-edge-on-spread

« back to all changes in this revision

Viewing changes to tests/autopilot/unity8/shell/emulators/edges_demo.py

  • Committer: Michael Zanetti
  • Date: 2015-01-12 11:21:17 UTC
  • mfrom: (1459.1.85 unity8)
  • Revision ID: michael.zanetti@canonical.com-20150112112117-0x9srs9dx0ndp60g
merge trunk

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
#
 
3
# Unity Autopilot Test Suite
 
4
# Copyright (C) 2014 Canonical
 
5
#
 
6
# This program is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
 
 
20
import logging
 
21
import time
 
22
 
 
23
import ubuntuuitoolkit
 
24
 
 
25
import autopilot
 
26
from autopilot import introspection
 
27
 
 
28
 
 
29
logger = logging.getLogger(__name__)
 
30
 
 
31
 
 
32
class RightEdgeDemoOverlay(
 
33
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
34
 
 
35
    @classmethod
 
36
    def validate_dbus_object(cls, path, state):
 
37
        name = introspection.get_classname_from_path(path)
 
38
        if name == b'EdgeDemoOverlay':
 
39
            if state['edge'][1] == 'right':
 
40
                return True
 
41
        return False
 
42
 
 
43
    @autopilot.logging.log_action(logger.info)
 
44
    def swipe(self):
 
45
        """Swipe to the left to complete this demo step."""
 
46
        x, y, width, height = self.globalRect
 
47
        start_x = x + width
 
48
        stop_x = x
 
49
        start_y = stop_y = y + height // 2
 
50
        self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
 
51
        return self.get_root_instance().wait_select_single(
 
52
            edge='top', active=True)
 
53
 
 
54
 
 
55
class TopEdgeDemoOverlay(
 
56
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
57
 
 
58
    @classmethod
 
59
    def validate_dbus_object(cls, path, state):
 
60
        name = introspection.get_classname_from_path(path)
 
61
        if name == b'EdgeDemoOverlay':
 
62
            if state['edge'][1] == 'top':
 
63
                return True
 
64
        return False
 
65
 
 
66
    @autopilot.logging.log_action(logger.info)
 
67
    def swipe(self):
 
68
        """Swipe to the bottom to complete this demo step."""
 
69
        x, y, width, height = self.globalRect
 
70
        start_x = stop_x = x + width // 2
 
71
        start_y = y
 
72
        stop_y = y + height
 
73
        self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
 
74
        return self.get_root_instance().wait_select_single(
 
75
            edge='bottom', active=True)
 
76
 
 
77
 
 
78
class BottomEdgeDemoOverlay(
 
79
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
80
 
 
81
    @classmethod
 
82
    def validate_dbus_object(cls, path, state):
 
83
        name = introspection.get_classname_from_path(path)
 
84
        if name == b'EdgeDemoOverlay':
 
85
            if state['edge'][1] == 'bottom':
 
86
                return True
 
87
        return False
 
88
 
 
89
    @autopilot.logging.log_action(logger.info)
 
90
    def swipe(self):
 
91
        """Swipe to the top to complete this demo step."""
 
92
        x, y, width, height = self.globalRect
 
93
        start_x = stop_x = x + width // 2
 
94
        start_y = y + height
 
95
        stop_y = y
 
96
        self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
 
97
        return self.get_root_instance().wait_select_single(
 
98
            edge='left', active=True)
 
99
 
 
100
 
 
101
class LeftEdgeDemoOverlay(
 
102
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
103
 
 
104
    @classmethod
 
105
    def validate_dbus_object(cls, path, state):
 
106
        name = introspection.get_classname_from_path(path)
 
107
        if name == b'EdgeDemoOverlay':
 
108
            if state['edge'][1] == 'left':
 
109
                return True
 
110
        return False
 
111
 
 
112
    @autopilot.logging.log_action(logger.info)
 
113
    def swipe(self):
 
114
        """Swipe to the right to complete this demo step."""
 
115
        x, y, width, height = self.globalRect
 
116
        start_x = x
 
117
        stop_x = x + width
 
118
        start_y = stop_y = y + height // 2
 
119
        self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
 
120
        return self.get_root_instance().wait_select_single(
 
121
            edge='none', active=True)
 
122
 
 
123
 
 
124
class FinalEdgeDemoOverlay(
 
125
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
126
 
 
127
    @classmethod
 
128
    def validate_dbus_object(cls, path, state):
 
129
        name = introspection.get_classname_from_path(path)
 
130
        if name == b'EdgeDemoOverlay':
 
131
            if state['edge'][1] == 'none':
 
132
                return True
 
133
        return False
 
134
 
 
135
    @autopilot.logging.log_action(logger.info)
 
136
    def tap_to_start(self):
 
137
        """Tap to finish the demo and start using the Ubuntu Touch."""
 
138
        time.sleep(1)
 
139
        self.pointing_device.click_object(self)
 
140
        self.shown.wait_for(False)