on xenial help sign in
commit8b3a9a0dc53a9663f6bd8f1f3d05303efe4cced1 authorThomi Richards <thomi.richards@canonical.com> dateFri 12 Jul 2013, 14:40 (13 years ago) parente9eae63
2 files changed+155−2
tests/autopilot/unity8/shell/tests/__init__.py+44−2 tests/autopilot/unity8/shell/tests/test_lock_screen.py+111
tests/autopilot/unity8/shell/tests/__init__.py+44−2
@@ -7,19 +7,61 @@
77
88"""unity8 autopilot tests."""
99
10+from autopilot.platform import model
11+from autopilot.testcase import AutopilotTestCase
12+import logging
1013import os.path
1114import sysconfig
1215
13−from autopilot.testcase import AutopilotTestCase
14−from autopilot.platform import model
1516
1617from unity8.shell.emulators.main_window import MainWindow
1718
1819
20+logger = logging.getLogger(__name__)
21+
22+
1923class FormFactors(object):
2024 Phone, Tablet, Desktop = range(3)
2125
2226
27+class Unity8TestCase(AutopilotTestCase):
28+
29+ """A sane test case base class for the Unity8 shell tests."""
30+
31+ def launch_unity(self):
32+ """Launch the unity8 shell, return a proxy object for it."""
33+ shell_binary_path = self._get_shell_binary_path()
34+ app_proxy = self.launch_test_application(
35+ shell_binary_path,
36+ "-fullscreen",
37+ app_type='qt'
38+ )
39+ logger.debug("Started unity8 shell, backend is: %r", app_proxy._Backend)
40+ return app_proxy
41+
42+
43+ def _get_shell_binary_path(self):
44+ """Return a path to the unity8 binary, either the locally built binary
45+ or the version installed on the system.
46+
47+ The locally built binary will be preferred.
48+
49+ """
50+
51+ local_path = os.path.abspath(
52+ os.path.join(
53+ os.path.dirname(__file__),
54+ "../../../../../builddir/unity8"
55+ )
56+ )
57+ if os.path.exists(local_path):
58+ return local_path
59+ try:
60+ return subprocess.check_output(['which', 'unity8']).strip()
61+ except subprocess.CalledProcessError as e:
62+ self.fail("Unable to locate unity8 binary: %r" % e)
63+
64+
2365class ShellTestCase(AutopilotTestCase):
2466
2567 """A common test case class that provides several useful methods for shell tests."""
tests/autopilot/unity8/shell/tests/test_lock_screen.pynew file+111
@@ -0,0 +1,111 @@
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.shell.tests import Unity8TestCase
29+from unity8.shell.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 TestLockscreen(Unity8TestCase):
44+
45+ """Tests for the lock screen."""
46+
47+ # if model() == 'Desktop':
48+ # scenarios = [
49+ # ('Pinlock', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single-pin")),
50+ # ('Keylock', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single-passphrase")),
51+ # ]
52+ # else:
53+ # scenarios = [
54+ # ('Pinlock', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single-pin")),
55+ # ('Keylock', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single-key")),
56+ # ]
57+
58+ # def setUp(self):
59+ # super(TestLockscreen, self).setUp()
60+
61+
62+ # dash = self.main_window.get_dash()
63+ # self.assertThat(dash.showScopeOnLoaded, Eventually(Equals(""), timeout=30))
64+
65+ def test_can_unlock_screen(self):
66+ """Must be able to unlock the screen."""
67+ self.app = self.launch_unity()
68+
69+ # def test_unlock(self):
70+ # self.unlock_greeter()
71+
72+ # pinPadLoader = self.main_window.get_pinPadLoader();
73+ # self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
74+ # lockscreen = self.main_window.get_lockscreen();
75+ # self.assertThat(lockscreen.shown, Eventually(Equals(True)))
76+
77+ # if self.lightdm_mock == "single-pin":
78+ # self.touch.tap_object(self.main_window.get_pinPadButton(1))
79+ # self.touch.tap_object(self.main_window.get_pinPadButton(2))
80+ # self.touch.tap_object(self.main_window.get_pinPadButton(3))
81+ # self.touch.tap_object(self.main_window.get_pinPadButton(4))
82+ # self.assertThat(lockscreen.shown, Eventually(Equals(False)))
83+ # else:
84+ # pinentryField = self.main_window.get_pinentryField()
85+ # self.touch.tap_object(pinentryField)
86+ # self.keyboard.type("password\n")
87+ # self.assertThat(lockscreen.shown, Eventually(Equals(False)))
88+
89+ # def test_unlock_wrong(self):
90+ # self.unlock_greeter()
91+
92+ # pinPadLoader = self.main_window.get_pinPadLoader();
93+ # self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
94+ # lockscreen = self.main_window.get_lockscreen();
95+ # self.assertThat(lockscreen.shown, Eventually(Equals(True)))
96+ # pinentryField = self.main_window.get_pinentryField()
97+
98+ # if self.lightdm_mock == "single-pin":
99+ # self.touch.tap_object(self.main_window.get_pinPadButton(4))
100+ # self.touch.tap_object(self.main_window.get_pinPadButton(3))
101+ # self.touch.tap_object(self.main_window.get_pinPadButton(2))
102+ # self.assertThat(pinentryField.text, Eventually(Equals("432")))
103+ # self.touch.tap_object(self.main_window.get_pinPadButton(1))
104+
105+ # self.assertThat(pinentryField.text, Eventually(Equals("")))
106+ # self.assertThat(lockscreen.shown, Eventually(Equals(True)))
107+ # else:
108+ # self.touch.tap_object(pinentryField)
109+ # self.keyboard.type("foobar\n")
110+ # self.assertThat(pinentryField.text, Eventually(Equals("")))
111+ # self.assertThat(lockscreen.shown, Eventually(Equals(True)))