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