2
* Copyright 2013 Canonical Ltd.
2
* Copyright 2013-2015 Canonical Ltd.
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
311
// perform a drag in the given direction until the given condition is true
312
// The condition is a function to be evaluated after every step
313
function touchDragUntil(item, startX, startY, stepX, stepY, condition) {
315
var root = fetchRootItem(item);
316
var pos = item.mapToItem(root, startX, startY);
318
// convert step to scene coords
320
var stepStart = item.mapToItem(root, 0, 0);
321
var stepEnd = item.mapToItem(root, stepX, stepY);
323
stepX = stepEnd.x - stepStart.x;
324
stepY = stepEnd.y - stepStart.y;
326
var event = touchEvent(item)
327
event.press(0 /* touchId */, pos.x, pos.y)
330
// we have to stop at some point
334
while (!condition() && stepsDone < maxSteps) {
336
fakeDateTime.currentTimeMs += 25;
341
event = touchEvent(item);
342
event.move(0 /* touchId */, pos.x, pos.y);
348
event = touchEvent(item)
349
event.release(0 /* touchId */, pos.x, pos.y)
311
353
function touchPinch(item, x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End) {
312
354
// Make sure the item is rendered
313
355
waitForRendering(item);
419
461
return qtest_results.waitForRendering(item, timeout);
465
Wait until any transition animation has finished for the given StateGroup or Item
467
function waitUntilTransitionsEnd(stateGroup) {
468
var transitions = stateGroup.transitions;
469
for (var i = 0; i < transitions.length; ++i) {
470
var transition = transitions[i];
471
tryCompare(transition, "running", false, 2000);