~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_components/tst_bug1510919.qml

  • Committer: Zsombor Egri
  • Date: 2015-11-16 06:35:05 UTC
  • mfrom: (1664.1.1 listitemSelectModeBugs)
  • Revision ID: zsombor.egri@canonical.com-20151116063505-cwn2qfks7qzk10g9
re-sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
17
import QtQuick 2.4
 
18
import Ubuntu.Components 1.3
 
19
import QtTest 1.0
 
20
import Ubuntu.Test 1.0
 
21
 
 
22
MainView {
 
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
}