~zsombi/ubuntu-ui-toolkit/platform_menu

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_components/tst_scrollbar.qml

  • Committer: Christian Dywan
  • Date: 2015-12-18 15:28:33 UTC
  • mfrom: (1783 staging)
  • mto: This revision was merged to the branch mainline in revision 1787.
  • Revision ID: christian.dywan@canonical.com-20151218152833-qk8et50txa2cdhv3
MergeĀ lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
                Rectangle {
47
47
                    id: content
48
48
                    width: units.gu(40)
49
 
                    height: units.gu(50)
 
49
                    //make this much taller than the flickable to avoid timing issues when
 
50
                    //detecting if the flickable is flicking in the tests
 
51
                    height: units.gu(200)
50
52
                    color: "blue"
51
53
                }
52
54
            }
60
62
    SignalSpy {
61
63
        id: signalSpy
62
64
    }
 
65
    SignalSpy {
 
66
        id: anotherSignalSpy
 
67
    }
63
68
 
64
69
    Flickable {
65
70
        anchors.fill: parent
126
131
        }
127
132
        function setupSignalSpy(spy, target, signalName) {
128
133
            spy.clear()
 
134
            //reset signalName otherwise it will look for the old signalName in the new target
 
135
            spy.signalName = ""
129
136
            spy.target = target
130
137
            spy.signalName = signalName
131
138
        }
176
183
                    scrollbar_trailingAlign_anchors.flickableItem.top, "top anchor")
177
184
        }
178
185
 
179
 
        function test_indicatorWhileFlicking() {
 
186
        function test_indicatorStyleWhileFlicking_shortContent() {
180
187
            var freshTestItem = getFreshFlickable()
181
188
            if (!freshTestItem) return
182
189
 
183
190
            var flickable = freshTestItem.flickable
184
191
            var scrollbar = freshTestItem.scrollbar
185
192
 
186
 
            setupSignalSpy(signalSpy, flickable, "movementEnded")
187
 
 
188
 
            flick(flickable, 1, 2, units.gu(2), units.gu(3))
189
 
            compare(flickable.moving, true, "not moving")
190
 
            compare(scrollbar.__styleInstance.state, "indicator", "wrong style while flicking")
191
 
 
192
 
            signalSpy.wait()
193
 
            compare(signalSpy.count, 1, "flick not completed")
194
 
 
195
 
            compare(scrollbar.__styleInstance.state, "hidden", "wrong style while flicking short item")
 
193
            compare(scrollbar.__styleInstance.veryLongContentItem, false, "Scrollable item should be short.")
 
194
 
 
195
            setupSignalSpy(signalSpy, flickable, "movingChanged")
 
196
 
 
197
            flick(flickable, 1, 2, units.gu(2), -units.gu(10))
 
198
 
 
199
            signalSpy.wait()
 
200
            compare(signalSpy.count, 1, "No movingChanged signal after simulating a flick.")
 
201
            compare(flickable.moving, true, "Flickable not moving after simulating a flick.")
 
202
            compare(scrollbar.__styleInstance.state, "indicator", "Wrong style while flicking.")
 
203
 
 
204
            //we don't set it up before because the hinting feature already changes the style to thumb
 
205
            //at the beginning
 
206
            setupSignalSpy(anotherSignalSpy, scrollbar.__styleInstance, "stateChanged")
 
207
 
 
208
            //make sure the flickable stops
 
209
            mousePress(flickable, 0, 0)
 
210
            mouseMove(flickable, 0, 0)
 
211
            mouseRelease(flickable, 0, 0)
 
212
 
 
213
            signalSpy.wait()
 
214
            compare(flickable.moving, false, "Flickable still moving after simulating mouse click.")
 
215
            compare(signalSpy.count, 2, "No movingChanged signal after Flickable stopped moving.")
 
216
 
 
217
            anotherSignalSpy.wait()
 
218
            compare(anotherSignalSpy.count, 1, "State unchanged after Flickable stopped moving.")
 
219
            compare(scrollbar.__styleInstance.state, "hidden", "Wrong style after the item stopped moving.")
 
220
 
196
221
            freshTestItem.destroy()
197
222
        }
198
223
 
199
 
        function test_thumbStyleVeryLongContent() {
 
224
        function test_thumbStyleWhileFlicking_veryLongContent() {
200
225
            var freshTestItem = getFreshFlickable()
201
226
            if (!freshTestItem) return
202
227
 
203
228
            var flickable = freshTestItem.flickable
204
229
            var scrollbar = freshTestItem.scrollbar
205
230
 
 
231
            setupSignalSpy(signalSpy, scrollbar.__styleInstance, "veryLongContentItemChanged")
206
232
            setVeryLongContentItem(flickable)
207
 
            compare(scrollbar.__styleInstance.veryLongContentItem, true, "very long content item not detected")
208
 
 
209
 
            setupSignalSpy(signalSpy, flickable, "movementEnded")
210
 
 
211
 
            flick(flickable, 1, 2, units.gu(2), units.gu(3))
212
 
            compare(flickable.moving, true, "not moving")
213
 
            compare(scrollbar.__styleInstance.state, "thumb", "wrong style while flicking a very long item")
214
 
 
215
 
            signalSpy.wait()
216
 
            compare(signalSpy.count, 1, "flick not completed")
217
 
 
218
 
            compare(scrollbar.__styleInstance.state, "hidden", "wrong style while flicking a very long item")
 
233
            signalSpy.wait()
 
234
 
 
235
            compare(scrollbar.__styleInstance.veryLongContentItem, true, "Very long content item not detected")
 
236
 
 
237
            setupSignalSpy(signalSpy, flickable, "movingChanged")
 
238
            flick(flickable, 1, 2, units.gu(2), -units.gu(10))
 
239
 
 
240
            signalSpy.wait()
 
241
            compare(signalSpy.count, 1, "No movingChanged signal after simulating a flick.")
 
242
            compare(flickable.moving, true, "Flickable not moving after simulating a flick.")
 
243
            compare(scrollbar.__styleInstance.state, "thumb", "Wrong style while flicking a very long item")
 
244
 
 
245
            //we don't set it up before because the hinting feature already changes the style to thumb
 
246
            //at the beginning
 
247
            setupSignalSpy(anotherSignalSpy, scrollbar.__styleInstance, "stateChanged")
 
248
 
 
249
            //make sure the flickable stops
 
250
            mousePress(flickable, 0, 0)
 
251
            mouseMove(flickable, 0, 0)
 
252
            mouseRelease(flickable, 0, 0)
 
253
 
 
254
            signalSpy.wait()
 
255
            compare(flickable.moving, false, "Flickable still moving after simulating mouse click.")
 
256
            compare(signalSpy.count, 2, "No movingChanged signal after Flickable stopped moving.")
 
257
 
 
258
            anotherSignalSpy.wait()
 
259
            compare(anotherSignalSpy.count, 1, "State unchanged after Flickable stopped moving.")
 
260
            compare(scrollbar.__styleInstance.state, "hidden", "Wrong style after a the item stopped moving.")
219
261
            freshTestItem.destroy()
220
262
        }
221
263
    }