void TestImageDelegate::fields() { QFETCH(QString, imagePath); Image image(imagePath); image.extraInfo().insert("SPECIAL", 1); sapi::ImageDelegate delegate(&image); QSignalSpy loadSpy(&image, SIGNAL(loaded())); QSignalSpy makeThumbnailSpy(&image, SIGNAL(thumbnailLoaded())); image.load(); QVERIFY(loadSpy.wait()); QCOMPARE(delegate.name(), image.name()); QCOMPARE(delegate.size(), image.size()); QCOMPARE(delegate.hash(), image.source()->hashStr()); QCOMPARE(delegate.extraInfo(), image.extraInfo()); QCOMPARE(delegate.isAnimation(), image.isAnimation()); QCOMPARE(delegate.frameCount(), image.frameCount()); QCOMPARE(delegate.durations(), image.durations()); for (int i = 0; i < delegate.frameCount(); ++i) { QCOMPARE(*(delegate.frames()[i]), *(image.frames()[i])); } if (makeThumbnailSpy.count() == 0) { QVERIFY(makeThumbnailSpy.wait()); } QCOMPARE(delegate.thumbnail(), image.thumbnail()); QVERIFY(!delegate.readRaw().isNull()); }
bool waitForLoadFailed(QQuickWebView* webView, int timeout) { QEventLoop loop; LoadSpy loadSpy(webView); QObject::connect(&loadSpy, SIGNAL(loadFailed()), &loop, SLOT(quit())); QTimer timer; QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); if (timeout > 0) { QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); timer.setSingleShot(true); timer.start(timeout); } loop.exec(); return timeoutSpy.isEmpty(); }