~ubuntu-branches/ubuntu/trusty/unity8/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/qmltests/Panel/tst_Indicators.qml

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2014-02-03 16:56:47 UTC
  • mfrom: (1.1.64)
  • Revision ID: package-import@ubuntu.com-20140203165647-ik9w833cac4zu9da
Tags: 7.84+14.04.20140130.is.7.84+14.04.20131220-0ubuntu1
Reverting to last known good version, as after installing a click
application, it redirects you to the first click application everytime.
(LP: #1275832)

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        when: windowShown
84
84
 
85
85
        function init() {
86
 
            indicators.initialise();
87
 
 
88
86
            indicators.hide();
89
87
            tryCompare(indicators.hideAnimation, "running", false);
90
88
            tryCompare(indicators, "state", "initial");
103
101
            // tests changing the lateral position of the revealer activates the correct indicator items.
104
102
 
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")
109
105
 
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);
112
108
 
113
109
                if (!indicatorItem.visible)
114
110
                    continue;
115
111
 
116
112
                var indicatorPosition = indicators.mapFromItem(indicatorItem,
117
 
                        indicatorItem.width/2, indicatorItem.height/2);
 
113
                        indicatorItem.width/2, indicatorItem.height/2)
118
114
 
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 */)
123
119
 
124
120
                compare(indicatorRow.currentItem, indicatorItem,
125
121
                        "Incorrect item activated at position " + i);
127
123
                touchFlick(indicators,
128
124
                           indicatorPosition.x, indicators.openedHeight * 0.4,
129
125
                           indicatorPosition.x, indicatorPosition.y,
130
 
                           false /* beginTouch */, true /* endTouch */);
 
126
                           false /* beginTouch */, true /* endTouch */)
131
127
 
132
128
                // wait until fully closed
133
 
                tryCompare(indicators, "height", indicators.panelHeight);
 
129
                tryCompare(indicators, "height", indicators.panelHeight)
134
130
            }
135
131
        }
136
132
 
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.")
147
143
        }
148
144
 
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.")
152
148
        }
153
149
 
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")
160
156
        }
161
157
 
162
158
        function test_fully_open() {
165
161
            compare(indicators.fullyOpened, true);
166
162
        }
167
163
 
168
 
        function init_invisible_indicator(identifier) {
169
 
            tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
170
 
            var item = findChild(indicators, identifier+"-delegate");
171
 
 
172
 
            item.enabled = false;
173
 
        }
174
 
 
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 }]
181
167
        }
182
168
 
183
169
        function test_row_visible_menuContent_visible(data) {
184
 
            indicators.show();
185
 
 
186
 
            var indicatorTabs = findChild(indicators, "tabs");
187
 
            var indicatorRowItems = findChild(indicators, "indicatorRowItems");
188
 
 
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));
193
 
                    count--;
194
 
                }
195
 
            }
196
 
 
197
 
            tryCompare(indicatorRowItems, "count", count);
198
 
 
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");
202
 
 
203
 
                // check for item
204
 
                tryCompareFunction(function() { return findChild(indicatorRowItems, widgetName) !== null }, data.visible[i]);
205
 
 
206
 
                // check for tab
207
 
                tryCompareFunction(function() { return findChild(indicatorTabs, pageName) !== null }, data.visible[i]);
208
 
            }
209
 
        }
210
 
 
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" }];
216
 
        }
217
 
 
218
 
        function test_indicator_visible_correct_tabs(data) {
219
 
            var indicatorTabs = findChild(indicators, "tabs");
220
 
            var indicatorRow = findChild(indicators, "indicatorRow");
221
 
 
222
 
            indicators.show();
223
 
            indicatorRow.setCurrentItemIndex(data.currentIndex);
224
 
            tryCompare(indicators, "fullyOpened", true);
225
 
 
226
 
            for (var i = 0; i< data.visible.length; i++) {
227
 
                if (data.visible[i] === false) {
228
 
                    init_invisible_indicator("indicator-fake" + (i + 1));
229
 
                }
230
 
            }
231
 
 
232
 
            // check for current selected item
233
 
            tryCompare(indicatorRow, "currentItemIndex", data.expectedIndex);
234
 
 
235
 
            // check for current selected tab
236
 
            tryCompareFunction(function() { return findChild(indicatorTabs, data.expectedTab) === indicatorTabs.selectedTab }, true);
237
 
 
 
170
            var indicatorTabs = findChild(indicators, "tabs");
 
171
            var rowRepeater = findChild(indicators, "rowRepeater");
 
172
 
 
173
            var indicatorItem = rowRepeater.itemAt(data.index);
 
174
            tryCompareFunction(function() { return indicatorItem.width > 0}, true);
 
175
            tryCompare(indicatorItem, "visible", data.visible);
 
176
 
 
177
            var indicatorTab = findChild(indicatorTabs, data.name)
 
178
            tryCompareFunction(function() { return indicatorTab !== undefined }, data.visible);
238
179
        }
239
180
    }
240
181
}