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

Proposed by Zsombor Egri on 2015-10-30
Status: Merged
Approved by: Zoltan Balogh on 2015-11-02
Approved revision: 1248
Merged at revision: 1248
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/switchFixTrunk
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 107 lines (+79/-2)
3 files modified
src/Ubuntu/Components/plugin/ucabstractbutton.cpp (+1/-1)
tests/unit_x11/tst_components/tst_abstractbutton13.qml (+3/-1)
tests/unit_x11/tst_components/tst_bug1510919.qml (+75/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/switchFixTrunk
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-10-30
Ubuntu SDK team 2015-10-30 Pending
Review via email: mp+276259@code.launchpad.net

Commit message

Switch and CheckBox fix when checked is not toggled when clicked() signal is emitted.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
2--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-09-30 18:55:20 +0000
3+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-10-30 13:30:25 +0000
4@@ -81,7 +81,7 @@
5 {
6 UCActionItem::componentComplete();
7 // connect to the right slot, using macros so we get the proper slot
8- connect(this, SIGNAL(clicked()), this, SLOT(trigger()));
9+ connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(trigger()));
10
11 // bind mouse area
12 connect(m_mouseArea, &QQuickMouseArea::pressedChanged, this, &UCAbstractButton::pressedChanged);
13
14=== modified file 'tests/unit_x11/tst_components/tst_abstractbutton13.qml'
15--- tests/unit_x11/tst_components/tst_abstractbutton13.qml 2015-09-30 18:55:20 +0000
16+++ tests/unit_x11/tst_components/tst_abstractbutton13.qml 2015-10-30 13:30:25 +0000
17@@ -97,7 +97,9 @@
18 absButton.action = action1
19 compare(absButton.action, action1, "Action can be set")
20 var numTriggers = action1.triggerCount
21- absButton.clicked()
22+ triggeredSpy.target = absButton.action;
23+ mouseClick(absButton, centerOf(absButton).x, centerOf(absButton).y);
24+ triggeredSpy.wait(500);
25 compare(action1.triggerCount, numTriggers+1, "Button clicked triggers action")
26 absButton.action = null
27 }
28
29=== added file 'tests/unit_x11/tst_components/tst_bug1510919.qml'
30--- tests/unit_x11/tst_components/tst_bug1510919.qml 1970-01-01 00:00:00 +0000
31+++ tests/unit_x11/tst_components/tst_bug1510919.qml 2015-10-30 13:30:25 +0000
32@@ -0,0 +1,75 @@
33+/*
34+ * Copyright 2015 Canonical Ltd.
35+ *
36+ * This program is free software; you can redistribute it and/or modify
37+ * it under the terms of the GNU Lesser General Public License as published by
38+ * the Free Software Foundation; version 3.
39+ *
40+ * This program is distributed in the hope that it will be useful,
41+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
42+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43+ * GNU Lesser General Public License for more details.
44+ *
45+ * You should have received a copy of the GNU Lesser General Public License
46+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
47+ */
48+
49+import QtQuick 2.4
50+import Ubuntu.Components 1.3
51+import QtTest 1.0
52+import Ubuntu.Test 1.0
53+
54+MainView {
55+ width: units.gu(40)
56+ height: units.gu(71)
57+
58+ Column {
59+ CheckBox {
60+ id: checkBox
61+ }
62+ Switch {
63+ id: switchBox
64+ }
65+ }
66+
67+ UbuntuTestCase {
68+ name: "CheckAndSwitch"
69+ when: windowShown
70+
71+ SignalSpy {
72+ id: clickSpy
73+ signalName: "clicked"
74+ }
75+
76+ function cleanup() {
77+ clickSpy.target = null;
78+ clickSpy.clear();
79+ checkBox.checked = false;
80+ switchBox.checked = false;
81+ }
82+
83+ function initTestCase() {
84+ TestExtras.registerTouchDevice();
85+ }
86+
87+ function test_checked_in_sync_with_clicked_data() {
88+ return [
89+ {tag: "CheckBox with touch", item: checkBox, touch: true},
90+ {tag: "CheckBox with mouse", item: checkBox, touch: false},
91+ {tag: "Switch with touch", item: switchBox, touch: true},
92+ {tag: "Switch with mouse", item: switchBox, touch: false},
93+ ];
94+ }
95+ function test_checked_in_sync_with_clicked(data) {
96+ var checked = data.item.checked;
97+ clickSpy.target = data.item;
98+ if (data.touch) {
99+ TestExtras.touchClick(0, data.item, centerOf(data.item));
100+ } else {
101+ mouseClick(data.item, centerOf(data.item).x, centerOf(data.item).y);
102+ }
103+ clickSpy.wait(500);
104+ compare(data.item.checked, !checked, "checked property shoudl be altered!");
105+ }
106+ }
107+}

Subscribers

People subscribed via source and target branches

to status/vote changes: