53
50
indicatorsModel: indicatorModel
55
Component.onCompleted: indicatorModel.load()
58
53
Indicators.IndicatorsModel {
55
Component.onCompleted: load()
63
59
name: "IndicatorRow"
66
function get_indicator_item(index) {
67
return findChild(indicatorRow.row, "item" + index);
70
62
function test_set_current_item() {
72
indicatorRow.setCurrentItemIndex(0);
64
indicatorRow.setCurrentItem(0);
73
65
compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
75
indicatorRow.setCurrentItemIndex(1);
67
indicatorRow.setCurrentItem(1);
76
68
compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
78
indicatorRow.setCurrentItemIndex(2);
70
indicatorRow.setCurrentItem(2);
79
71
compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
82
function test_highlight_data() {
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 }
95
function test_highlight(data) {
98
indicatorRow.unitProgress = data.progress;
99
indicatorRow.setCurrentItemIndex(data.index);
101
compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
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");
108
function test_opacity_data() {
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 }
121
function test_opacity(data) {
124
indicatorRow.unitProgress = data.progress;
125
indicatorRow.setCurrentItemIndex(data.index);
127
tryCompare(indicatorRow.currentItem, "opacity", data.current);
129
for (var i = 0; i < indicatorRow.row.count; i++) {
130
tryCompare(get_indicator_item(i), "opacity", i === data.index ? data.current: data.other);
134
function test_dimmed_data() {
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 }
147
function test_dimmed(data) {
150
indicatorRow.unitProgress = data.progress;
151
indicatorRow.setCurrentItemIndex(data.index);
153
compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
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");
76
name: "IndicatorRow_IconPosition"
79
function get_indicator_item_at(index) {
80
return findChild(indicatorRow, "rowRepeater").itemAt(index);
83
function test_current_item_commit() {
86
indicatorRow.setCurrentItem(1);
87
indicatorRow.state = "commit";
88
tryCompare(get_indicator_item_at(0), "opacity", 0.0);
89
tryCompare(get_indicator_item_at(1), "opacity", 1.0);
90
tryCompare(get_indicator_item_at(2), "opacity", 0.0);
91
tryCompare(get_indicator_item_at(3), "opacity", 0.0);
92
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";
109
indicatorRow.setCurrentItem(0);
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");
118
function test_hint_state() {
121
indicatorRow.state = "hint";
122
indicatorRow.setCurrentItem(0);
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");
131
function test_revealed_state() {
134
indicatorRow.state = "reveal";
135
indicatorRow.setCurrentItem(0);
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");
144
function test_commit_state() {
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() {
160
indicatorRow.state = "locked";
161
indicatorRow.setCurrentItem(0);
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");
172
name: "IndicatorRow_Dimmed"
175
function get_indicator_item_at(index) {
176
return findChild(indicatorRow, "rowRepeater").itemAt(index);
179
function test_intial_state() {
182
indicatorRow.state = "initial";
183
indicatorRow.setCurrentItem(0);
185
compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
186
compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
187
compare(get_indicator_item_at(2).dimmed, false, "Other indicators should not dim when in initial state");
188
compare(get_indicator_item_at(3).dimmed, false, "Other indicators should not dim when in initial state");
189
compare(get_indicator_item_at(4).dimmed, false, "Other indicators should not dim when in initial state");
192
function test_hint_state() {
195
indicatorRow.state = "hint";
196
indicatorRow.setCurrentItem(0);
198
compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
199
compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
200
compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
201
compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in hint state");
202
compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in hint state");
205
function test_revealed_state() {
208
indicatorRow.state = "reveal";
209
indicatorRow.setCurrentItem(0);
211
compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
212
compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
213
compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in reveal state");
214
compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in reveal state");
215
compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in reveal state");
218
function test_commit_state() {
221
indicatorRow.state = "commit";
222
indicatorRow.setCurrentItem(0);
224
compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
225
compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
226
compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in commit state");
227
compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in commit state");
228
compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in commit state");
231
function test_locked_state() {
234
indicatorRow.state = "locked";
235
indicatorRow.setCurrentItem(0);
237
compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
238
compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
239
compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
240
compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in locked state");
241
compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");