@@ -35,7 +35,7 @@ Item {
3535 indicatorModel.load();
3636
3737 indicatorRow.state = "initial";
38− indicatorRow.currentItem = null;
38+ indicatorRow.setCurrentItemIndex(-1);
3939 indicatorRow.unitProgress = 0.0;
4040 }
4141
@@ -51,6 +51,8 @@ Item {
5151 }
5252
5353 indicatorsModel: indicatorModel
54+
55+ Component.onCompleted: indicatorModel.load()
5456 }
5557
5658 Indicators.IndicatorsModel {
@@ -61,199 +63,98 @@ Item {
6163 name: "IndicatorRow"
6264 when: windowShown
6365
66+ function get_indicator_item(index) {
67+ return findChild(indicatorRow.row, "item" + index);
68+ }
69+
6470 function test_set_current_item() {
6571 init_test();
66− indicatorRow.setCurrentItem(0);
72+ indicatorRow.setCurrentItemIndex(0);
6773 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
6874
69− indicatorRow.setCurrentItem(1);
75+ indicatorRow.setCurrentItemIndex(1);
7076 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
7177
72− indicatorRow.setCurrentItem(2);
78+ indicatorRow.setCurrentItemIndex(2);
7379 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
7480 }
75− }
76−
77− UT.UnityTestCase {
78− name: "IndicatorRow_IconPosition"
79− when: windowShown
80−
81− function get_indicator_item_at(index) {
82− return findChild(indicatorRow, "rowRepeater").itemAt(index);
83− }
84−
85− function test_current_item_commit() {
86− init_test();
87−
88− indicatorRow.setCurrentItem(2);
89− indicatorRow.state = "commit";
90− tryCompare(get_indicator_item_at(0), "opacity", 0.0);
91− tryCompare(get_indicator_item_at(1), "opacity", 0.0);
92− tryCompare(get_indicator_item_at(2), "opacity", 1.0);
93− tryCompare(get_indicator_item_at(3), "opacity", 0.0);
94− tryCompare(get_indicator_item_at(4), "opacity", 0.0);
95− }
96− }
97−
98− UT.UnityTestCase {
99− name: "IndicatorRow_Highlight"
100− when: windowShown
101−
102− function get_indicator_item_at(index) {
103− return findChild(indicatorRow, "rowRepeater").itemAt(index);
104− }
105−
106− function test_intial_state() {
107− init_test();
108−
109− indicatorRow.state = "initial";
110− indicatorRow.setCurrentItem(0);
111−
112− compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
113− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
114− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in initial state");
115− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in initial state");
116− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in initial state");
117− }
118−
119− function test_hint_state() {
120− init_test();
121−
122− indicatorRow.state = "hint";
123− indicatorRow.setCurrentItem(0);
124−
125− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
126− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
127− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in hint state");
128− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in hint state");
129− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in hint state");
130− }
131−
132− function test_revealed_state() {
133− init_test();
134−
135− indicatorRow.state = "reveal";
136− indicatorRow.setCurrentItem(0);
137−
138− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
139− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
140− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
141− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
142− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
143− }
144−
145− function test_commit_state() {
146− init_test();
147−
148− indicatorRow.state = "commit";
149− indicatorRow.setCurrentItem(0);
15081
151− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
152− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
153− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
154− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
155− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
82+ function test_highlight_data() {
83+ return [
84+ { index: 0, progress: 0.0, current: false, other: false },
85+ { index: 0, progress: 0.1, current: true, other: false },
86+ { index: 0, progress: 0.5, current: true, other: false },
87+ { index: 0, progress: 1.0, current: true, other: false },
88+ { index: 2, progress: 0.0, current: false, other: false },
89+ { index: 2, progress: 0.1, current: true, other: false },
90+ { index: 2, progress: 0.5, current: true, other: false },
91+ { index: 2, progress: 1.0, current: true, other: false }
92+ ];
15693 }
15794
158− function test_locked_state() {
95+ function test_highlight(data) {
15996 init_test();
16097
161− indicatorRow.state = "locked";
162− indicatorRow.setCurrentItem(0);
98+ indicatorRow.unitProgress = data.progress;
99+ indicatorRow.setCurrentItemIndex(data.index);
163100
164− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
165− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
166− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in locked state");
167− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in locked state");
168− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in locked state");
169− }
101+ compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
170102
171− function test_opacity() {
172− init_test();
173−
174− indicatorRow.state = "reveal";
175− indicatorRow.unitProgress = 0.5;
176− indicatorRow.setCurrentItem(2);
177−
178− compare(get_indicator_item_at(0).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
179− compare(get_indicator_item_at(1).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
180− compare(get_indicator_item_at(2).opacity, 1.0, "Current indicator should not change in response to panel progress");
181− compare(get_indicator_item_at(3).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
182− compare(get_indicator_item_at(4).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
103+ for (var i = 0; i < indicatorRow.row.count; i++) {
104+ compare(get_indicator_item(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
105+ }
183106 }
184− }
185107
186− UT.UnityTestCase {
187− name: "IndicatorRow_Dimmed"
188− when: windowShown
189−
190− function get_indicator_item_at(index) {
191− return findChild(indicatorRow, "rowRepeater").itemAt(index);
108+ function test_opacity_data() {
109+ return [
110+ { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
111+ { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
112+ { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
113+ { index: 0, progress: 1.0, current: 1.0, other: 0.0 },
114+ { index: 2, progress: 0.0, current: 1.0, other: 1.0 },
115+ { index: 2, progress: 0.1, current: 1.0, other: 0.9 },
116+ { index: 2, progress: 0.5, current: 1.0, other: 0.5 },
117+ { index: 2, progress: 1.0, current: 1.0, other: 0.0 }
118+ ];
192119 }
193120
194− function test_intial_state() {
121+ function test_opacity(data) {
195122 init_test();
196123
197− indicatorRow.state = "initial";
198− indicatorRow.setCurrentItem(0);
199−
200− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
201− compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
202− compare(get_indicator_item_at(2).dimmed, false, "Other indicators should not dim when in initial state");
203− compare(get_indicator_item_at(3).dimmed, false, "Other indicators should not dim when in initial state");
204− compare(get_indicator_item_at(4).dimmed, false, "Other indicators should not dim when in initial state");
205− }
206−
207− function test_hint_state() {
208− init_test();
124+ indicatorRow.unitProgress = data.progress;
125+ indicatorRow.setCurrentItemIndex(data.index);
209126
210− indicatorRow.state = "hint";
211− indicatorRow.setCurrentItem(0);
127+ tryCompare(indicatorRow.currentItem, "opacity", data.current);
212128
213− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
214− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
215− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
216− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in hint state");
217− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in hint state");
129+ for (var i = 0; i < indicatorRow.row.count; i++) {
130+ tryCompare(get_indicator_item(i), "opacity", i === data.index ? data.current: data.other);
131+ }
218132 }
219133
220− function test_revealed_state() {
221− init_test();
222−
223− indicatorRow.state = "reveal";
224− indicatorRow.setCurrentItem(0);
225−
226− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
227− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
228− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in reveal state");
229− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in reveal state");
230− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in reveal state");
134+ function test_dimmed_data() {
135+ return [
136+ { index: 0, progress: 0.0, current: false, other: false },
137+ { index: 0, progress: 0.1, current: false, other: true },
138+ { index: 0, progress: 0.5, current: false, other: true },
139+ { index: 0, progress: 1.0, current: false, other: true },
140+ { index: 2, progress: 0.0, current: false, other: false },
141+ { index: 2, progress: 0.1, current: false, other: true },
142+ { index: 2, progress: 0.5, current: false, other: true },
143+ { index: 2, progress: 1.0, current: false, other: true }
144+ ];
231145 }
232146
233− function test_commit_state() {
147+ function test_dimmed(data) {
234148 init_test();
235149
236− indicatorRow.state = "commit";
237− indicatorRow.setCurrentItem(0);
238−
239− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
240− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
241− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in commit state");
242− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in commit state");
243− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in commit state");
244− }
245−
246− function test_locked_state() {
247− init_test();
150+ indicatorRow.unitProgress = data.progress;
151+ indicatorRow.setCurrentItemIndex(data.index);
248152
249− indicatorRow.state = "locked";
250− indicatorRow.setCurrentItem(0);
153+ compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
251154
252− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
253− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
254− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
255− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in locked state");
256− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");
155+ for (var i = 0; i < indicatorRow.row.count; i++) {
156+ compare(get_indicator_item(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
157+ }
257158 }
258159 }
259160}