on xenial help sign in
Removed the tests for the alternate paths of the autopilot helpers.
0bd9d71Leonardo Arias Fonseca
tests/autopilot/unity8/shell/tests/test_emulators.py+4−47
@@ -28,13 +28,8 @@ don't break them for those external projects.
28
28
29"""
29"""
30
30
31−try:
32− from unittest import mock
33−except ImportError:
34− import mock
35−
36from unity8 import process_helpers
31from unity8 import process_helpers
37−from unity8.shell import emulators, fixture_setup, tests
32+from unity8.shell import fixture_setup, tests
38from unity8.shell.emulators import dash as dash_emulators
33from unity8.shell.emulators import dash as dash_emulators
39
34
40
35
@@ -55,35 +50,6 @@ class DashEmulatorTestCase(tests.DashBaseTestCase):
55 text_field = self.dash._get_search_text_field()
50 text_field = self.dash._get_search_text_field()
56 self.assertEqual(text_field.text, 'Test')
51 self.assertEqual(text_field.text, 'Test')
57
52
58− def test_open_unexisting_scope(self):
59− scope_name = 'unexisting'
60− with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
61− exception = self.assertRaises(
62− emulators.UnityEmulatorException,
63− self.dash.open_scope, scope_name)
64−
65− self.assertEqual(
66− 'No scope found with id unexisting', str(exception))
67− self.assertFalse(mock_pointer.called)
68−
69− def test_open_already_opened_scope(self):
70− scope_id = self._get_current_scope_id()
71− with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
72− scope = self.dash.open_scope(scope_id)
73−
74− self.assertFalse(mock_pointer.called)
75− self._assert_scope_is_opened(scope, scope_id)
76−
77− def _assert_scope_is_opened(self, scope, scope_id):
78− self.assertTrue(scope.isCurrent)
79− scope_loader = scope.get_parent()
80− self.assertEqual(scope_loader.scopeId, scope_id)
81−
82− def _get_current_scope_id(self):
83− scope = self.dash.dash_content_list.select_single(
84− 'QQuickLoader', isCurrent=True)
85− return scope.scopeId
86−
87 def test_open_scope_to_the_right(self):
53 def test_open_scope_to_the_right(self):
88 leftmost_scope = self._get_leftmost_scope_id()
54 leftmost_scope = self._get_leftmost_scope_id()
89 self.dash.open_scope(leftmost_scope)
55 self.dash.open_scope(leftmost_scope)
@@ -161,15 +127,6 @@ class DashAppsEmulatorTestCase(tests.DashBaseTestCase):
161 super(DashAppsEmulatorTestCase, self).setUp()
127 super(DashAppsEmulatorTestCase, self).setUp()
162 self.applications_scope = self.dash.open_scope('clickscope')
128 self.applications_scope = self.dash.open_scope('clickscope')
163
129
164− def test_get_applications_with_unexisting_category(self):
165− exception = self.assertRaises(
166− emulators.UnityEmulatorException,
167− self.applications_scope.get_applications,
168− 'unexisting category')
169−
170− self.assertEqual(
171− 'No category found with name unexisting category', str(exception))
172−
173 def test_get_applications_should_return_correct_applications(self):
130 def test_get_applications_should_return_correct_applications(self):
174 category = '2'
131 category = '2'
175 category_element = self.applications_scope._get_category_element(
132 category_element = self.applications_scope._get_category_element(
@@ -181,9 +138,9 @@ class DashAppsEmulatorTestCase(tests.DashBaseTestCase):
181 :expected_apps_count]
138 :expected_apps_count]
182 x_center = list_view.globalRect.x + list_view.width / 2
139 x_center = list_view.globalRect.x + list_view.width / 2
183 y_center = list_view.globalRect.y + list_view.height / 2
140 y_center = list_view.globalRect.y + list_view.height / 2
141+ y_diff = (
184− y_diff = category_element.y - list_view.height + category_element.height
142+ category_element.y - list_view.height + category_element.height)
185− list_view._slow_drag(x_center, x_center,
143+ list_view._slow_drag(x_center, x_center, y_center, y_center - y_diff)
186− y_center, y_center - y_diff)
187 applications = self.applications_scope.get_applications(category)
144 applications = self.applications_scope.get_applications(category)
188 self.assertEqual(expected_applications, applications)
145 self.assertEqual(expected_applications, applications)
189
146