on xenial help sign in
added autopilot tests for lockscreens
bc971cdMichael Zanetti
tests/autopilot/unity8/emulators/main_window.py+12
@@ -47,3 +47,15 @@ class MainWindow(object):
47
47
48 def get_launcher(self):
48 def get_launcher(self):
49 return self.app.select_single("Launcher")
49 return self.app.select_single("Launcher")
50+
51+ def get_pinPadLoader(self):
52+ return self.app.select_single("QQuickLoader", objectName="pinPadLoader")
53+
54+ def get_pinPadButton(self, buttonId):
55+ return self.app.select_single("PinPadButton", objectName="pinPadButton%i" % buttonId)
56+
57+ def get_lockscreen(self):
58+ return self.app.select_single("Lockscreen")
59+
60+ def get_pinentryField(self):
61+ return self.app.select_single("TextField", objectName="pinentryField")
tests/autopilot/unity8/tests/testcases.py → tests/autopilot/unity8/tests/testhud.pyrenamed+2−2
@@ -40,7 +40,7 @@ import os
40from os import path
40from os import path
41
41
42
42
43−class TestShell(ShellTestCase, TestShellHelpers):
43+class TestHud(ShellTestCase, TestShellHelpers):
44
44
45 """Tests the Shell"""
45 """Tests the Shell"""
46
46
@@ -70,7 +70,7 @@ class TestShell(ShellTestCase, TestShellHelpers):
70 divisor = 1
70 divisor = 1
71 while (sg.get_screen_width() < self.app_width / divisor or sg.get_screen_height() < self.app_height / divisor):
71 while (sg.get_screen_width() < self.app_width / divisor or sg.get_screen_height() < self.app_height / divisor):
72 divisor = divisor * 2
72 divisor = divisor * 2
73− super(TestShell, self).setUp("%sx%s" % (self.app_width / divisor, self.app_height / divisor), "%s" % (self.grid_unit_px / divisor))
73+ super(TestHud, self).setUp("%sx%s" % (self.app_width / divisor, self.app_height / divisor), "%s" % (self.grid_unit_px / divisor))
74
74
75 dash = self.main_window.get_dash()
75 dash = self.main_window.get_dash()
76 self.assertThat(dash.showLensOnLoaded, Eventually(Equals(""), timeout=30))
76 self.assertThat(dash.showLensOnLoaded, Eventually(Equals(""), timeout=30))
tests/autopilot/unity8/tests/testlockscreen.pynew file+118
@@ -0,0 +1,118 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+# Copyright 2013 Canonical
3+#
4+# This program is free software: you can redistribute it and/or modify it
5+# under the terms of the GNU General Public License version 3, as published
6+# by the Free Software Foundation.
7+
8+
9+# This file contains general purpose test cases for Unity.
10+# Each test written in this file will be executed for a variety of
11+# configurations, such as Phone, Tablet or Desktop form factors.
12+#
13+# Sometimes there is the need to disable a certain test for a particular
14+# configuration. To do so, add this in a new line directly below your test:
15+#
16+# test_testname.blacklist = (FormFactors.Tablet, FormFactors.Desktop,)
17+#
18+# Available form factors are:
19+# FormFactors.Phone
20+# FormFactors.Tablet
21+# FormFactors.Desktop
22+
23+
24+"""Tests for the Shell"""
25+
26+from __future__ import absolute_import
27+
28+from unity8.tests import ShellTestCase, FormFactors
29+from unity8.tests.helpers import TestShellHelpers
30+
31+from autopilot.input import Mouse, Touch, Pointer
32+from testtools.matchers import Equals, NotEquals, GreaterThan, MismatchError
33+from autopilot.matchers import Eventually
34+from autopilot.display import Display
35+from autopilot.platform import model
36+
37+import unittest
38+import time
39+import os
40+from os import path
41+
42+
43+class TestShell(ShellTestCase, TestShellHelpers):
44+
45+ """Tests the Shell"""
46+
47+ # Scenarios:
48+ # Fill in the scenarios to run the whole test suite with multiple configurations.
49+ # Use app_width, app_height and grid_unit_px to set the apps geometry.
50+ # Set app_width and app_height to 0 to use fullscreen.
51+ # Set grid_unit_px to 0 to use the current system environment.
52+
53+ if model() == 'Desktop':
54+ scenarios = [
55+ ('Pinlock', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single-pin")),
56+ ('Keylock', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single-passphrase")),
57+ ]
58+ else:
59+ scenarios = [
60+ ('Pinlock', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single-pin")),
61+ ('Keylock', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single-key")),
62+ ]
63+
64+ def setUp(self):
65+ self.touch = Touch.create()
66+
67+ sg = Display().create()
68+ divisor = 1
69+ while (sg.get_screen_width() < self.app_width / divisor or sg.get_screen_height() < self.app_height / divisor):
70+ divisor = divisor * 2
71+ super(TestShell, self).setUp("%sx%s" % (self.app_width / divisor, self.app_height / divisor), "%s" % (self.grid_unit_px / divisor))
72+
73+ dash = self.main_window.get_dash()
74+ self.assertThat(dash.showLensOnLoaded, Eventually(Equals(""), timeout=30))
75+
76+ def test_unlock(self):
77+ self.unlock_greeter()
78+
79+ pinPadLoader = self.main_window.get_pinPadLoader();
80+ self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
81+ lockscreen = self.main_window.get_lockscreen();
82+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
83+
84+ if self.lightdm_mock == "single-pin":
85+ self.touch.tap_object(self.main_window.get_pinPadButton(1))
86+ self.touch.tap_object(self.main_window.get_pinPadButton(2))
87+ self.touch.tap_object(self.main_window.get_pinPadButton(3))
88+ self.touch.tap_object(self.main_window.get_pinPadButton(4))
89+ self.assertThat(lockscreen.shown, Eventually(Equals(False)))
90+ else:
91+ pinentryField = self.main_window.get_pinentryField()
92+ self.touch.tap_object(pinentryField)
93+ self.keyboard.type("password\n")
94+ self.assertThat(lockscreen.shown, Eventually(Equals(False)))
95+
96+ def test_unlock_wrong(self):
97+ self.unlock_greeter()
98+
99+ pinPadLoader = self.main_window.get_pinPadLoader();
100+ self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
101+ lockscreen = self.main_window.get_lockscreen();
102+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
103+ pinentryField = self.main_window.get_pinentryField()
104+
105+ if self.lightdm_mock == "single-pin":
106+ self.touch.tap_object(self.main_window.get_pinPadButton(4))
107+ self.touch.tap_object(self.main_window.get_pinPadButton(3))
108+ self.touch.tap_object(self.main_window.get_pinPadButton(2))
109+ self.assertThat(pinentryField.text, Eventually(Equals("432")))
110+ self.touch.tap_object(self.main_window.get_pinPadButton(1))
111+
112+ self.assertThat(pinentryField.text, Eventually(Equals("")))
113+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
114+ else:
115+ self.touch.tap_object(pinentryField)
116+ self.keyboard.type("foobar\n")
117+ self.assertThat(pinentryField.text, Eventually(Equals("")))
118+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))