[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/gwenview
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2010-08-23 22:23:34
Message-ID: 20100823222334.5D346AC871 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1167186 by gateau:
Prevent ThumbnailLoadJobTest::testLoadLocal() from failing
M +10 -0 lib/thumbnailloadjob.cpp
M +8 -0 lib/thumbnailloadjob.h
M +8 -0 tests/thumbnailloadjobtest.cpp
--- trunk/KDE/kdegraphics/gwenview/lib/thumbnailloadjob.cpp #1167185:1167186
@@ -142,7 +142,12 @@
return mCache.value(path);
}
+bool ThumbnailCache::isEmpty() const {
+ QMutexLocker locker(&mMutex);
+ return mCache.isEmpty();
+}
+
//------------------------------------------------------------------------
//
// ThumbnailThread
@@ -704,4 +709,9 @@
}
+bool ThumbnailLoadJob::isPendingThumbnailCacheEmpty() {
+ return sThumbnailCache->isEmpty();
+}
+
+
} // namespace
--- trunk/KDE/kdegraphics/gwenview/lib/thumbnailloadjob.h #1167185:1167186
@@ -92,6 +92,8 @@
// Return thumbnail if it has still not been stored
QImage value(const QString&) const;
+ bool isEmpty() const;
+
public Q_SLOTS:
void queueThumbnail(const QString&, const QImage&);
@@ -167,6 +169,12 @@
*/
static void moveThumbnail(const KUrl& oldUrl, const KUrl& newUrl);
+ /**
+ * Returns true if all thumbnails have been written to disk. Useful for
+ * unit-testing.
+ */
+ static bool isPendingThumbnailCacheEmpty();
+
Q_SIGNALS:
/**
* Emitted when the thumbnail for the @p item has been loaded
--- trunk/KDE/kdegraphics/gwenview/tests/thumbnailloadjobtest.cpp #1167185:1167186
@@ -107,12 +107,15 @@
void ThumbnailLoadJobTest::testLoadLocal() {
QDir dir(mSandBox.mPath);
+ // Create a list of items which will be thumbnailed
KFileItemList list;
Q_FOREACH(const QFileInfo& info, dir.entryInfoList(QDir::Files)) {
KUrl url("file://" + info.absoluteFilePath());
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
list << item;
}
+
+ // Generate the thumbnails
QPointer<ThumbnailLoadJob> job = new ThumbnailLoadJob(list, ThumbnailGroup::Normal);
QSignalSpy spy(job, SIGNAL(thumbnailLoaded(const KFileItem&, const QPixmap&, const QSize&)));
// FIXME: job->exec() causes a double free(), so wait for the job to be
@@ -123,6 +126,11 @@
QTest::qWait(100);
}
+ while (!ThumbnailLoadJob::isPendingThumbnailCacheEmpty()) {
+ QTest::qWait(100);
+ }
+
+ // Check we generated the correct number of thumbnails
QDir thumbnailDir = ThumbnailLoadJob::thumbnailBaseDir(ThumbnailGroup::Normal);
// There should be one file less because small.png is a png and is too
// small to have a thumbnail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic