~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-touch/tests/unit/tst_latchbutton.qml

  • Committer: Sylvain Pineau
  • Date: 2014-07-29 16:05:54 UTC
  • mto: This revision was merged to the branch mainline in revision 3149.
  • Revision ID: sylvain.pineau@canonical.com-20140729160554-qev8887xbunn9tmi
checkbox-ng:launchers:checkbox-cli: The checkbox-cli launcher

Running the default whitelist (with the suite selection screen skipped)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of Checkbox
3
 
 *
4
 
 * Copyright 2014 Canonical Ltd.
5
 
 *
6
 
 * Authors:
7
 
 * - Maciej Kisielewski <maciej.kisielewski@canonical.com>
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or modify
10
 
 * it under the terms of the GNU General Public License as published by
11
 
 * the Free Software Foundation; version 3.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
 */
21
 
 
22
 
import QtQuick 2.0
23
 
import QtTest 1.0
24
 
import Ubuntu.Components 0.1
25
 
import "../../components"
26
 
 
27
 
Item {
28
 
 
29
 
    /*
30
 
        This test checks if only one latchedClicked is emited even when
31
 
        multiple clicked calls are made to the underlaying button
32
 
    */
33
 
    TestCase{
34
 
        LatchButton {
35
 
            id: lb_latching
36
 
            onLatchedClicked: {
37
 
                tc_test_latching.counter++
38
 
            }
39
 
        }
40
 
        id: tc_test_latching
41
 
        property var counter: 0
42
 
 
43
 
        function test_latching() {
44
 
            for (var i = 0; i < 10; i++) {
45
 
                lb_latching.clicked()
46
 
            }
47
 
            compare(1, counter,
48
 
                "latchedClicked should be signalled signalled 1 time. Got " +
49
 
                 counter + " times.")
50
 
        }
51
 
    }
52
 
 
53
 
    /*
54
 
        This test checks if latchedClicked signal is emited next time button
55
 
        is clicked after unlatch method was called.
56
 
    */
57
 
    TestCase{
58
 
        LatchButton {
59
 
            id: lb_unlatching
60
 
            onLatchedClicked: {
61
 
                tc_test_unlatching.counter++
62
 
            }
63
 
        }
64
 
        id: tc_test_unlatching
65
 
        property var counter: 0
66
 
 
67
 
        function test_unlatching() {
68
 
            for (var i = 0; i < 3; i++) {
69
 
                lb_unlatching.clicked()
70
 
            }
71
 
            lb_unlatching.unlatch()
72
 
            for (var i = 0; i < 3; i++) {
73
 
                lb_unlatching.clicked()
74
 
            }
75
 
            compare(2, counter,
76
 
                "latchedClicked should be signalled signalled 2 times. Got "
77
 
                + counter + " times.")
78
 
        }
79
 
    }
80
 
}