From 383465e908c880c00546dc182424b5de17b63de6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 14 Apr 2015 14:38:07 +0200 Subject: Stabilize tst_qquickimage::noLoading The test loads an image from a remote source and it has a QSignalSpy installed for the progressChanged(qreal) signal on the QQuickImage. The test counts the number of times the signal is emitted and expects it to hit an exact value. That seems wrong when loading an image over the network, as we have no control over in what pieces the data arrives on our end. And as it turns out, the test occasionally fails in the CI system, which is also reproducible. To stabilize the test, we now expect at least two emissions of the signal when loading from the network (0% and 100%) but there may be more (0% 10% 80% 100% for example). In addition the reload case is simplified by resetting the spy and verifying that progressChanged was not emitted at all. Change-Id: Ib2e660651d40b92eff889ebe3baabb74d6e00fb4 Reviewed-by: Liang Qi Reviewed-by: Albert Astals Cid Reviewed-by: Gunnar Sletta --- tests/auto/quick/qquickimage/tst_qquickimage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/auto/quick/qquickimage/tst_qquickimage.cpp') diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 69c39b41d2..b8c0f6a22a 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -555,16 +555,17 @@ void tst_qquickimage::noLoading() QTRY_VERIFY(obj->status() == QQuickImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 2); - QTRY_COMPARE(progressSpy.count(), 2); + QTRY_VERIFY(progressSpy.count() >= 2); QTRY_COMPARE(statusSpy.count(), 3); // Loading remote file again - should not go through 'Loading' state. + progressSpy.clear(); ctxt->setContextProperty("srcImage", testFileUrl("green.png")); ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); QTRY_VERIFY(obj->status() == QQuickImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 4); - QTRY_COMPARE(progressSpy.count(), 2); + QTRY_COMPARE(progressSpy.count(), 0); QTRY_COMPARE(statusSpy.count(), 5); delete obj; -- cgit v1.2.3