old render cleanup part 3
This commit is contained in:
45 files changed
+1057
-1135
No files matched your search
@@ -48,7 +48,6 @@ static bool addZipEntry(zipFile zf, const char *name, const QByteArray &data)
|
||||
return zipCloseFileInZip(zf) == ZIP_OK;
|
||||
}
|
||||
|
||||
// Create a QByteArray containing a valid PNG for an image of given size and color.
|
||||
static QByteArray makePng(int w, int h, QRgb color = qRgb(255, 0, 0))
|
||||
{
|
||||
QImage img(w, h, QImage::Format_RGB32);
|
||||
@@ -60,8 +59,6 @@ static QByteArray makePng(int w, int h, QRgb color = qRgb(255, 0, 0))
|
||||
return data;
|
||||
}
|
||||
|
||||
// Build a minimal CBZ containing a single image entry.
|
||||
// Returns the path of the temp file (caller removes).
|
||||
static QString buildCbzWithPng(const char *entryPath, int imgW, int imgH,
|
||||
QRgb color = qRgb(255, 0, 0))
|
||||
{
|
||||
@@ -124,19 +121,6 @@ private slots:
|
||||
QVERIFY(img.isNull());
|
||||
}
|
||||
|
||||
void clearResetsState()
|
||||
{
|
||||
const QString cbzPath = buildCbzWithPng("images/test.png", 4, 4);
|
||||
QVERIFY(!cbzPath.isEmpty());
|
||||
|
||||
const QImage img = loadFromCbz(
|
||||
QString{}, QStringLiteral("images/test.png"), QSize());
|
||||
|
||||
QFile::remove(cbzPath);
|
||||
|
||||
QVERIFY(img.isNull());
|
||||
}
|
||||
|
||||
void requestedSizeHonored()
|
||||
{
|
||||
const QString cbzPath = buildCbzWithPng("img.png", 400, 300);
|
||||
@@ -209,28 +193,9 @@ private slots:
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Embedded-path URL format tests
|
||||
// Embedded-path URL format tests (stateless provider)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void coverImageUrlEmbedsCbzPath()
|
||||
{
|
||||
const QString cbzPath = buildCbzWithPng("img.png", 4, 4);
|
||||
QVERIFY(!cbzPath.isEmpty());
|
||||
|
||||
EntryImageProvider provider = makeCbzProvider();
|
||||
provider.setFilePath(cbzPath);
|
||||
|
||||
const QString url = provider.coverImageUrl(QStringLiteral("cover.jpg"));
|
||||
|
||||
QFile::remove(cbzPath);
|
||||
|
||||
QVERIFY2(url.startsWith(QStringLiteral("image://cbz/cover.jpg?src=")),
|
||||
qPrintable("Expected query-param URL, got: " + url));
|
||||
const QString encodedPath = QString::fromUtf8(QUrl::toPercentEncoding(cbzPath));
|
||||
QVERIFY2(url.contains(encodedPath),
|
||||
qPrintable("URL should contain encoded cbz path. URL: " + url));
|
||||
}
|
||||
|
||||
void requestImageResponseUsesEmbeddedPath()
|
||||
{
|
||||
const QString cbzA = buildCbzWithPng("img.png", 4, 4, qRgb(255, 0, 0));
|
||||
@@ -238,7 +203,6 @@ private slots:
|
||||
QVERIFY(!cbzA.isEmpty() && !cbzB.isEmpty());
|
||||
|
||||
EntryImageProvider provider = makeCbzProvider();
|
||||
provider.setFilePath(cbzA); // configured for A
|
||||
|
||||
// Build an embedded-format id pointing to B via query parameter
|
||||
const QString encodedB = QString::fromUtf8(QUrl::toPercentEncoding(cbzB));
|
||||
@@ -260,45 +224,15 @@ private slots:
|
||||
delete resp;
|
||||
}
|
||||
|
||||
void requestImageResponseFallsBackToProviderPath()
|
||||
void requestImageResponseWithoutSourcePathReturnsNull()
|
||||
{
|
||||
const QString cbzA = buildCbzWithPng("img.png", 4, 4, qRgb(255, 0, 0));
|
||||
QVERIFY(!cbzA.isEmpty());
|
||||
|
||||
EntryImageProvider provider = makeCbzProvider();
|
||||
provider.setFilePath(cbzA);
|
||||
|
||||
QQuickImageResponse *resp = provider.requestImageResponse(
|
||||
QStringLiteral("img.png"), QSize());
|
||||
QSignalSpy spy(resp, &QQuickImageResponse::finished);
|
||||
QThreadPool::globalInstance()->waitForDone();
|
||||
if (spy.isEmpty()) spy.wait(5000);
|
||||
|
||||
QFile::remove(cbzA);
|
||||
|
||||
QVERIFY(resp->textureFactory() != nullptr);
|
||||
const QImage img = resp->textureFactory()->image();
|
||||
QVERIFY(!img.isNull());
|
||||
QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0));
|
||||
|
||||
delete resp;
|
||||
}
|
||||
|
||||
void responseAfterClearIsNull()
|
||||
{
|
||||
const QString cbzPath = buildCbzWithPng("img.png", 4, 4);
|
||||
QVERIFY(!cbzPath.isEmpty());
|
||||
|
||||
EntryImageProvider provider = makeCbzProvider();
|
||||
provider.setFilePath(cbzPath);
|
||||
provider.clear();
|
||||
|
||||
// Id without ?src= has no container to load from
|
||||
QQuickImageResponse *resp = provider.requestImageResponse(
|
||||
QStringLiteral("img.png"), QSize());
|
||||
QThreadPool::globalInstance()->waitForDone();
|
||||
|
||||
QFile::remove(cbzPath);
|
||||
|
||||
QVERIFY(resp->textureFactory() == nullptr);
|
||||
delete resp;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user