Unity 8
 All Classes Functions Properties
main_window.py
1 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2 #
3 # Unity Autopilot Test Suite
4 # Copyright (C) 2012, 2013, 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 from autopilot import logging as autopilot_logging
23 from autopilot import input
24 
25 from unity8.shell import emulators
26 from unity8.shell.emulators.greeter import Greeter
27 from unity8.shell.emulators.hud import Hud
28 from unity8.shell.emulators.dash import Dash
29 from unity8.shell.emulators.launcher import Launcher
30 
31 logger = logging.getLogger(__name__)
32 
33 
35  """An emulator class that makes it easy to interact with the shell"""
36 
37  def get_greeter(self):
38  return self.select_single(Greeter)
39 
40  def get_greeter_content_loader(self):
41  return self.wait_select_single(
42  "QQuickLoader",
43  objectName="greeterContentLoader"
44  )
45 
46  def get_login_loader(self):
47  return self.select_single("QQuickLoader", objectName="loginLoader")
48 
49  def get_login_list(self):
50  return self.select_single("LoginList")
51 
52  def get_hud(self):
53  return self.select_single(Hud)
54 
55  def get_hud_showable(self):
56  return self.select_single("Showable", objectName="hudShowable")
57 
58  def get_hud_show_button(self):
59  return self.select_single("HudButton")
60 
61  def get_hud_edge_drag_area(self):
62  return self.select_single(objectName="hudDragArea")
63 
64  def get_dash(self):
65  return self.select_single(Dash)
66 
67  def get_bottombar(self):
68  return self.select_single("Bottombar")
69 
70  def get_launcher(self):
71  return self.select_single(Launcher)
72 
73  def get_pinPadLoader(self):
74  return self.select_single(
75  "QQuickLoader",
76  objectName="pinPadLoader"
77  )
78 
79  def get_pinPadButton(self, buttonId):
80  return self.select_single(
81  "PinPadButton",
82  objectName="pinPadButton%i" % buttonId
83  )
84 
85  def get_lockscreen(self):
86  return self.select_single("Lockscreen")
87 
88  def get_pinentryField(self):
89  return self.select_single(objectName="pinentryField")
90 
91  def _get_indicator_widget(self, indicator_name):
92  return self.select_single(
93  'DefaultIndicatorWidget',
94  objectName=indicator_name+'-widget'
95  )
96 
97  def _get_indicator_page(self, indicator_name):
98  return self.select_single(
99  'DefaultIndicatorPage',
100  objectName=indicator_name+'-page'
101  )
102 
103  @autopilot_logging.log_action(logger.info)
104  def open_indicator_page(self, indicator_name):
105  """Swipe to open the indicator, wait until it's open.
106 
107  :returns: The indicator page.
108  """
109  widget = self._get_indicator_widget(indicator_name)
110  start_x, start_y = input.get_center_point(widget)
111  end_x = start_x
112  end_y = self.height
113  self.pointing_device.drag(start_x, start_y, end_x, end_y)
114  self.wait_select_single('Indicators', fullyOpened=True)
115  return self._get_indicator_page(indicator_name)
116 
117  @autopilot_logging.log_action(logger.info)
118  def show_dash_swiping(self):
119  """Show the dash swiping from the left."""
120  width = self.width
121  height = self.height
122  start_x = 0
123  start_y = height // 2
124  end_x = width
125  end_y = start_y
126 
127  self.pointing_device.drag(start_x, start_y, end_x, end_y)
128  return self.get_dash()
129 
131  """Return the id of the focused application."""
132  return self.select_single('Shell').focusedApplicationId
133 
134  @autopilot_logging.log_action(logger.info)
135  def search(self, query):
136  self.get_dash().enter_search_query(query)