Cover encrypted group images and fixed private generation in desktop submission tests
This commit is contained in:
1 parent
206abcae10
commit
b3e7db7b26
1 file changed
+10
-5
@@ -525,14 +525,17 @@ private slots:
|
||||
void imageHasTypedMetadataInGroupAndPm_data() {
|
||||
QTest::addColumn<bool>("dm");
|
||||
QTest::addColumn<QString>("format");
|
||||
for (bool dm : {false, true}) for (const QString& format : {QString("PNG"), QString("JPEG")})
|
||||
QTest::newRow(qPrintable(QString("%1-%2").arg(dm ? "pm" : "group", format))) << dm << format;
|
||||
QTest::addColumn<bool>("encrypted");
|
||||
for (bool dm : {false, true}) for (bool encrypted : {false, true}) for (const QString& format : {QString("PNG"), QString("JPEG")}) {
|
||||
if (dm && encrypted) continue;
|
||||
QTest::newRow(qPrintable(QString("%1-%2-%3").arg(dm ? "pm" : "group", format).arg(encrypted))) << dm << format << encrypted;
|
||||
}
|
||||
}
|
||||
void imageHasTypedMetadataInGroupAndPm() {
|
||||
QFETCH(bool, dm); QFETCH(QString, format);
|
||||
QFETCH(bool, dm); QFETCH(QString, format); QFETCH(bool, encrypted);
|
||||
QTemporaryDir dir; QVERIFY(dir.isValid());
|
||||
InputBar bar(nullptr, nullptr); bar.show();
|
||||
bar.setRecordingContext(dir.filePath("media"), dm ? "dm:456" : "123"); bar.setDmMode(dm); bar.setDmGeneration(7);
|
||||
bar.setRecordingContext(dir.filePath("media"), dm ? "dm:456" : "123", dm ? 7 : 0); bar.setDmMode(dm);
|
||||
auto* editor = bar.findChild<QTextEdit*>(); QVERIFY(editor);
|
||||
const QString path = dir.filePath("фото.PNG"); // Фактический JPEG должен победить расширение PNG.
|
||||
QImage image(120, 80, QImage::Format_ARGB32); image.fill(Qt::red); QVERIFY(image.save(path, qPrintable(format)));
|
||||
@@ -540,11 +543,13 @@ private slots:
|
||||
connect(&bar, &InputBar::submitAttachment, &bar, [&](const QString& target, attachment_send_req* request) {
|
||||
++sends; QCOMPARE(target, dm ? QString("dm:456") : QString("123"));
|
||||
QCOMPARE(request->info.kind, format == "PNG" ? ATTACHMENT_PNG : ATTACHMENT_JPEG);
|
||||
QCOMPARE(request->info.width, 120); QCOMPARE(request->info.height, 80); QCOMPARE(request->dm_generation, UINT64_C(7));
|
||||
QCOMPARE(request->info.width, 120); QCOMPARE(request->info.height, 80);
|
||||
QCOMPARE(request->dm_generation, dm ? UINT64_C(7) : UINT64_C(0)); QCOMPARE(request->encrypted, (int)encrypted);
|
||||
QCOMPARE(QString::fromUtf8(request->source), path); QVERIFY(!request->temporary_source);
|
||||
const auto id = request->request_id; attachment_send_discard(request); bar.submissionResult(id, true);
|
||||
});
|
||||
QVERIFY(dropUrls(editor->viewport(), {QUrl::fromLocalFile(path)}));
|
||||
if (encrypted) { auto* check = bar.findChild<QCheckBox*>(); QVERIFY(check); check->setChecked(true); }
|
||||
QTest::keyClick(editor, Qt::Key_Return);
|
||||
QCOMPARE(sends, 1); QVERIFY(QFile::exists(path));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user