Merge lp:~chris.gagnon/ubuntu-ui-toolkit/autopilot-emulator-Picker into lp:ubuntu-ui-toolkit

Proposed by Chris Gagnon
Status: Rejected
Rejected by: Tim Peeters
Proposed branch: lp:~chris.gagnon/ubuntu-ui-toolkit/autopilot-emulator-Picker
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 211 lines (+193/-0)
2 files modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+64/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+129/-0)
To merge this branch: bzr merge lp:~chris.gagnon/ubuntu-ui-toolkit/autopilot-emulator-Picker
Reviewer Review Type Date Requested Status
Tim Peeters Needs Resubmitting
PS Jenkins bot continuous-integration Approve
Chris Gagnon (community) Needs Resubmitting
Leo Arias (community) code review Needs Fixing
I Ahmad Pending
Review via email: mp+192161@code.launchpad.net

Commit message

picker emulator for autopilot

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:805
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1046/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/483
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3147
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/903
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/903
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/903/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/360
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4631
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4631/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3149
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3149/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2627
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2678
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/285
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/284

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1046/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
I Ahmad (iahmad) wrote :

I ll wait for Jenkins bot to clear it first.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:806
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1049/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/486
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3151
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/906
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/906
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/906/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/362
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4634
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4634/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3153
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3153/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2629
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2680
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/289
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/288

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1049/rebuild

review: Approve (continuous-integration)
805. By Tim Peeters

Initially show toolbar, but automatically hide after timeout. Fixes: https://bugs.launchpad.net/bugs/1207369.

Approved by Christian Dywan, PS Jenkins bot.

Revision history for this message
Leo Arias (elopio) wrote :

21 + """returns a list of buttons that can be picked
22 + :parameter opacity: buttons at or < the opacity will not be returned"""

According to pep257, it shoud be "Return" instead of "returns", and it recommends to put the closing """ on its own line.

I hate that we are using the opacity instead of something like (element.visible and element.enabled). I know you are just following the convention devs are using, but I'm wondering if you guys agree with me here. Should we start a discussion about this with the devs?

28 + def get_pickable_text(self, opacity=.25):

Shouldn't it be get_pickable_texts or get_pickable_text_list ?

38 + def get_pick_abstractbutton_from_text(self, text):
76 + def select_pick_text(self, text, opacity=.25):

Just like on the previous branch comment, I would just like to know if it's possible to assign an object name to the abstract button, so we don't have to work with text.

63 + return 'Can only be used on Desktop!'
74 + return "Can only be used on Desktop!"

I'll review the tests tomorrow, because I'm close to EOD today.

This should raise an exception.

review: Needs Fixing (code review)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

> I hate that we are using the opacity instead of something like (element.visible and element.enabled).

no if the parent is visible then the child object is visible in QML. maybe a adding a hidden property?

> Shouldn't it be get_pickable_texts or get_pickable_text_list

it's get_pickable_text_list now

>assign an object name to the abstract button, so we don't have to work with text.

How do you know what the item that you want to pick will be? it seems like getting a pick from the text in the pick is something people will want in an emulator. the pick text might be created programatically, it seems like double the code to add an objectName to every item in a listview. If you hate text use the index?

review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:807
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1056/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/7
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/7/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/4
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/4
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/4/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/6
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/7
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/7/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/7
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/7/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2644/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2695/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/327
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/326

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1056/rebuild

review: Needs Fixing (continuous-integration)
806. By Timo Jyrinki

Partially revert bzr802 that deleted changelog entries, preventing building.

807. By Launchpad Translations on behalf of ubuntu-sdk-team

Launchpad automatic translations update.

808. By Tim Peeters

Put tab bar in selection mode when apps are launched. Fixes: https://bugs.launchpad.net/bugs/1223597.

Approved by PS Jenkins bot, Tim Peeters, Zsombor Egri.

809. By Cris Dywan

Support checkbox used with an action.

Approved by PS Jenkins bot, Zsombor Egri.

810. By Renato Araujo Oliveira Filho

Implemented emulator for swipe to remove. Fixes: https://bugs.launchpad.net/bugs/1236464.

Approved by PS Jenkins bot, Olivier Tilloy, Leo Arias.

811. By Zsombor Egri

Warnings treated as errors in all types of builds (debug or release). Fixes: https://bugs.launchpad.net/bugs/1246290.

Approved by PS Jenkins bot, Christian Dywan.

812. By Cris Dywan

Install autopilot modules in qmake not debian packaging.

Approved by PS Jenkins bot, Tim Peeters.

813. By Cris Dywan

Drop the $$ from system calls where output isn't needed.

Approved by PS Jenkins bot, Tim Peeters.

814. By Zsombor Egri

Introducing topmostItem property to drive whether InverseMouseArea should filter sensingArea events or to stay in the normal z-order/stack order of its parent. Fixes: https://bugs.launchpad.net/bugs/1240460.

Approved by PS Jenkins bot, Christian Dywan.

815. By Launchpad Translations on behalf of ubuntu-sdk-team

Launchpad automatic translations update.

816. By Cris Dywan

Look for locale folder as per XDG basedir spec and rewrite test

The new test case covers the whole range of changing languages,
checking the strings from both QML and C++ and binding to a folder. Fixes: https://bugs.launchpad.net/bugs/1175726, https://bugs.launchpad.net/bugs/1233071.

Approved by PS Jenkins bot, Tim Peeters.

817. By Cris Dywan

Define window within OrientationHelper to avoid a race condition. Fixes: https://bugs.launchpad.net/bugs/1239760.

Approved by PS Jenkins bot.

818. By Leo Arias

Added the change_state method to the CheckBox autopilot emulator.
Cleaned up the autopilot gallery toggles tests.

Approved by PS Jenkins bot, Chris Gagnon, Zoltan Balogh.

819. By Tim Peeters

Close tabbar and toolbar when user interacts with app contents. Fixes: https://bugs.launchpad.net/bugs/1223604.

Approved by Christian Dywan, PS Jenkins bot, Tim Peeters.

820. By Leo Arias

Added the objectNames to the ComposerSheet buttons. Fixes: https://bugs.launchpad.net/bugs/1244518.

Approved by PS Jenkins bot, Tim Peeters.

821. By PS Jenkins bot

Releasing 0.1.46+14.04.20131105.1-0ubuntu1 (revision 820 from lp:ubuntu-ui-toolkit).

Approved by PS Jenkins bot.

822. By Leo Arias

Update the tests to work with autopilot 1.4.

Approved by PS Jenkins bot, Chris Gagnon.

823. By PS Jenkins bot

Releasing 0.1.46+14.04.20131106-0ubuntu1 (revision 822 from lp:ubuntu-ui-toolkit).

Approved by PS Jenkins bot.

824. By Leo Arias

Add a check for the autopilot version on the emulator init. Fixes: https://bugs.launchpad.net/bugs/1248570.

Approved by PS Jenkins bot, Christian Dywan.

825. By Nicolas d'Offay

Reverted API break on the selectors. Fixes: https://bugs.launchpad.net/bugs/1248646.

Approved by Tim Peeters, Timo Jyrinki, PS Jenkins bot.

826. By Tim Peeters

Ensure the toolbar is opened when clicking a toolbar in autopilot tests. Fixes: https://bugs.launchpad.net/bugs/1248487.

Approved by PS Jenkins bot, Leo Arias.

827. By Tim Peeters

before fixing the actual bug, the test gives me these errors:

QWARN : tst_MainView::testNoWarnings_bug186065() unity::action::ActionManager::ActionManager(QObject*):
 Could not determine application identifier. HUD will not work properly.
 Provide your application identifier in $APP_ID environment variable.
QWARN : tst_MainView::testNoWarnings_bug186065() file:///home/tim/dev/ubuntu-ui-toolkit/fix1244660/modules/Ubuntu/Components/MainView.qml:257: TypeError: Cannot call method 'hasOwnProperty' of null

** (process:27191): CRITICAL **: Unable to get session bus: Operation was cancelled
QWARN : tst_MainView::testNoWarnings_bug186065() Don't know how to handle 'QList<QQmlError>', use qRegisterMetaType to register it.
PASS : tst_MainView::testNoWarnings_bug186065()
PASS : tst_MainView::cleanupTestCase()
Totals: 8 passed, 0 failed, 0 skipped
********* Finished testing of tst_MainView *********

I get the same when I execute unit_x11/tst_orientation/tst_orientation:
QWARN : tst_OrientationTest::test_defaults() Don't know how to handle 'QList<QQmlError>', use qRegisterMetaType to register it.
PASS : tst_OrientationTest::test_defaults()

Should I execute the tests in a different way?. Fixes: https://bugs.launchpad.net/bugs/1244660.

Approved by PS Jenkins bot, Christian Dywan.

828. By Robert Bruce Park
829. By PS Jenkins bot

Releasing 0.1.46+14.04.20131108.3-0ubuntu1 (revision 828 from lp:ubuntu-ui-toolkit).

Approved by PS Jenkins bot.

830. By Robert Bruce Park
831. By Launchpad Translations on behalf of ubuntu-sdk-team

Launchpad automatic translations update.

832. By Timo Jyrinki

Releasing 0.1.46+14.04.20131108.4-0ubuntu1 (revision 830 from lp:ubuntu-ui-toolkit).

833. By Chris Gagnon

sync with trunk, update emulator to use arguements and keyword arguments, instead of text

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

If this MR is still valid, please resubmit it for merging into our staging branch

review: Needs Resubmitting

Unmerged revisions

833. By Chris Gagnon

sync with trunk, update emulator to use arguements and keyword arguments, instead of text

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
2--- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-11-08 17:15:11 +0000
3+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-11-14 00:05:24 +0000
4@@ -465,6 +465,70 @@
5 format(self.objectName))
6
7
8+class Picker(UbuntuUIToolkitEmulatorBase):
9+ """Picker Autopilot emulator."""
10+
11+ def get_current_pick(self):
12+ """Return current pick from picker"""
13+ focused_abstract_button = self.select_single(
14+ 'AbstractButton', focus=True)
15+ label = focused_abstract_button.select_single('Label')
16+ return label
17+
18+ def _get_pickable(self, opacity=.25):
19+ """Return a list of buttons that can be picked
20+ :parameter opacity: buttons at or < the opacity will not be returned
21+ """
22+ buttons = self._get_abstract_buttons()
23+ buttons_list = [
24+ button for button in buttons if button.opacity > opacity]
25+ return buttons_list
26+
27+ def get_pickable_text_list(self, opacity=.25):
28+ """Return a list of text in AbstractButton that can be picked
29+ :parameter opacity: buttons at or < the opacity will not be returned
30+ """
31+ buttons = self._get_pickable(opacity)
32+ text_list = [button.select_single('Label').text for button in buttons]
33+ return text_list
34+
35+ def _get_abstract_buttons(self):
36+ return self.select_many('AbstractButton')
37+
38+ def get_abstractbutton(self, *args, **kwargs):
39+ """Return pick AbstractButton from text"""
40+ buttons = self._get_abstract_buttons()
41+ for button in buttons:
42+ try:
43+ if button.select_single(*args, **kwargs):
44+ return button
45+ except dbus.StateNotFoundError:
46+ pass
47+
48+ raise ValueError(
49+ "Could not find button args {} with kwargs {}"".".format(
50+ args, kwargs.items(),
51+ )
52+ )
53+
54+ def select_pick(self, *args, **kwargs):
55+ """Click/Tap the text in the picker, default opacity is opacity=.25
56+ """
57+ opacity = kwargs.get('opacity', .25)
58+
59+ button = self.get_abstractbutton(*args, **kwargs)
60+ if button.opacity > opacity:
61+ self.pointing_device.click_object(button)
62+ button.focus.wait_for(True)
63+ else:
64+ raise ValueError(
65+ 'arg {} with kwargs {} is not visible!'.format(
66+ args,
67+ kwargs.items(),
68+ )
69+ )
70+
71+
72 class Base(Empty):
73 pass
74
75
76=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
77--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-08 17:15:11 +0000
78+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-14 00:05:24 +0000
79@@ -690,3 +690,132 @@
80 self._go_to_page1()
81 self.main_view.go_back()
82 self.assertEqual(self.header.title, 'Page 0')
83+
84+TEST_QML_PICKER_LINEAR = ("""
85+import QtQuick 2.0
86+import Ubuntu.Components 0.1
87+import Ubuntu.Components.Pickers 0.1
88+
89+MainView {
90+ width: units.gu(48)
91+ height: units.gu(60)
92+ Picker {
93+ objectName: "test_picker"
94+ circular: false
95+ model: ["Line1",
96+ "Line2",
97+ "Line3",
98+ "Line4",
99+ "Line5",
100+ "Line6",
101+ "Line7",
102+ "Line8",
103+ "Line9",
104+ "Line10"]
105+
106+ delegate: PickerDelegate {
107+ Label {
108+ text: modelData
109+ anchors.verticalCenter: parent.verticalCenter
110+ }
111+ }
112+ }
113+}
114+""")
115+
116+TEST_QML_PICKER_CIRCULAR = ("""
117+import QtQuick 2.0
118+import Ubuntu.Components 0.1
119+import Ubuntu.Components.Pickers 0.1
120+
121+MainView {
122+ width: units.gu(48)
123+ height: units.gu(60)
124+ Picker {
125+ objectName: "test_picker"
126+ circular: false
127+ model: ["Line1",
128+ "Line2",
129+ "Line3",
130+ "Line4",
131+ "Line5",
132+ "Line6",
133+ "Line7",
134+ "Line8",
135+ "Line9",
136+ "Line10"]
137+
138+ delegate: PickerDelegate {
139+ Label {
140+ text: modelData
141+ anchors.verticalCenter: parent.verticalCenter
142+ }
143+ }
144+ }
145+}
146+""")
147+
148+
149+class PickerTestCase(tests.QMLStringAppTestCase):
150+
151+ scenarios = [
152+ ('picker linear', dict(
153+ test_qml=TEST_QML_PICKER_LINEAR)),
154+ ('picker circular', dict(
155+ test_qml=TEST_QML_PICKER_CIRCULAR)),
156+ ]
157+
158+ def setUp(self):
159+ super(PickerTestCase, self).setUp()
160+ self.picker = self.main_view.select_single(
161+ emulators.Picker, objectName='test_picker')
162+
163+ def test_current_pick(self):
164+ """get_current_pick must return the default pick"""
165+ self.assertEquals(self.picker.get_current_pick().text, 'Line1')
166+
167+ def test_select_pick(self):
168+ """Must be to select a pick in picker based on args and kwargs"""
169+ self.picker.select_pick('Label', text='Line2')
170+ self.assertEquals(self.picker.get_current_pick().text, 'Line2')
171+
172+ def test_negative_select_text_does_not_exist(self):
173+ """select_pick_text must return a value error if it does not exist"""
174+ error = self.assertRaises(
175+ ValueError, lambda: self.picker.select_pick(
176+ 'Label',
177+ text='this should fail',
178+ opacity=.25,
179+ )
180+ )
181+ self.assertEqual(
182+ error.message,
183+ "Could not find button args ('Label',) with kwargs [('opacity',"
184+ " 0.25), ('text', 'this should fail')]."
185+ )
186+
187+ def test_negative_select_pick_not_visible(self):
188+ """select_pick_text must return ValueError, if pick with text is hidden
189+ """
190+ error = self.assertRaises(
191+ ValueError, lambda: self.picker.select_pick(
192+ 'Label',
193+ text='Line5',
194+ )
195+ )
196+ self.assertEqual(
197+ error.message,
198+ "arg ('Label',) with kwargs [('text', 'Line5')] is not visible!",
199+ )
200+
201+ def test_get_pickable_text_list(self):
202+ """returns a list of picks that are pickable"""
203+ pickable = self.picker.get_pickable_text_list()
204+ pickable.sort()
205+ expected = ["Line1", "Line2", "Line3"]
206+ self.assertEquals(pickable, expected)
207+
208+ def test_get_pickable_opacity(self):
209+ pickable = self.picker.get_pickable_text_list(.99)
210+ expected = ["Line1"]
211+ self.assertEquals(pickable, expected)

Subscribers

People subscribed via source and target branches

to status/vote changes: