mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
gwenview: test animated document loader with WebP image
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
a52db499cd
commit
e6bbe6f23a
9 changed files with 8 additions and 14 deletions
|
@ -64,8 +64,8 @@ void AnimatedDocumentLoadedImpl::init()
|
|||
emit isAnimatedUpdated();
|
||||
if (!document()->image().isNull()) {
|
||||
// We may reach this point without an image if the first frame got
|
||||
// downsampled by LoadingDocumentImpl (unlikely for now because the gif
|
||||
// io handler does not support the QImageIOHandler::ScaledSize option)
|
||||
// downsampled by LoadingDocumentImpl (unlikely for now because the
|
||||
// handler many not support the QImageIOHandler::ScaledSize option)
|
||||
emit imageRectUpdated(document()->image().rect());
|
||||
emit loaded();
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
bool isEditable() const;
|
||||
|
||||
/**
|
||||
* Returns true if the image is animated (eg: gif or mng format)
|
||||
* Returns true if the image is animated (eg: webp format)
|
||||
*/
|
||||
bool isAnimated() const;
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ struct LoadingDocumentImplPrivate
|
|||
return;
|
||||
}
|
||||
/*
|
||||
* QImageReader is not really helpful to detect animated gif:
|
||||
* QImageReader is not really helpful to detect animated images:
|
||||
* - QImageReader::imageCount() returns 0
|
||||
* - QImageReader::nextImageDelay() may return something > 0 if the
|
||||
* image consists of only one frame but includes a "Graphic
|
||||
|
@ -251,7 +251,7 @@ struct LoadingDocumentImplPrivate
|
|||
* animation) (Bug #185523)
|
||||
*
|
||||
* Decoding the next frame is the only reliable way I found to
|
||||
* detect an animated gif
|
||||
* detect an animated images
|
||||
*/
|
||||
LOG("May be an animated image. delay:" << reader.nextImageDelay());
|
||||
QImage nextImage;
|
||||
|
|
|
@ -114,9 +114,6 @@ void DocumentTest::testLoad()
|
|||
image = image.copy(poiRect);
|
||||
expectedImage = expectedImage.copy(poiRect);
|
||||
}
|
||||
if (fileName == QLatin1String("4frames.gif")) {
|
||||
QEXPECT_FAIL("", "Wonky GIF handler", Continue);
|
||||
}
|
||||
QCOMPARE(image, expectedImage);
|
||||
QCOMPARE(QString(doc->format()), QString(expectedFormat));
|
||||
}
|
||||
|
@ -165,10 +162,7 @@ void DocumentTest::testLoad_data()
|
|||
// FIXME: Test svgz
|
||||
|
||||
// Animated
|
||||
testLoad_newRow("4frames.gif", "gif", MimeTypeUtils::KIND_IMAGE, true);
|
||||
testLoad_newRow("1frame.gif", "gif", MimeTypeUtils::KIND_IMAGE, false);
|
||||
testLoad_newRow("185523_1frame_with_graphic_control_extension.gif",
|
||||
"gif", MimeTypeUtils::KIND_IMAGE, false);
|
||||
testLoad_newRow("butterfly.webp", "webp", MimeTypeUtils::KIND_IMAGE, true);
|
||||
}
|
||||
|
||||
void DocumentTest::testLoadTwoPasses()
|
||||
|
@ -280,7 +274,7 @@ void DocumentTest::testLoadRemote()
|
|||
|
||||
void DocumentTest::testLoadAnimated()
|
||||
{
|
||||
KUrl srcUrl = urlForTestFile("40frames.gif");
|
||||
KUrl srcUrl = urlForTestFile("butterfly.webp");
|
||||
Document::Ptr doc = DocumentFactory::instance()->load(srcUrl);
|
||||
QSignalSpy spy(doc.data(), SIGNAL(imageRectUpdated(QRect)));
|
||||
doc->startLoadingFullImage();
|
||||
|
@ -290,7 +284,7 @@ void DocumentTest::testLoadAnimated()
|
|||
// Test we do not receive imageRectUpdated() until animation is started
|
||||
// (the imageRectUpdated() is triggered by the loading of the first image)
|
||||
QTest::qWait(1000);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
// Test we now receive some imageRectUpdated()
|
||||
doc->startAnimation();
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 77 B |
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 434 B |
BIN
gwenview/tests/data/butterfly.webp
Normal file
BIN
gwenview/tests/data/butterfly.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
Loading…
Add table
Reference in a new issue