@@ -35,7 +35,7 @@ Item {
35 indicatorModel.load();
35 indicatorModel.load();
37 indicatorRow.state = "initial";
37 indicatorRow.state = "initial";
38− indicatorRow.currentItem = null;
38+ indicatorRow.setCurrentItemIndex(-1);
39 indicatorRow.unitProgress = 0.0;
39 indicatorRow.unitProgress = 0.0;
@@ -51,6 +51,8 @@ Item {
53 indicatorsModel: indicatorModel
53 indicatorsModel: indicatorModel
55+ Component.onCompleted: indicatorModel.load()
56 Indicators.IndicatorsModel {
58 Indicators.IndicatorsModel {
@@ -61,199 +63,98 @@ Item {
61 name: "IndicatorRow"
63 name: "IndicatorRow"
62 when: windowShown
64 when: windowShown
66+ function get_indicator_item(index) {
67+ return findChild(indicatorRow.row, "item" + index);
64 function test_set_current_item() {
70 function test_set_current_item() {
65 init_test();
71 init_test();
66− indicatorRow.setCurrentItem(0);
72+ indicatorRow.setCurrentItemIndex(0);
67 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
73 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
69− indicatorRow.setCurrentItem(1);
75+ indicatorRow.setCurrentItemIndex(1);
70 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
76 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
72− indicatorRow.setCurrentItem(2);
78+ indicatorRow.setCurrentItemIndex(2);
73 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
79 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
78− name: "IndicatorRow_IconPosition"
81− function get_indicator_item_at(index) {
82− return findChild(indicatorRow, "rowRepeater").itemAt(index);
85− function test_current_item_commit() {
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);
99− name: "IndicatorRow_Highlight"
102− function get_indicator_item_at(index) {
103− return findChild(indicatorRow, "rowRepeater").itemAt(index);
106− function test_intial_state() {
109− indicatorRow.state = "initial";
110− indicatorRow.setCurrentItem(0);
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");
119− function test_hint_state() {
122− indicatorRow.state = "hint";
123− indicatorRow.setCurrentItem(0);
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");
132− function test_revealed_state() {
135− indicatorRow.state = "reveal";
136− indicatorRow.setCurrentItem(0);
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");
145− function test_commit_state() {
148− indicatorRow.state = "commit";
149− indicatorRow.setCurrentItem(0);
151− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
82+ function test_highlight_data() {
152− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
83+ return [
153− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
84+ { index: 0, progress: 0.0, current: false, other: false },
154− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
85+ { index: 0, progress: 0.1, current: true, other: false },
155− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
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 }
158− function test_locked_state() {
95+ function test_highlight(data) {
159 init_test();
96 init_test();
161− indicatorRow.state = "locked";
98+ indicatorRow.unitProgress = data.progress;
162− indicatorRow.setCurrentItem(0);
99+ indicatorRow.setCurrentItemIndex(data.index);
164− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
101+ compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
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");
171− function test_opacity() {
103+ for (var i = 0; i < indicatorRow.row.count; i++) {
172− init_test();
104+ compare(get_indicator_item(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
174− indicatorRow.state = "reveal";
175− indicatorRow.unitProgress = 0.5;
176− indicatorRow.setCurrentItem(2);
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");
186− UT.UnityTestCase {
108+ function test_opacity_data() {
187− name: "IndicatorRow_Dimmed"
109+ return [
188− when: windowShown
110+ { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
189−
111+ { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
190− function get_indicator_item_at(index) {
112+ { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
191− return findChild(indicatorRow, "rowRepeater").itemAt(index);
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 }
194− function test_intial_state() {
121+ function test_opacity(data) {
195 init_test();
122 init_test();
197− indicatorRow.state = "initial";
124+ indicatorRow.unitProgress = data.progress;
198− indicatorRow.setCurrentItem(0);
125+ indicatorRow.setCurrentItemIndex(data.index);
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");
207− function test_hint_state() {
210− indicatorRow.state = "hint";
127+ tryCompare(indicatorRow.currentItem, "opacity", data.current);
211− indicatorRow.setCurrentItem(0);
213− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
129+ for (var i = 0; i < indicatorRow.row.count; i++) {
214− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
130+ tryCompare(get_indicator_item(i), "opacity", i === data.index ? data.current: data.other);
215− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
131+ }
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");
220− function test_revealed_state() {
134+ function test_dimmed_data() {
221− init_test();
135+ return [
222−
136+ { index: 0, progress: 0.0, current: false, other: false },
223− indicatorRow.state = "reveal";
137+ { index: 0, progress: 0.1, current: false, other: true },
224− indicatorRow.setCurrentItem(0);
138+ { index: 0, progress: 0.5, current: false, other: true },
225−
139+ { index: 0, progress: 1.0, current: false, other: true },
226− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
140+ { index: 2, progress: 0.0, current: false, other: false },
227− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
141+ { index: 2, progress: 0.1, current: false, other: true },
228− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in reveal state");
142+ { index: 2, progress: 0.5, current: false, other: true },
229− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in reveal state");
143+ { index: 2, progress: 1.0, current: false, other: true }
230− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in reveal state");
144+ ];
233− function test_commit_state() {
147+ function test_dimmed(data) {
234 init_test();
148 init_test();
236− indicatorRow.state = "commit";
150+ indicatorRow.unitProgress = data.progress;
237− indicatorRow.setCurrentItem(0);
151+ indicatorRow.setCurrentItemIndex(data.index);
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");
246− function test_locked_state() {
249− indicatorRow.state = "locked";
153+ compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
250− indicatorRow.setCurrentItem(0);
252− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
155+ for (var i = 0; i < indicatorRow.row.count; i++) {
253− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
156+ compare(get_indicator_item(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
254− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
157+ }
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");