diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-11-24 16:45:44 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-11-25 12:53:30 +0000 |
commit | 3fadff6e01232f70492a05b1fb779968d9662462 (patch) | |
tree | f86b2cd05b712e1363f87a36345a60f5cddcaded /tests | |
parent | e77b6dc6ea801c720f241342246a57d237850e3f (diff) | |
download | qtlocation-3fadff6e01232f70492a05b1fb779968d9662462.tar.gz |
Fix tile fetcher from test plugin.
Requesting tiles immediately with test plugin
was not implemented, what's more the current
delayed implementation was keeping pointer only
to last requested tile, which on slow machines
ended up on "downloading" only one tile (last one)
This change is required to fix the CI qtlocation
flaky tests.
Change-Id: I107701692a70b45401e7219ad7ee0f4a372efb04
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/geotestplugin/qgeotilefetcher_test.h | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h index 4d0ff750..18fe8650 100644 --- a/tests/auto/geotestplugin/qgeotilefetcher_test.h +++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h @@ -68,23 +68,21 @@ Q_SIGNALS: class QGeoTileFetcherTest: public QGeoTileFetcher { -Q_OBJECT + Q_OBJECT public: QGeoTileFetcherTest(QObject *parent = 0) - : QGeoTileFetcher(parent), finishRequestImmediately_(false), mappingReply_(0), - errorCode_(QGeoTiledMapReply::NoError) + : QGeoTileFetcher(parent), finishRequestImmediately_(false), errorCode_(QGeoTiledMapReply::NoError) { } bool init() { - return true; } QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec) { - mappingReply_ = new TiledMapReplyTest(spec, this); + TiledMapReplyTest* mappingReply = new TiledMapReplyTest(spec, this); QImage im(256, 256, QImage::Format_RGB888); im.fill(QColor("lightgray")); @@ -113,12 +111,19 @@ public: buffer.open(QIODevice::WriteOnly); pm.save(&buffer, "PNG"); - mappingReply_->callSetMapImageData(bytes); - mappingReply_->callSetMapImageFormat("png"); + mappingReply->callSetMapImageData(bytes); + mappingReply->callSetMapImageFormat("png"); - timer_.start(500, this); + if (finishRequestImmediately_) { + updateRequest(mappingReply); + return mappingReply; + } else { + if (m_queue.isEmpty()) + timer_.start(500, this); + m_queue.append(mappingReply); + } - return mappingReply_; + return mappingReply; } void setParams(const QVariantMap ¶meters) @@ -141,31 +146,35 @@ public Q_SLOTS: } protected: - void timerEvent(QTimerEvent *event) - { - if (event->timerId() != timer_.timerId()) { - QGeoTileFetcher::timerEvent(event); - return; - } - - Q_ASSERT(mappingReply_); - timer_.stop(); - if (errorCode_) { - mappingReply_->callSetError(errorCode_, errorString_); - emit tileError(mappingReply_->tileSpec(), errorString_); - } else { - mappingReply_->callSetError(QGeoTiledMapReply::NoError, "no error"); - mappingReply_->callSetFinished(true); - } - } + void updateRequest(TiledMapReplyTest* mappingReply) + { + if (errorCode_) { + mappingReply->callSetError(errorCode_, errorString_); + emit tileError(mappingReply->tileSpec(), errorString_); + } else { + mappingReply->callSetError(QGeoTiledMapReply::NoError, "no error"); + mappingReply->callSetFinished(true); + } + } + + void timerEvent(QTimerEvent *event) + { + if (event->timerId() != timer_.timerId()) { + QGeoTileFetcher::timerEvent(event); + return; + } + updateRequest(m_queue.takeFirst()); + if (m_queue.isEmpty()) + timer_.stop(); + } private: bool finishRequestImmediately_; - TiledMapReplyTest* mappingReply_; QBasicTimer timer_; QGeoTiledMapReply::Error errorCode_; QString errorString_; QSize tileSize_; + QList<TiledMapReplyTest*> m_queue; }; #endif |