diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -82,3 +82,8 @@ LINK_LIBRARIES Qt5::Test KF5::CoreAddons okularcore ) target_compile_definitions(generatorstest PRIVATE GENERATORS_BUILD_DIR="${CMAKE_BINARY_DIR}/generators") + +ecm_add_test(signatureformtest.cpp + TEST_NAME "signatureformtest" + LINK_LIBRARIES Qt5::Test okularcore +) diff --git a/autotests/data/pdf_with_signature.pdf b/autotests/data/pdf_with_signature.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include + +#include +#include + +#include "../settings_core.h" +#include +#include +#include + +class SignatureFormTest : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + void testSignatureForm(); + +private: + Okular::Document *m_document; +}; + +void SignatureFormTest::initTestCase() +{ + Okular::SettingsCore::instance( QStringLiteral("signatureformtest") ); + m_document = new Okular::Document( nullptr ); +} + +void SignatureFormTest::cleanupTestCase() +{ + delete m_document; +} + +void SignatureFormTest::testSignatureForm() +{ + const QString testFile = QStringLiteral(KDESRCDIR "data/pdf_with_signature.pdf"); + QMimeDatabase db; + const QMimeType mime = db.mimeTypeForFile( testFile ); + QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess ); + + const Okular::Page *page = m_document->page( 0 ); + QLinkedList< Okular::FormField * > pageFields = page->formFields(); + QCOMPARE( pageFields.size(), 1 ); + QCOMPARE( pageFields.first()->type(), Okular::FormField::FormSignature ); + + Okular::FormFieldSignature *sf = static_cast< Okular::FormFieldSignature * >( pageFields.first() ); + QCOMPARE( sf->signatureType(), Okular::FormFieldSignature::AdbePkcs7detached ); +} + + +QTEST_MAIN( SignatureFormTest ) +#include "signatureformtest.moc"