Merge lp:~fboucault/ubuntu-ui-toolkit/fix_1197355 into lp:ubuntu-ui-toolkit

Proposed by Florian Boucault
Status: Merged
Approved by: Tim Peeters
Approved revision: 581
Merged at revision: 580
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/fix_1197355
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 972 lines (+185/-448)
9 files modified
debian/control (+0/-2)
examples/ubuntu-ui-toolkit-gallery/Buttons.qml (+2/-2)
tests/autopilot/UbuntuUiToolkit/__init__.py (+5/-14)
tests/autopilot/UbuntuUiToolkit/emulators/__init__.py (+5/-112)
tests/autopilot/UbuntuUiToolkit/emulators/main_window.py (+22/-0)
tests/autopilot/UbuntuUiToolkit/tests/__init__.py (+52/-66)
tests/autopilot/UbuntuUiToolkit/tests/gallery/__init__.py (+6/-14)
tests/autopilot/UbuntuUiToolkit/tests/gallery/test_gallery.py (+93/-96)
tests/autopilot/UbuntuUiToolkit/tests/test_emulators.py (+0/-142)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/fix_1197355
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Pending
Review via email: mp+172861@code.launchpad.net

Commit message

Reverted revisions 562 & 569 that broke the autopilot tests.
Fixed button related autopilot test.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
581. By Florian Boucault

