diff options
-rw-r--r-- | poppler/Form.cc | 6 | ||||
-rw-r--r-- | qt5/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | qt5/tests/check_forms.cpp | 43 |
3 files changed, 47 insertions, 3 deletions
diff --git a/poppler/Form.cc b/poppler/Form.cc index 50ed0120..3f6f3ff4 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -235,16 +235,16 @@ void FormWidgetButton::setState (bool astate) return; // Silently return if can't set ON state - if (astate && !onStr) + if (astate && !getOnStr()) return; - parent()->setState(astate ? onStr->getCString() : (char *)"Off"); + parent()->setState(astate ? getOnStr() : (char *)"Off"); // Parent will call setAppearanceState() } bool FormWidgetButton::getState () const { - return onStr ? parent()->getState(onStr->getCString()) : false; + return getOnStr() ? parent()->getState( getOnStr() ) : false; } FormFieldButton *FormWidgetButton::parent() const diff --git a/qt5/tests/CMakeLists.txt b/qt5/tests/CMakeLists.txt index af8de6ef..7fda2687 100644 --- a/qt5/tests/CMakeLists.txt +++ b/qt5/tests/CMakeLists.txt @@ -62,6 +62,7 @@ qt5_add_qtest(check_qt5_links check_links.cpp) qt5_add_qtest(check_qt5_annotations check_annotations.cpp) qt5_add_qtest(check_qt5_metadata check_metadata.cpp) qt5_add_qtest(check_qt5_optcontent check_optcontent.cpp) +qt5_add_qtest(check_qt5_forms check_forms.cpp) qt5_add_qtest(check_qt5_pagelayout check_pagelayout.cpp) qt5_add_qtest(check_qt5_pagemode check_pagemode.cpp) qt5_add_qtest(check_qt5_password check_password.cpp) diff --git a/qt5/tests/check_forms.cpp b/qt5/tests/check_forms.cpp new file mode 100644 index 00000000..3c0ecf8b --- /dev/null +++ b/qt5/tests/check_forms.cpp @@ -0,0 +1,43 @@ +#include <QtTest/QtTest> + +#include <poppler-qt5.h> +#include <poppler-form.h> +#include <Form.h> + +class TestForms: public QObject +{ + Q_OBJECT +private slots: + void testCheckbox();// Test for issue #655 +}; + +void TestForms::testCheckbox() +{ + // Test for checkbox issue #655 + QScopedPointer< Poppler::Document > document(Poppler::Document::load(TESTDATADIR "/unittestcases/latex-hyperref-checkbox-issue-655.pdf")); + QVERIFY( document ); + + QScopedPointer< Poppler::Page > page(document->page(0)); + QVERIFY( page ); + + QList<Poppler::FormField*> forms = page->formFields(); + QCOMPARE( forms.size(), 1 ); + + Poppler::FormField *form = forms.at(0); + QCOMPARE( form->type() , Poppler::FormField::FormButton ); + + Poppler::FormFieldButton *chkFormFieldButton = static_cast<Poppler::FormFieldButton *>(form); + + // Test this is actually a Checkbox + QCOMPARE( chkFormFieldButton->buttonType() , Poppler::FormFieldButton::CheckBox ); + + // checkbox comes initially 'unchecked' + QCOMPARE( chkFormFieldButton->state() , false ); + // let's mark it as 'checked' + chkFormFieldButton->setState( true ); + // now test if it was succesfully 'checked' + QCOMPARE( chkFormFieldButton->state() , true ); +} + +QTEST_GUILESS_MAIN(TestForms) +#include "check_forms.moc" |