Changeset View
Changeset View
Standalone View
Standalone View
tests/auto/thumbnailprovidertest.cpp
Show All 28 Lines | |||||
29 | #include <qtest.h> | 29 | #include <qtest.h> | ||
30 | #include <QDebug> | 30 | #include <QDebug> | ||
31 | #include <KIO/CopyJob> | 31 | #include <KIO/CopyJob> | ||
32 | #include <KIO/DeleteJob> | 32 | #include <KIO/DeleteJob> | ||
33 | 33 | | |||
34 | // Local | 34 | // Local | ||
35 | #include "../lib/thumbnailprovider/thumbnailprovider.h" | 35 | #include "../lib/thumbnailprovider/thumbnailprovider.h" | ||
36 | #include "testutils.h" | 36 | #include "testutils.h" | ||
37 | #include "gwenviewconfig.h" | ||||
37 | 38 | | |||
38 | // libc | 39 | // libc | ||
39 | #include <errno.h> | 40 | #include <errno.h> | ||
40 | #include <string.h> | 41 | #include <string.h> | ||
41 | 42 | | |||
42 | using namespace Gwenview; | 43 | using namespace Gwenview; | ||
43 | 44 | | |||
44 | QTEST_MAIN(ThumbnailProviderTest) | 45 | QTEST_MAIN(ThumbnailProviderTest) | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | 203 | { | |||
207 | syncRun(&provider); | 208 | syncRun(&provider); | ||
208 | 209 | | |||
209 | QCOMPARE(spy.count(), 1); | 210 | QCOMPARE(spy.count(), 1); | ||
210 | expectedThumbnail = createColoredImage(128, 64, Qt::white); | 211 | expectedThumbnail = createColoredImage(128, 64, Qt::white); | ||
211 | thumbnailPix = qvariant_cast<QPixmap>(spy.at(0).at(1)); | 212 | thumbnailPix = qvariant_cast<QPixmap>(spy.at(0).at(1)); | ||
212 | QVERIFY(TestUtils::imageCompare(expectedThumbnail, thumbnailPix.toImage())); | 213 | QVERIFY(TestUtils::imageCompare(expectedThumbnail, thumbnailPix.toImage())); | ||
213 | } | 214 | } | ||
214 | 215 | | |||
215 | // Loading a large thumbnail should bring the red one | 216 | // Loading a large thumbnail should bring the red one, unless thumbnails are deleted on exit, | ||
217 | // which should bring the white one | ||||
216 | { | 218 | { | ||
217 | ThumbnailProvider provider; | 219 | ThumbnailProvider provider; | ||
218 | provider.setThumbnailGroup(ThumbnailGroup::Large); | 220 | provider.setThumbnailGroup(ThumbnailGroup::Large); | ||
219 | provider.appendItems(list); | 221 | provider.appendItems(list); | ||
220 | QSignalSpy spy(&provider, SIGNAL(thumbnailLoaded(KFileItem,QPixmap,QSize,qulonglong))); | 222 | QSignalSpy spy(&provider, SIGNAL(thumbnailLoaded(KFileItem,QPixmap,QSize,qulonglong))); | ||
221 | syncRun(&provider); | 223 | syncRun(&provider); | ||
222 | 224 | | |||
223 | QCOMPARE(spy.count(), 1); | 225 | QCOMPARE(spy.count(), 1); | ||
226 | if (GwenviewConfig::deleteThumbnailCacheOnExit()) { | ||||
ngraham: space after the `if` | |||||
227 | expectedThumbnail = createColoredImage(128, 64, Qt::white); | ||||
228 | } else { | ||||
224 | expectedThumbnail = createColoredImage(256, 128, QColor(254, 0, 0)); | 229 | expectedThumbnail = createColoredImage(256, 128, QColor(254, 0, 0)); | ||
230 | } | ||||
225 | thumbnailPix = qvariant_cast<QPixmap>(spy.at(0).at(1)); | 231 | thumbnailPix = qvariant_cast<QPixmap>(spy.at(0).at(1)); | ||
226 | QVERIFY(TestUtils::imageCompare(expectedThumbnail, thumbnailPix.toImage())); | 232 | QVERIFY(TestUtils::imageCompare(expectedThumbnail, thumbnailPix.toImage())); | ||
227 | } | 233 | } | ||
228 | } | 234 | } | ||
229 | 235 | | |||
230 | void ThumbnailProviderTest::testLoadRemote() | 236 | void ThumbnailProviderTest::testLoadRemote() | ||
231 | { | 237 | { | ||
232 | QUrl url = setUpRemoteTestDir("test.png"); | 238 | QUrl url = setUpRemoteTestDir("test.png"); | ||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |
space after the if