~unity-team/+junk/dashboard-playground

« back to all changes in this revision

Viewing changes to tests/qmltests/Panel/tst_IndicatorItem.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU 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 General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU 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 ".."
 
20
import "../../../Panel"
 
21
import Ubuntu.Components 0.1
 
22
import Unity.Test 0.1 as UT
 
23
 
 
24
Rectangle {
 
25
    width: units.gu(10)
 
26
    height: units.gu(5)
 
27
    color: "black"
 
28
 
 
29
    IndicatorItem {
 
30
        id: indicatorItem
 
31
        anchors.fill: parent
 
32
        iconSource: "../../../Panel/graphics/Clock.png"
 
33
        label: "Clock"
 
34
    }
 
35
 
 
36
    UT.UnityTestCase {
 
37
        name: "IndicatorItem"
 
38
 
 
39
        function init_test() {
 
40
            indicatorItem.iconSource = "../../../Panel/graphics/Clock.png"
 
41
            indicatorItem.label = "Clock"
 
42
        }
 
43
 
 
44
        function test_dimmed() {
 
45
            init_test()
 
46
 
 
47
            var itemRow = findChild(indicatorItem, "itemRow")
 
48
            indicatorItem.dimmed = true
 
49
            compare(itemRow.opacity > 0, true, "IndicatorItem opacity should not be 0")
 
50
            compare(itemRow.opacity < 1, true, "IndicatorItem opacity should not be 1")
 
51
        }
 
52
 
 
53
        function test_empty() {
 
54
            init_test()
 
55
 
 
56
            indicatorItem.iconSource = ""
 
57
            indicatorItem.label = ""
 
58
            compare(indicatorItem.visible, false, "IndicatorItem should not be visible")
 
59
        }
 
60
 
 
61
        function test_noLabel() {
 
62
            init_test()
 
63
 
 
64
            var itemImage = findChild(indicatorItem, "itemImage")
 
65
            var itemLabel = findChild(indicatorItem, "itemLabel")
 
66
            indicatorItem.label = ""
 
67
            compare(itemImage.visible, true, "The image should be visible")
 
68
            compare(itemImage.width > 0, true, "The image should have a positive width")
 
69
            compare(itemLabel.width > 0, false, "The label should not have a positive width")
 
70
        }
 
71
 
 
72
        function test_noImage() {
 
73
            init_test()
 
74
 
 
75
            var itemImage = findChild(indicatorItem, "itemImage")
 
76
            var itemLabel = findChild(indicatorItem, "itemLabel")
 
77
            indicatorItem.iconSource = ""
 
78
            compare(itemImage.visible, false, "The image should not be visible")
 
79
            compare(itemLabel.width > 0, true, "The label should have a positive width")
 
80
        }
 
81
    }
 
82
}