on xenial help sign in
Use timeStep as delay time

Passing iterations / speed didn't make much sense since that parameter is a delay in milliseconds and the default parameters would give a value of 5 / units.gu(10) that is smaller than 1 millisecond. Qt 5.7 calculation for velocity was very unhappy if we moved things so fast in less than 1ms and ignored the movements, so this also makes tests pass on Qt 5.7 (LP: #1642919) Approved by: Josh Arenson, Unity8 CI Bot

commit2e631ceed5655849509c4f0dd7682d54dd279e85 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 7 Dec 2016, 13:42 (10 years ago) parent8cbeffd5612925
3 files changed+11−10
tests/qmltests/Dash/tst_Dash.qml+4−3 tests/qmltests/Launcher/tst_Launcher.qml+3−3 tests/utils/modules/Unity/Test/UnityTestCase.qml+4−4
tests/qmltests/Dash/tst_Dash.qml+4−3
@@ -310,8 +310,9 @@ Item {
310310 var stopX = units.gu(1)
311311 var stopY = startY;
312312 waitForRendering(dashContentList)
313− mouseFlick(dash, startX, startY, stopX, stopY);
314− mouseFlick(dash, startX, startY, stopX, stopY);
313+ mouseFlick(dash, startX, startY, stopX, stopY, true, true, units.gu(200));
314+ compare(dashContentList.currentIndex, 1, "Could not flick to scope id 1");
315+ mouseFlick(dash, startX, startY, stopX, stopY, units.gu(200));
315316 compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
316317 var dashCommunicatorService = findInvisibleChild(dash, "dashCommunicatorService");
317318 dashCommunicatorService.mockSetCurrentScope(0, true, false);
@@ -411,7 +412,7 @@ Item {
411412 compare(dashContentList.currentItem.scopeId, "clickscope");
412413
413414 // Move to second scope
414− mouseFlick(dash, dash.width / 2, units.gu(2), dash.width / 5, units.gu(2));
415+ mouseFlick(dash, dash.width / 2, units.gu(2), dash.width / 5, units.gu(2), true, true, units.gu(20));
415416 tryCompare(dashContentList, "currentIndex", 1);
416417 compare(dashContentList.currentItem.scopeId, "MockScope1");
417418 }
tests/qmltests/Launcher/tst_Launcher.qml+3−3
@@ -824,7 +824,7 @@ Rectangle {
824824
825825 // Dragging a bit (> 1.5 gu)
826826 newMouseX -= units.gu(2)
827− mouseFlick(launcher, currentMouseX, currentMouseY, newMouseX, newMouseY, false, false, 100)
827+ mouseFlick(launcher, currentMouseX, currentMouseY, newMouseX, newMouseY, false, false)
828828 currentMouseX = newMouseX
829829
830830 // Other items need to expand and become 0.6 opaque
@@ -832,8 +832,8 @@ Rectangle {
832832 tryCompare(item0, "itemOpacity", 0.6)
833833
834834 // Dragging a bit more
835− newMouseY += initialItemHeight * 1.5
836− mouseFlick(launcher, currentMouseX, currentMouseY, newMouseX, newMouseY, false, false, 100)
835+ newMouseY += initialItemHeight * 1.25
836+ mouseFlick(launcher, currentMouseX, currentMouseY, newMouseX, newMouseY, false, false)
837837 currentMouseY = newMouseY
838838
839839 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
tests/utils/modules/Unity/Test/UnityTestCase.qml+4−4
@@ -163,9 +163,9 @@ TestCase {
163163 if (i === iterations - 1) {
164164 // Avoid any rounding errors by making the last move be at precisely
165165 // the point specified
166− mouseMove(item, toX, toY, iterations / speed)
166+ mouseMove(item, toX, toY, timeStep)
167167 } else {
168− mouseMove(item, x + (i + 1) * diffX, y + (i + 1) * diffY, iterations / speed)
168+ mouseMove(item, x + (i + 1) * diffX, y + (i + 1) * diffY, timeStep)
169169 }
170170 }
171171 if (releaseMouse) {
@@ -346,12 +346,12 @@ TestCase {
346346 if (i === iterations - 1) {
347347 // Avoid any rounding errors by making the last move be at precisely
348348 // the point specified
349− wait(iterations / speed)
349+ wait(timeStep)
350350 var event = touchEvent(item)
351351 event.move(0 /* touchId */, rootTo.x, rootTo.y)
352352 event.commit()
353353 } else {
354− wait(iterations / speed)
354+ wait(timeStep)
355355 var event = touchEvent(item)
356356 event.move(0 /* touchId */, rootFrom.x + (i + 1) * diffX, rootFrom.y + (i + 1) * diffY)
357357 event.commit()