Fixed autopilot test for button.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-07-02 23:33:44 +0000
3+++ debian/control 2013-07-03 18:40:32 +0000
4@@ -104,8 +104,6 @@
5 dpkg-dev,
6 libqt5test5,
7 libqt5widgets5,
8- python-autopilot (>= 1.3),
9- python-mock,
10 ubuntu-ui-toolkit-examples (>= ${source:Version}),
11 Description: Test package for Ubuntu UI Toolkit
12 Autopilot tests for the ubuntu-ui-toolkit package
13
14=== modified file 'examples/ubuntu-ui-toolkit-gallery/Buttons.qml'
15--- examples/ubuntu-ui-toolkit-gallery/Buttons.qml 2013-07-02 00:15:07 +0000
16+++ examples/ubuntu-ui-toolkit-gallery/Buttons.qml 2013-07-03 18:40:32 +0000
17@@ -49,7 +49,7 @@
18 }
19
20 Button {
21- objectName: "button_iconsource_text"
22+ objectName: "button_iconsource_right_text"
23 width: units.gu(15)
24 text: i18n.tr("Call")
25 iconSource: "call.png"
26@@ -57,7 +57,7 @@
27 }
28
29 Button {
30- objectName: "button_iconsource_text"
31+ objectName: "button_iconsource_left_text"
32 width: units.gu(15)
33 text: i18n.tr("Call")
34 iconSource: "call.png"
35
36=== modified file 'tests/autopilot/UbuntuUiToolkit/__init__.py'
37--- tests/autopilot/UbuntuUiToolkit/__init__.py 2013-06-27 03:11:40 +0000
38+++ tests/autopilot/UbuntuUiToolkit/__init__.py 2013-07-03 18:40:32 +0000
39@@ -1,17 +1,8 @@
40 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
41-#
42-# Copyright (C) 2012, 2013 Canonical Ltd.
43-#
44-# This program is free software; you can redistribute it and/or modify
45-# it under the terms of the GNU Lesser General Public License as published by
46-# the Free Software Foundation; version 3.
47-#
48-# This program is distributed in the hope that it will be useful,
49-# but WITHOUT ANY WARRANTY; without even the implied warranty of
50-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51-# GNU Lesser General Public License for more details.
52-#
53-# You should have received a copy of the GNU Lesser General Public License
54-# along with this program. If not, see <http://www.gnu.org/licenses/>.
55+# Copyright 2012 Canonical
56+#
57+# This program is free software: you can redistribute it and/or modify it
58+# under the terms of the GNU Lesser General Public License version 3, as published
59+# by the Free Software Foundation.
60
61 """Ubuntu UI Toolkit autopilot tests and emulators - top level package."""
62
63=== added directory 'tests/autopilot/UbuntuUiToolkit/emulators'
64=== renamed file 'tests/autopilot/UbuntuUiToolkit/emulators.py' => 'tests/autopilot/UbuntuUiToolkit/emulators/__init__.py'
65--- tests/autopilot/UbuntuUiToolkit/emulators.py 2013-06-27 06:40:44 +0000
66+++ tests/autopilot/UbuntuUiToolkit/emulators/__init__.py 2013-07-03 18:40:32 +0000
67@@ -1,113 +1,6 @@
68 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
69-#
70-# Copyright (C) 2012, 2013 Canonical Ltd.
71-#
72-# This program is free software; you can redistribute it and/or modify
73-# it under the terms of the GNU Lesser General Public License as published by
74-# the Free Software Foundation; version 3.
75-#
76-# This program is distributed in the hope that it will be useful,
77-# but WITHOUT ANY WARRANTY; without even the implied warranty of
78-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79-# GNU Lesser General Public License for more details.
80-#
81-# You should have received a copy of the GNU Lesser General Public License
82-# along with this program. If not, see <http://www.gnu.org/licenses/>.
83-
84-from autopilot import input, platform
85-from autopilot.introspection import dbus
86-
87-
88-def get_pointing_device():
89- """Get the pointing device depending on the platform.
90-
91- If the platform is `Desktop`, the pointing device will be a `Mouse`.
92- If not, the pointing device will be `Touch`.
93-
94- """
95- if platform.model == 'Desktop':
96- input_device_class = input.Mouse
97- else:
98- input_device_class = input.Touch
99- return input.Pointer(input_device_class.create())
100-
101-
102-class UbuntuUIToolkitEmulatorBase(dbus.CustomEmulatorBase):
103- """A base class for all the Ubuntu UI Toolkit emulators."""
104-
105-
106-class MainView(UbuntuUIToolkitEmulatorBase):
107- """MainView Autopilot emulator."""
108-
109- def __init__(self, *args):
110- super(MainView, self).__init__(*args)
111- self.pointing_device = get_pointing_device()
112-
113- def get_header(self):
114- """Get the Header emulator of the MainView."""
115- return self.select_single('Header')
116-
117- def get_toolbar(self):
118- """Get the Toolbar emulator of the MainView."""
119- return self.select_single(Toolbar)
120-
121- def open_toolbar(self):
122- """Open the toolbar if it's not already opened.
123-
124- :return: the toolbar.
125-
126- """
127- toolbar = self.get_toolbar()
128- if not toolbar.opened:
129- self._drag_to_open_toolbar()
130- toolbar.opened.wait_for(True)
131-
132- return toolbar
133-
134- def _drag_to_open_toolbar(self):
135- x = self.globalRect[0]
136- y = self.globalRect[1]
137- line_x = x + self.width * 0.50
138- start_y = y + self.height - 1
139- stop_y = y + self.height * 0.95
140-
141- self.pointing_device.drag(line_x, start_y, line_x, stop_y)
142-
143- def close_toolbar(self):
144- """Close the toolbar if it's opened."""
145- toolbar = self.get_toolbar()
146- if toolbar.opened:
147- self._drag_to_close_toolbar()
148- toolbar.opened.wait_for(False)
149-
150- def _drag_to_close_toolbar(self):
151- x = self.globalRect[0]
152- y = self.globalRect[1]
153- line_x = x + self.width * 0.50
154- start_y = y + self.height * 0.95
155- stop_y = y + self.height - 1
156-
157- self.pointing_device.drag(line_x, start_y, line_x, stop_y)
158-
159-
160-class Toolbar(UbuntuUIToolkitEmulatorBase):
161- """Toolbar Autopilot emulator."""
162-
163- def __init__(self, *args):
164- super(Toolbar, self).__init__(*args)
165- self.pointing_device = get_pointing_device()
166-
167- def click_button(self, object_name):
168- """Click a button of the toolbar.
169-
170- :param object_name: The QML objectName property of the button.
171-
172- """
173- button = self._get_button(object_name)
174- not_found_error = 'Button with objectName "{0}" not found.'.format(
175- object_name)
176- assert button is not None, not_found_error
177- self.pointing_device.click_object(button)
178-
179- def _get_button(self, object_name):
180- return self.select_single('ActionItem', objectName=object_name)
181+# Copyright 2012 Canonical
182+#
183+# This program is free software: you can redistribute it and/or modify it
184+# under the terms of the GNU General Public License version 3, as published
185+# by the Free Software Foundation.
186
187=== added file 'tests/autopilot/UbuntuUiToolkit/emulators/main_window.py'
188--- tests/autopilot/UbuntuUiToolkit/emulators/main_window.py 1970-01-01 00:00:00 +0000
189+++ tests/autopilot/UbuntuUiToolkit/emulators/main_window.py 2013-07-03 18:40:32 +0000
190@@ -0,0 +1,22 @@
191+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
192+# Copyright 2013 Canonical
193+#
194+# This program is free software: you can redistribute it and/or modify it
195+# under the terms of the GNU General Public License version 3, as published
196+# by the Free Software Foundation.
197+
198+class MainWindow(object):
199+ """An emulator class that makes it easy to interact with the camera-app."""
200+
201+ def __init__(self, app):
202+ self.app = app
203+
204+ def get_qml_view(self):
205+ """Get the main QML view"""
206+ return self.app.select_single("QQuickView")
207+
208+ def get_object(self, typeName, name):
209+ return self.app.select_single(typeName, objectName=name)
210+
211+ def get_object_by_text(self, typeName, itemText):
212+ return self.app.select_single(typeName, text=itemText)
213
214=== modified file 'tests/autopilot/UbuntuUiToolkit/tests/__init__.py'
215--- tests/autopilot/UbuntuUiToolkit/tests/__init__.py 2013-06-27 03:01:28 +0000
216+++ tests/autopilot/UbuntuUiToolkit/tests/__init__.py 2013-07-03 18:40:32 +0000
217@@ -1,18 +1,9 @@
218 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
219-#
220-# Copyright (C) 2012, 2013 Canonical Ltd.
221-#
222-# This program is free software; you can redistribute it and/or modify
223-# it under the terms of the GNU Lesser General Public License as published by
224-# the Free Software Foundation; version 3.
225-#
226-# This program is distributed in the hope that it will be useful,
227-# but WITHOUT ANY WARRANTY; without even the implied warranty of
228-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229-# GNU Lesser General Public License for more details.
230-#
231-# You should have received a copy of the GNU Lesser General Public License
232-# along with this program. If not, see <http://www.gnu.org/licenses/>.
233+# Copyright 2012 Canonical
234+#
235+# This program is free software: you can redistribute it and/or modify it
236+# under the terms of the GNU Lesser General Public License version 3, as published
237+# by the Free Software Foundation.
238
239 """Ubuntu UI Toolkit autopilot tests."""
240
241@@ -27,8 +18,7 @@
242 from testtools.matchers import Is, Not, Equals
243 from autopilot.testcase import AutopilotTestCase
244
245-from UbuntuUiToolkit import emulators
246-
247+from UbuntuUiToolkit.emulators.main_window import MainWindow
248
249 def get_module_include_path():
250 return os.path.abspath(
251@@ -39,21 +29,22 @@
252 '..',
253 '..',
254 'modules')
255- )
256+ )
257
258
259 class UbuntuUiToolkitTestCase(AutopilotTestCase):
260- """Common test case class for SDK tests."""
261+
262+ """A common test case class that provides several useful methods for SDK tests."""
263
264 if model() == 'Desktop':
265 scenarios = [
266- ('with mouse', dict(input_device_class=Mouse))
267+ ('with mouse', dict(input_device_class=Mouse))
268 ]
269 else:
270 scenarios = [
271- ('with touch', dict(input_device_class=Touch))
272+ ('with touch', dict(input_device_class=Touch))
273 ]
274-
275+
276 def setUp(self):
277 self.pointing_device = Pointer(self.input_device_class.create())
278 super(UbuntuUiToolkitTestCase, self).setUp()
279@@ -63,8 +54,8 @@
280 # If the test class has defined a 'test_qml' class attribute then we
281 # write it to disk and launch it inside the Qml Viewer. If not, then we
282 # silently do nothing (presumably the test has something else planned).
283- arch = subprocess.check_output(
284- ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
285+ arch = subprocess.check_output(["dpkg-architecture",
286+ "-qDEB_HOST_MULTIARCH"]).strip()
287 if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring):
288 qml_path = mktemp(suffix='.qml')
289 open(qml_path, 'w').write(self.test_qml)
290@@ -73,48 +64,39 @@
291 self.app = self.launch_test_application(
292 "/usr/lib/" + arch + "/qt5/bin/qmlscene",
293 "-I", get_module_include_path(),
294- qml_path,
295- emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
296+ qml_path)
297
298- if (hasattr(self, 'test_qml_file') and
299- isinstance(self.test_qml_file, basestring)):
300+ if hasattr(self, 'test_qml_file') and isinstance(self.test_qml_file, basestring):
301 qml_path = self.test_qml_file
302 self.app = self.launch_test_application(
303 "/usr/lib/" + arch + "/qt5/bin/qmlscene",
304 "-I", get_module_include_path(),
305- qml_path,
306- emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
307+ qml_path)
308
309- self.assertThat(
310- self.main_view.visible, Eventually(Equals(True)))
311+ self.assertThat(self.main_window.get_qml_view().visible,
312+ Eventually(Equals(True)))
313
314 def checkListItem(self, itemText):
315- item = self.getListItem(itemText)
316- self.assertThat(item, Not(Is(None)))
317+ item = self.main_window.get_object_by_text("Standard", itemText)
318+ self.assertThat(item, Not(Is(None)));
319
320 def getListItem(self, itemText):
321- # XXX We shouldn't access the elements by text, because that's likely
322- # to change often and might be translated. We should always use the
323- # objectName instead. --elopio - 2013-06-26
324- return self.main_view.select_single("Standard", text=itemText)
325+ return self.main_window.get_object_by_text("Standard", itemText)
326
327 def getWidgetLoaderAndListView(self):
328- contentLoader = self.main_view.select_single(
329- "QQuickLoader", objectName="contentLoader")
330- listView = self.main_view.select_single(
331- "QQuickListView", objectName="widgetList")
332- self.assertThat(listView, Not(Is(None)))
333- self.assertThat(listView.visible, Eventually(Equals(True)))
334+ contentLoader = self.main_window.get_object("QQuickLoader", "contentLoader")
335+ listView = self.main_window.get_object("QQuickListView", "widgetList")
336+ self.assertThat(listView, Not(Is(None)));
337+ self.assertThat(listView.visible, Eventually(Equals(True)));
338 return (contentLoader, listView)
339
340 def loadItem(self, item):
341- contentLoader = self.main_view.select_single(
342- "QQuickLoader", objectName="contentLoader")
343+ contentLoader = self.main_window.get_object("QQuickLoader", "contentLoader")
344 self.selectItem(item)
345- self.assertThat(contentLoader.progress, Eventually(Equals(1.0)))
346- loadedPage = self.getListItem(item)
347- self.assertThat(loadedPage, Not(Is(None)))
348- self.assertThat(loadedPage.visible, Eventually(Equals(True)))
349+ self.assertThat(contentLoader.progress,Eventually(Equals(1.0)))
350+ loadedPage = self.main_window.get_object_by_text("Standard", item)
351+ self.assertThat(loadedPage, Not(Is(None)));
352+ self.assertThat(loadedPage.visible, Eventually(Equals(True)));
353
354 def drag(self, itemText, itemTextTo):
355 item = self.getListItem(itemText)
356@@ -134,35 +116,39 @@
357
358 self.assertThat(item.selected, Eventually(Equals(True)))
359
360+ def getMainView(self):
361+ mainView = self.app.select_many("MainView")[0]
362+ self.assertThat(mainView, Not(Is(None)));
363+ return mainView
364+
365 def getOrientationHelper(self):
366- orientationHelper = self.main_view.select_many(
367- "OrientationHelper")[0]
368- self.assertThat(orientationHelper, Not(Is(None)))
369+ orientationHelper = self.getMainView().select_many("OrientationHelper")[0]
370+ self.assertThat(orientationHelper, Not(Is(None)));
371 return orientationHelper
372
373- def checkPageHeader(self, pageTitle):
374- orientationHelper = self.getOrientationHelper()
375- header = orientationHelper.select_many("Header", title=pageTitle)[0]
376- self.assertThat(header, Not(Is(None)))
377+ def checkPageHeader(self,pageTitle):
378+ orientationHelper = self.getOrientationHelper();
379+ header = orientationHelper.select_many("Header",title=pageTitle)[0]
380+ self.assertThat(header, Not(Is(None)));
381 return header
382
383- def getObject(self, objectName):
384+ def getObject(self,objectName):
385 obj = self.app.select_single(objectName=objectName)
386- self.assertThat(obj, Not(Is(None)))
387+ self.assertThat(obj, Not(Is(None)));
388 return obj
389
390- def tap(self, objectName):
391+ def tap(self,objectName):
392 obj = self.getObject(objectName)
393 self.pointing_device.move_to_object(obj)
394 self.pointing_device.click()
395
396- def mousePress(self, objectName):
397+ def mousePress(self,objectName):
398 obj = self.getObject(objectName)
399 self.pointing_device.move_to_object(obj)
400 self.pointing_device.press()
401
402 def mouseRelease(self):
403- self.pointing_device.release()
404+ self.pointing_device.release()
405
406 def type_string(self, string):
407 self.keyboard.type(string)
408@@ -170,14 +156,14 @@
409 def type_key(self, key):
410 self.keyboard.key(key)
411
412- def tap_clearButton(self, objectName):
413+ def tap_clearButton(self,objectName):
414 textField = self.getObject(objectName)
415- self.assertThat(textField.hasClearButton, Equals(True))
416+ self.assertThat(textField.hasClearButton, Equals(True));
417 btn = textField.select_single("AbstractButton")
418 self.pointing_device.move_to_object(btn)
419 self.pointing_device.click()
420
421 @property
422- def main_view(self):
423- """Return the MainView of the application."""
424- return self.app.select_single(emulators.MainView)
425+ def main_window(self):
426+ return MainWindow(self.app)
427+
428
429=== modified file 'tests/autopilot/UbuntuUiToolkit/tests/gallery/__init__.py'
430--- tests/autopilot/UbuntuUiToolkit/tests/gallery/__init__.py 2013-06-27 03:11:40 +0000
431+++ tests/autopilot/UbuntuUiToolkit/tests/gallery/__init__.py 2013-07-03 18:40:32 +0000
432@@ -1,17 +1,9 @@
433 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
434-#
435-# Copyright (C) 2012, 2013 Canonical Ltd.
436-#
437-# This program is free software; you can redistribute it and/or modify
438-# it under the terms of the GNU Lesser General Public License as published by
439-# the Free Software Foundation; version 3.
440-#
441-# This program is distributed in the hope that it will be useful,
442-# but WITHOUT ANY WARRANTY; without even the implied warranty of
443-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
444-# GNU Lesser General Public License for more details.
445-#
446-# You should have received a copy of the GNU Lesser General Public License
447-# along with this program. If not, see <http://www.gnu.org/licenses/>.
448+# Copyright 2012 Canonical
449+#
450+# This program is free software: you can redistribute it and/or modify it
451+# under the terms of the GNU Lesser General Public License version 3, as published
452+# by the Free Software Foundation.
453+
454
455 """Tests for the Ubuntu UI Toolkit Gallery"""
456
457=== modified file 'tests/autopilot/UbuntuUiToolkit/tests/gallery/test_gallery.py'
458--- tests/autopilot/UbuntuUiToolkit/tests/gallery/test_gallery.py 2013-06-27 02:29:35 +0000
459+++ tests/autopilot/UbuntuUiToolkit/tests/gallery/test_gallery.py 2013-07-03 18:40:32 +0000
460@@ -1,18 +1,9 @@
461 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
462-#
463-# Copyright (C) 2012, 2013 Canonical Ltd.
464-#
465-# This program is free software; you can redistribute it and/or modify
466-# it under the terms of the GNU Lesser General Public License as published by
467-# the Free Software Foundation; version 3.
468-#
469-# This program is distributed in the hope that it will be useful,
470-# but WITHOUT ANY WARRANTY; without even the implied warranty of
471-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
472-# GNU Lesser General Public License for more details.
473-#
474-# You should have received a copy of the GNU Lesser General Public License
475-# along with this program. If not, see <http://www.gnu.org/licenses/>.
476+# Copyright 2012 Canonical
477+#
478+# This program is free software: you can redistribute it and/or modify it
479+# under the terms of the GNU Lesser General Public License version 3, as published
480+# by the Free Software Foundation.
481
482 """Tests for the Ubuntu UI Toolkit Gallery"""
483
484@@ -23,6 +14,7 @@
485 import os
486 import time
487 from UbuntuUiToolkit.tests import UbuntuUiToolkitTestCase
488+from UbuntuUiToolkit.emulators.main_window import MainWindow
489
490
491 class GenericTests(UbuntuUiToolkitTestCase):
492@@ -30,44 +22,40 @@
493
494 # Support both running from system and in the source directory
495 runPath = os.path.dirname(os.path.realpath(__file__))
496- localSourceFile = (
497- runPath + "/../../../../../examples/ubuntu-ui-toolkit-gallery/"
498- "ubuntu-ui-toolkit-gallery.qml")
499+ localSourceFile = runPath + "/../../../../../examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml"
500 if (os.path.isfile(localSourceFile)):
501 print "Using local source directory"
502 test_qml_file = localSourceFile
503 else:
504 print "Using system QML file"
505- test_qml_file = (
506- "/usr/lib/ubuntu-ui-toolkit/examples/ubuntu-ui-toolkit-gallery/"
507- "ubuntu-ui-toolkit-gallery.qml")
508+ test_qml_file = "/usr/lib/ubuntu-ui-toolkit/examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml"
509
510 def test_0_can_select_mainwindow(self):
511 """Must be able to select the main window."""
512
513- rootItem = self.main_view
514+ rootItem = self.main_window.get_qml_view()
515 self.assertThat(rootItem, Not(Is(None)))
516- self.assertThat(rootItem.visible, Eventually(Equals(True)))
517+ self.assertThat(rootItem.visible,Eventually(Equals(True)))
518
519 def test_can_select_listview(self):
520- """Must be able to select the listview from main"""
521-
522- contentLoader, listView = self.getWidgetLoaderAndListView()
523-
524- # Don't have the first, already selected item as the first item to
525- # check.
526+ """Must be able to select the listview from main"""
527+
528+ contentLoader,listView = self.getWidgetLoaderAndListView();
529+
530+ # Don't have the first, already selected item as the first item to check
531 items = [
532- "Navigation",
533- "Toggles",
534- "Buttons",
535- "Slider",
536- "Text Field",
537- "Progress and activity",
538- "Ubuntu Shape",
539- "Icons",
540- "Label",
541- "List Items",
542- ]
543+ "Navigation",
544+ "Toggles",
545+ "Buttons",
546+ "Slider",
547+ "Text Field",
548+ "Progress and activity",
549+ "Ubuntu Shape",
550+ "Icons",
551+ "Label",
552+ "List Items",
553+ ]
554+
555
556 for item in items:
557 self.checkListItem(item)
558@@ -75,20 +63,20 @@
559 self.checkPageHeader(item)
560
561 # scroll view to expose more items
562- self.drag("Icons", "Text Field")
563+ self.drag("Icons","Text Field")
564
565- # Wait for the scrolling to finish, the next click fails on the
566+ # Wait for the scrolling to finish, the next click fails on the
567 # slower Intel machine but succeeds on AMD and NVIDIA.
568 # (LP: #1180226)
569 time.sleep(1)
570
571 # now that we have more items, lets continue
572 items = [
573- "Dialog",
574- "Popover",
575- "Sheet",
576- "Animations"
577- ]
578+ "Dialog",
579+ "Popover",
580+ "Sheet",
581+ "Animations"
582+ ]
583
584 for item in items:
585 self.checkListItem(item)
586@@ -108,14 +96,14 @@
587
588 # check default states
589 item_data = [
590- ["checkbox_unchecked", False, True],
591- ["checkbox_checked", True, True],
592- ["checkbox_disabled_unchecked", False, False],
593- ["checkbox_disabled_checked", True, False],
594- ["switch_unchecked", False, True],
595- ["switch_checked", True, True],
596- ["switch_disabled_unchecked", False, False],
597- ["switch_disabled_checked", True, False]
598+ ["checkbox_unchecked",False,True],
599+ ["checkbox_checked",True,True],
600+ ["checkbox_disabled_unchecked",False,False],
601+ ["checkbox_disabled_checked",True,False],
602+ ["switch_unchecked",False,True],
603+ ["switch_checked",True,True],
604+ ["switch_disabled_unchecked",False,False],
605+ ["switch_disabled_checked",True,False]
606 ]
607
608 for data in item_data:
609@@ -126,7 +114,7 @@
610 obj = self.getObject(objName)
611 self.assertThat(obj.checked, Equals(objChecked))
612 self.assertThat(obj.enabled, Equals(objEnabled))
613-
614+
615 # try to interact with objects
616 self.tap(objName)
617
618@@ -141,11 +129,12 @@
619 self.checkPageHeader(item)
620
621 item_data = [
622- ["button_text", True, None, None, "Call"],
623- ["button_text_disabled", False, None, None, "Call"],
624- ["button_color", True, [93, 163, 87, 255], None, "Call"],
625- ["button_iconsource", True, None, "call_icon.png", None],
626- ["button_iconsource_text", True, None, "call_icon.png", "Call"]
627+ ["button_text",True,None,None,"Call"],
628+ ["button_text_disabled",False,None,None,"Call"],
629+ ["button_color",True,[0,0,0,255],None,"Call"],
630+ ["button_iconsource",True,None,"call.png",None],
631+ ["button_iconsource_right_text",True,None,"call.png","Call"],
632+ ["button_iconsource_left_text",True,None,"call.png","Call"]
633 ]
634
635 for data in item_data:
636@@ -159,15 +148,15 @@
637 self.assertThat(obj.enabled, Equals(objEnabled))
638
639 print obj.color
640- if (objColor is not None):
641+ if (objColor != None):
642 self.assertThat(obj.color, Equals(objColor))
643
644- if (objIcon is not None):
645+ if (objIcon != None):
646 self.assertThat(obj.iconSource.endswith(objIcon), Equals(True))
647
648- if (objText is not None):
649+ if (objText != None):
650 self.assertThat(obj.text, Equals(objText))
651-
652+
653 # try to interact with objects
654 self.mousePress(objName)
655
656@@ -179,16 +168,16 @@
657 self.mouseRelease()
658
659 self.assertThat(obj.pressed, Equals(False))
660-
661+
662 def test_slider(self):
663 item = "Slider"
664 self.loadItem(item)
665 self.checkPageHeader(item)
666
667 item_data = [
668- ["slider_standard"],
669- ["slider_live"],
670- ["slider_range"]
671+ [ "slider_standard" ],
672+ [ "slider_live" ],
673+ [ "slider_range" ]
674 ]
675
676 for data in item_data:
677@@ -197,18 +186,18 @@
678 self.tap(objName)
679
680 # TODO: move slider value
681-
682+
683 # def test_textarea(self):
684 # item = "Text Field"
685 # self.loadItem(item)
686 # self.checkPageHeader(item)
687
688 # template_textinputs = self.getObject("textinputs")
689-
690+
691 # item_data = [
692-# ["textarea_default", True, -1, template_textinputs.longText, None ],
693-# [ "textarea_expanding", True, -1, "", None],
694-# [ "textarea_richtext", True, -1, template_textinputs.richText, None ]
695+# [ "textarea_default", True, -1, template_textinputs.longText, None ],
696+# [ "textarea_expanding", True, -1, "", None],
697+# [ "textarea_richtext", True, -1, template_textinputs.richText, None ]
698 # ]
699
700 # for data in item_data:
701@@ -222,7 +211,7 @@
702 # self.tap(objName)
703
704 # self.assertThat(obj.enabled, Equals(objEnabled))
705-# # self.assertThat(obj.focus, Equals(obj.enabled))
706+# # self.assertThat(obj.focus, Equals(obj.enabled))
707 # self.assertThat(obj.highlighted, Equals(obj.focus))
708 # #self.assertThat(obj.hasClearButton, Equals(True))
709 # self.assertThat(obj.text, Equals(objText))
710@@ -236,18 +225,21 @@
711
712 # self.assertThat(obj.text,Equals("Hello World!"))
713
714+
715+
716+
717 def test_textfield(self):
718 item = "Text Field"
719 self.loadItem(item)
720 self.checkPageHeader(item)
721
722 template_textinputs = self.getObject("textinputs")
723-
724+
725 item_data = [
726- ["textfield_standard", True, 0, "", None],
727- ["textfield_password", True, 2, "password", None],
728- ["textfield_numbers", True, 0, "123", True],
729- ["textfield_disabled", False, 0, "", None],
730+ [ "textfield_standard", True, 0, "", None ],
731+ [ "textfield_password", True, 2, "password", None ],
732+ [ "textfield_numbers", True, 0, "123", True ],
733+ [ "textfield_disabled", False, 0, "", None ],
734 ]
735
736 for data in item_data:
737@@ -261,26 +253,25 @@
738 self.tap(objName)
739
740 self.assertThat(obj.enabled, Equals(objEnabled))
741- self.assertThat(obj.focus, Equals(obj.enabled))
742+ self.assertThat(obj.focus, Equals(obj.enabled))
743 self.assertThat(obj.highlighted, Equals(obj.focus))
744 self.assertThat(obj.errorHighlight, Equals(False))
745 self.assertThat(obj.acceptableInput, Equals(True))
746 self.assertThat(obj.hasClearButton, Equals(True))
747 self.assertThat(obj.text, Equals(objText))
748
749- if (objEchoMode != -1):
750+ if (objEchoMode!=-1):
751 self.assertThat(obj.echoMode, Equals(objEchoMode))
752-
753+
754 if (objNumbersOnly):
755 self.type_string("abc")
756- self.assertThat(obj.text, Equals(objText))
757+ self.assertThat(obj.text,Equals(objText))
758 self.assertThat(obj.errorHighlight, Equals(False))
759 self.assertThat(obj.acceptableInput, Equals(True))
760 else:
761 self.type_string("Hello World!")
762 if (objEnabled):
763- self.assertThat(
764- obj.text, Equals("%sHello World!" % (objText)))
765+ self.assertThat(obj.text, Equals("%sHello World!" % (objText)))
766 self.assertThat(obj.errorHighlight, Equals(False))
767 self.assertThat(obj.acceptableInput, Equals(True))
768 else:
769@@ -288,15 +279,18 @@
770
771 self.tap_clearButton(objName)
772
773+
774+
775+
776 def test_progress_and_activity(self):
777 item = "Progress and activity"
778 self.loadItem(item)
779 self.checkPageHeader(item)
780
781 item_data = [
782- ["progressbar_standard"],
783- ["progressbar_indeterminate"],
784- ["activityindicator_standard"]
785+ [ "progressbar_standard" ],
786+ [ "progressbar_indeterminate" ],
787+ [ "activityindicator_standard" ]
788 ]
789
790 for data in item_data:
791@@ -305,6 +299,7 @@
792 self.tap(objName)
793
794 # TODO: check for properties
795+
796
797 def test_ubuntushape(self):
798 item = "Ubuntu Shape"
799@@ -312,16 +307,18 @@
800 self.checkPageHeader(item)
801
802 item_data = [
803- ["ubuntushape_color_hex"],
804- ["ubuntushape_color_lightblue"],
805- ["ubuntushape_color_darkgray"],
806- ["ubuntushape_image"],
807- ["ubuntushape_radius_small"],
808- ["ubuntushape_radius_medium"],
809- ["ubuntushape_sizes_15_6"],
810- ["ubuntushape_sizes_10_14"]
811+ [ "ubuntushape_color_hex" ],
812+ [ "ubuntushape_color_lightblue" ],
813+ [ "ubuntushape_color_darkgray" ],
814+ [ "ubuntushape_image" ],
815+ [ "ubuntushape_radius_small" ],
816+ [ "ubuntushape_radius_medium" ],
817+ [ "ubuntushape_sizes_15_6" ],
818+ [ "ubuntushape_sizes_10_14" ]
819 ]
820
821 for data in item_data:
822 objName = data[0]
823 obj = self.getObject(objName)
824+
825+
826
827=== removed file 'tests/autopilot/UbuntuUiToolkit/tests/test_emulators.py'
828--- tests/autopilot/UbuntuUiToolkit/tests/test_emulators.py 2013-06-28 18:14:58 +0000
829+++ tests/autopilot/UbuntuUiToolkit/tests/test_emulators.py 1970-01-01 00:00:00 +0000
830@@ -1,142 +0,0 @@
831-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
832-#
833-# Copyright (C) 2013 Canonical Ltd.
834-#
835-# This program is free software; you can redistribute it and/or modify
836-# it under the terms of the GNU Lesser General Public License as published by
837-# the Free Software Foundation; version 3.
838-#
839-# This program is distributed in the hope that it will be useful,
840-# but WITHOUT ANY WARRANTY; without even the implied warranty of
841-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
842-# GNU Lesser General Public License for more details.
843-#
844-# You should have received a copy of the GNU Lesser General Public License
845-# along with this program. If not, see <http://www.gnu.org/licenses/>.
846-
847-import mock
848-
849-from UbuntuUiToolkit import tests
850-from UbuntuUiToolkit import emulators
851-
852-
853-class MainViewTestCase(tests.UbuntuUiToolkitTestCase):
854-
855- test_qml = ("""
856-import QtQuick 2.0
857-import Ubuntu.Components 0.1
858-
859-MainView {
860- width: units.gu(48)
861- height: units.gu(60)
862-}
863-""")
864-
865- def test_main_view_custom_emulator(self):
866- self.assertIsInstance(self.main_view, emulators.MainView)
867-
868- def test_get_header_without_header(self):
869- header = self.main_view.get_header()
870- self.assertFalse(header.visible)
871-
872- def test_toolbar_custom_emulator(self):
873- toolbar = self.main_view.get_toolbar()
874- self.assertIsInstance(toolbar, emulators.Toolbar)
875- self.assertFalse(toolbar.opened)
876-
877-
878-class PageTestCase(tests.UbuntuUiToolkitTestCase):
879-
880- test_qml = ("""
881-import QtQuick 2.0
882-import Ubuntu.Components 0.1
883-
884-MainView {
885- width: units.gu(48)
886- height: units.gu(60)
887-
888- Page {
889- title: "Test title"
890- }
891-}
892-""")
893-
894- def test_get_header(self):
895- header = self.main_view.get_header()
896- self.assertTrue(header.visible)
897- self.assertEqual(header.title, "Test title")
898-
899-
900-class ToolbarTestCase(tests.UbuntuUiToolkitTestCase):
901-
902- test_qml = ("""
903-import QtQuick 2.0
904-import Ubuntu.Components 0.1
905-
906-MainView {
907- width: units.gu(50)
908- height: units.gu(50)
909-
910- Page {
911-
912- Label {
913- id: "label"
914- objectName: "clicked_label"
915- anchors.centerIn: parent
916- text: "Button not clicked."
917- }
918-
919- tools: ToolbarItems {
920- ToolbarButton {
921- objectName: "buttonName"
922- action: Action {
923- text: "buttonText"
924- onTriggered: label.text = "Button clicked."
925- }
926- }
927- locked: false
928- opened: false
929- }
930- }
931-}
932-""")
933-
934- def test_open_toolbar(self):
935- toolbar = self.main_view.open_toolbar()
936- self.assertTrue(toolbar.opened)
937-
938- def test_opened_toolbar_is_not_opened_again(self):
939- toolbar = self.main_view.open_toolbar()
940- with mock.patch.object(
941- self.main_view.pointing_device, 'drag') as mock_drag:
942- self.main_view.open_toolbar()
943-
944- self.assertFalse(mock_drag.called)
945- self.assertTrue(toolbar.opened)
946-
947- def test_close_toolbar(self):
948- toolbar = self.main_view.open_toolbar()
949- self.main_view.close_toolbar()
950- self.assertFalse(toolbar.opened)
951-
952- def test_closed_toolbar_is_not_closed_again(self):
953- with mock.patch.object(
954- self.main_view.pointing_device, 'drag') as mock_drag:
955- self.main_view.close_toolbar()
956-
957- self.assertFalse(mock_drag.called)
958- self.assertFalse(self.main_view.get_toolbar().opened)
959-
960- def test_click_toolbar_button(self):
961- label = self.app.select_single('Label', objectName='clicked_label')
962- self.assertNotEqual(label.text, 'Button clicked.')
963- toolbar = self.main_view.open_toolbar()
964- toolbar.click_button('buttonName')
965- self.assertEqual(label.text, 'Button clicked.')
966-
967- def test_click_unexisting_button(self):
968- toolbar = self.main_view.open_toolbar()
969- error = self.assertRaises(
970- AssertionError, toolbar.click_button, 'unexisting')
971- self.assertEqual(
972- error.message, 'Button with objectName "unexisting" not found.')

Subscribers

People subscribed via source and target branches

to status/vote changes: