Merge lp:~tpeeters/ubuntu-ui-toolkit/landing16-fix1099455 into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1277
Merged at revision: 1274
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/landing16-fix1099455
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 190 lines (+157/-1)
3 files modified
src/Ubuntu/Components/ListItems/1.3/Standard.qml (+4/-1)
tests/unit_x11/tst_components/tst_listitems13_standard.qml (+138/-0)
tests/unit_x11/tst_components/tst_listitems_standard.qml (+15/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/landing16-fix1099455
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+281137@code.launchpad.net

Commit message

Fix issue with trigger() for ListItems.Standard.

To post a comment you must log in.
1276. By Tim Peeters

duplicate tests

1277. By Tim Peeters

revert original test

Revision history for this message
Zsombor Egri (zsombi) wrote :

Nice, looks great! This proves that the AbstractButton works as was planned, not triggering when the __acceptEvents is set to false.

review: Approve
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 'src/Ubuntu/Components/ListItems/1.3/Standard.qml'
2--- src/Ubuntu/Components/ListItems/1.3/Standard.qml 2015-04-29 07:21:29 +0000
3+++ src/Ubuntu/Components/ListItems/1.3/Standard.qml 2015-12-21 19:44:15 +0000
4@@ -273,7 +273,10 @@
5
6 Connections {
7 target: listItem.__mouseArea
8- onClicked: listItem.clicked()
9+ onClicked: {
10+ listItem.trigger();
11+ listItem.clicked();
12+ }
13 onPressAndHold: listItem.pressAndHold()
14 }
15 }
16
17=== added file 'tests/unit_x11/tst_components/tst_listitems13_standard.qml'
18--- tests/unit_x11/tst_components/tst_listitems13_standard.qml 1970-01-01 00:00:00 +0000
19+++ tests/unit_x11/tst_components/tst_listitems13_standard.qml 2015-12-21 19:44:15 +0000
20@@ -0,0 +1,138 @@
21+/*
22+ * Copyright 2015 Canonical Ltd.
23+ *
24+ * This program is free software; you can redistribute it and/or modify
25+ * it under the terms of the GNU Lesser General Public License as published by
26+ * the Free Software Foundation; version 3.
27+ *
28+ * This program is distributed in the hope that it will be useful,
29+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+ * GNU Lesser General Public License for more details.
32+ *
33+ * You should have received a copy of the GNU Lesser General Public License
34+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
35+ */
36+
37+import QtQuick 2.4
38+import QtTest 1.0
39+import Ubuntu.Components 1.3
40+import Ubuntu.Components.ListItems 1.3 as ListItem
41+
42+Item {
43+ width: 400
44+ height: 400
45+
46+ Rectangle {
47+ id: testItem
48+ }
49+
50+ AbstractButton {
51+ id: testControl
52+ visible: false
53+ }
54+
55+ ListItem.Standard {
56+ id: listItemStandard
57+ anchors.fill: parent
58+ }
59+
60+ TestCase {
61+ name: "ListItemsStandardAPI"
62+ when: windowShown
63+
64+ function test_clickToTrigger_bug1527811() {
65+ compare(listItemTriggeredSpy.valid, true, "triggered signal exists")
66+ var listItemTriggeredCount = listItemTriggeredSpy.count
67+ mouseMove(listItemStandard, 10, 10)
68+ mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
69+ compare(listItemTriggeredSpy.count, listItemTriggeredCount + 1,
70+ "Clicking the list item triggers it")
71+ }
72+
73+ function test_fallbackIconSource() {
74+ expectFail("","https://bugs.launchpad.net/tavastia/+bug/1076762")
75+ compare(listItemStandard.fallbackIconSource,undefined,"fallbackIconSource is not set by default")
76+ }
77+
78+ function test_control() {
79+ listItemStandard.control = testControl
80+ compare(listItemStandard.control,testControl,"set/get")
81+ listItemStandard.control = null
82+ compare(listItemStandard.control, null, "unset")
83+ }
84+
85+ function test_clicked() {
86+ compare(listItemClickedSpy.valid, true, "clicked signal exists")
87+ compare(controlClickedSpy.valid, true, "control has clicked signal")
88+ var listItemClickedCount = listItemClickedSpy.count
89+ var controlClickedCount = controlClickedSpy.count
90+ mouseMove(listItemStandard, 10, 10)
91+ mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
92+ listItemClickedCount++;
93+ compare(listItemClickedSpy.count, listItemClickedCount, "List item clicked triggered")
94+ listItemStandard.control = testControl;
95+ mouseMove(listItemStandard, 10, 10)
96+ mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
97+ compare(listItemStandard.control, testControl, "control can be set")
98+ listItemClickedCount++;
99+ compare(controlClickedSpy.count, controlClickedCount, "Control clicked triggered")
100+ compare(listItemClickedSpy.count, listItemClickedCount, "List item clicked not triggered when there is a control")
101+ listItemStandard.control = null;
102+ }
103+
104+ function test_bug1166982_disabled_control_clicked() {
105+ var controlClickedCount = controlClickedSpy.count
106+ listItemStandard.control = testControl
107+ testControl.enabled = false
108+ mouseMove(listItemStandard, 10, 10)
109+ mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
110+ compare(controlClickedSpy.count, controlClickedCount, "Control clicked not triggered with disabled control")
111+ testControl.enabled = true
112+ listItemStandard.control = null
113+ }
114+
115+ function test_icon() {
116+ ignoreWarning("WARNING: ListItems.Standard.icon is DEPRECATED. Use iconName and iconSource instead.")
117+ compare(listItemStandard.icon,undefined,"icon is not set by default")
118+
119+ // test with url
120+ var newIcon = Qt.resolvedUrl("../../../examples/ubuntu-ui-toolkit-gallery/small_avatar.png")
121+ listItemStandard.icon = newIcon
122+ compare(listItemStandard.icon,newIcon,"set/get from url")
123+ }
124+
125+ function test_iconFrame() {
126+ compare(listItemStandard.iconFrame,true,"iconFrame is true by default")
127+ }
128+
129+ function test_progression() {
130+ compare(listItemStandard.progression,false,"progression is false by default")
131+ }
132+
133+ function test_text() {
134+ compare(listItemStandard.text,"","text is '' by default")
135+ var newText = "Hello World!"
136+ listItemStandard.text = newText
137+ compare(listItemStandard.text,newText,"set/get")
138+ }
139+
140+ SignalSpy {
141+ id: listItemClickedSpy
142+ target: listItemStandard
143+ signalName: "clicked"
144+ }
145+
146+ SignalSpy {
147+ id: controlClickedSpy
148+ target: testControl
149+ signalName: "clicked"
150+ }
151+
152+ SignalSpy {
153+ id: listItemTriggeredSpy
154+ target: listItemStandard
155+ signalName: "triggered"
156+ }
157+ }
158+}
159
160=== modified file 'tests/unit_x11/tst_components/tst_listitems_standard.qml'
161--- tests/unit_x11/tst_components/tst_listitems_standard.qml 2015-03-03 13:20:06 +0000
162+++ tests/unit_x11/tst_components/tst_listitems_standard.qml 2015-12-21 19:44:15 +0000
163@@ -41,6 +41,15 @@
164 name: "ListItemsStandardAPI"
165 when: windowShown
166
167+ function test_clickToTrigger_bug1527811() {
168+ compare(listItemTriggeredSpy.valid, true, "triggered signal exists")
169+ var listItemTriggeredCount = listItemTriggeredSpy.count
170+ mouseMove(listItemStandard, 10, 10)
171+ mouseClick(listItemStandard, 10, 10, Qt.LeftButton)
172+ compare(listItemTriggeredSpy.count, listItemTriggeredCount + 1,
173+ "Clicking the list item triggers it")
174+ }
175+
176 function test_fallbackIconSource() {
177 expectFail("","https://bugs.launchpad.net/tavastia/+bug/1076762")
178 compare(listItemStandard.fallbackIconSource,undefined,"fallbackIconSource is not set by default")
179@@ -119,5 +128,11 @@
180 target: testControl
181 signalName: "clicked"
182 }
183+
184+ SignalSpy {
185+ id: listItemTriggeredSpy
186+ target: listItemStandard
187+ signalName: "triggered"
188+ }
189 }
190 }

Subscribers

People subscribed via source and target branches

to status/vote changes: