on xenial help sign in
code cleanup.
da33378Thomi Richards
tests/autopilot/setup.py+16−5
@@ -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+# Unity8 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
tests/autopilot/unity8/__init__.py+16−4
@@ -1,9 +1,21 @@
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+# Unity8 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+#
7
19
8"""unity8 autopilot tests and emulators - top level package."""
20"""unity8 autopilot tests and emulators - top level package."""
9import os
21import os
tests/autopilot/unity8/shell/__init__.py+17−5
@@ -1,18 +1,30 @@
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+# Unity8 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+#
7
19
8"""unity8 shell autopilot tests and emulators - sub level package."""
20"""unity8 shell autopilot tests and emulators - sub level package."""
9
21
10from functools import wraps
22from functools import wraps
23+import logging
11import os.path
24import os.path
12
25
13from unity8 import get_lib_path, running_installed_tests
26from unity8 import get_lib_path, running_installed_tests
14
27
15−import logging
16
28
17logger = logging.getLogger(__name__)
29logger = logging.getLogger(__name__)
18
30
tests/autopilot/unity8/shell/emulators/__init__.py+16−4
@@ -1,9 +1,21 @@
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+# Unity8 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+#
7
19
8
20
9from autopilot.introspection import CustomEmulatorBase
21from autopilot.introspection import CustomEmulatorBase
tests/autopilot/unity8/shell/emulators/dash.py+20
@@ -1,3 +1,22 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity8 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+
1from unity8.shell.emulators import Unity8EmulatorBase
20from unity8.shell.emulators import Unity8EmulatorBase
2
21
3
22
@@ -18,6 +37,7 @@ class Dash(Unity8EmulatorBase):
18 Will return None if the icon isn't found.
37 Will return None if the icon isn't found.
19
38
20 :param text: String containing the text of the icon to search for.
39 :param text: String containing the text of the icon to search for.
40+
21 """
41 """
22 app_grid = self.get_home_applications_grid()
42 app_grid = self.get_home_applications_grid()
23 resp_grid = app_grid.select_single('ResponsiveGridView')
43 resp_grid = app_grid.select_single('ResponsiveGridView')
tests/autopilot/unity8/shell/emulators/greeter.py+20−1
@@ -1,3 +1,22 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity8 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+
1from unity8.shell.emulators import Unity8EmulatorBase
20from unity8.shell.emulators import Unity8EmulatorBase
2from autopilot.input import Touch
21from autopilot.input import Touch
3
22
@@ -28,7 +47,7 @@ class Greeter(Unity8EmulatorBase):
28
47
29 self.created.wait_for(False)
48 self.created.wait_for(False)
30
49
31− #TODO: This was moved here from helpers.TestShellHelpersg
50+ #TODO: This was moved here from helpers.TestShellHelpers
32 # Needs a cleanup (used in borked above).
51 # Needs a cleanup (used in borked above).
33 def select_greeter_user(self, username):
52 def select_greeter_user(self, username):
34 greeter = self.main_window.get_greeter()
53 greeter = self.main_window.get_greeter()
tests/autopilot/unity8/shell/emulators/hud.py+19−1
@@ -1,3 +1,22 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity8 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+
1from unity8 import get_grid_size
20from unity8 import get_grid_size
2from unity8.shell.emulators import Unity8EmulatorBase
21from unity8.shell.emulators import Unity8EmulatorBase
3from autopilot.input import Touch
22from autopilot.input import Touch
@@ -18,7 +37,6 @@ class Hud(Unity8EmulatorBase):
18
37
19 start_x = int(window.x + (window.width / 2))
38 start_x = int(window.x + (window.width / 2))
20 end_x = start_x
39 end_x = start_x
21− # start_y = window.y + (window.height - 3)
22 start_y = window.y + window.height
40 start_y = window.y + window.height
23 end_y = int(hud_show_button.y + (hud_show_button.height/2))
41 end_y = int(hud_show_button.y + (hud_show_button.height/2))
24
42
tests/autopilot/unity8/shell/emulators/launcher.py+19
@@ -1,3 +1,22 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity8 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+
1from unity8.shell.emulators import Unity8EmulatorBase
20from unity8.shell.emulators import Unity8EmulatorBase
2from autopilot.input import Touch
21from autopilot.input import Touch
3
22
tests/autopilot/unity8/shell/emulators/main_window.py+30−9
@@ -1,9 +1,21 @@
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+# Unity8 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+#
7
19
8
20
9from unity8.shell.emulators.greeter import Greeter
21from unity8.shell.emulators.greeter import Greeter
@@ -26,7 +38,10 @@ class MainWindow(object):
26 return self.app.select_single(Greeter)
38 return self.app.select_single(Greeter)
27
39
28 def get_greeter_content_loader(self):
40 def get_greeter_content_loader(self):
41+ return self.app.select_single(
42+ "QQuickLoader",
29− return self.app.select_single("QQuickLoader", objectName="greeterContentLoader")
43+ objectName="greeterContentLoader"
44+ )
30
45
31 def get_login_loader(self):
46 def get_login_loader(self):
32 return self.app.select_single("QQuickLoader", objectName="loginLoader")
47 return self.app.select_single("QQuickLoader", objectName="loginLoader")
@@ -35,7 +50,7 @@ class MainWindow(object):
35 return self.app.select_single("LoginList")
50 return self.app.select_single("LoginList")
36
51
37 def get_hud(self):
52 def get_hud(self):
38− return self.app.select_single("Hud")
53+ return self.app.select_single(Hud)
39
54
40 def get_hud_showable(self):
55 def get_hud_showable(self):
41 return self.app.select_single("Showable", objectName="hudShowable")
56 return self.app.select_single("Showable", objectName="hudShowable")
@@ -47,19 +62,25 @@ class MainWindow(object):
47 return self.app.select_single(Dash)
62 return self.app.select_single(Dash)
48
63
49 def get_dash_home_applications_grid(self):
64 def get_dash_home_applications_grid(self):
65+ return self.app.select_single(
66+ "ApplicationsFilterGrid",
50− return self.app.select_single("ApplicationsFilterGrid", objectName="dashHomeApplicationsGrid")
67+ objectName="dashHomeApplicationsGrid"
68+ )
51
69
52 def get_bottombar(self):
70 def get_bottombar(self):
53 return self.app.select_single("Bottombar")
71 return self.app.select_single("Bottombar")
54
72
55 def get_launcher(self):
73 def get_launcher(self):
56− return self.app.select_single("Launcher")
74+ return self.app.select_single(Launcher)
57
75
58 def get_pinPadLoader(self):
76 def get_pinPadLoader(self):
59 return self.app.select_single("QQuickLoader", objectName="pinPadLoader")
77 return self.app.select_single("QQuickLoader", objectName="pinPadLoader")
60
78
61 def get_pinPadButton(self, buttonId):
79 def get_pinPadButton(self, buttonId):
80+ return self.app.select_single(
81+ "PinPadButton",
62− return self.app.select_single("PinPadButton", objectName="pinPadButton%i" % buttonId)
82+ objectName="pinPadButton%i" % buttonId
83+ )
63
84
64 def get_lockscreen(self):
85 def get_lockscreen(self):
65 return self.app.select_single("Lockscreen")
86 return self.app.select_single("Lockscreen")
tests/autopilot/unity8/shell/tests/__init__.py+51−26
@@ -1,46 +1,66 @@
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+# Unity8 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+#
7
19
8"""unity8 autopilot tests."""
20"""unity8 autopilot tests."""
9
21
10from autopilot.platform import model
22from autopilot.platform import model
11from autopilot.testcase import AutopilotTestCase
23from autopilot.testcase import AutopilotTestCase
12from autopilot.matchers import Eventually
24from autopilot.matchers import Eventually
13−from testtools.matchers import Equals, NotEquals
14from autopilot.input import Touch
25from autopilot.input import Touch
15from autopilot.display import Display
26from autopilot.display import Display
16import logging
27import logging
17import os.path
28import os.path
18−import sysconfig
29+from testtools.matchers import Equals, NotEquals
19
30
20from unity8 import get_lib_path, get_unity8_binary_path
31from unity8 import get_lib_path, get_unity8_binary_path
21−from unity8.shell.emulators.main_window import MainWindow
22from unity8.shell.emulators import Unity8EmulatorBase
32from unity8.shell.emulators import Unity8EmulatorBase
23from unity8.shell.emulators.dash import Dash
33from unity8.shell.emulators.dash import Dash
34+from unity8.shell.emulators.main_window import MainWindow
24
35
25
36
26logger = logging.getLogger(__name__)
37logger = logging.getLogger(__name__)
27
38
28
39
29−class FormFactors(object):
30− Phone, Tablet, Desktop = range(3)
31−
32def _get_device_emulation_scenarios():
40def _get_device_emulation_scenarios():
33 if model() == 'Desktop':
41 if model() == 'Desktop':
34 return [
42 return [
43+ (
44+ 'Desktop Nexus 4',
35− ('Desktop Nexus 4', dict(app_width=768, app_height=1280, grid_unit_px=18)),
45+ dict(app_width=768, app_height=1280, grid_unit_px=18)
46+ ),
47+ (
48+ 'Desktop Nexus 10',
36− ('Desktop Nexus 10', dict(app_width=2560, app_height=1600, grid_unit_px=20)),
49+ dict(app_width=2560, app_height=1600, grid_unit_px=20)
50+ ),
37 ]
51 ]
38 else:
52 else:
53+ return [
54+ (
55+ 'Native Device',
39− return [ ('Native Device', dict(app_width=0, app_height=0, grid_unit_px=0)) ]
56+ dict(app_width=0, app_height=0, grid_unit_px=0)
57+ )
58+ ]
59+
40
60
41class Unity8TestCase(AutopilotTestCase):
61class Unity8TestCase(AutopilotTestCase):
42
62
43− """A sane test case base class for the Unity8 shell tests."""
63+ """A test case base class for the Unity8 shell tests."""
44
64
45 def setUp(self):
65 def setUp(self):
46 super(Unity8TestCase, self).setUp()
66 super(Unity8TestCase, self).setUp()
@@ -49,7 +69,6 @@ class Unity8TestCase(AutopilotTestCase):
49 self._setup_display_details()
69 self._setup_display_details()
50
70
51 def _setup_display_details(self):
71 def _setup_display_details(self):
52− # This needs a bit of a cleanup, make it clearer
53 scale_divisor = self._determine_geometry()
72 scale_divisor = self._determine_geometry()
54 self._setup_grid_size(scale_divisor)
73 self._setup_grid_size(scale_divisor)
55
74
@@ -65,12 +84,18 @@ class Unity8TestCase(AutopilotTestCase):
65 scale_divisor = self._get_scaled_down_geo(width, height)
84 scale_divisor = self._get_scaled_down_geo(width, height)
66 width = width / scale_divisor
85 width = width / scale_divisor
67 height = height / scale_divisor
86 height = height / scale_divisor
87+ logger.info(
68− logger.info("Provided geometry larger than Display, scaled down to: %sx%s",
88+ "Geometry larger than display, scaled down to: %dx%d",
69 width,
89 width,
70 height
90 height
71 )
91 )
72− geo_string = "%sx%s" % (width, height)
92+ geo_string = "%dx%d" % (width, height)
73− self.unity_geometry_args = ['-geometry', geo_string, '-frameless', '-mousetouch']
93+ self.unity_geometry_args = [
94+ '-geometry',
95+ geo_string,
96+ '-frameless',
97+ '-mousetouch'
98+ ]
74 return scale_divisor
99 return scale_divisor
75
100
76 def _setup_grid_size(self, scale_divisor):
101 def _setup_grid_size(self, scale_divisor):
@@ -122,18 +147,18 @@ class Unity8TestCase(AutopilotTestCase):
122 self._set_proxy(app_proxy)
147 self._set_proxy(app_proxy)
123
148
124 # Ensure that the dash is visible before we return:
149 # Ensure that the dash is visible before we return:
150+ self.assertThat(
125− self.assertThat(self.get_dash().showScopeOnLoaded, Eventually(Equals("")))
151+ self.get_dash().showScopeOnLoaded,
152+ Eventually(Equals(""))
153+ )
126 return app_proxy
154 return app_proxy
127
155
128 def _patch_environment(self, lib_path):
156 def _patch_environment(self, lib_path):
129 """Patch environment variables for launching the unity8 shell."""
157 """Patch environment variables for launching the unity8 shell."""
130− # ld_lib_path_patches = (
131− # os.path.join(lib_path, "qml/mocks/libusermetrics"),
132− # os.path.join(lib_path, "qml/mocks/LightDM/" + self.lightdm_mock),
133− # )
134−
135− # self.patch_environment("LD_LIBRARY_PATH", ":".join(ld_lib_path_patches))
158+ self.patch_environment(
159+ "QML2_IMPORT_PATH",
136− self.patch_environment("QML2_IMPORT_PATH", os.path.join(lib_path, "qml/mocks"))
160+ os.path.join(lib_path, "qml/mocks")
161+ )
137
162
138 def _set_proxy(self, proxy):
163 def _set_proxy(self, proxy):
139 """Keep a copy of the proxy object, so we can use it to get common parts
164 """Keep a copy of the proxy object, so we can use it to get common parts
tests/autopilot/unity8/shell/tests/test_big_screen_alignment.pydeleted−30
@@ -1,30 +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 autopilot.matchers import Eventually
11−from testtools.matchers import Equals
12−
13−from unity8.shell.tests import Unity8TestCase
14−
15−
16−# TODO: Find out if these tests are still required, if so, what they're supposed
17−# to be testing, and whether they're supposed to work on the devices.
18−class ScreenAlignmentTests(Unity8TestCase):
19−
20− scenarios = [
21− ('Big Screen', dict(app_width=2560, app_height=1600, grid_unit_px=20, scale_geo=False))
22− ]
23−
24− def test_hud_not_shown_greeter(self):
25− self.launch_unity()
26− self.assertThat(self.main_window.get_qml_view().visible,
27− Eventually(Equals(True))
28− )
29− hud_showable = self.main_window.get_hud_showable()
30− self.assertThat(hud_showable.y, Eventually(Equals(1600)))
tests/autopilot/unity8/shell/tests/test_hud.py+25−50
@@ -1,9 +1,21 @@
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+# Unity8 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+#
7
19
8from __future__ import absolute_import
20from __future__ import absolute_import
9
21
@@ -21,7 +33,7 @@ SwipeCoords = namedtuple('SwipeCoords', 'start_x end_x start_y end_y')
21
33
22class TestHud(Unity8TestCase):
34class TestHud(Unity8TestCase):
23
35
24− """Tests the Shell HUD"""
36+ """Tests the Shell HUD."""
25
37
26 scenarios = _get_device_emulation_scenarios()
38 scenarios = _get_device_emulation_scenarios()
27
39
@@ -35,7 +47,10 @@ class TestHud(Unity8TestCase):
35
47
36 self._launch_test_app_from_app_screen()
48 self._launch_test_app_from_app_screen()
37
49
38− swipe_coords = self._get_hud_button_swipe_coords(window, hud_show_button)
50+ swipe_coords = self._get_hud_button_swipe_coords(
51+ window,
52+ hud_show_button
53+ )
39 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
54 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
40 self.addCleanup(self.touch.release)
55 self.addCleanup(self.touch.release)
41 self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
56 self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
@@ -52,7 +67,10 @@ class TestHud(Unity8TestCase):
52
67
53 self._launch_test_app_from_app_screen()
68 self._launch_test_app_from_app_screen()
54
69
55− swipe_coords = self._get_hud_button_swipe_coords(window, hud_show_button)
70+ swipe_coords = self._get_hud_button_swipe_coords(
71+ window,
72+ hud_show_button
73+ )
56 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
74 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
57 self.addCleanup(self._maybe_release_finger)
75 self.addCleanup(self._maybe_release_finger)
58 self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
76 self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
@@ -62,39 +80,6 @@ class TestHud(Unity8TestCase):
62 self.touch.release()
80 self.touch.release()
63 self.assertThat(hud.shown, Eventually(Equals(True)))
81 self.assertThat(hud.shown, Eventually(Equals(True)))
64
82
65− # def test_show_hud_button_dont_open(self):
66− # self.launch_unity()
67− # hud_show_button = self.main_window.get_hud_show_button()
68− # hud = self.main_window.get_hud()
69− # greeter = self.main_window.get_greeter()
70− # greeter.unlock()
71−
72− # self.unlock_greeter()
73− # self.open_first_dash_home_app()
74− # hud_show_button = self.main_window.get_hud_show_button()
75− # hud = self.main_window.get_hud()
76− # window = self.main_window.get_qml_view()
77− # start_x = int(window.x + window.width / 2)
78− # start_y = window.y + window.height - 2
79− # self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
80− # self.touch.press(start_x, start_y)
81− # self.touch._finger_move(start_x, start_y - self.grid_size)
82− # self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
83− # self.touch._finger_move(start_x, start_y - self.grid_size * 2)
84− # self.touch._finger_move(start_x, start_y - self.grid_size * 3)
85− # self.touch._finger_move(start_x, start_y - self.grid_size * 4)
86− # self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
87− # self.assertThat(hud_show_button.mouseOver, Eventually(Equals(False)))
88− # self.touch._finger_move(start_x, start_y - self.grid_size * 34)
89− # self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
90− # self.assertThat(hud_show_button.mouseOver, Eventually(Equals(True)))
91− # self.touch._finger_move(start_x, start_y - self.grid_size)
92− # self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
93− # self.assertThat(hud_show_button.mouseOver, Eventually(Equals(False)))
94− # self.touch.release()
95− # self.assertThat(hud_show_button.opacity, Eventually(Equals(0)))
96− # self.assertThat(hud.shown, Eventually(Equals(False)))
97−
98 @with_lightdm_mock("single")
83 @with_lightdm_mock("single")
99 def test_hide_hud_click(self):
84 def test_hide_hud_click(self):
100 """Tapping the close button of the Hud must dismiss it."""
85 """Tapping the close button of the Hud must dismiss it."""
@@ -109,16 +94,6 @@ class TestHud(Unity8TestCase):
109 self.touch.tap(x, y)
94 self.touch.tap(x, y)
110 self.assertThat(hud.shown, Eventually(Equals(False)))
95 self.assertThat(hud.shown, Eventually(Equals(False)))
111
96
112− # def test_hide_hud_click_outside_handle(self):
113− # hud = self.main_window.get_hud()
114− # self.unlock_greeter()
115− # self.show_hud()
116− # rect = hud.globalRect
117− # x = int(rect[0] + rect[2] / 2)
118− # y = rect[1] + hud.handleHeight + 1
119− # self.touch.tap(x, y)
120− # self.assertRaises(MismatchError, lambda: self.assertThat(hud.shown, Eventually(Equals(False), timeout=3)))
121−
122 @with_lightdm_mock("single")
97 @with_lightdm_mock("single")
123 def test_hide_hud_dragging(self):
98 def test_hide_hud_dragging(self):
124 """Once open the Hud must close if the upper bar is dragged and released
99 """Once open the Hud must close if the upper bar is dragged and released
tests/autopilot/unity8/shell/tests/test_lock_screen.py+16−8
@@ -1,9 +1,21 @@
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+# Unity8 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+#
7
19
8
20
9from __future__ import absolute_import
21from __future__ import absolute_import
@@ -13,14 +25,10 @@ from unity8.shell.tests import Unity8TestCase, _get_device_emulation_scenarios
13
25
14from autopilot.matchers import Eventually
26from autopilot.matchers import Eventually
15from autopilot.platform import model
27from autopilot.platform import model
16−import logging
17from testtools import skipUnless
28from testtools import skipUnless
18from testtools.matchers import Equals
29from testtools.matchers import Equals
19
30
20
31
21−logger = logging.getLogger(__name__)
22−
23−
24class TestLockscreen(Unity8TestCase):
32class TestLockscreen(Unity8TestCase):
25
33
26 """Tests for the lock screen."""
34 """Tests for the lock screen."""