Merge lp:~zsombi/ubuntu-ui-toolkit/fixComboButton into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 1315
Merged at revision: 1316
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/fixComboButton
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 259 lines (+244/-0)
2 files modified
src/Ubuntu/Components/1.3/ComboButton.qml (+9/-0)
tests/unit_x11/tst_components/tst_combobutton13.qml (+235/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/fixComboButton
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) test Approve
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu SDK team Pending
Review via email: mp+294387@code.launchpad.net

Commit message

Fix regression introduced in ComboButton due to the binding loop bug on AbstractButton implicit sizes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

I can confirm that fixes the address book app problem.

review: Approve (test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/1.3/ComboButton.qml'
2--- src/Ubuntu/Components/1.3/ComboButton.qml 2016-03-01 19:00:50 +0000
3+++ src/Ubuntu/Components/1.3/ComboButton.qml 2016-05-11 15:40:04 +0000
4@@ -301,6 +301,15 @@
5
6 // update sensing area to report clicks only on the main button area
7 // area excluding dropDown button and combo list
8+ Component.onCompleted: {
9+ __mouseArea.anchors.rightMargin = Qt.binding(function() {
10+ return combo.__styleInstance.dropDownWidth;
11+ });
12+ __mouseArea.anchors.bottomMargin = Qt.binding(function () {
13+ return combo.expanded ? (combo.height - combo.collapsedHeight) : 0;
14+ });
15+ }
16+
17 sensingMargins {
18 bottom: -(combo.height - combo.collapsedHeight)
19 right: -combo.__styleInstance.dropDownWidth
20
21=== added file 'tests/unit_x11/tst_components/tst_combobutton13.qml'
22--- tests/unit_x11/tst_components/tst_combobutton13.qml 1970-01-01 00:00:00 +0000
23+++ tests/unit_x11/tst_components/tst_combobutton13.qml 2016-05-11 15:40:04 +0000
24@@ -0,0 +1,235 @@
25+/*
26+ * Copyright 2014 Canonical Ltd.
27+ *
28+ * This program is free software; you can redistribute it and/or modify
29+ * it under the terms of the GNU Lesser General Public License as published by
30+ * the Free Software Foundation; version 3.
31+ *
32+ * This program is distributed in the hope that it will be useful,
33+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
34+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35+ * GNU Lesser General Public License for more details.
36+ *
37+ * You should have received a copy of the GNU Lesser General Public License
38+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
39+ */
40+
41+import QtQuick 2.4
42+import QtTest 1.0
43+import Ubuntu.Test 1.3
44+import Ubuntu.Components 1.3
45+import Ubuntu.Components.ListItems 1.3
46+
47+Item {
48+ width: units.gu(40)
49+ height: units.gu(71)
50+
51+ Column {
52+ ComboButton {
53+ id: combo
54+ }
55+
56+ ComboButton {
57+ id: rectCombo
58+ onClicked: expanded = false
59+
60+ Rectangle {
61+ id: rect
62+ width: parent.width
63+ height: units.gu(40)
64+ gradient: Gradient {
65+ GradientStop {
66+ position: 0.0
67+ color: "red"
68+ }
69+ GradientStop {
70+ position: 0.5
71+ color: "green"
72+ }
73+ GradientStop {
74+ position: 1.0
75+ color: "blue"
76+ }
77+ }
78+ }
79+ }
80+
81+ ComboButton {
82+ id: columnCombo
83+ expandedHeight: -1
84+ Column {
85+ id: column
86+ anchors {
87+ left: parent.left
88+ right: parent.right
89+ }
90+ height: childrenRect.height
91+ Repeater {
92+ model: 5
93+ Rectangle {
94+ width: parent.width
95+ height: units.gu(5)
96+ color: Qt.rgba(Math.random(1), Math.random(1), Math.random(1), 1);
97+ }
98+ }
99+ }
100+ }
101+
102+ ComboButton {
103+ id: longCombo
104+ expandedHeight: units.gu(40)
105+ Rectangle {
106+ id: longRect
107+ height: units.gu(10)
108+ color: "cyan"
109+ }
110+ }
111+
112+ ComboButton {
113+ id: listCombo
114+ ListView {
115+ id: list
116+ model: 20
117+ height: listCombo.comboListHeight
118+ delegate: Standard {
119+ text: modelData
120+ }
121+ }
122+ }
123+ }
124+
125+ SignalSpy { id: spy }
126+
127+ UbuntuTestCase {
128+ name: "ComboButton"
129+ when: windowShown
130+
131+ function cleanup() {
132+ rectCombo.expanded =
133+ columnCombo.expanded =
134+ longCombo.expanded =
135+ listCombo.expanded = false;
136+ spy.clear();
137+ spy.signalName = "";
138+ spy.target = undefined;
139+ }
140+
141+ function test_0_defaults() {
142+ compare(combo.expanded, false, "not expanded by default");
143+ compare(combo.collapsedHeight, combo.implicitHeight, "collapsedHeight is implicitHeight");
144+ compare(combo.expandedHeight, combo.collapsedHeight + units.gu(19.5), "expanded height default");
145+ var lheight = combo.expandedHeight - combo.collapsedHeight - combo.__styleInstance.comboListMargin;
146+ compare(combo.comboListHeight, lheight, "comboListHeight default");
147+ compare(combo.comboList.length, 0, "comboList is empty");
148+ verify(combo.font === Qt.font({family: "Ubuntu", pixelSize: FontUtils.sizeToPixels("medium")}), "Default font differs.");
149+ }
150+
151+ function test_comboListWidth() {
152+ var comboListHolder = findChild(rectCombo, "combobutton_combolist");
153+ compare(rect.width, comboListHolder.width, "rectCombo list content width is not adjusted");
154+ comboListHolder = findChild(columnCombo, "combobutton_combolist");
155+ compare(column.width, comboListHolder.width, "columnCombo list content width is not adjusted");
156+ comboListHolder = findChild(longCombo, "combobutton_combolist");
157+ compare(longRect.width, comboListHolder.width, "longCombo list content width is not adjusted");
158+ comboListHolder = findChild(listCombo, "combobutton_combolist");
159+ compare(list.width, comboListHolder.width, "listCombo list content width is not adjusted");
160+ }
161+
162+ function test_expandRectComboThroughProperty() {
163+ rectCombo.expanded = true;
164+ waitForRendering(rectCombo);
165+ var comboListPanel = findChild(rectCombo, "combobutton_combopanel");
166+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
167+ }
168+
169+ function test_expandRectComboThroughClick() {
170+ var dropDown = findChild(rectCombo, "combobutton_dropdown");
171+ mouseClick(dropDown, dropDown.width / 2, dropDown.height / 2);
172+ waitForRendering(rectCombo);
173+ compare(rectCombo.expanded, true, "combo is not expanded");
174+ var comboListPanel = findChild(rectCombo, "combobutton_combopanel");
175+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
176+ }
177+
178+ function test_autoCollapse() {
179+ var dropDown = findChild(rectCombo, "combobutton_dropdown");
180+ var comboListPanel = findChild(rectCombo, "combobutton_combopanel");
181+ mouseClick(dropDown, dropDown.width / 2, dropDown.height / 2);
182+ waitForRendering(rectCombo);
183+ compare(rectCombo.expanded, true, "combo is not expanded");
184+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
185+
186+ mouseClick(rectCombo, rectCombo.width / 2, rectCombo.collapsedHeight / 2);
187+ waitForRendering(rectCombo);
188+ compare(rectCombo.expanded, false, "combo is not collapsed");
189+ tryCompareFunction(function() { return comboListPanel.opacity}, 0.0);
190+ }
191+
192+ function test_flickRectCombo() {
193+ // skip the test temporarily due to flakyness on powerpc target
194+ // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1315244
195+ skip("The test is flaky on powerpc target");
196+ var dropDown = findChild(rectCombo, "combobutton_dropdown");
197+ var comboListPanel = findChild(rectCombo, "combobutton_combopanel");
198+ var comboList = findChild(rectCombo, "combobutton_combolist");
199+ mouseClick(dropDown, dropDown.width / 2, dropDown.height / 2);
200+ waitForRendering(rectCombo);
201+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
202+ verify(comboList.height > rectCombo.expandedHeight);
203+ // comboList flicker is the combolist parent's parent
204+ var comboListFlicker = findChild(rectCombo, "combobutton_contentflicker");
205+ compare(comboListFlicker.interactive, true, "combo list holder must be interactive");
206+
207+ // drag the rectangle, the Flickable should be moving
208+ var x = comboListFlicker.width / 2;
209+ var y = comboListFlicker.height / 2;
210+ var dy = comboListFlicker.height / 6;
211+ spy.target = comboListFlicker;
212+ spy.signalName = "onMovementEnded";
213+ mouseDrag(comboList, x, y, 0, -dy);
214+ waitForRendering(comboListFlicker);
215+ spy.wait();
216+ }
217+
218+ function test_autoExpandHeight() {
219+ var comboListPanel = findChild(columnCombo, "combobutton_combopanel");
220+ var comboList = findChild(columnCombo, "combobutton_combolist");
221+ columnCombo.expanded = true;
222+ waitForRendering(columnCombo);
223+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
224+ var comboListFlicker = findChild(columnCombo, "combobutton_contentflicker");
225+ compare(comboListFlicker.interactive, false, "combo list holder must not be interactive");
226+ compare(comboListFlicker.height, columnCombo.comboListHeight, "combo list height differs from the holder height");
227+ }
228+
229+ function test_emptyComboExpanded() {
230+ var comboListPanel = findChild(combo, "combobutton_combopanel");
231+ var comboList = findChild(combo, "combobutton_combolist");
232+ combo.expanded = true;
233+ waitForRendering(combo);
234+ waitForRendering(comboListPanel);
235+ tryCompareFunction(function() { return comboListPanel.opacity}, 0.0, 1000);
236+ }
237+
238+ function test_longCombo() {
239+ var comboListPanel = findChild(longCombo, "combobutton_combopanel");
240+ var comboList = findChild(longCombo, "combobutton_combolist");
241+ longCombo.expanded = true;
242+ waitForRendering(longCombo);
243+ waitForRendering(comboListPanel);
244+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
245+ verify(comboListPanel.height < longCombo.expandedHeight);
246+ }
247+
248+ function test_listCombo() {
249+ var comboListPanel = findChild(listCombo, "combobutton_combopanel");
250+ var comboList = findChild(listCombo, "combobutton_combolist");
251+ listCombo.expanded = true;
252+ waitForRendering(listCombo);
253+ waitForRendering(comboListPanel);
254+ tryCompareFunction(function() { return comboListPanel.opacity}, 1.0);
255+
256+ compare(list.height, comboList.height, "list and comboList height differs");
257+ }
258+ }
259+}

Subscribers

People subscribed via source and target branches

to status/vote changes: