@@ -33,7 +33,7 @@ Item {
3333 function init_test()
3434 {
3535 indicatorRow.state = "initial";
36− indicatorRow.currentItem = null;
36+ indicatorRow.setCurrentItemIndex(-1);
3737 indicatorRow.unitProgress = 0.0;
3838 }
3939
@@ -60,199 +60,98 @@ Item {
6060 name: "IndicatorRow"
6161 when: windowShown
6262
63+ function get_indicator_item_at(index) {
64+ return findChild(indicatorRow.row, "item" + index);
65+ }
66+
6367 function test_set_current_item() {
6468 init_test();
65− indicatorRow.setCurrentItem(0);
69+ indicatorRow.setCurrentItemIndex(0);
6670 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
6771
68− indicatorRow.setCurrentItem(1);
72+ indicatorRow.setCurrentItemIndex(1);
6973 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
7074
71− indicatorRow.setCurrentItem(2);
75+ indicatorRow.setCurrentItemIndex(2);
7276 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
7377 }
74− }
7578
76− UT.UnityTestCase {
77− name: "IndicatorRow_IconPosition"
78− when: windowShown
79−
80− function get_indicator_item_at(index) {
81− return findChild(indicatorRow, "rowRepeater").itemAt(index);
79+ function test_highlight_data() {
80+ return [
81+ { index: 0, progress: 0.0, current: false, other: false },
82+ { index: 0, progress: 0.1, current: true, other: false },
83+ { index: 0, progress: 0.5, current: true, other: false },
84+ { index: 0, progress: 1.0, current: true, other: false },
85+ { index: 2, progress: 0.0, current: false, other: false },
86+ { index: 2, progress: 0.1, current: true, other: false },
87+ { index: 2, progress: 0.5, current: true, other: false },
88+ { index: 2, progress: 1.0, current: true, other: false }
89+ ];
8290 }
8391
84− function test_current_item_commit() {
92+ function test_highlight(data) {
8593 init_test();
8694
87− indicatorRow.setCurrentItem(2);
88− indicatorRow.state = "commit";
89− tryCompare(get_indicator_item_at(0), "opacity", 0.0);
90− tryCompare(get_indicator_item_at(1), "opacity", 0.0);
91− tryCompare(get_indicator_item_at(2), "opacity", 1.0);
92− tryCompare(get_indicator_item_at(3), "opacity", 0.0);
93− tryCompare(get_indicator_item_at(4), "opacity", 0.0);
94− }
95− }
96−
97− UT.UnityTestCase {
98− name: "IndicatorRow_Highlight"
99− when: windowShown
100−
101− function get_indicator_item_at(index) {
102− return findChild(indicatorRow, "rowRepeater").itemAt(index);
103− }
104−
105− function test_intial_state() {
106− init_test();
95+ indicatorRow.unitProgress = data.progress;
96+ indicatorRow.setCurrentItemIndex(data.index);
10797
108− indicatorRow.state = "initial";
109− indicatorRow.setCurrentItem(0);
98+ compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
11099
111− compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
112− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
113− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in initial state");
114− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in initial state");
115− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in initial state");
100+ for (var i = 0; i < indicatorRow.row.count; i++) {
101+ compare(get_indicator_item_at(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
102+ }
116103 }
117104
118− function test_hint_state() {
119− init_test();
120−
121− indicatorRow.state = "hint";
122− indicatorRow.setCurrentItem(0);
123−
124− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
125− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
126− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in hint state");
127− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in hint state");
128− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in hint state");
105+ function test_opacity_data() {
106+ return [
107+ { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
108+ { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
109+ { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
110+ { index: 0, progress: 1.0, current: 1.0, other: 0.0 },
111+ { index: 2, progress: 0.0, current: 1.0, other: 1.0 },
112+ { index: 2, progress: 0.1, current: 1.0, other: 0.9 },
113+ { index: 2, progress: 0.5, current: 1.0, other: 0.5 },
114+ { index: 2, progress: 1.0, current: 1.0, other: 0.0 }
115+ ];
129116 }
130117
131− function test_revealed_state() {
118+ function test_opacity(data) {
132119 init_test();
133120
134− indicatorRow.state = "reveal";
135− indicatorRow.setCurrentItem(0);
121+ indicatorRow.unitProgress = data.progress;
122+ indicatorRow.setCurrentItemIndex(data.index);
136123
137− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
138− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
139− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
140− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
141− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
142− }
124+ compare(indicatorRow.currentItem.opacity, data.current, "Indicator opacity did not match for current item");
143125
144− function test_commit_state() {
145− init_test();
146−
147− indicatorRow.state = "commit";
148− indicatorRow.setCurrentItem(0);
149−
150− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
151− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
152− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
153− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
154− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
126+ for (var i = 0; i < indicatorRow.row.count; i++) {
127+ tryCompare(get_indicator_item_at(i), "opacity", i === data.index ? data.current: data.other);
128+ }
155129 }
156130
157− function test_locked_state() {
158− init_test();
159−
160− indicatorRow.state = "locked";
161− indicatorRow.setCurrentItem(0);
162−
163− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
164− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
165− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in locked state");
166− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in locked state");
167− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in locked state");
131+ function test_dimmed_data() {
132+ return [
133+ { index: 0, progress: 0.0, current: false, other: false },
134+ { index: 0, progress: 0.1, current: false, other: true },
135+ { index: 0, progress: 0.5, current: false, other: true },
136+ { index: 0, progress: 1.0, current: false, other: true },
137+ { index: 2, progress: 0.0, current: false, other: false },
138+ { index: 2, progress: 0.1, current: false, other: true },
139+ { index: 2, progress: 0.5, current: false, other: true },
140+ { index: 2, progress: 1.0, current: false, other: true }
141+ ];
168142 }
169143
170− function test_opacity() {
144+ function test_dimmed(data) {
171145 init_test();
172146
173− indicatorRow.state = "reveal";
174− indicatorRow.unitProgress = 0.5;
175− indicatorRow.setCurrentItem(2);
176−
177− compare(get_indicator_item_at(0).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
178− compare(get_indicator_item_at(1).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
179− compare(get_indicator_item_at(2).opacity, 1.0, "Current indicator should not change in response to panel progress");
180− compare(get_indicator_item_at(3).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
181− compare(get_indicator_item_at(4).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
182− }
183− }
184−
185− UT.UnityTestCase {
186− name: "IndicatorRow_Dimmed"
187− when: windowShown
188−
189− function get_indicator_item_at(index) {
190− return findChild(indicatorRow, "rowRepeater").itemAt(index);
191− }
192−
193− function test_intial_state() {
194− init_test();
195−
196− indicatorRow.state = "initial";
197− indicatorRow.setCurrentItem(0);
198−
199− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
200− compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
201− compare(get_indicator_item_at(2).dimmed, false, "Other indicators should not dim when in initial state");
202− compare(get_indicator_item_at(3).dimmed, false, "Other indicators should not dim when in initial state");
203− compare(get_indicator_item_at(4).dimmed, false, "Other indicators should not dim when in initial state");
204− }
205−
206− function test_hint_state() {
207− init_test();
208−
209− indicatorRow.state = "hint";
210− indicatorRow.setCurrentItem(0);
211−
212− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
213− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
214− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
215− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in hint state");
216− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in hint state");
217− }
218−
219− function test_revealed_state() {
220− init_test();
221−
222− indicatorRow.state = "reveal";
223− indicatorRow.setCurrentItem(0);
224−
225− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
226− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
227− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in reveal state");
228− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in reveal state");
229− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in reveal state");
230− }
231−
232− function test_commit_state() {
233− init_test();
234−
235− indicatorRow.state = "commit";
236− indicatorRow.setCurrentItem(0);
237−
238− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
239− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
240− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in commit state");
241− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in commit state");
242− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in commit state");
243− }
244−
245− function test_locked_state() {
246− init_test();
147+ indicatorRow.unitProgress = data.progress;
148+ indicatorRow.setCurrentItemIndex(data.index);
247149
248− indicatorRow.state = "locked";
249− indicatorRow.setCurrentItem(0);
150+ compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
250151
251− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
252− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
253− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
254− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in locked state");
255− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");
152+ for (var i = 0; i < indicatorRow.row.count; i++) {
153+ compare(get_indicator_item_at(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
154+ }
256155 }
257156 }
258157}