Unity 8
greeter.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 ubuntuuitoolkit
21 
22 from autopilot.utilities import sleep
23 from unity8.shell.emulators import UnityEmulatorBase
24 
25 
27  """An emulator that understands the greeter screen."""
28 
29  def wait_swiped_away(self):
30  # We have to be careful here, because coverPage can go away at any time
31  # if there isn't a lockscreen behind it (it hides completely, then
32  # the greeter disposes it). But if there *is* a lockscreen, then we
33  # need a different check, by looking at its showProgress. So make our
34  # own wait_for loop and check both possibilities.
35  for i in range(10):
36  if not self.required:
37  return
38  coverPage = self.select_single(objectName='coverPage')
39  if coverPage.showProgress == 0:
40  return
41  sleep(1)
42 
43  raise AssertionError("Greeter cover page still up after 10s")
44 
45 
46  def swipe(self):
47  """Swipe the greeter screen away."""
48  self.waiting.wait_for(False)
49  coverPage = self.select_single(objectName='coverPage')
50  coverPage.showProgress.wait_for(1)
51 
52  rect = self.globalRect
53  start_x = rect[0] + rect[2] - 3
54  start_y = int(rect[1] + rect[3] / 2)
55  stop_x = int(rect[0] + rect[2] * 0.2)
56  stop_y = start_y
57  self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
58 
59  self.wait_swiped_away()
60 
61  def get_prompt(self):
62  return self.select_single(
63  ubuntuuitoolkit.TextField, objectName='passwordInput')