103
101
// tests changing the lateral position of the revealer activates the correct indicator items.
105
103
var indicatorRow = findChild(indicators, "indicatorRow")
106
verify(indicatorRow !== null);
107
var indicatorRowItems = findChild(indicatorRow, "indicatorRowItems");
108
verify(indicatorRowItems !== null);
104
var rowRepeater = findChild(indicators, "rowRepeater")
110
for (var i = 0; i < indicatorRowItems.count; i++) {
111
var indicatorItem = findChild(indicatorRowItems, "item" + i);
106
for (var i = 0; i < rowRepeater.count; i++) {
107
var indicatorItem = rowRepeater.itemAt(i);
113
109
if (!indicatorItem.visible)
116
112
var indicatorPosition = indicators.mapFromItem(indicatorItem,
117
indicatorItem.width/2, indicatorItem.height/2);
113
indicatorItem.width/2, indicatorItem.height/2)
119
115
touchFlick(indicators,
120
116
indicatorPosition.x, indicatorPosition.y,
121
117
indicatorPosition.x, indicators.openedHeight * 0.4,
122
true /* beginTouch */, false /* endTouch */);
118
true /* beginTouch */, false /* endTouch */)
124
120
compare(indicatorRow.currentItem, indicatorItem,
125
121
"Incorrect item activated at position " + i);
143
139
function test_progress_changes_state_to_not_initial() {
144
140
indicators.height = indicators.openedHeight / 2
145
141
compare(indicators.state!="initial", true,
146
"Indicators should not be in initial state when partially opened.");
142
"Indicators should not be in initial state when partially opened.")
149
145
function test_progress_changes_state_to_locked() {
150
146
indicators.height = indicators.openedHeight - indicators.panelHeight
151
compare(indicators.state, "locked", "Indicators should be locked when fully opened.");
147
compare(indicators.state, "locked", "Indicators should be locked when fully opened.")
154
150
function test_partially_open() {
155
151
indicators.height = indicators.openedHeight / 2
156
152
compare(indicators.partiallyOpened, true,
157
"Indicator should show as partially opened when height is half of openedHeight");
153
"Indicator should show as partially opened when height is half of openedHeight")
158
154
compare(indicators.fullyOpened, false,
159
"Indicator should not show as fully opened when height is half of openedHeight");
155
"Indicator should not show as fully opened when height is half of openedHeight")
162
158
function test_fully_open() {
165
161
compare(indicators.fullyOpened, true);
168
function init_invisible_indicator(identifier) {
169
tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
170
var item = findChild(indicators, identifier+"-delegate");
172
item.enabled = false;
175
164
function test_row_visible_menuContent_visible_data() { return [
176
{tag: "first", visible: [false, true, true, true, true] },
177
{tag: "adjacent", visible: [true, false, false, true, true] },
178
{tag: "bounds", visible: [false, true, true, true, false] },
179
{tag: "disjoint", visible: [true, false, true, false, true] },
180
{tag: "last", visible: [true, true, true, true, false] }];
165
{tag: "visible", index: 0, name: "indicator-fake1", visible: true },
166
{tag: "invisible", index: 1, name: "indicator-fake2", visible: false }]
183
169
function test_row_visible_menuContent_visible(data) {
186
var indicatorTabs = findChild(indicators, "tabs");
187
var indicatorRowItems = findChild(indicators, "indicatorRowItems");
189
var count = data.visible.length
190
for (var i = 0; i< data.visible.length; i++) {
191
if (data.visible[i] === false) {
192
init_invisible_indicator("indicator-fake" + (i + 1));
197
tryCompare(indicatorRowItems, "count", count);
199
for (i = 0; i < data.visible.length; i++) {
200
var widgetName = "indicator-fake" + (i + 1 + "-widget");
201
var pageName = "indicator-fake" + (i + 1 + "-page");
204
tryCompareFunction(function() { return findChild(indicatorRowItems, widgetName) !== null }, data.visible[i]);
207
tryCompareFunction(function() { return findChild(indicatorTabs, pageName) !== null }, data.visible[i]);
211
function test_indicator_visible_correct_tabs_data() { return [
212
{tag: "current-first", currentIndex: 0, visible: [false, true, true, true, true], expectedIndex: 0, expectedTab: "indicator-fake2" },
213
{tag: "current-last", currentIndex: 4, visible: [true, true, true, true, false], expectedIndex: 3, expectedTab: "indicator-fake4" },
214
{tag: "after", currentIndex: 0, visible: [true, false, true, true, true], expectedIndex: 0, expectedTab: "indicator-fake1" },
215
{tag: "before", currentIndex: 1, visible: [false, true, true, true, true], expectedIndex: 1, expectedTab: "indicator-fake2" }];
218
function test_indicator_visible_correct_tabs(data) {
219
var indicatorTabs = findChild(indicators, "tabs");
220
var indicatorRow = findChild(indicators, "indicatorRow");
223
indicatorRow.setCurrentItemIndex(data.currentIndex);
224
tryCompare(indicators, "fullyOpened", true);
226
for (var i = 0; i< data.visible.length; i++) {
227
if (data.visible[i] === false) {
228
init_invisible_indicator("indicator-fake" + (i + 1));
232
// check for current selected item
233
tryCompare(indicatorRow, "currentItemIndex", data.expectedIndex);
235
// check for current selected tab
236
tryCompareFunction(function() { return findChild(indicatorTabs, data.expectedTab) === indicatorTabs.selectedTab }, true);
170
var indicatorTabs = findChild(indicators, "tabs");
171
var rowRepeater = findChild(indicators, "rowRepeater");
173
var indicatorItem = rowRepeater.itemAt(data.index);
174
tryCompareFunction(function() { return indicatorItem.width > 0}, true);
175
tryCompare(indicatorItem, "visible", data.visible);
177
var indicatorTab = findChild(indicatorTabs, data.name)
178
tryCompareFunction(function() { return indicatorTab !== undefined }, data.visible);