on xenial help sign in
Reload infographics object before each test
d76390fTomás Tormo
tests/mocks/libusermetrics/UserMetrics.cpp+2−2
@@ -362,8 +362,8 @@ void UserMetricsPrivate::finishSetFakeData()
362 m_secondColor = m_newData->secondColor();
362 m_secondColor = m_newData->secondColor();
363 m_secondMonth.setVariantList(m_newData->secondMonth());
363 m_secondMonth.setVariantList(m_newData->secondMonth());
364
364
365− bool currentDayChanged = m_currentDay != m_newData->length();
365+ bool currentDayChanged = m_currentDay != m_username.length();
366− m_currentDay = m_newData->length();
366+ m_currentDay = m_username.length();
367
367
368 q_ptr->labelChanged(m_label);
368 q_ptr->labelChanged(m_label);
369 if (currentDayChanged)
369 if (currentDayChanged)
tests/qmltests/Greeter/tst_Infographics.qml+40−19
@@ -38,15 +38,43 @@ Item {
38 width: units.gu(120)
38 width: units.gu(120)
39 height: units.gu(120)
39 height: units.gu(120)
40
40
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+
41 UT.UnityTestCase {
54 UT.UnityTestCase {
42 name: "Infographics"
55 name: "Infographics"
43 when: windowShown
56 when: windowShown
44
57
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
45− property var dataCircle: findChild(infographic, "dataCircle")
72+ dataCircle = findChild(infographic, "dataCircle")
46− property var dots: findChild(infographic, "dots")
73+ dots = findChild(infographic, "dots")
47− property var label: findChild(infographic, "label")
74+ label = findChild(infographic, "label")
48− property var presentCircles: findChild(infographic, "presentCircles")
75+ presentCircles = findChild(infographic, "presentCircles")
49− property var pastCircles: findChild(infographic, "pastCircles")
76+ pastCircles = findChild(infographic, "pastCircles")
77+ }
50
78
51 function test_dot_states_data() {
79 function test_dot_states_data() {
52 return [
80 return [
@@ -74,8 +102,9 @@ Item {
74
102
75 function test_set_username_data() {
103 function test_set_username_data() {
76 return [
104 return [
77− { username: "", label: "", visible: false },
105+ { username: "has-password", label: "<b>19</b> minutes talk time", visible: true },
78− { username: "two-factor", label: "", visible: true },
106+ { username: "two-factor", label: "", visible: true },
107+ { username: "", label: "", visible: false },
79
108
80 ]
109 ]
81 }
110 }
@@ -89,26 +118,18 @@ Item {
89 function test_set_current_day_data(data)
118 function test_set_current_day_data(data)
90 {
119 {
91 return [
120 return [
92− { tag: "Same day", currentDaySet: 0, currentDayExpected: 0 },
121+ { tag: "Same day", username: "", expectedDay: "".length}, // Expecting day 0, since the UserMetrics mock sets this value at creation time
93− { tag: "Wrong day", currentDaySet: 1, currentDayExpected: 0 },
122+ { tag: "Different day", username: "has-password", expectedDay: "has-password".length},
94 ]
123 ]
95 }
124 }
96
125
97 function test_set_current_day(data)
126 function test_set_current_day(data)
98 {
127 {
99− infographic.currentDay = data.currentDaySet
128+ infographicModel.username = data.username
100− infographic.startShowAnimation()
101− compare(infographic.currentDay, data.currentDayExpected)
129+ tryCompare(infographic, "currentDay", data.expectedDay)
102 }
130 }
103 }
131 }
104
132
105− Infographics {
106− id: infographic
107−
108− anchors.fill: parent
109− model: infographicModel
110− }
111−
112 Dot { id: dot }
133 Dot { id: dot }
113 ObjectPositioner { id: objectPositioner }
134 ObjectPositioner { id: objectPositioner }
114}
135}