Exercise group encryption choice through real Qt input events
This commit is contained in:
1 parent
98f71735a0
commit
a31ade1054
1 file changed
+23
@@ -21,6 +21,7 @@ extern "C" {
|
||||
#include <QUrl>
|
||||
#include <QMessageBox>
|
||||
#include <QAbstractButton>
|
||||
#include <QPushButton>
|
||||
|
||||
static QString makeFile(const QTemporaryDir& dir, const QString& name, const QByteArray& contents = "test") {
|
||||
const QString path = dir.filePath(name);
|
||||
@@ -46,6 +47,28 @@ static bool dropUrls(QWidget* target, const QList<QUrl>& urls, bool process = tr
|
||||
class FileDropTest : public QObject {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void encryptedAttachmentCapturesTargetAndResetsChoice() {
|
||||
QTemporaryDir dir; QVERIFY(dir.isValid());
|
||||
const QString file = makeFile(dir, "private.txt", "private bytes");
|
||||
InputBar bar(nullptr, nullptr); bar.show(); bar.setRecordingContext(dir.filePath("media"), "123");
|
||||
auto* editor = bar.findChild<QTextEdit*>(); QVERIFY(editor);
|
||||
auto* encrypt = bar.findChild<QPushButton*>("encryptAttachmentButton"); QVERIFY(encrypt);
|
||||
QSignalSpy ordinary(&bar, &InputBar::sendFileAttachment);
|
||||
int encrypted = 0;
|
||||
connect(&bar, &InputBar::submitAttachment, &bar, [&](const QString& target, attachment_send_req* request) {
|
||||
QCOMPARE(target, QString("123")); QVERIFY(request->encrypted); QCOMPARE(request->info.kind, ATTACHMENT_FILE);
|
||||
QCOMPARE(QString::fromUtf8(request->source), file); QCOMPARE(QString::fromUtf8(request->info.name), QString("private.txt"));
|
||||
++encrypted; u_free(request);
|
||||
});
|
||||
QVERIFY(dropUrls(editor->viewport(), {QUrl::fromLocalFile(file)}));
|
||||
QTest::mouseClick(encrypt, Qt::LeftButton); QVERIFY(encrypt->isChecked());
|
||||
QTest::keyClick(editor, Qt::Key_Return);
|
||||
QCOMPARE(encrypted, 1); QCOMPARE(ordinary.size(), 0); QVERIFY(!encrypt->isChecked()); QVERIFY(QFile::exists(file));
|
||||
QTest::mouseClick(encrypt, Qt::LeftButton); QVERIFY(encrypt->isChecked());
|
||||
bar.setRecordingContext(dir.filePath("media"), "456"); QVERIFY(!encrypt->isChecked());
|
||||
bar.setDmMode(true); QVERIFY(encrypt->isHidden()); QVERIFY(!encrypt->isChecked());
|
||||
}
|
||||
|
||||
void replyDraftAndLateResults() {
|
||||
InputBar bar(nullptr, nullptr); bar.resize(600, 160); bar.show(); bar.setRecordingContext("/tmp", "123");
|
||||
auto* editor = bar.findChild<QTextEdit*>(); QVERIFY(editor);
|
||||
|
||||
Reference in new issue
Block a user