Changeset View
Changeset View
Standalone View
Standalone View
autotests/signatureformtest.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2018 by Chinmoy Ranjan Pradhan <chinmoyrp65@gmail.com> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | ***************************************************************************/ | ||||
9 | | ||||
10 | #include <QtTest> | ||||
11 | | ||||
12 | #include <QMimeType> | ||||
13 | #include <QMimeDatabase> | ||||
14 | | ||||
15 | #include "../settings_core.h" | ||||
16 | #include <core/document.h> | ||||
17 | #include <core/form.h> | ||||
18 | #include <core/page.h> | ||||
19 | | ||||
20 | class SignatureFormTest : public QObject | ||||
21 | { | ||||
22 | Q_OBJECT | ||||
23 | | ||||
24 | private slots: | ||||
25 | void initTestCase(); | ||||
26 | void cleanupTestCase(); | ||||
27 | void testSignatureForm(); | ||||
28 | | ||||
29 | private: | ||||
30 | Okular::Document *m_document; | ||||
31 | }; | ||||
32 | | ||||
33 | void SignatureFormTest::initTestCase() | ||||
34 | { | ||||
35 | Okular::SettingsCore::instance( QStringLiteral("signatureformtest") ); | ||||
36 | m_document = new Okular::Document( nullptr ); | ||||
37 | } | ||||
38 | | ||||
39 | void SignatureFormTest::cleanupTestCase() | ||||
40 | { | ||||
41 | delete m_document; | ||||
42 | } | ||||
43 | | ||||
44 | void SignatureFormTest::testSignatureForm() | ||||
45 | { | ||||
46 | const QString testFile = QStringLiteral(KDESRCDIR "data/pdf_with_signature.pdf"); | ||||
47 | QMimeDatabase db; | ||||
48 | const QMimeType mime = db.mimeTypeForFile( testFile ); | ||||
49 | QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess ); | ||||
50 | | ||||
51 | const Okular::Page *page = m_document->page( 0 ); | ||||
52 | QLinkedList< Okular::FormField * > pageFields = page->formFields(); | ||||
53 | QCOMPARE( pageFields.size(), 1 ); | ||||
54 | QCOMPARE( pageFields.first()->type(), Okular::FormField::FormSignature ); | ||||
55 | | ||||
56 | Okular::FormFieldSignature *sf = static_cast< Okular::FormFieldSignature * >( pageFields.first() ); | ||||
57 | QCOMPARE( sf->signatureType(), Okular::FormFieldSignature::AdbePkcs7detached ); | ||||
58 | } | ||||
59 | | ||||
60 | | ||||
61 | QTEST_MAIN( SignatureFormTest ) | ||||
62 | #include "signatureformtest.moc" |