~mzanetti/unity8/fix-1648251

« back to all changes in this revision

Viewing changes to tests/qmltests/Greeter/tst_Infographics.qml

  • Committer: Michael Zanetti
  • Date: 2016-12-01 12:20:34 UTC
  • mfrom: (2525.1.179 unity8)
  • Revision ID: michael.zanetti@canonical.com-20161201122034-cpvbf7webbhg2wph
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    width: units.gu(120)
39
39
    height: units.gu(120)
40
40
 
 
41
    Loader {
 
42
        id: loader
 
43
 
 
44
        active: false
 
45
        anchors.fill: parent
 
46
 
 
47
        property bool componentDestroyed: true
 
48
        sourceComponent: Component {
 
49
            Infographics {
 
50
                id: infographic
 
51
                width: loader.width
 
52
                height: loader.height
 
53
                model: infographicModel
 
54
 
 
55
                Component.onDestruction: {
 
56
                    loader.componentDestroyed = true
 
57
                }
 
58
            }
 
59
        }
 
60
    }
 
61
 
41
62
    UT.UnityTestCase {
42
63
        name: "Infographics"
43
64
        when: windowShown
44
65
 
45
 
        property var dataCircle: findChild(infographic, "dataCircle")
46
 
        property var dots: findChild(infographic, "dots")
47
 
        property var label: findChild(infographic, "label")
48
 
        property var presentCircles: findChild(infographic, "presentCircles")
49
 
        property var pastCircles: findChild(infographic, "pastCircles")
 
66
        property var dataCircle
 
67
        property var dots
 
68
        property var label
 
69
        property var presentCircles
 
70
        property var pastCircles
 
71
        property var infographic
 
72
 
 
73
        function reloadInfographic() {
 
74
            loader.active = false;
 
75
            tryCompare(loader, "status", Loader.Null);
 
76
            tryCompare(loader, "item", null);
 
77
            tryCompare(loader, "componentDestroyed", true);
 
78
            loader.active = true;
 
79
            tryCompare(loader, "status", Loader.Ready);
 
80
            loader.componentDestroyed = false
 
81
            infographic = loader.item
 
82
        }
 
83
 
 
84
        function reloadModel() {
 
85
           infographicModel.reset()
 
86
        }
 
87
 
 
88
        function init() {
 
89
            reloadModel()
 
90
            reloadInfographic()
 
91
            dataCircle = findChild(infographic, "dataCircle")
 
92
            dots =  findChild(infographic, "dots")
 
93
            label =  findChild(infographic, "label")
 
94
            presentCircles =  findChild(infographic, "presentCircles")
 
95
            pastCircles = findChild(infographic, "pastCircles")
 
96
        }
50
97
 
51
98
        function test_dot_states_data() {
52
99
            return [
74
121
 
75
122
        function test_set_username_data() {
76
123
            return [
77
 
                { username: "has-password", label: "<b>19</b> minutes talk time", visible: true },
78
 
                { username: "two-factor", label: "", visible: true },
79
 
                { username: "", label: "", visible: false },
 
124
               { username: "has-password", label: "<b>19</b> minutes talk time", visible: true },
 
125
               { username: "two-factor", label: "", visible: true },
 
126
               { username: "", label: "", visible: false },
 
127
 
80
128
            ]
81
129
        }
82
130
 
85
133
            tryCompare(label, "text", data.label)
86
134
            compare(infographic.visible, data.visible);
87
135
        }
88
 
    }
89
 
 
90
 
    Infographics {
91
 
        id: infographic
92
 
 
93
 
        anchors.fill: parent
94
 
        model: infographicModel
 
136
 
 
137
        function test_update_userdata_when_new_day_data()
 
138
        {
 
139
            return [
 
140
               { tag: "Same day",          currentDayOffset: 0, label: "<b>19</b> minutes talk time" },
 
141
               { tag: "Different day", currentDayOffset: 1, label: "<b>33</b> messages today" },
 
142
            ]
 
143
        }
 
144
 
 
145
        function test_update_userdata_when_new_day(data)
 
146
        {
 
147
            //Given
 
148
            var today = new Date().getDay()
 
149
            infographicModel.username = "single"
 
150
            infographic.currentWeekDay = (today - data.currentDayOffset)
 
151
 
 
152
            //When
 
153
            infographic.handleTimerTrigger()
 
154
 
 
155
            //Then
 
156
            tryCompare(infographic, "currentWeekDay", today)
 
157
            tryCompare(label, "text", data.label)
 
158
        }
95
159
    }
96
160
 
97
161
    Dot { id: dot }