@@ -0,0 +1,118 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+# Copyright 2013 Canonical
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.
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.
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:
16+# test_testname.blacklist = (FormFactors.Tablet, FormFactors.Desktop,)
18+# Available form factors are:
24+"""Tests for the Shell"""
26+from __future__ import absolute_import
28+from unity8.tests import ShellTestCase, FormFactors
29+from unity8.tests.helpers import TestShellHelpers
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
43+class TestShell(ShellTestCase, TestShellHelpers):
45+ """Tests the Shell"""
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.
53+ if model() == 'Desktop':
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")),
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")),
65+ self.touch = Touch.create()
67+ sg = Display().create()
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))
73+ dash = self.main_window.get_dash()
74+ self.assertThat(dash.showLensOnLoaded, Eventually(Equals(""), timeout=30))
76+ def test_unlock(self):
77+ self.unlock_greeter()
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)))
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)))
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)))
96+ def test_unlock_wrong(self):
97+ self.unlock_greeter()
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()
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))
112+ self.assertThat(pinentryField.text, Eventually(Equals("")))
113+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
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)))