~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-yakkety-landing-027

« back to all changes in this revision

Viewing changes to tests/plugins/system-update/tst_systemupdate_entrycomponent.qml

  • Committer: Bileto Bot
  • Author(s): jonas-drange
  • Date: 2016-08-17 11:18:05 UTC
  • mfrom: (1631.6.245 updates-rewrite)
  • Revision ID: ci-train-bot@canonical.com-20160817111805-moyvik9wloy79ul3
rewrite the system update panel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2016 Canonical Ltd.
 
5
 *
 
6
 * This program is free software: you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License version 3, as published
 
8
 * by the Free Software Foundation.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
12
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
13
 * PURPOSE.  See the GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import QtTest 1.0
 
21
import Ubuntu.Components 1.3
 
22
import Ubuntu.Connectivity 1.0
 
23
import Ubuntu.DownloadManager 1.2
 
24
import Ubuntu.SystemSettings.Update 1.0
 
25
import Ubuntu.Test 0.1
 
26
 
 
27
import Source 1.0
 
28
 
 
29
Item {
 
30
    id: testRoot
 
31
    width: units.gu(50)
 
32
    height: units.gu(90)
 
33
 
 
34
    Component {
 
35
        id: entryComponent
 
36
 
 
37
        EntryComponent {
 
38
            property var model
 
39
            width: testRoot.width
 
40
        }
 
41
    }
 
42
 
 
43
    // Test suite when there's no Image update.
 
44
    UbuntuTestCase {
 
45
        name: "EntryComponentNoImageUpdateTestCase"
 
46
        when: windowShown
 
47
 
 
48
        property var instance: null
 
49
 
 
50
        function init() {
 
51
            SystemImage.mockTargetBuildNumber(0);
 
52
            SystemImage.mockCurrentBuildNumber(0);
 
53
            instance = entryComponent.createObject(testRoot, {
 
54
                "model": {
 
55
                    displayName: "System Updates Test",
 
56
                    icon: "file:///usr/share/icons/suru/places/scalable/distributor-logo.svg"
 
57
                }
 
58
            });
 
59
        }
 
60
 
 
61
        function cleanup() {
 
62
            instance.destroy();
 
63
            UpdateManager.model.reset();
 
64
        }
 
65
 
 
66
        function test_defaultVisibility() {
 
67
            compare(instance.height, 0, "default visibility was wrong");
 
68
        }
 
69
 
 
70
        function test_clickUpdates() {
 
71
            UpdateManager.model.mockAddUpdate("app" + 0, 0, Update.KindClick);
 
72
            tryCompare(instance, "height", units.gu(7), 5000, "item did not have the correct height when we had click updates");
 
73
        }
 
74
    }
 
75
 
 
76
    // Test suite for when we have an image update.
 
77
    UbuntuTestCase {
 
78
        name: "EntryComponentImageUpdateTestCase"
 
79
        when: windowShown
 
80
 
 
81
        property var instance: null
 
82
 
 
83
        function init() {
 
84
            SystemImage.mockCurrentBuildNumber(0);
 
85
            SystemImage.mockTargetBuildNumber(1);
 
86
            instance = entryComponent.createObject(testRoot, {
 
87
                "model": {
 
88
                    displayName: "System Updates Test",
 
89
                    icon: "file:///usr/share/icons/suru/places/scalable/distributor-logo.svg"
 
90
                }
 
91
            });
 
92
        }
 
93
 
 
94
        function cleanup() {
 
95
            instance.destroy();
 
96
            UpdateManager.model.reset();
 
97
        }
 
98
 
 
99
        function test_visibleWhenImageUpdate() {
 
100
            tryCompare(instance, "height", units.gu(7), 5000, "item did not have the correct height when we had image updates");
 
101
        }
 
102
 
 
103
        function test_clickUpdates() {
 
104
            UpdateManager.model.mockAddUpdate("app" + 0, 0, Update.KindClick);
 
105
            tryCompare(instance, "height", units.gu(7), 5000, "item did not have the correct height when we had all types of updates");
 
106
        }
 
107
    }
 
108
}