@@ -33,7 +33,7 @@ Item {
33 function init_test()
33 function init_test()
35 indicatorRow.state = "initial";
35 indicatorRow.state = "initial";
36− indicatorRow.currentItem = null;
36+ indicatorRow.setCurrentItemIndex(-1);
37 indicatorRow.unitProgress = 0.0;
37 indicatorRow.unitProgress = 0.0;
@@ -60,199 +60,98 @@ Item {
60 name: "IndicatorRow"
60 name: "IndicatorRow"
61 when: windowShown
61 when: windowShown
63+ function get_indicator_item_at(index) {
64+ return findChild(indicatorRow.row, "item" + index);
63 function test_set_current_item() {
67 function test_set_current_item() {
64 init_test();
68 init_test();
65− indicatorRow.setCurrentItem(0);
69+ indicatorRow.setCurrentItemIndex(0);
66 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
70 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
68− indicatorRow.setCurrentItem(1);
72+ indicatorRow.setCurrentItemIndex(1);
69 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
73 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
71− indicatorRow.setCurrentItem(2);
75+ indicatorRow.setCurrentItemIndex(2);
72 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
76 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
76− UT.UnityTestCase {
79+ function test_highlight_data() {
77− name: "IndicatorRow_IconPosition"
80+ return [
78− when: windowShown
81+ { index: 0, progress: 0.0, current: false, other: false },
79−
82+ { index: 0, progress: 0.1, current: true, other: false },
80− function get_indicator_item_at(index) {
83+ { index: 0, progress: 0.5, current: true, other: false },
81− return findChild(indicatorRow, "rowRepeater").itemAt(index);
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 }
84− function test_current_item_commit() {
92+ function test_highlight(data) {
85 init_test();
93 init_test();
87− indicatorRow.setCurrentItem(2);
95+ indicatorRow.unitProgress = data.progress;
88− indicatorRow.state = "commit";
96+ indicatorRow.setCurrentItemIndex(data.index);
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);
98− name: "IndicatorRow_Highlight"
101− function get_indicator_item_at(index) {
102− return findChild(indicatorRow, "rowRepeater").itemAt(index);
105− function test_intial_state() {
108− indicatorRow.state = "initial";
98+ compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
109− indicatorRow.setCurrentItem(0);
111− compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
100+ for (var i = 0; i < indicatorRow.row.count; i++) {
112− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
101+ compare(get_indicator_item_at(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
113− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in initial state");
102+ }
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");
118− function test_hint_state() {
105+ function test_opacity_data() {
119− init_test();
106+ return [
120−
107+ { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
121− indicatorRow.state = "hint";
108+ { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
122− indicatorRow.setCurrentItem(0);
109+ { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
123−
110+ { index: 0, progress: 1.0, current: 1.0, other: 0.0 },
124− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
111+ { index: 2, progress: 0.0, current: 1.0, other: 1.0 },
125− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
112+ { index: 2, progress: 0.1, current: 1.0, other: 0.9 },
126− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in hint state");
113+ { index: 2, progress: 0.5, current: 1.0, other: 0.5 },
127− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in hint state");
114+ { index: 2, progress: 1.0, current: 1.0, other: 0.0 }
128− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in hint state");
115+ ];
131− function test_revealed_state() {
118+ function test_opacity(data) {
132 init_test();
119 init_test();
134− indicatorRow.state = "reveal";
121+ indicatorRow.unitProgress = data.progress;
135− indicatorRow.setCurrentItem(0);
122+ indicatorRow.setCurrentItemIndex(data.index);
137− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
124+ compare(indicatorRow.currentItem.opacity, data.current, "Indicator opacity did not match for current item");
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");
144− function test_commit_state() {
126+ for (var i = 0; i < indicatorRow.row.count; i++) {
145− init_test();
127+ tryCompare(get_indicator_item_at(i), "opacity", i === data.index ? data.current: data.other);
147− indicatorRow.state = "commit";
148− indicatorRow.setCurrentItem(0);
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");
157− function test_locked_state() {
131+ function test_dimmed_data() {
158− init_test();
132+ return [
159−
133+ { index: 0, progress: 0.0, current: false, other: false },
160− indicatorRow.state = "locked";
134+ { index: 0, progress: 0.1, current: false, other: true },
161− indicatorRow.setCurrentItem(0);
135+ { index: 0, progress: 0.5, current: false, other: true },
162−
136+ { index: 0, progress: 1.0, current: false, other: true },
163− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
137+ { index: 2, progress: 0.0, current: false, other: false },
164− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
138+ { index: 2, progress: 0.1, current: false, other: true },
165− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in locked state");
139+ { index: 2, progress: 0.5, current: false, other: true },
166− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in locked state");
140+ { index: 2, progress: 1.0, current: false, other: true }
167− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in locked state");
141+ ];
170− function test_opacity() {
144+ function test_dimmed(data) {
171 init_test();
145 init_test();
173− indicatorRow.state = "reveal";
147+ indicatorRow.unitProgress = data.progress;
174− indicatorRow.unitProgress = 0.5;
148+ indicatorRow.setCurrentItemIndex(data.index);
175− indicatorRow.setCurrentItem(2);
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");
186− name: "IndicatorRow_Dimmed"
189− function get_indicator_item_at(index) {
190− return findChild(indicatorRow, "rowRepeater").itemAt(index);
193− function test_intial_state() {
196− indicatorRow.state = "initial";
197− indicatorRow.setCurrentItem(0);
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");
206− function test_hint_state() {
209− indicatorRow.state = "hint";
210− indicatorRow.setCurrentItem(0);
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");
219− function test_revealed_state() {
222− indicatorRow.state = "reveal";
223− indicatorRow.setCurrentItem(0);
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");
232− function test_commit_state() {
235− indicatorRow.state = "commit";
236− indicatorRow.setCurrentItem(0);
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");
245− function test_locked_state() {
248− indicatorRow.state = "locked";
150+ compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
249− indicatorRow.setCurrentItem(0);
251− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
152+ for (var i = 0; i < indicatorRow.row.count; i++) {
252− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
153+ compare(get_indicator_item_at(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
253− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
154+ }
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");