Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 77a71a02 authored by Fabio D'Urso's avatar Fabio D'Urso

Test that Okular doesn't crash after a canceled reload

This would have caught the crash I'm going to fix in the next patch
parent 889c9429
......@@ -4,7 +4,7 @@ kde4_add_unit_test( shelltest shelltest.cpp ../shell/shellutils.cpp )
target_link_libraries( shelltest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
kde4_add_unit_test( parttest parttest.cpp )
target_link_libraries( parttest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularpart okularcore )
target_link_libraries( parttest ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularpart okularcore )
kde4_add_unit_test( searchtest searchtest.cpp )
target_link_libraries( searchtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
......@@ -27,12 +27,41 @@ class PartTest
private slots:
void testReload();
void testCanceledReload();
void testTOCReload();
void testFowardPDF();
void testFowardPDF_data();
void testGeneratorPreferences();
class PartThatHijacksQueryClose : public Okular::Part
PartThatHijacksQueryClose(QWidget* parentWidget, QObject* parent,
const QVariantList& args, KComponentData componentData)
: Okular::Part(parentWidget, parent, args, componentData),
enum Behavior { PassThru, ReturnTrue, ReturnFalse };
void setQueryCloseBehavior(Behavior new_behavior)
behavior = new_behavior;
bool queryClose()
if (behavior == PassThru)
return Okular::Part::queryClose();
else // ReturnTrue or ReturnFalse
return (behavior == ReturnTrue);
Behavior behavior;
// Test that Okular doesn't crash after a successful reload
void PartTest::testReload()
QVariantList dummyArgs;
......@@ -42,6 +71,22 @@ void PartTest::testReload()
// Test that Okular doesn't crash after a canceled reload
void PartTest::testCanceledReload()
QVariantList dummyArgs;
PartThatHijacksQueryClose part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
part.openDocument(KDESRCDIR "data/file1.pdf");
// When queryClose() returns false, the reload operation is canceled (as if
// the user had chosen Cancel in the "Save changes?" message box)
void PartTest::testTOCReload()
QVariantList dummyArgs;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment