on xenial help sign in
merged with parent
f45415dNick Dedekind
Dash/DashContent.qml+5
@@ -115,6 +115,11 @@ Item {
115 asynchronous: true
115 asynchronous: true
116 source: scopeMapper.map(scope.id)
116 source: scopeMapper.map(scope.id)
117
117
118+ // these are needed for autopilot tests
119+ readonly property string scopeId: scope.id
120+ readonly property bool isCurrent: ListView.isCurrentItem
121+ readonly property bool isLoaded: status == Loader.Ready
122+
118 onLoaded: {
123 onLoaded: {
119 item.scope = Qt.binding(function() { return scope })
124 item.scope = Qt.binding(function() { return scope })
120 item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
125 item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
Panel/IndicatorRow.qml+28−21
@@ -26,8 +26,6 @@ Item {
26 property alias row: row
26 property alias row: row
27 property QtObject indicatorsModel: null
27 property QtObject indicatorsModel: null
28
28
29− Behavior on y { StandardAnimation {} }
30−
31 width: units.gu(40)
29 width: units.gu(40)
32 height: units.gu(3)
30 height: units.gu(3)
33
31
@@ -54,30 +52,39 @@ Item {
54 objectName: "rowRepeater"
52 objectName: "rowRepeater"
55 model: indicatorsModel ? indicatorsModel : undefined
53 model: indicatorsModel ? indicatorsModel : undefined
56
54
57− IndicatorItem {
55+ Item {
56+ id: itemWrapper
57+ height: indicatorRow.height
58+ width: childrenRect.width
59+
60+ property int ownIndex: index
58− id: indicatorItem
61+ property alias highlighted: indicatorItem.highlighted
62+ property alias dimmed: indicatorItem.dimmed
59
63
60− property int ownIndex: index
64+ IndicatorItem {
65+ id: indicatorItem
66+ height: parent.height
61
67
68+ highlighted: indicatorRow.state != "initial" ? itemWrapper.ownIndex == indicatorRow.currentItemIndex : false
69+ dimmed: indicatorRow.state != "initial" ? itemWrapper.ownIndex != indicatorRow.currentItemIndex : false
70+
62− widgetSource: model.widgetSource
71+ widgetSource: model.widgetSource
72+ indicatorProperties : model.indicatorProperties
73+ }
63
74
64− indicatorProperties : model.indicatorProperties
75+ opacity: {
65− highlighted: indicatorRow.state != "initial" ? ownIndex == indicatorRow.currentItemIndex : false
66− dimmed: indicatorRow.state != "initial" ? ownIndex != indicatorRow.currentItemIndex : false
67− height: indicatorRow.height
68− y: {
69− if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
76+ if (!indicatorItem.highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
70− return -indicatorRow.height;
77+ return 0.0;
71− } else {
78+ } else {
72− return 0;
79+ return 1.0;
73− }
74− }
75− Behavior on y {
76− StandardAnimation {
77− // flow away from current index
78− duration: (rowRepeater.count - Math.abs(indicatorRow.currentItemIndex - index)) * (500/rowRepeater.count)
79 }
80 }
80 }
81 }
82+ Behavior on opacity {
83+ StandardAnimation {
84+ // flow away from current index
85+ duration: (rowRepeater.count - Math.abs(indicatorRow.currentItemIndex - index)) * (500/rowRepeater.count)
86+ }
87+ }
81 }
88 }
82 }
89 }
83 }
90 }
Panel/Indicators.qml+10−17
@@ -33,6 +33,7 @@ Showable {
33 readonly property int lockThreshold: openedHeight / 2
33 readonly property int lockThreshold: openedHeight / 2
34 property bool fullyOpened: height == openedHeight
34 property bool fullyOpened: height == openedHeight
35 property bool partiallyOpened: height > panelHeight && !fullyOpened
35 property bool partiallyOpened: height > panelHeight && !fullyOpened
36+ property real visualBottom: Math.max(y+height, y+indicatorRow.y+indicatorRow.height)
36
37
37 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
38 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
38 // use its own values. Need to ask design about this.
39 // use its own values. Need to ask design about this.
@@ -100,8 +101,8 @@ Showable {
100 /*
101 /*
101 Vertical velocity check. Don't change the indicator if we're moving too quickly.
102 Vertical velocity check. Don't change the indicator if we're moving too quickly.
102 */
103 */
103− var verticalVelocity = Math.abs(yVelocityCalculator.calculate());
104+ var verticalSpeed = Math.abs(yVelocityCalculator.calculate());
104− if (verticalVelocity >= 0.3 && indicatorRow.currentItem!=null) {
105+ if (verticalSpeed >= 0.05 && indicatorRow.currentItem!=null) {
105 return;
106 return;
106 }
107 }
107
108
@@ -278,16 +279,15 @@ Showable {
278 }
279 }
279 }
280 }
280
281
281− property var dragHandle: null
282+ property var activeDragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle.dragging ? hideDragHandle : null
282 // connections to the active drag handle
283 // connections to the active drag handle
283 Connections {
284 Connections {
284− target: dragHandle
285+ target: activeDragHandle
285 onTouchXChanged: {
286 onTouchXChanged: {
286− var buffer = dragHandle.dragging ? true : false;
287− indicators.calculateCurrentItem(dragHandle.touchX, buffer);
287+ indicators.calculateCurrentItem(activeDragHandle.touchX, true);
288 }
288 }
289 onTouchSceneYChanged: {
289 onTouchSceneYChanged: {
290− yVelocityCalculator.trackedPosition = dragHandle.touchSceneY;
290+ yVelocityCalculator.trackedPosition = activeDragHandle.touchSceneY;
291 }
291 }
292 }
292 }
293
293
@@ -312,24 +312,17 @@ Showable {
312 menuContent.activateContent();
312 menuContent.activateContent();
313 }
313 }
314 }
314 }
315− onDraggingChanged: {
316− dragHandle = dragging ? showDragHandle : null;
317− }
318 }
315 }
319 DragHandle {
316 DragHandle {
320 id: hideDragHandle
317 id: hideDragHandle
321 anchors.fill: handle
318 anchors.fill: handle
322 direction: Direction.Upwards
319 direction: Direction.Upwards
323 enabled: indicators.shown
320 enabled: indicators.shown
324− hintDisplacement: units.gu(2)
321+ hintDisplacement: indicators.hintValue
325 autoCompleteDragThreshold: maxTotalDragDistance / 6
322 autoCompleteDragThreshold: maxTotalDragDistance / 6
326 stretch: true
323 stretch: true
327 maxTotalDragDistance: openedHeight - panelHeight
324 maxTotalDragDistance: openedHeight - panelHeight
328 distanceThreshold: 0
325 distanceThreshold: 0
329−
330− onDraggingChanged: {
331− dragHandle = dragging ? hideDragHandle : null;
332− }
333 }
326 }
334
327
335 AxisVelocityCalculator {
328 AxisVelocityCalculator {
@@ -348,8 +341,8 @@ Showable {
348 }
341 }
349 StateChangeScript {
342 StateChangeScript {
350 script: {
343 script: {
351− if (dragHandle) {
344+ if (activeDragHandle) {
352− calculateCurrentItem(dragHandle.touchX, false);
345+ calculateCurrentItem(activeDragHandle.touchX, false);
353 }
346 }
354 }
347 }
355 }
348 }
Panel/MenuContent.qml+1−1
@@ -150,7 +150,7 @@ Rectangle {
150 Indicators.MenuContentActivator {
150 Indicators.MenuContentActivator {
151 id: menuActivator
151 id: menuActivator
152 running: content.__contentActive
152 running: content.__contentActive
153− baseIndex: content.currentIndex
153+ baseIndex: content.currentMenuIndex
154 count: indicatorsModel.count
154 count: indicatorsModel.count
155 }
155 }
156}
156}
Panel/Panel.qml+1−1
@@ -90,10 +90,10 @@ Item {
90 id: indicatorsSeparatorLine
90 id: indicatorsSeparatorLine
91 visible: true
91 visible: true
92 anchors {
92 anchors {
93− top: indicatorsMenu.bottom
94 left: indicatorsMenu.left
93 left: indicatorsMenu.left
95 right: indicatorsMenu.right
94 right: indicatorsMenu.right
96 }
95 }
96+ y: indicatorsMenu.visualBottom
97 }
97 }
98
98
99 BorderImage {
99 BorderImage {
cmake/modules/autopilot.cmake+2−1
@@ -2,8 +2,9 @@ add_custom_target(autopilot)
2
2
3function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
3function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
4 add_custom_target(autopilot-${TEST_NAME}
4 add_custom_target(autopilot-${TEST_NAME}
5− COMMAND autopilot run ${TEST_SUITE}
5+ COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_PRIVATE_LIBDIR}/qml/mocks autopilot run ${TEST_SUITE}
6 WORKING_DIRECTORY ${WORKING_DIR}
6 WORKING_DIRECTORY ${WORKING_DIR}
7+ DEPENDS install
7 )
8 )
8
9
9 add_dependencies(autopilot autopilot-${TEST_NAME})
10 add_dependencies(autopilot autopilot-${TEST_NAME})
tests/autopilot/setup.py+17−6
@@ -1,11 +1,22 @@
1#!/usr/bin/python
1#!/usr/bin/python
2−
3# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
4−# Copyright 2013 Canonical
5#
3#
4+# Unity Autopilot Test Suite
5+# Copyright (C) 2012-2013 Canonical
6+#
6−# This program is free software: you can redistribute it and/or modify it
7+# This program is free software: you can redistribute it and/or modify
7−# under the terms of the GNU General Public License version 3, as published
8+# it under the terms of the GNU General Public License as published by
8−# by the Free Software Foundation.
9+# the Free Software Foundation, either version 3 of the License, or
10+# (at your option) any later version.
11+#
12+# This program is distributed in the hope that it will be useful,
13+# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+# GNU General Public License for more details.
16+#
17+# You should have received a copy of the GNU General Public License
18+# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+#
9
20
10
21
11from distutils.core import setup
22from distutils.core import setup
@@ -14,7 +25,7 @@ from setuptools import find_packages
14setup(
25setup(
15 name='unity',
26 name='unity',
16 version='8.0',
27 version='8.0',
17− description='Unity 8 autopilot tests.',
28+ description='Unity autopilot tests.',
18 url='https://launchpad.net/unity',
29 url='https://launchpad.net/unity',
19 license='GPLv3',
30 license='GPLv3',
20 packages=find_packages(),
31 packages=find_packages(),
tests/autopilot/unity8/__init__.py+90−5
@@ -1,8 +1,93 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3#
2#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
5+#
4−# This program is free software: you can redistribute it and/or modify it
6+# This program is free software: you can redistribute it and/or modify
5−# under the terms of the GNU General Public License version 3, as published
7+# it under the terms of the GNU General Public License as published by
6−# by the Free Software Foundation.
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+"""unity autopilot tests and emulators - top level package."""
21+import os
22+import os.path
23+import subprocess
24+import sysconfig
25+
26+
27+def running_installed_tests():
28+ binary_path = get_binary_path()
29+ return binary_path.startswith('/usr')
30+
31+
32+def get_lib_path():
33+ """Return the library path to use in this test run."""
34+ if running_installed_tests():
35+ lib_path = os.path.join(
36+ "/usr/lib/",
37+ sysconfig.get_config_var('MULTIARCH'),
38+ "unity8"
39+ )
40+ else:
41+ binary_path = get_binary_path()
42+ lib_path = os.path.dirname(binary_path)
43+ return lib_path
44+
45+
46+def get_default_extra_mock_libraries():
47+ mocks_path = get_mocks_library_path()
48+ return os.path.join(mocks_path, 'libusermetrics')
49+
50+
51+def get_mocks_library_path():
52+ if running_installed_tests():
53+ mock_path = "qml/mocks/"
54+ else:
55+ mock_path = "../lib/x86_64-linux-gnu/unity8/qml/mocks/"
56+ lib_path = get_lib_path()
57+ ld_library_path = os.path.abspath(
58+ os.path.join(
59+ lib_path,
60+ mock_path,
61+ )
62+ )
63+
64+ if not os.path.exists(ld_library_path):
65+ raise RuntimeError(
66+ "Expected library path does not exists: %s." % (ld_library_path)
67+ )
68+ return ld_library_path
69+
70+
71+def get_binary_path(binary="unity8"):
72+ """Return the path to the specified binary."""
73+ binary_path = os.path.abspath(
74+ os.path.join(
75+ os.path.dirname(__file__),
76+ "../../../builddir/install/bin/%s" % binary
77+ )
78+ )
79+ if not os.path.exists(binary_path):
80+ try:
81+ binary_path = subprocess.check_output(['which', binary]).strip()
82+ except subprocess.CalledProcessError as e:
83+ raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
84+ return binary_path
85+
7
86
8−"""unity8 autopilot tests and emulators - top level package."""
87+def get_grid_size():
88+ grid_size = os.getenv('GRID_UNIT_PX')
89+ if grid_size is None:
90+ raise RuntimeError(
91+ "Environment variable GRID_UNIT_PX has not been set."
92+ )
93+ return int(grid_size)
tests/autopilot/unity8/indicators_client/__init__.py+1−1
@@ -5,4 +5,4 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8−"""unity8 indicators-client autopilot tests and emulators - sub level package."""
8+"""unity indicators-client autopilot tests and emulators - sub level package."""
tests/autopilot/unity8/indicators_client/tests/__init__.py+13−9
@@ -5,7 +5,7 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8−"""qml-phone-shell autopilot tests."""
8+"""indicators-client autopilot tests."""
9
9
10import os.path
10import os.path
11
11
@@ -15,6 +15,7 @@ from autopilot.matchers import Eventually
15from autopilot.platform import model
15from autopilot.platform import model
16from testtools.matchers import Equals
16from testtools.matchers import Equals
17
17
18+from unity8 import get_binary_path
18from unity8.indicators_client.emulators.main_window import MainWindow
19from unity8.indicators_client.emulators.main_window import MainWindow
19from logging import getLogger
20from logging import getLogger
20import sys
21import sys
@@ -29,9 +30,12 @@ class IndicatorsTestCase(AutopilotTestCase):
29
30
30 """A common test case class that provides several useful methods for indicator tests."""
31 """A common test case class that provides several useful methods for indicator tests."""
31
32
33+ geometry = None
34+ grid_unit = None
35+
32 if model() == 'Desktop':
36 if model() == 'Desktop':
33 scenarios = [
37 scenarios = [
34− ('with mouse', dict(input_device_class=Mouse)),
38+ ('with mouse', dict(input_device_class=Mouse, geometry="400x800", grid_unit="12")),
35 ]
39 ]
36 else:
40 else:
37 scenarios = [
41 scenarios = [
@@ -41,11 +45,11 @@ class IndicatorsTestCase(AutopilotTestCase):
41 def setUp(self, geometry, grid_size):
45 def setUp(self, geometry, grid_size):
42 self.pointing_device = Pointer(self.input_device_class.create())
46 self.pointing_device = Pointer(self.input_device_class.create())
43 super(IndicatorsTestCase, self).setUp()
47 super(IndicatorsTestCase, self).setUp()
44− if grid_size != "0":
48+ if grid_size is not None:
45− os.environ['GRID_UNIT_PX'] = grid_size
49+ self.patch_environment("GRID_UNIT_PX", str(grid_size))
46 self.grid_size = int(grid_size)
50 self.grid_size = int(grid_size)
47 else:
51 else:
48− self.grid_size = int(os.environ['GRID_UNIT_PX'])
52+ self.grid_size = int(os.getenv('GRID_UNIT_PX'))
49
53
50 if os.path.realpath(__file__).startswith("/usr/"):
54 if os.path.realpath(__file__).startswith("/usr/"):
51 self.launch_test_installed(geometry)
55 self.launch_test_installed(geometry)
@@ -53,15 +57,15 @@ class IndicatorsTestCase(AutopilotTestCase):
53 self.launch_test_local(geometry)
57 self.launch_test_local(geometry)
54
58
55 def launch_test_local(self, geometry):
59 def launch_test_local(self, geometry):
56− if geometry != "0x0":
60+ if geometry is None:
57− self.app = self.launch_test_application("../../builddir/src/Panel/Indicators/client/indicators-client",
61+ self.app = self.launch_test_application(get_binary_path("indicators-client"),
58 "-geometry", geometry, app_type='qt')
62 "-geometry", geometry, app_type='qt')
59 else:
63 else:
60− self.app = self.launch_test_application("../../builddir/src/Panel/Indicators/client/indicators-client",
64+ self.app = self.launch_test_application(get_binary_path("indicators-client"),
61 app_type='qt')
65 app_type='qt')
62
66
63 def launch_test_installed(self, geometry):
67 def launch_test_installed(self, geometry):
64− if geometry != "0x0":
68+ if geometry is not None:
65 self.app = self.launch_test_application("indicators-client", "-geometry", geometry, app_type='qt')
69 self.app = self.launch_test_application("indicators-client", "-geometry", geometry, app_type='qt')
66 else:
70 else:
67 self.app = self.launch_test_application("indicators-client", app_type='qt')
71 self.app = self.launch_test_application("indicators-client", app_type='qt')
tests/autopilot/unity8/indicators_client/tests/test_battery.py+4−1
@@ -8,6 +8,7 @@
8"""Add tests here if you want to ensure the behaviour of the power indicator menus are correct"""
8"""Add tests here if you want to ensure the behaviour of the power indicator menus are correct"""
9
9
10from testtools.matchers import Equals, NotEquals
10from testtools.matchers import Equals, NotEquals
11+from autopilot.input import Touch
11from autopilot.matchers import Eventually
12from autopilot.matchers import Eventually
12
13
13from unity8.indicators_client.tests import IndicatorsTestCase
14from unity8.indicators_client.tests import IndicatorsTestCase
@@ -17,7 +18,7 @@ import math
17
18
18class TestDisplayMenus(IndicatorsTestCase):
19class TestDisplayMenus(IndicatorsTestCase):
19 def setUp(self):
20 def setUp(self):
20− super(TestDisplayMenus, self).setUp("400x800", "12")
21+ super(TestDisplayMenus, self).setUp(self.geometry, self.grid_unit)
21
22
22 # This opens the messaging menu so you don't have to do that in
23 # This opens the messaging menu so you don't have to do that in
23 # every test case
24 # every test case
@@ -82,6 +83,8 @@ class TestDisplayMenus(IndicatorsTestCase):
82 def test_brightness_slider(self):
83 def test_brightness_slider(self):
83 """Test the auto-bright switch"""
84 """Test the auto-bright switch"""
84
85
86+ if self.input_device_class is Touch:
87+ self.skipTest("Dragging is broken with Touch input (LP: #1203808).")
85 fn_brightness_menu = lambda: self.app.select_single("SliderMenuItem", objectName="brightness");
88 fn_brightness_menu = lambda: self.app.select_single("SliderMenuItem", objectName="brightness");
86 self.assertThat(fn_brightness_menu, Eventually(NotEquals(None)));
89 self.assertThat(fn_brightness_menu, Eventually(NotEquals(None)));
87 brightness_menu = fn_brightness_menu();
90 brightness_menu = fn_brightness_menu();
tests/autopilot/unity8/shell/__init__.py+61−5
@@ -1,8 +1,64 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3#
2#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
5+#
4−# This program is free software: you can redistribute it and/or modify it
6+# This program is free software: you can redistribute it and/or modify
5−# under the terms of the GNU General Public License version 3, as published
7+# it under the terms of the GNU General Public License as published by
6−# by the Free Software Foundation.
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+"""unity shell autopilot tests and emulators - sub level package."""
21+
22+from functools import wraps
23+import logging
24+import os.path
25+
26+from unity8 import get_mocks_library_path, get_default_extra_mock_libraries
27+
28+
29+logger = logging.getLogger(__name__)
30+
31+
32+def with_lightdm_mock(mock_type):
33+ """A simple decorator that sets up the LightDM mock for a single test."""
34+ def with_lightdm_mock_internal(fn):
35+ @wraps(fn)
36+ def wrapper(*args, **kwargs):
37+ logger.info("Setting up LightDM mock type '%s'", mock_type)
38+ new_ld_library_path = "%s:%s" % (
39+ get_default_extra_mock_libraries(),
40+ _get_ld_library_path(mock_type)
41+ )
42+ logger.info("New library path: %s", new_ld_library_path)
43+ tests_self = args[0]
44+ tests_self.patch_environment(
45+ 'LD_LIBRARY_PATH',
46+ new_ld_library_path
47+ )
48+ return fn(*args, **kwargs)
49+ return wrapper
50+ return with_lightdm_mock_internal
51+
52+
53+def _get_ld_library_path(mock_type):
54+ lib_path = get_mocks_library_path()
55+ new_ld_library_path = os.path.abspath(
56+ os.path.join(lib_path, "LightDM", mock_type)
57+ )
7
58
8−"""unity8 shell autopilot tests and emulators - sub level package."""
59+ if not os.path.exists(new_ld_library_path):
60+ raise RuntimeError(
61+ "LightDM mock '%s' does not exist at path '%s'."
62+ % (mock_type, new_ld_library_path)
63+ )
64+ return new_ld_library_path
tests/autopilot/unity8/shell/emulators/__init__.py+23−4
@@ -1,6 +1,25 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3#
2#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
5+#
4−# This program is free software: you can redistribute it and/or modify it
6+# This program is free software: you can redistribute it and/or modify
5−# under the terms of the GNU General Public License version 3, as published
7+# it under the terms of the GNU General Public License as published by
6−# by the Free Software Foundation.
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+
21+from autopilot.introspection import CustomEmulatorBase
22+
23+
24+class UnityEmulatorBase(CustomEmulatorBase):
25+ """A base class for all unity emulators."""
tests/autopilot/unity8/shell/emulators/dash.pynew file+52
@@ -0,0 +1,52 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+from unity8.shell.emulators import UnityEmulatorBase
21+
22+
23+class Dash(UnityEmulatorBase):
24+
25+ """An emulator that understands the Dash."""
26+
27+ def get_home_applications_grid(self):
28+ return self.select_single(
29+ "ApplicationsFilterGrid",
30+ objectName="dashHomeApplicationsGrid"
31+ )
32+
33+ def get_application_icon(self, text):
34+ """Returns a 'Tile' icon that has the text 'text' from the application
35+ grid.
36+
37+ Will return None if the icon isn't found.
38+
39+ :param text: String containing the text of the icon to search for.
40+
41+ """
42+ app_grid = self.get_home_applications_grid()
43+ resp_grid = app_grid.select_single('ResponsiveGridView')
44+ return resp_grid.select_single('Tile', text=text)
45+
46+ def get_scope(self, scope_name='home'):
47+ dash_content = self.select_single(
48+ 'QQuickListView',
49+ objectName='dashContentList'
50+ )
51+ scope_id = "%s.scope" % scope_name
52+ return dash_content.select_single('QQuickLoader', scopeId=scope_id)
tests/autopilot/unity8/shell/emulators/greeter.pynew file+40
@@ -0,0 +1,40 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+from unity8.shell.emulators import UnityEmulatorBase
21+from autopilot.input import Touch
22+
23+
24+class Greeter(UnityEmulatorBase):
25+
26+ """An emulator that understands the greeter screen."""
27+
28+ def unlock(self):
29+ """Swipe the greeter screen away."""
30+ self.created.wait_for(True)
31+ touch = Touch.create()
32+
33+ rect = self.globalRect
34+ start_x = rect[0] + rect[2] - 3
35+ start_y = int(rect[1] + rect[3] / 2)
36+ stop_x = int(rect[0] + rect[2] * 0.2)
37+ stop_y = start_y
38+ touch.drag(start_x, start_y, stop_x, stop_y)
39+
40+ self.created.wait_for(False)
tests/autopilot/unity8/shell/emulators/hud.pynew file+83
@@ -0,0 +1,83 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+from collections import namedtuple
21+
22+from unity8 import get_grid_size
23+from unity8.shell.emulators import UnityEmulatorBase
24+from autopilot.input import Touch
25+
26+
27+SwipeCoords = namedtuple('SwipeCoords', 'start_x end_x start_y end_y')
28+
29+
30+class Hud(UnityEmulatorBase):
31+
32+ """An emulator that understands the Hud."""
33+
34+ def show(self):
35+ """Swipes open the Hud."""
36+ touch = Touch.create()
37+
38+ window = self.get_root_instance().select_single('QQuickView')
39+ hud_show_button = window.select_single("HudButton")
40+
41+ start_x = int(window.x + (window.width / 2))
42+ end_x = start_x
43+ start_y = window.y + window.height
44+ end_y = int(hud_show_button.y + (hud_show_button.height/2))
45+
46+ touch.press(start_x, start_y)
47+ touch._finger_move(end_x, end_y)
48+ try:
49+ hud_show_button.opacity.wait_for(1.0)
50+ touch.release()
51+ self.shown.wait_for(True)
52+ except AssertionError:
53+ raise
54+ finally:
55+ if touch._touch_finger is not None:
56+ touch.release()
57+
58+ def dismiss(self):
59+ """Closes the open Hud."""
60+ # Ensure that the Hud is actually open
61+ self.shown.wait_for(True)
62+ touch = Touch.create()
63+ x, y = self.get_close_button_coords()
64+ touch.tap(x, y)
65+ self.y.wait_for(self.height)
66+
67+ def get_close_button_coords(self):
68+ """Returns the coordinates of the Huds close button bar."""
69+ rect = self.globalRect
70+ x = int(rect[0] + rect[2] / 2)
71+ y = rect[1] + get_grid_size()
72+ return x, y
73+
74+ def get_button_swipe_coords(self, main_view, hud_show_button):
75+ """Returns the coords both start and end x,y for swiping to make the
76+ 'hud show' button appear.
77+ """
78+ start_x = int(main_view.x + (main_view.width / 2))
79+ end_x = start_x
80+ start_y = main_view.y + (main_view.height - 3)
81+ end_y = int(hud_show_button.y + (hud_show_button.height/2))
82+
83+ return SwipeCoords(start_x, end_x, start_y, end_y)
tests/autopilot/unity8/shell/emulators/launcher.pynew file+38
@@ -0,0 +1,38 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+from unity8.shell.emulators import UnityEmulatorBase
21+from autopilot.input import Touch
22+
23+
24+class Launcher(UnityEmulatorBase):
25+
26+ """An emulator that understands the Launcher."""
27+
28+ def show(self):
29+ """Swipes open the launcher."""
30+ touch = Touch.create()
31+
32+ view = self.get_root_instance().select_single('QQuickView')
33+ start_x = view.x + 1
34+ start_y = view.y + view.height / 2
35+ stop_x = start_x + self.panelWidth + 1
36+ stop_y = start_y
37+ touch.drag(start_x, start_y, stop_x, stop_y)
38+ self.shown.wait_for(True)
tests/autopilot/unity8/shell/emulators/main_window.py+43−12
@@ -1,9 +1,28 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3#
2#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
5+#
4−# This program is free software: you can redistribute it and/or modify it
6+# This program is free software: you can redistribute it and/or modify
5−# under the terms of the GNU General Public License version 3, as published
7+# it under the terms of the GNU General Public License as published by
6−# by the Free Software Foundation.
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+
21+from unity8.shell.emulators.greeter import Greeter
22+from unity8.shell.emulators.hud import Hud
23+from unity8.shell.emulators.dash import Dash
24+from unity8.shell.emulators.launcher import Launcher
25+
7
26
8class MainWindow(object):
27class MainWindow(object):
9 """An emulator class that makes it easy to interact with the shell"""
28 """An emulator class that makes it easy to interact with the shell"""
@@ -16,10 +35,13 @@ class MainWindow(object):
16 return self.app.select_single("QQuickView")
35 return self.app.select_single("QQuickView")
17
36
18 def get_greeter(self):
37 def get_greeter(self):
19− return self.app.select_single("Greeter")
38+ return self.app.select_single(Greeter)
20
39
21 def get_greeter_content_loader(self):
40 def get_greeter_content_loader(self):
41+ return self.app.select_single(
42+ "QQuickLoader",
22− return self.app.select_single("QQuickLoader", objectName="greeterContentLoader")
43+ objectName="greeterContentLoader"
44+ )
23
45
24 def get_login_loader(self):
46 def get_login_loader(self):
25 return self.app.select_single("QQuickLoader", objectName="loginLoader")
47 return self.app.select_single("QQuickLoader", objectName="loginLoader")
@@ -28,7 +50,7 @@ class MainWindow(object):
28 return self.app.select_single("LoginList")
50 return self.app.select_single("LoginList")
29
51
30 def get_hud(self):
52 def get_hud(self):
31− return self.app.select_single("Hud")
53+ return self.app.select_single(Hud)
32
54
33 def get_hud_showable(self):
55 def get_hud_showable(self):
34 return self.app.select_single("Showable", objectName="hudShowable")
56 return self.app.select_single("Showable", objectName="hudShowable")
@@ -37,22 +59,31 @@ class MainWindow(object):
37 return self.app.select_single("HudButton")
59 return self.app.select_single("HudButton")
38
60
39 def get_dash(self):
61 def get_dash(self):
40− return self.app.select_single("Dash")
62+ return self.app.select_single(Dash)
41
63
42 def get_dash_home_applications_grid(self):
64 def get_dash_home_applications_grid(self):
65+ return self.app.select_single(
66+ "ApplicationsFilterGrid",
43− return self.app.select_single("ApplicationsFilterGrid", objectName="dashHomeApplicationsGrid")
67+ objectName="dashHomeApplicationsGrid"
68+ )
44
69
45 def get_bottombar(self):
70 def get_bottombar(self):
46 return self.app.select_single("Bottombar")
71 return self.app.select_single("Bottombar")
47
72
48 def get_launcher(self):
73 def get_launcher(self):
49− return self.app.select_single("Launcher")
74+ return self.app.select_single(Launcher)
50
75
51 def get_pinPadLoader(self):
76 def get_pinPadLoader(self):
52− return self.app.select_single("QQuickLoader", objectName="pinPadLoader")
77+ return self.app.select_single(
78+ "QQuickLoader",
79+ objectName="pinPadLoader"
80+ )
53
81
54 def get_pinPadButton(self, buttonId):
82 def get_pinPadButton(self, buttonId):
83+ return self.app.select_single(
84+ "PinPadButton",
55− return self.app.select_single("PinPadButton", objectName="pinPadButton%i" % buttonId)
85+ objectName="pinPadButton%i" % buttonId
86+ )
56
87
57 def get_lockscreen(self):
88 def get_lockscreen(self):
58 return self.app.select_single("Lockscreen")
89 return self.app.select_single("Lockscreen")
tests/autopilot/unity8/shell/tests/__init__.py+165−59
@@ -1,81 +1,187 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3#
2#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
5+#
4−# This program is free software: you can redistribute it and/or modify it
6+# This program is free software: you can redistribute it and/or modify
5−# under the terms of the GNU General Public License version 3, as published
7+# it under the terms of the GNU General Public License as published by
6−# by the Free Software Foundation.
8+# the Free Software Foundation, either version 3 of the License, or
7−
9+# (at your option) any later version.
8−"""unity8 autopilot tests."""
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+#
9
19
10−import os.path
20+"""unity autopilot tests."""
11−import sysconfig
12
21
22+from autopilot.platform import model
13from autopilot.testcase import AutopilotTestCase
23from autopilot.testcase import AutopilotTestCase
14from autopilot.matchers import Eventually
24from autopilot.matchers import Eventually
15−from autopilot.platform import model
25+from autopilot.input import Touch
26+from autopilot.display import Display
27+import logging
28+import os.path
16−from testtools.matchers import Equals
29+from testtools.matchers import Equals, NotEquals
17
30
31+from unity8 import get_lib_path, get_binary_path, get_mocks_library_path
32+from unity8.shell.emulators import UnityEmulatorBase
33+from unity8.shell.emulators.dash import Dash
18from unity8.shell.emulators.main_window import MainWindow
34from unity8.shell.emulators.main_window import MainWindow
19
35
20−class FormFactors(object):
21− Phone, Tablet, Desktop = range(3)
22
36
23−class ShellTestCase(AutopilotTestCase):
37+logger = logging.getLogger(__name__)
24
38
25− """A common test case class that provides several useful methods for shell tests."""
26
39
27− libdir = "/usr/lib/{0}/unity8".format(sysconfig.get_config_var('MULTIARCH'))
40+def _get_device_emulation_scenarios():
28− lightdm_mock = "full"
41+ if model() == 'Desktop':
42+ return [
43+ (
44+ 'Desktop Nexus 4',
45+ dict(app_width=768, app_height=1280, grid_unit_px=18)
46+ ),
47+ (
48+ 'Desktop Nexus 10',
49+ dict(app_width=2560, app_height=1600, grid_unit_px=20)
50+ ),
51+ ]
52+ else:
53+ return [
54+ (
55+ 'Native Device',
56+ dict(app_width=0, app_height=0, grid_unit_px=0)
57+ )
58+ ]
29
59
60+
61+class UnityTestCase(AutopilotTestCase):
62+
63+ """A test case base class for the Unity shell tests."""
64+
30− def setUp(self, geometry, grid_size):
65+ def setUp(self):
31− super(ShellTestCase, self).setUp()
66+ super(UnityTestCase, self).setUp()
32− # Lets assume we are installed system wide if this file is somewhere in /usr
67+ self._proxy = None
33− if grid_size != "0":
68+ self.touch = Touch.create()
34− os.environ['GRID_UNIT_PX'] = grid_size
69+ self._setup_display_details()
35− self.grid_size = int(grid_size)
70+
36− else:
71+ def _setup_display_details(self):
37− self.grid_size = int(os.environ['GRID_UNIT_PX'])
72+ scale_divisor = self._determine_geometry()
38− if os.path.realpath(__file__).startswith("/usr/"):
73+ self._setup_grid_size(scale_divisor)
39− self.launch_test_installed(geometry)
74+
75+ def _determine_geometry(self):
76+ """Use the geometry that may be supplied or use the default."""
77+ width = getattr(self, 'app_width', 0)
78+ height = getattr(self, 'app_height', 0)
79+ scale_divisor = 1
80+ if width == 0 and width == 0:
81+ self.unity_geometry_args = ['-fullscreen']
40 else:
82 else:
41− self.launch_test_local(geometry)
83+ if self._geo_larger_than_display(width, height):
42−
84+ scale_divisor = self._get_scaled_down_geo(width, height)
43− def launch_test_local(self, geometry):
85+ width = width / scale_divisor
44− os.environ['LD_LIBRARY_PATH'] = "../../builddir/tests/mocks/libusermetrics:../../builddir/tests/mocks/LightDM" + self.lightdm_mock
86+ height = height / scale_divisor
45− os.environ['QML2_IMPORT_PATH'] = "../../builddir/tests/mocks"
87+ logger.info(
46− if geometry != "0x0":
88+ "Geometry larger than display, scaled down to: %dx%d",
47− self.app = self.launch_test_application(
89+ width,
48− "../../builddir/unity8", "-geometry", geometry, "-frameless", app_type='qt')
90+ height
91+ )
92+ geo_string = "%dx%d" % (width, height)
93+ self.unity_geometry_args = [
94+ '-geometry',
95+ geo_string,
96+ '-frameless',
97+ '-mousetouch'
98+ ]
99+ return scale_divisor
100+
101+ def _setup_grid_size(self, scale_divisor):
102+ """Use the grid size that may be supplied or use the default."""
103+ if getattr(self, 'grid_unit_px', 0) == 0:
104+ self.grid_size = int(os.getenv('GRID_UNIT_PX'))
49 else:
105 else:
50− self.app = self.launch_test_application(
106+ self.grid_size = int(self.grid_unit_px / scale_divisor)
51− "../../builddir/unity8", "-fullscreen", app_type='qt')
107+ self.patch_environment("GRID_UNIT_PX", str(self.grid_size))
52−
108+
53− def launch_test_installed(self, geometry):
109+ def _geo_larger_than_display(self, width, height):
54− os.environ['LD_LIBRARY_PATH'] = "{0}/qml/mocks/libusermetrics:{0}/qml/mocks/LightDM/{1}".format(self.libdir, self.lightdm_mock)
110+ should_scale = getattr(self, 'scale_geo', True)
55− os.environ['QML2_IMPORT_PATH'] = "{0}/qml/mocks".format(self.libdir)
111+ if should_scale:
56− if model() == 'Desktop' and geometry != "0x0":
112+ screen = Display.create()
57− self.app = self.launch_test_application(
113+ screen_width = screen.get_screen_width()
58− "unity8", "-geometry", geometry, "-frameless", app_type='qt')
114+ screen_height = screen.get_screen_height()
115+ return (width > screen_width) or (height > screen_height)
59 else:
116 else:
117+ return False
118+
119+ def _get_scaled_down_geo(self, width, height):
120+ divisor = 1
121+ while self._geo_larger_than_display(width / divisor, height / divisor):
122+ divisor = divisor * 2
123+ return divisor
124+
125+ def launch_unity(self):
126+ """Launch the unity shell, return a proxy object for it."""
127+ binary_path = get_binary_path()
128+ lib_path = get_lib_path()
129+
130+ logger.info(
131+ "Lib path is '%s', binary path is '%s'",
132+ lib_path,
133+ binary_path
134+ )
135+
136+ self._setup_extra_mock_environment_patch()
137+
60− self.app = self.launch_test_application(
138+ app_proxy = self.launch_test_application(
139+ binary_path,
140+ *self.unity_geometry_args,
61− "unity8", "-fullscreen", app_type='qt')
141+ app_type='qt',
142+ emulator_base=UnityEmulatorBase
143+ )
144+ self._set_proxy(app_proxy)
145+
146+ # Ensure that the dash is visible before we return:
147+ logger.debug("Unity started, waiting for it to be ready.")
148+ self.assertUnityReady()
149+ logger.debug("Unity loaded and ready.")
150+
151+ return app_proxy
152+
153+ def _setup_extra_mock_environment_patch(self):
154+ mocks_library_path = get_mocks_library_path()
155+ self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)
156+
157+ def _set_proxy(self, proxy):
158+ """Keep a copy of the proxy object, so we can use it to get common
159+ parts of the shell later on.
160+
161+ """
162+ self._proxy = proxy
163+ self.addCleanup(self._clear_proxy)
164+
165+ def _clear_proxy(self):
166+ self._proxy = None
62
167
63− def skipWrapper(*args, **kwargs):
168+ def assertUnityReady(self):
64− pass
169+ dash = self.get_dash()
170+ home_scope = dash.get_scope('home')
65
171
66− def form_factor(self):
172+ # FIXME! There is a huge timeout here for when we're doing CI on
67− return FormFactors.Desktop
173+ # VMs. See lp:1203715
174+ self.assertThat(
175+ home_scope.isLoaded,
176+ Eventually(Equals(True), timeout=60)
177+ )
178+ self.assertThat(home_scope.isCurrent, Eventually(Equals(True)))
68
179
69− def __getattribute__(self, attr_name):
180+ def get_dash(self):
70− attr = object.__getattribute__(self, attr_name);
181+ dash = self._proxy.select_single(Dash)
71− if attr_name.startswith("test_"):
182+ self.assertThat(dash, NotEquals(None))
72− try:
73− if self.form_factor() in attr.blacklist:
74− return self.skipWrapper
75− except:
76− pass
77− return attr
183+ return dash
78
184
79 @property
185 @property
80 def main_window(self):
186 def main_window(self):
81− return MainWindow(self.app)
187+ return MainWindow(self._proxy)
tests/autopilot/unity8/shell/tests/helpers.pydeleted−161
@@ -1,161 +0,0 @@
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−from testtools.matchers import Equals, NotEquals
9−from autopilot.matchers import Eventually
10−
11−import logging
12−
13−logger = logging.getLogger(__name__)
14−
15−class TestShellHelpers(object):
16− """Helpers for testing the Shell"""
17−
18− def select_greeter_user(self, username):
19− greeter = self.main_window.get_greeter()
20− self.assertThat(greeter.created, Eventually(Equals(True)))
21− self.assertThat(greeter.multiUser, Eventually(Equals(True)))
22−
23− login_loader = self.main_window.get_login_loader()
24− self.assertThat(login_loader.progress, Eventually(Equals(1)))
25−
26− login_list = self.main_window.get_login_list()
27− list_view = login_list.get_children_by_type("QQuickListView")[0]
28−
29− try_count = 0
30− max_tries = 50 # just in case we go off rails
31− while try_count < max_tries:
32− users = list_view.get_children_by_type("QQuickItem")[0].get_children_by_type("QQuickItem")
33− target_user = None
34− for user in users:
35− try:
36− user_label = user.get_children_by_type("Label")[0]
37− if user.opacity < 0.1:
38− continue # off-screen item
39− if user_label.text == username:
40− target_user = user
41− break
42− elif target_user is None or user.y > target_user.y:
43− target_user = user
44− except Exception:
45− pass
46− if target_user is None:
47− break
48− user_label = target_user.get_children_by_type("Label")[0]
49− self.touch.tap_object(user_label)
50− self.assertThat(list_view.movingInternally, Eventually(Equals(False)))
51− if user_label.text == username:
52− return login_list.get_children_by_type("TextField")[0]
53− try_count = try_count + 1
54− self.fail() # We didn't find it
55−
56− def unlock_greeter(self, retries=2):
57− greeter = self.main_window.get_greeter()
58− self.assertThat(greeter.created, Eventually(Equals(True)))
59−
60− if greeter.multiUser:
61− password_field = self.select_greeter_user("No Password")
62− self.assertThat(password_field.opacity, Eventually(Equals(1)))
63− self.touch.tap_object(password_field)
64−
65− else:
66− rect = greeter.globalRect
67− start_x = rect[0] + rect[2] - 3
68− start_y = int(rect[1] + rect[3] / 2)
69− stop_x = int(rect[0] + rect[2] * 0.2)
70− stop_y = start_y
71− self.touch.drag(start_x, start_y, stop_x, stop_y)
72−
73− # Because the shell loads up lots of stuff, unlocking the greeter can
74− # be a bit stuttery while scopes are still consuming all resources.
75− # Give it another (max retries) chance
76− try:
77− self.assertThat(greeter.created, Eventually(Equals(False)))
78− except:
79− if retries > 0:
80− logger.warning("Failed to unlock greeter. Retrying...")
81− self.unlock_greeter(retries-1)
82− else:
83− logger.warning("Failed to unlock greeter. Giving up. Tests may fail...")
84−
85−
86− def open_first_dash_home_app(self, retries=2):
87− self.assertThat(lambda: self.main_window.get_dash_home_applications_grid(), Eventually(NotEquals(None)))
88− app_grid = self.main_window.get_dash_home_applications_grid()
89− # Wait for the grids to be expanded
90− self.assertThat(app_grid.get_children()[0].totalContentHeight, Eventually(NotEquals(0)))
91− self.assertThat(app_grid.get_children()[0].height, Eventually(Equals(app_grid.get_children()[0].totalContentHeight)))
92− first_app = app_grid.get_children()[0].get_children()[0].get_children()[0].get_children()[0]
93− self.touch.tap_object(first_app)
94− bottombar = self.main_window.get_bottombar()
95−
96− # if we have huge amounts of pixels (e.g. Nexus10), but slow video (e.g. VM) it might take a little
97− # until the dash is fully rendered after sliding away the greeter/lockscreen and the click might
98− # go to the void for the first time because there's no real way to know what the display has
99− # painted already. Give it another (max retries) chance.
100− try:
101− self.assertThat(lambda: getattr(bottombar, "applicationIsOnForeground"),
102− Eventually(Equals(True)))
103− except:
104− if retries > 0:
105− logger.warning("Failed to launch app. Retrying...")
106− self.open_first_dash_home_app(retries-1)
107− else:
108− logger.warning("Failed to launch app. Giving up. Tests may fail...")
109−
110−
111− def show_hud(self, retries=2):
112− self.open_first_dash_home_app()
113−
114− hud_show_button = self.main_window.get_hud_show_button()
115− hud = self.main_window.get_hud()
116− window = self.main_window.get_qml_view()
117− start_x = int(window.x + window.width / 2)
118− start_y = window.y + window.height - 3
119− self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
120− self.touch.press(start_x, start_y)
121− self.touch._finger_move(start_x, start_y - self.grid_size)
122− self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
123− self.touch._finger_move(start_x, start_y - self.grid_size * 2)
124− self.touch._finger_move(start_x, start_y - self.grid_size * 3)
125− self.touch._finger_move(start_x, start_y - self.grid_size * 4)
126− try:
127− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
128− except:
129− if retries > 0:
130− logger.warning("Failed to get hud button to show. Retrying...")
131− self.touch.release()
132− self.show_hud(retries-1)
133− return
134− else:
135− logger.warning("Failed to get hud button to show. Giving up. Tests may fail...")
136− self.assertThat(hud_show_button.mouseOver, Eventually(Equals(False)))
137− self.touch._finger_move(start_x, start_y - self.grid_size * 34)
138− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
139− self.assertThat(hud_show_button.mouseOver, Eventually(Equals(True)))
140− self.touch.release()
141− self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
142− self.assertThat(hud.shown, Eventually(Equals(True)))
143−
144− def close_hud_click(self):
145− hud = self.main_window.get_hud()
146− self.assertThat(hud.shown, Eventually(Equals(True)))
147− rect = hud.globalRect
148− x = int(rect[0] + rect[2] / 2)
149− y = rect[1] + self.grid_size
150− self.touch.tap(x, y)
151− self.assertThat(hud.shown, Eventually(Equals(False)))
152−
153− def show_launcher(self):
154− launcher = self.main_window.get_launcher()
155− view = self.main_window.get_qml_view()
156− start_x = view.x + 1
157− start_y = view.y + view.height / 2
158− stop_x = start_x + launcher.panelWidth + 1
159− stop_y = start_y
160− self.touch.drag(start_x, start_y, stop_x, stop_y)
161− self.assertThat(launcher.shown, Eventually(Equals(True)))
tests/autopilot/unity8/shell/tests/test_hud.pynew file+156
@@ -0,0 +1,156 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+from __future__ import absolute_import
21+
22+from unity8.shell import with_lightdm_mock
23+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
24+
25+from testtools.matchers import Equals
26+from autopilot.matchers import Eventually
27+
28+
29+class TestHud(UnityTestCase):
30+
31+ """Tests the Shell HUD."""
32+
33+ scenarios = _get_device_emulation_scenarios()
34+
35+ @with_lightdm_mock("single")
36+ def test_show_hud_button_appears(self):
37+ """Swiping up while an app is active must show the 'show hud' button.
38+
39+ """
40+ self.launch_unity()
41+ self.main_window.get_greeter().unlock()
42+ window = self.main_window.get_qml_view()
43+ hud_show_button = self.main_window.get_hud_show_button()
44+ hud = self.main_window.get_hud()
45+
46+ self._launch_test_app_from_app_screen()
47+
48+ swipe_coords = hud.get_button_swipe_coords(
49+ window,
50+ hud_show_button
51+ )
52+ self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
53+ self.addCleanup(self.touch.release)
54+ self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
55+ self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
56+
57+ @with_lightdm_mock("single")
58+ def test_show_hud_appears(self):
59+ """Releasing the touch on the 'show hud' button must display the hud.
60+
61+ """
62+ self.launch_unity()
63+ self.main_window.get_greeter().unlock()
64+ window = self.main_window.get_qml_view()
65+ hud_show_button = self.main_window.get_hud_show_button()
66+ hud = self.main_window.get_hud()
67+
68+ self._launch_test_app_from_app_screen()
69+
70+ swipe_coords = hud.get_button_swipe_coords(
71+ window,
72+ hud_show_button
73+ )
74+ self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
75+ self.addCleanup(self._maybe_release_finger)
76+ self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
77+
78+ self.assertThat(hud.shown, Eventually(Equals(False)))
79+ self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
80+ self.touch.release()
81+ self.assertThat(hud.shown, Eventually(Equals(True)))
82+
83+ @with_lightdm_mock("single")
84+ def test_hide_hud_click(self):
85+ """Tapping the close button of the Hud must dismiss it."""
86+ self.launch_unity()
87+ self.main_window.get_greeter().unlock()
88+ hud = self.main_window.get_hud()
89+
90+ self._launch_test_app_from_app_screen()
91+ hud.show()
92+
93+ x, y = hud.get_close_button_coords()
94+ self.touch.tap(x, y)
95+ self.assertThat(hud.shown, Eventually(Equals(False)))
96+
97+ @with_lightdm_mock("single")
98+ def test_hide_hud_dragging(self):
99+ """Once open the Hud must close if the upper bar is dragged and
100+ released downward.
101+
102+ """
103+ self.launch_unity()
104+ self.main_window.get_greeter().unlock()
105+ hud = self.main_window.get_hud()
106+ window = self.main_window.get_qml_view()
107+
108+ self._launch_test_app_from_app_screen()
109+ hud.show()
110+
111+ start_x, start_y = hud.get_close_button_coords()
112+ end_x = start_x
113+ end_y = int(window.height / 2)
114+
115+ self.touch.drag(start_x, start_y, end_x, end_y)
116+ self.assertThat(hud.shown, Eventually(Equals(False)))
117+
118+ @with_lightdm_mock("single")
119+ def test_launcher_hides_hud(self):
120+ """Opening the Launcher while the Hud is active must close the Hud."""
121+ self.launch_unity()
122+ self.main_window.get_greeter().unlock()
123+ hud = self.main_window.get_hud()
124+ launcher = self.main_window.get_launcher()
125+
126+ self._launch_test_app_from_app_screen()
127+
128+ hud.show()
129+ launcher.show()
130+
131+ self.assertThat(hud.shown, Eventually(Equals(False)))
132+
133+ def _launch_test_app_from_app_screen(self):
134+ """Launches the camera app using the Dash UI.
135+
136+ Because when testing on the desktop running
137+ self.launch_application() will launch the application on the desktop
138+ itself and not within the Unity UI.
139+
140+ """
141+ dash = self.main_window.get_dash()
142+ icon = dash.get_application_icon('Camera')
143+ self.touch.tap_object(icon)
144+
145+ # Ensure application is open
146+ bottombar = self.main_window.get_bottombar()
147+ self.assertThat(bottombar.applicationIsOnForeground,
148+ Eventually(Equals(True)))
149+
150+ # Because some tests are manually manipulating the finger, we want to
151+ # cleanup if the test fails, but we don't want to fail with an exception if
152+ # we don't.
153+ def _maybe_release_finger(self):
154+ """Only release the finger if it is in fact down."""
155+ if self.touch._touch_finger is not None:
156+ self.touch.release()
tests/autopilot/unity8/shell/tests/test_lock_screen.pynew file+133
@@ -0,0 +1,133 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 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+
21+from __future__ import absolute_import
22+
23+from unity8.shell import with_lightdm_mock
24+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
25+
26+from autopilot.matchers import Eventually
27+from autopilot.platform import model
28+from testtools import skipUnless
29+from testtools.matchers import Equals
30+
31+
32+class TestLockscreen(UnityTestCase):
33+
34+ """Tests for the lock screen."""
35+
36+ scenarios = _get_device_emulation_scenarios()
37+
38+ @with_lightdm_mock("single-pin")
39+ def test_can_unlock_pin_screen(self):
40+ """Must be able to unlock the PIN entry lock screen."""
41+ self.launch_unity()
42+ greeter = self.main_window.get_greeter()
43+ greeter.unlock()
44+
45+ lockscreen = self._wait_for_lockscreen()
46+ self._enter_pincode("1234")
47+
48+ self.assertThat(lockscreen.shown, Eventually(Equals(False)))
49+
50+ @skipUnless(model() == 'Desktop', "Broken passphrase entry on UInput (LP: #1203788).")
51+ @with_lightdm_mock("single-passphrase")
52+ def test_can_unlock_passphrase_screen(self):
53+ """Must be able to unlock the passphrase entry screen."""
54+ self.launch_unity()
55+ greeter = self.main_window.get_greeter()
56+ greeter.unlock()
57+
58+ lockscreen = self._wait_for_lockscreen()
59+ self._enter_passphrase("password")
60+
61+ self.assertThat(lockscreen.shown, Eventually(Equals(False)))
62+
63+ @with_lightdm_mock("single-pin")
64+ def test_pin_screen_wrong_code(self):
65+ """Entering the wrong pin code must not dismiss the lock screen."""
66+ self.launch_unity()
67+ greeter = self.main_window.get_greeter()
68+ greeter.unlock()
69+
70+ lockscreen = self._wait_for_lockscreen()
71+ self._enter_pincode("4321")
72+
73+ pinentryField = self.main_window.get_pinentryField()
74+ self.assertThat(pinentryField.text, Eventually(Equals("")))
75+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
76+
77+ @skipUnless(model() == 'Desktop', "Broken passphrase entry on UInput (LP: #1203788).")
78+ @with_lightdm_mock("single-passphrase")
79+ def test_passphrase_screen_wrong_password(self):
80+ """Entering the wrong password must not dismiss the lock screen."""
81+ self.launch_unity()
82+ greeter = self.main_window.get_greeter()
83+ greeter.unlock()
84+
85+ lockscreen = self._wait_for_lockscreen()
86+ self._enter_passphrase("foobar")
87+
88+ pinentryField = self.main_window.get_pinentryField()
89+ self.assertThat(pinentryField.text, Eventually(Equals("")))
90+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
91+
92+ def _wait_for_lockscreen(self):
93+ """Wait for the lock screen to load, and return it."""
94+ pinPadLoader = self.main_window.get_pinPadLoader()
95+ self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
96+ lockscreen = self.main_window.get_lockscreen()
97+ self.assertThat(lockscreen.shown, Eventually(Equals(True)))
98+ return lockscreen
99+
100+ def _enter_pincode(self, code):
101+ """Enter code 'code' into the single-pin lightdm pincode entry
102+ screen.
103+
104+ :param code: must be a string of numeric characters.
105+ :raises: TypeError if code is not a string.
106+ :raises: ValueError if code contains non-numeric characters.
107+
108+ """
109+
110+ if not isinstance(code, basestring):
111+ raise TypeError("'code' parameter must be a string.")
112+ for num in code:
113+ if not num.isdigit():
114+ raise ValueError(
115+ "'code' parameter contains non-numeric characters."
116+ )
117+ self.touch.tap_object(self.main_window.get_pinPadButton(int(num)))
118+
119+ def _enter_passphrase(self, passphrase):
120+ """Enter the password specified in 'passphrase' into the password entry
121+ field.
122+
123+ :param passphrase: The string you want to enter.
124+ :raises: TypeError if passphrase is not a string.
125+
126+ """
127+ if not isinstance(passphrase, basestring):
128+ raise TypeError("'passphrase' parameter must be a string.")
129+
130+ pinentryField = self.main_window.get_pinentryField()
131+ self.touch.tap_object(pinentryField)
132+ self.keyboard.type(passphrase)
133+ self.keyboard.type("\n")
tests/autopilot/unity8/shell/tests/testbigscreen.pydeleted−25
@@ -1,25 +0,0 @@
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−"""Add tests here if you want to ensure everything is aligned correctly on huge screens. Because this test does not fit on most screens, you should not use input devices here or your tests are likely to fail"""
9−
10−from testtools.matchers import Equals
11−from autopilot.matchers import Eventually
12−
13−from unity8.shell.tests import ShellTestCase
14−
15−class TestBig(ShellTestCase):
16− def setUp(self):
17− super(TestBig, self).setUp("2560x1600", "20")
18− self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
19−
20− def tearDown(self):
21− super(TestBig, self).tearDown()
22−
23− def test_hud_not_shown_greeter(self):
24− hud_showable = self.main_window.get_hud_showable()
25− self.assertThat(hud_showable.y, Eventually(Equals(1600)))
tests/autopilot/unity8/shell/tests/testhud.pydeleted−145
@@ -1,145 +0,0 @@
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 ShellTestCase, FormFactors
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 TestHud(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− ('Nexus 4', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single")),
56− ('Nexus 10', dict(app_width=2560, app_height=1600, grid_unit_px=20, lightdm_mock="full")),
57−# TODO: don't run fullscreen tests just yet as the VM is performing too badly for that. Enable this once
58−# Autopilot tests are running on bear metal.
59−# ('Fullscreen', dict(app_width=0, app_height=0, grid_unit_px=10, lightdm_mock="full")),
60− ]
61− else:
62− scenarios = [
63− ('Fullscreen', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single")),
64− ]
65−
66− def setUp(self):
67− self.touch = Touch.create()
68−
69− sg = Display().create()
70− divisor = 1
71− while (sg.get_screen_width() < self.app_width / divisor or sg.get_screen_height() < self.app_height / divisor):
72− divisor = divisor * 2
73− super(TestHud, self).setUp("%sx%s" % (self.app_width / divisor, self.app_height / divisor), "%s" % (self.grid_unit_px / divisor))
74−
75− dash = self.main_window.get_dash()
76− self.assertThat(dash.showScopeOnLoaded, Eventually(Equals(""), timeout=30))
77−
78− def test_show_hud(self):
79− hud = self.main_window.get_hud()
80− self.unlock_greeter()
81− self.show_hud()
82− self.assertThat(hud.shown, Eventually(Equals(True)))
83−
84− def test_show_hud_button_dont_open(self):
85− self.unlock_greeter()
86− self.open_first_dash_home_app()
87− hud_show_button = self.main_window.get_hud_show_button()
88− hud = self.main_window.get_hud()
89− window = self.main_window.get_qml_view()
90− start_x = int(window.x + window.width / 2)
91− start_y = window.y + window.height - 2
92− self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
93− self.touch.press(start_x, start_y)
94− self.touch._finger_move(start_x, start_y - self.grid_size)
95− self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
96− self.touch._finger_move(start_x, start_y - self.grid_size * 2)
97− self.touch._finger_move(start_x, start_y - self.grid_size * 3)
98− self.touch._finger_move(start_x, start_y - self.grid_size * 4)
99− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
100− self.assertThat(hud_show_button.mouseOver, Eventually(Equals(False)))
101− self.touch._finger_move(start_x, start_y - self.grid_size * 34)
102− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
103− self.assertThat(hud_show_button.mouseOver, Eventually(Equals(True)))
104− self.touch._finger_move(start_x, start_y - self.grid_size)
105− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
106− self.assertThat(hud_show_button.mouseOver, Eventually(Equals(False)))
107− self.touch.release()
108− self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
109− self.assertThat(hud.shown, Eventually(Equals(False)))
110−
111− def test_hide_hud_click(self):
112− hud = self.main_window.get_hud()
113− self.unlock_greeter()
114− self.show_hud()
115− self.close_hud_click()
116− self.assertThat(hud.shown, Eventually(Equals(False)))
117−
118− def test_hide_hud_click_outside_handle(self):
119− hud = self.main_window.get_hud()
120− self.unlock_greeter()
121− self.show_hud()
122− rect = hud.globalRect
123− x = int(rect[0] + rect[2] / 2)
124− y = rect[1] + hud.handleHeight + 1
125− self.touch.tap(x, y)
126− self.assertRaises(MismatchError, lambda: self.assertThat(hud.shown, Eventually(Equals(False), timeout=3)))
127−
128− def test_hide_hud_dragging(self):
129− hud = self.main_window.get_hud()
130− self.unlock_greeter()
131− self.show_hud()
132− rect = hud.globalRect
133− start_x = rect[0] + (rect[2] - rect[0]) / 2
134− start_y = rect[1] + 1
135− stop_x = start_x
136− stop_y = start_y + (rect[3] - rect[1]) / 2
137− self.touch.drag(start_x, start_y, stop_x, stop_y)
138− self.assertThat(hud.shown, Eventually(Equals(False)))
139−
140− def test_hide_hud_launcher(self):
141− hud = self.main_window.get_hud()
142− self.unlock_greeter()
143− self.show_hud()
144− self.show_launcher()
145− self.assertThat(hud.shown, Eventually(Equals(False)))
tests/autopilot/unity8/shell/tests/testlockscreen.pydeleted−118
@@ -1,118 +0,0 @@
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 ShellTestCase, FormFactors
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 TestLockscreens(ShellTestCase, TestShellHelpers):
44−
45− """Tests the Lockscreens"""
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(TestLockscreens, 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.showScopeOnLoaded, 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)))
tests/qmltests/Panel/tst_IndicatorRow.qml+19−19
@@ -61,13 +61,13 @@ Item {
61
61
62 function test_set_current_item() {
62 function test_set_current_item() {
63 init_test();
63 init_test();
64− indicatorRow.setItem(0);
64+ indicatorRow.setCurrentItem(0);
65 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu1", "Incorrect item at position 0");
65 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu1", "Incorrect item at position 0");
66
66
67− indicatorRow.setItem(1);
67+ indicatorRow.setCurrentItem(1);
68 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu2", "Incorrect item at position 1");
68 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu2", "Incorrect item at position 1");
69
69
70− indicatorRow.setItem(2);
70+ indicatorRow.setCurrentItem(2);
71 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu3", "Incorrect item at position 2");
71 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu3", "Incorrect item at position 2");
72 }
72 }
73 }
73 }
@@ -83,13 +83,13 @@ Item {
83 function test_current_item_commit() {
83 function test_current_item_commit() {
84 init_test();
84 init_test();
85
85
86− indicatorRow.setItem(1);
86+ indicatorRow.setCurrentItem(1);
87 indicatorRow.state = "commit";
87 indicatorRow.state = "commit";
88− tryCompare(get_indicator_item_at(0), "y", -indicatorRow.height);
88+ tryCompare(get_indicator_item_at(0), "opacity", 0.0);
89− tryCompare(get_indicator_item_at(1), "y", 0);
89+ tryCompare(get_indicator_item_at(1), "opacity", 1.0);
90− tryCompare(get_indicator_item_at(2), "y", -indicatorRow.height);
90+ tryCompare(get_indicator_item_at(2), "opacity", 0.0);
91− tryCompare(get_indicator_item_at(3), "y", -indicatorRow.height);
91+ tryCompare(get_indicator_item_at(3), "opacity", 0.0);
92− tryCompare(get_indicator_item_at(4), "y", -indicatorRow.height);
92+ tryCompare(get_indicator_item_at(4), "opacity", 0.0);
93
93
94 }
94 }
95 }
95 }
@@ -106,7 +106,7 @@ Item {
106 init_test();
106 init_test();
107
107
108 indicatorRow.state = "initial";
108 indicatorRow.state = "initial";
109− indicatorRow.setItem(0);
109+ indicatorRow.setCurrentItem(0);
110
110
111 compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
111 compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
112 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
112 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
@@ -119,7 +119,7 @@ Item {
119 init_test();
119 init_test();
120
120
121 indicatorRow.state = "hint";
121 indicatorRow.state = "hint";
122− indicatorRow.setItem(0);
122+ indicatorRow.setCurrentItem(0);
123
123
124 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
124 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
125 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
125 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
@@ -132,7 +132,7 @@ Item {
132 init_test();
132 init_test();
133
133
134 indicatorRow.state = "reveal";
134 indicatorRow.state = "reveal";
135− indicatorRow.setItem(0);
135+ indicatorRow.setCurrentItem(0);
136
136
137 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
137 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
138 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
138 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
@@ -145,7 +145,7 @@ Item {
145 init_test();
145 init_test();
146
146
147 indicatorRow.state = "commit";
147 indicatorRow.state = "commit";
148− indicatorRow.setItem(0);
148+ indicatorRow.setCurrentItem(0);
149
149
150 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
150 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
151 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
151 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
@@ -158,7 +158,7 @@ Item {
158 init_test();
158 init_test();
159
159
160 indicatorRow.state = "locked";
160 indicatorRow.state = "locked";
161− indicatorRow.setItem(0);
161+ indicatorRow.setCurrentItem(0);
162
162
163 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
163 compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
164 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
164 compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
@@ -180,7 +180,7 @@ Item {
180 init_test();
180 init_test();
181
181
182 indicatorRow.state = "initial";
182 indicatorRow.state = "initial";
183− indicatorRow.setItem(0);
183+ indicatorRow.setCurrentItem(0);
184
184
185 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
185 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
186 compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
186 compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
@@ -193,7 +193,7 @@ Item {
193 init_test();
193 init_test();
194
194
195 indicatorRow.state = "hint";
195 indicatorRow.state = "hint";
196− indicatorRow.setItem(0);
196+ indicatorRow.setCurrentItem(0);
197
197
198 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
198 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
199 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
199 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
@@ -206,7 +206,7 @@ Item {
206 init_test();
206 init_test();
207
207
208 indicatorRow.state = "reveal";
208 indicatorRow.state = "reveal";
209− indicatorRow.setItem(0);
209+ indicatorRow.setCurrentItem(0);
210
210
211 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
211 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
212 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
212 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
@@ -219,7 +219,7 @@ Item {
219 init_test();
219 init_test();
220
220
221 indicatorRow.state = "commit";
221 indicatorRow.state = "commit";
222− indicatorRow.setItem(0);
222+ indicatorRow.setCurrentItem(0);
223
223
224 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
224 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
225 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
225 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
@@ -232,7 +232,7 @@ Item {
232 init_test();
232 init_test();
233
233
234 indicatorRow.state = "locked";
234 indicatorRow.state = "locked";
235− indicatorRow.setItem(0);
235+ indicatorRow.setCurrentItem(0);
236
236
237 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
237 compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
238 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
238 compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
tests/qmltests/Panel/tst_MenuContent.qml+4−4
@@ -77,15 +77,15 @@ Item {
77
77
78 function activate_next_content()
78 function activate_next_content()
79 {
79 {
80− if (menuContent.currentIndex == -1)
80+ if (menuContent.currentMenuIndex == -1)
81 activate_content(0);
81 activate_content(0);
82 else
82 else
83− activate_content((menuContent.currentIndex + 1) % indicatorsModel.count)
83+ activate_content((menuContent.currentMenuIndex + 1) % indicatorsModel.count)
84 }
84 }
85
85
86 function activate_content(index)
86 function activate_content(index)
87 {
87 {
88− menuContent.currentIndex = index
88+ menuContent.currentMenuIndex = index
89 }
89 }
90
90
91 function get_test_menu_objecName(index) {
91 function get_test_menu_objecName(index) {
@@ -197,7 +197,7 @@ Item {
197
197
198 for (var i = 0; i < 100; i++) {
198 for (var i = 0; i < 100; i++) {
199 activate_content(i % menu_count);
199 activate_content(i % menu_count);
200− compare(menuContent.currentIndex, i%menu_count);
200+ compare(menuContent.currentMenuIndex, i%menu_count);
201 }
201 }
202 wait(100);
202 wait(100);
203 }
203 }
tests/qmltests/Panel/tst_Panel.qml+83−43
@@ -30,11 +30,11 @@ Item {
30 width: units.gu(40)
30 width: units.gu(40)
31 height: units.gu(80)
31 height: units.gu(80)
32
32
33− property bool search_clicked: false
33+ property bool searchClicked: false
34
34
35 Connections {
35 Connections {
36 target: panel
36 target: panel
37− onSearchClicked: search_clicked = true
37+ onSearchClicked: searchClicked = true
38 }
38 }
39
39
40 Panel {
40 Panel {
@@ -54,27 +54,26 @@ Item {
54
54
55
55
56 function init() {
56 function init() {
57− search_clicked = false;
57+ searchClicked = false;
58 panel.indicators.hide();
58 panel.indicators.hide();
59 tryCompare(panel.indicators.hideAnimation, "running", false);
59 tryCompare(panel.indicators.hideAnimation, "running", false);
60 tryCompare(panel.indicators, "state", "initial");
60 tryCompare(panel.indicators, "state", "initial");
61 }
61 }
62
62
63 function get_indicator_item(index) {
63 function get_indicator_item(index) {
64− var row_repeater = findChild(panel.indicators, "rowRepeater");
64+ var rowRepeater = findChild(panel.indicators, "rowRepeater");
65− verify(row_repeater != undefined);
65+ verify(rowRepeater != undefined);
66− return row_repeater.itemAt(index);
66+ return rowRepeater.itemAt(index);
67 }
67 }
68
68
69 function get_indicator_item_position(index) {
69 function get_indicator_item_position(index) {
70+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
71+ verify(indicatorRow != undefined);
70
72
71− var indicator_row = findChild(panel.indicators, "indicatorRow");
72− verify(indicator_row != undefined);
73−
74− var indicator_item = get_indicator_item(index);
73+ var indicatorItem = get_indicator_item(index);
75− verify(indicator_item != undefined);
74+ verify(indicatorItem != undefined);
76
75
77− return panel.mapFromItem(indicator_item, indicator_item.width/2, indicator_item.height/2);
76+ return panel.mapFromItem(indicatorItem, indicatorItem.width/2, indicatorItem.height/2);
78 }
77 }
79
78
80 // Pressing on the indicator panel should activate the indicator hints
79 // Pressing on the indicator panel should activate the indicator hints
@@ -85,9 +84,9 @@ Item {
85 // (switches between normal and fullscreen modes are animated)
84 // (switches between normal and fullscreen modes are animated)
86 tryCompare(panel.indicators, "y", 0);
85 tryCompare(panel.indicators, "y", 0);
87
86
88− var indicator_item_coord = get_indicator_item_position(0);
87+ var indicatorItemCoord = get_indicator_item_position(0);
89
88
90− touchPress(panel, indicator_item_coord.x, panel.panelHeight / 2);
89+ touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
91
90
92 // hint animation should be run, meaning that indicators will move downwards
91 // hint animation should be run, meaning that indicators will move downwards
93 // by hintValue pixels without any drag taking place
92 // by hintValue pixels without any drag taking place
@@ -96,7 +95,7 @@ Item {
96 tryCompare(panel.indicators, "partiallyOpened", true);
95 tryCompare(panel.indicators, "partiallyOpened", true);
97 tryCompare(panel.indicators, "fullyOpened", false);
96 tryCompare(panel.indicators, "fullyOpened", false);
98
97
99− touchRelease(panel, indicator_item_coord.x, panel.panelHeight/2);
98+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
100 }
99 }
101
100
102 // Pressing on the top edge of the screen should have no effect if the panel
101 // Pressing on the top edge of the screen should have no effect if the panel
@@ -107,9 +106,9 @@ Item {
107 // (switches between normal and fullscreen modes are animated)
106 // (switches between normal and fullscreen modes are animated)
108 tryCompare(panel.indicators, "y", -panel.panelHeight);
107 tryCompare(panel.indicators, "y", -panel.panelHeight);
109
108
110− var indicator_item_coord = get_indicator_item_position(0);
109+ var indicatorItemCoord = get_indicator_item_position(0);
111
110
112− touchPress(panel, indicator_item_coord.x, panel.panelHeight / 2);
111+ touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
113
112
114 // Give some time for a hint animation to change things, if any
113 // Give some time for a hint animation to change things, if any
115 wait(500);
114 wait(500);
@@ -126,7 +125,7 @@ Item {
126 compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
125 compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
127 " opened when panel is pressed in fullscreenmode");
126 " opened when panel is pressed in fullscreenmode");
128
127
129− touchRelease(panel, indicator_item_coord.x, panel.panelHeight/2);
128+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
130 }
129 }
131
130
132 function test_drag_show_data() { return get_window_data(); }
131 function test_drag_show_data() { return get_window_data(); }
@@ -137,14 +136,14 @@ Item {
137 function test_drag_show(data) {
136 function test_drag_show(data) {
138 panel.fullscreenMode = data.fullscreenFlag;
137 panel.fullscreenMode = data.fullscreenFlag;
139
138
140− var indicator_row = findChild(panel.indicators, "indicatorRow");
139+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
141− verify(indicator_row != undefined);
140+ verify(indicatorRow != undefined);
142
141
143− var row_repeater = findChild(panel.indicators, "rowRepeater");
142+ var rowRepeater = findChild(panel.indicators, "rowRepeater");
144− verify(indicator_row != undefined);
143+ verify(indicatorRow != undefined);
145
144
146− var menu_content = findChild(panel.indicators, "menuContent");
145+ var menuContent = findChild(panel.indicators, "menuContent");
147− verify(indicator_row != undefined);
146+ verify(indicatorRow != undefined);
148
147
149 // Wait for the indicators to get into position.
148 // Wait for the indicators to get into position.
150 // (switches between normal and fullscreen modes are animated)
149 // (switches between normal and fullscreen modes are animated)
@@ -155,20 +154,20 @@ Item {
155 }
154 }
156
155
157 // do this for each indicator item
156 // do this for each indicator item
158− for (var i = 0; i < row_repeater.count; i++) {
157+ for (var i = 0; i < rowRepeater.count; i++) {
159
158
160− var indicator_item = get_indicator_item(i);
159+ var indicatorItem = get_indicator_item(i);
161− verify(indicator_item != undefined);
160+ verify(indicatorItem != undefined);
162
161
163− var indicator_item_coord = get_indicator_item_position(i);
162+ var indicatorItemCoord = get_indicator_item_position(i);
164
163
165 touchPress(panel,
164 touchPress(panel,
166− indicator_item_coord.x, panel.panelHeight / 2);
165+ indicatorItemCoord.x, panel.panelHeight / 2);
167
166
168 // 1) Drag the mouse down
167 // 1) Drag the mouse down
169 touchFlick(panel,
168 touchFlick(panel,
170− indicator_item_coord.x, panel.panelHeight / 2,
169+ indicatorItemCoord.x, panel.panelHeight / 2,
171− indicator_item_coord.x, panel.height * 0.8,
170+ indicatorItemCoord.x, panel.height * 0.8,
172 false /* beginTouch */, false /* endTouch */);
171 false /* beginTouch */, false /* endTouch */);
173
172
174 // Indicators height should follow the drag, and therefore increase accordingly.
173 // Indicators height should follow the drag, and therefore increase accordingly.
@@ -177,13 +176,13 @@ Item {
177 function() {return panel.indicators.height >= panel.height * 0.5},
176 function() {return panel.indicators.height >= panel.height * 0.5},
178 true);
177 true);
179
178
180− touchRelease(panel, indicator_item_coord.x, panel.height * 0.8);
179+ touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
181
180
182− compare(indicator_row.currentItem, indicator_item,
181+ compare(indicatorRow.currentItem, indicatorItem,
183 "Incorrect item activated at position " + i);
182 "Incorrect item activated at position " + i);
184− compare(menu_content.currentIndex, i, "Menu conetent should be enabled for item at position " + i);
183+ compare(menuContent.currentMenuIndex, i, "Menu conetent should be enabled for item at position " + i);
185
184
186− // init for next indicator_item
185+ // init for next indicatorItem
187 init();
186 init();
188 }
187 }
189 }
188 }
@@ -192,12 +191,12 @@ Item {
192 panel.fullscreenMode = false;
191 panel.fullscreenMode = false;
193 panel.searchVisible = true;
192 panel.searchVisible = true;
194
193
195− var search_indicator = findChild(panel, "search");
194+ var searchIndicator = findChild(panel, "search");
196− verify(search_indicator != undefined);
195+ verify(searchIndicator != undefined);
197
196
198− tap(search_indicator, 1, 1);
197+ tap(searchIndicator, 1, 1);
199
198
200− compare(search_clicked, true,
199+ compare(searchClicked, true,
201 "Tapping search indicator while it was enabled did not emit searchClicked signal");
200 "Tapping search indicator while it was enabled did not emit searchClicked signal");
202 }
201 }
203
202
@@ -205,13 +204,54 @@ Item {
205 panel.fullscreenMode = false;
204 panel.fullscreenMode = false;
206 panel.searchVisible = false;
205 panel.searchVisible = false;
207
206
208− var search_indicator = findChild(panel, "search");
207+ var searchIndicator = findChild(panel, "search");
209− verify(search_indicator != undefined);
208+ verify(searchIndicator != undefined);
210
209
211− tap(search_indicator, 1, 1);
210+ tap(searchIndicator, 1, 1);
212
211
213− compare(search_clicked, false,
212+ compare(searchClicked, false,
214 "Tapping search indicator while it was not visible emitted searchClicked signal");
213 "Tapping search indicator while it was not visible emitted searchClicked signal");
215 }
214 }
215+
216+ // Test the vertical velocity check when flicking the indicators open at an angle.
217+ // If the vertical velocity is above a specific point, we shouldnt change active indicators
218+ // if the x position changes
219+ function test_vertical_velocity_detector() {
220+ panel.fullscreenMode = false;
221+ panel.searchVisible = false;
222+
223+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
224+ verify(indicatorRow != undefined);
225+
226+ var rowRepeater = findChild(panel.indicators, "rowRepeater");
227+ verify(indicatorRow != undefined);
228+
229+ // Get the first indicator
230+ var indicatorItemFirst = get_indicator_item(0);
231+ verify(indicatorItemFirst != undefined);
232+
233+ var indicatorItemCoordFirst = get_indicator_item_position(0);
234+ var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.count - 1);
235+
236+ touchPress(panel,
237+ indicatorItemCoordFirst.x, panel.panelHeight / 2);
238+
239+ // 1) Drag the mouse down to hint a bit
240+ touchFlick(panel,
241+ indicatorItemCoordFirst.x, panel.panelHeight / 2,
242+ indicatorItemCoordFirst.x, panel.panelHeight * 2,
243+ false /* beginTouch */, false /* endTouch */);
244+
245+ tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
246+
247+ // 1) Flick mouse down to bottom
248+ touchFlick(panel,
249+ indicatorItemCoordFirst.x, panel.panelHeight * 2,
250+ indicatorItemCoordNext.x, panel.height,
251+ false /* beginTouch */, true /* endTouch */,
252+ units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity
253+
254+ compare(indicatorRow.currentItem, indicatorItemFirst, "First indicator should still be the current item");
255+ }
216 }
256 }
217}
257}
tests/utils/modules/Unity/Test/UnityTestCase.qml+22−18
@@ -32,32 +32,34 @@ TestCase {
32 // Qt uses in QQuickViewTestUtil::flick
32 // Qt uses in QQuickViewTestUtil::flick
33 // speed is in pixels/second
33 // speed is in pixels/second
34 function mouseFlick(item, x, y, toX, toY, pressMouse, releaseMouse,
34 function mouseFlick(item, x, y, toX, toY, pressMouse, releaseMouse,
35− speed) {
35+ speed, iterations) {
36 pressMouse = ((pressMouse != null) ? pressMouse : true); // Default to true for pressMouse if not present
36 pressMouse = ((pressMouse != null) ? pressMouse : true); // Default to true for pressMouse if not present
37 releaseMouse = ((releaseMouse != null) ? releaseMouse : true); // Default to true for releaseMouse if not present
37 releaseMouse = ((releaseMouse != null) ? releaseMouse : true); // Default to true for releaseMouse if not present
38
38
39 // set a default speed if not specified
39 // set a default speed if not specified
40 speed = (speed != null) ? speed : units.gu(10);
40 speed = (speed != null) ? speed : units.gu(10);
41
41
42+ // set a default iterations if not specified
43+ iterations = (iterations !== undefined) ? iterations : 5
44+
42 var distance = Math.sqrt(Math.pow(toX - x, 2) + Math.pow(toY - y, 2))
45 var distance = Math.sqrt(Math.pow(toX - x, 2) + Math.pow(toY - y, 2))
43 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
46 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
44
47
45− var nIterations = 5
46− var timeStep = totalTime / nIterations
48+ var timeStep = totalTime / iterations
47− var diffX = (toX - x) / nIterations
49+ var diffX = (toX - x) / iterations
48− var diffY = (toY - y) / nIterations
50+ var diffY = (toY - y) / iterations
49 if (pressMouse) {
51 if (pressMouse) {
50 fakeDateTime.currentTimeMs += timeStep
52 fakeDateTime.currentTimeMs += timeStep
51 mousePress(item, x, y)
53 mousePress(item, x, y)
52 }
54 }
53− for (var i = 0; i < nIterations; ++i) {
55+ for (var i = 0; i < iterations; ++i) {
54 fakeDateTime.currentTimeMs += timeStep
56 fakeDateTime.currentTimeMs += timeStep
55− if (i === nIterations - 1) {
57+ if (i === iterations - 1) {
56 // Avoid any rounding errors by making the last move be at precisely
58 // Avoid any rounding errors by making the last move be at precisely
57 // the point specified
59 // the point specified
58− mouseMove(item, toX, toY, nIterations / speed)
60+ mouseMove(item, toX, toY, iterations / speed)
59 } else {
61 } else {
60− mouseMove(item, x + (i + 1) * diffX, y + (i + 1) * diffY, nIterations / speed)
62+ mouseMove(item, x + (i + 1) * diffX, y + (i + 1) * diffY, iterations / speed)
61 }
63 }
62 }
64 }
63 if (releaseMouse) {
65 if (releaseMouse) {
@@ -186,7 +188,7 @@ TestCase {
186 }
188 }
187
189
188 // speed is in pixels/second
190 // speed is in pixels/second
189− function touchFlick(item, x, y, toX, toY, beginTouch, endTouch, speed) {
191+ function touchFlick(item, x, y, toX, toY, beginTouch, endTouch, speed, iterations) {
190
192
191 // Default to true for beginTouch if not present
193 // Default to true for beginTouch if not present
192 beginTouch = (beginTouch !== undefined) ? beginTouch : true
194 beginTouch = (beginTouch !== undefined) ? beginTouch : true
@@ -197,13 +199,15 @@ TestCase {
197 // Set a default speed if not specified
199 // Set a default speed if not specified
198 speed = (speed !== undefined) ? speed : units.gu(10)
200 speed = (speed !== undefined) ? speed : units.gu(10)
199
201
202+ // Set a default iterations if not specified
203+ var iterations = (iterations !== undefined) ? iterations : 5
204+
200 var distance = Math.sqrt(Math.pow(toX - x, 2) + Math.pow(toY - y, 2))
205 var distance = Math.sqrt(Math.pow(toX - x, 2) + Math.pow(toY - y, 2))
201 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
206 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
202
207
203− var nIterations = 5
204− var timeStep = totalTime / nIterations
208+ var timeStep = totalTime / iterations
205− var diffX = (toX - x) / nIterations
209+ var diffX = (toX - x) / iterations
206− var diffY = (toY - y) / nIterations
210+ var diffY = (toY - y) / iterations
207 if (beginTouch) {
211 if (beginTouch) {
208 fakeDateTime.currentTimeMs += timeStep
212 fakeDateTime.currentTimeMs += timeStep
209
213
@@ -211,17 +215,17 @@ TestCase {
211 event.press(0 /* touchId */, x, y)
215 event.press(0 /* touchId */, x, y)
212 event.commit()
216 event.commit()
213 }
217 }
214− for (var i = 0; i < nIterations; ++i) {
218+ for (var i = 0; i < iterations; ++i) {
215 fakeDateTime.currentTimeMs += timeStep
219 fakeDateTime.currentTimeMs += timeStep
216− if (i === nIterations - 1) {
220+ if (i === iterations - 1) {
217 // Avoid any rounding errors by making the last move be at precisely
221 // Avoid any rounding errors by making the last move be at precisely
218 // the point specified
222 // the point specified
219− wait(nIterations / speed)
223+ wait(iterations / speed)
220 var event = touchEvent()
224 var event = touchEvent()
221 event.move(0 /* touchId */, toX, toY)
225 event.move(0 /* touchId */, toX, toY)
222 event.commit()
226 event.commit()
223 } else {
227 } else {
224− wait(nIterations / speed)
228+ wait(iterations / speed)
225 var event = touchEvent()
229 var event = touchEvent()
226 event.move(0 /* touchId */, x + (i + 1) * diffX, y + (i + 1) * diffY)
230 event.move(0 /* touchId */, x + (i + 1) * diffX, y + (i + 1) * diffY)
227 event.commit()
231 event.commit()