~ubuntu-sdk-team/ubuntu-ui-toolkit/trunk

« back to all changes in this revision

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

  • Committer: CI Train Bot
  • Author(s): Christian Dywan, Zsombor Egri, Zoltán Balogh, Tim Peeters, Albert Astals Cid, Michael Sheldon, Benjamin Zeller
  • Date: 2015-12-17 17:13:49 UTC
  • mfrom: (1000.739.27 OTA9-landing-2015-12-16)
  • Revision ID: ci-train-bot@canonical.com-20151217171349-8xwclnhnx8v9oz4m
OTA9-landing-2015-12-16
Approved by: Zoltan Balogh

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2014 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.0
 
18
import QtTest 1.0
 
19
import Ubuntu.Test 1.0
 
20
import Ubuntu.Components 1.3
 
21
 
 
22
MainView {
 
23
    id: main
 
24
 
 
25
    width: units.gu(40)
 
26
    height: units.gu(71)
 
27
 
 
28
    Column {
 
29
        Switch {
 
30
            id: testSwitch
 
31
            checked: true
 
32
            property bool checkedNow: true
 
33
            onClicked: checkedNow = checked
 
34
        }
 
35
 
 
36
        CheckBox {
 
37
            id: testCheck
 
38
            checked: true
 
39
            property bool checkedNow: true
 
40
            onClicked: checkedNow = checked
 
41
        }
 
42
    }
 
43
 
 
44
    UbuntuTestCase {
 
45
        name: "Toggles13"
 
46
        when: windowShown
 
47
 
 
48
        SignalSpy {
 
49
            id: clickedSpy
 
50
            signalName: "clicked"
 
51
        }
 
52
 
 
53
        function cleanup() {
 
54
            clickedSpy.clear();
 
55
            clickedSpy.target = null;
 
56
        }
 
57
 
 
58
        function test_toggle_checked_delayed_bug1524234_data() {
 
59
            return [
 
60
                {tag: "CheckBox", testItem: testCheck, mouse: true},
 
61
                {tag: "Switch", testItem: testSwitch, mouse: true},
 
62
                {tag: "CheckBox, space key", testItem: testCheck, key: Qt.Key_Space},
 
63
                {tag: "Switch, space key", testItem: testSwitch, key: Qt.Key_Space},
 
64
            ];
 
65
        }
 
66
        function test_toggle_checked_delayed_bug1524234(data) {
 
67
            data.testItem.checkedNow = data.testItem.checked;
 
68
            data.testItem.forceActiveFocus();
 
69
            clickedSpy.target = data.testItem;
 
70
            if (data.key) {
 
71
                keyClick(data.key);
 
72
            } else {
 
73
                mouseClick(data.testItem, centerOf(data.testItem).x, centerOf(data.testItem).y);
 
74
            }
 
75
            clickedSpy.wait(400);
 
76
            compare(data.testItem.checkedNow, data.testItem.checked);
 
77
        }
 
78
    }
 
79
}
 
80