~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/Previews/tst_PreviewProgress.qml

  • Committer: Nick Dedekind
  • Date: 2014-03-07 15:54:57 UTC
  • mfrom: (638.1.118 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140307155457-f0s1zu5ll2czt3rq
merged with trunk

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 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 "../../../../qml/Dash/Previews"
 
20
import Unity.Test 0.1 as UT
 
21
import Ubuntu.Components 0.1
 
22
 
 
23
Rectangle {
 
24
    id: root
 
25
    width: units.gu(60)
 
26
    height: units.gu(80)
 
27
 
 
28
    property var progressjson: {
 
29
        "type": "progress",
 
30
        "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
 
31
    }
 
32
 
 
33
    property var progressjsonFinish: {
 
34
        "type": "progress",
 
35
        "source": { "dbus-name" : "somename", "dbus-object": "finish" }
 
36
    }
 
37
 
 
38
    property var progressjsonError: {
 
39
        "type": "progress",
 
40
        "source": { "dbus-name" : "somename", "dbus-object": "error" }
 
41
    }
 
42
 
 
43
    SignalSpy {
 
44
        id: spy
 
45
        signalName: "triggered"
 
46
    }
 
47
 
 
48
    PreviewProgress {
 
49
        id: previewProgress
 
50
        widgetId: "previewProgress"
 
51
        widgetData: progressjson
 
52
        width: units.gu(30)
 
53
 
 
54
        Rectangle {
 
55
            anchors.fill: parent
 
56
            color: "red"
 
57
            opacity: 0.1
 
58
        }
 
59
    }
 
60
 
 
61
    UT.UnityTestCase {
 
62
        name: "PreviewProgressTest"
 
63
        when: windowShown
 
64
 
 
65
        function test_json() {
 
66
            spy.target = previewProgress;
 
67
 
 
68
            // The mock DownloadTracker triggers its signals when you pass
 
69
            // finish/error as dbus-object to it. Exercise it here
 
70
            previewProgress.widgetData = progressjsonFinish;
 
71
            compare(spy.count, 1);
 
72
            var args = spy.signalArguments[0];
 
73
            compare(args[0], "previewProgress");
 
74
            compare(args[1], "finished");
 
75
            compare(args[2], progressjsonFinish);
 
76
 
 
77
            spy.clear();
 
78
 
 
79
            previewProgress.widgetData = progressjsonError;
 
80
            compare(spy.count, 1);
 
81
            var args = spy.signalArguments[0];
 
82
            compare(args[0], "previewProgress");
 
83
            compare(args[1], "failed");
 
84
            compare(args[2], progressjsonError);
 
85
        }
 
86
    }
 
87
}