Unity 8
tutorial.py
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 
22 import ubuntuuitoolkit
23 
24 import autopilot
25 from autopilot import introspection
26 
27 
28 logger = logging.getLogger(__name__)
29 
30 
31 class TutorialPage(
32  ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
33 
34  @classmethod
35  def validate_dbus_object(cls, path, state):
36  name = introspection.get_classname_from_path(path)
37  return name in (b'TutorialPage', b'TutorialLeft',
38  b'TutorialLeftFinish', b'TutorialRight',
39  b'TutorialBottom', b'TutorialBottomFinish')
40 
41  @autopilot.logging.log_action(logger.info)
42  def short_swipe_right(self):
43  self.shown.wait_for(True)
44  x, y, width, height = self.globalRect
45  start_x = x
46  stop_x = x + width // 3
47  start_y = stop_y = y + height // 2
48  self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
49 
50  @autopilot.logging.log_action(logger.info)
51  def swipe_left(self):
52  self.shown.wait_for(True)
53  x, y, width, height = self.globalRect
54  start_x = width
55  stop_x = x
56  start_y = stop_y = y + height // 2
57  self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
58 
59  @autopilot.logging.log_action(logger.info)
60  def swipe_up(self):
61  self.shown.wait_for(True)
62  x, y, width, height = self.globalRect
63  start_y = height
64  stop_y = y
65  start_x = stop_x = x + width // 2
66  self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
67 
68  @autopilot.logging.log_action(logger.info)
69  def tap(self):
70  """Tap the tick button to complete this step."""
71  self.shown.wait_for(True)
72  button = self.wait_select_single(objectName="tick")
73  self.pointing_device.click_object(button)