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

Proposed by Zsombor Egri
Status: Merged
Approved by: Zoltan Balogh
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
Ubuntu SDK team 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.

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

Subscribers

People subscribed via source and target branches

to status/vote changes: