@@ -38,15 +38,43 @@ Item {
3838 width: units.gu(120)
3939 height: units.gu(120)
4040
41+ Loader {
42+ id: loader
43+
44+ active: false
45+ anchors.fill: parent
46+
47+ sourceComponent: Component {
48+ Infographics {
49+ model: infographicModel
50+ }
51+ }
52+ }
53+
4154 UT.UnityTestCase {
4255 name: "Infographics"
4356 when: windowShown
4457
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")
58+ property var dataCircle
59+ property var dots
60+ property var label
61+ property var presentCircles
62+ property var pastCircles
63+ property var infographic
64+
65+ function init() {
66+ loader.active = false;
67+ tryCompare(loader, "status", Loader.Null);
68+ tryCompare(loader, "item", null);
69+ loader.active = true;
70+ tryCompare(loader, "status", Loader.Ready);
71+ infographic = loader.item
72+ dataCircle = findChild(infographic, "dataCircle")
73+ dots = findChild(infographic, "dots")
74+ label = findChild(infographic, "label")
75+ presentCircles = findChild(infographic, "presentCircles")
76+ pastCircles = findChild(infographic, "pastCircles")
77+ }
5078
5179 function test_dot_states_data() {
5280 return [
@@ -74,8 +102,9 @@ Item {
74102
75103 function test_set_username_data() {
76104 return [
77− { username: "", label: "", visible: false },
78− { username: "two-factor", label: "", visible: true },
105+ { username: "has-password", label: "<b>19</b> minutes talk time", visible: true },
106+ { username: "two-factor", label: "", visible: true },
107+ { username: "", label: "", visible: false },
79108
80109 ]
81110 }
@@ -89,26 +118,18 @@ Item {
89118 function test_set_current_day_data(data)
90119 {
91120 return [
92− { tag: "Same day", currentDaySet: 0, currentDayExpected: 0 },
93− { tag: "Wrong day", currentDaySet: 1, currentDayExpected: 0 },
121+ { tag: "Same day", username: "", expectedDay: "".length}, // Expecting day 0, since the UserMetrics mock sets this value at creation time
122+ { tag: "Different day", username: "has-password", expectedDay: "has-password".length},
94123 ]
95124 }
96125
97126 function test_set_current_day(data)
98127 {
99− infographic.currentDay = data.currentDaySet
100− infographic.startShowAnimation()
101− compare(infographic.currentDay, data.currentDayExpected)
128+ infographicModel.username = data.username
129+ tryCompare(infographic, "currentDay", data.expectedDay)
102130 }
103131 }
104132
105− Infographics {
106− id: infographic
107−
108− anchors.fill: parent
109− model: infographicModel
110− }
111−
112133 Dot { id: dot }
113134 ObjectPositioner { id: objectPositioner }
114135}