Commit 5261272e authored by Albert Astals Cid's avatar Albert Astals Cid

test to make sure the toc reload feature works

parent f40b42f8
/***************************************************************************
* Copyright (C) 2013 by Albert Astals Cid <aacid@kde.org> *
* *
* 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. *
***************************************************************************/
#ifndef OKULAR_PART_EXPORT_H
#define OKULAR_PART_EXPORT_H
/* needed for KDE_EXPORT macros */
#include <kdemacros.h>
#if defined _WIN32 || defined _WIN64
#ifndef OKULAR_PART_EXPORT
# ifdef MAKE_OKULARPART_LIB
# define OKULAR_PART_EXPORT KDE_EXPORT
# else
# define OKULAR_PART_EXPORT KDE_IMPORT
# endif
#endif
#else /* UNIX*/
/* export statements for unix */
#define OKULAR_PART_EXPORT KDE_EXPORT
#endif
#endif
......@@ -27,6 +27,8 @@
#include "kdocumentviewer.h"
#include "interfaces/viewerinterface.h"
#include "okular_part_export.h"
#include <QtDBus/QtDBus>
class QAction;
......@@ -90,12 +92,14 @@ enum EmbedMode
* @author Wilco Greven <greven@kde.org>
* @version 0.2
*/
class Part : public KParts::ReadWritePart, public Okular::DocumentObserver, public KDocumentViewer, public Okular::ViewerInterface
class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::DocumentObserver, public KDocumentViewer, public Okular::ViewerInterface
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
Q_INTERFACES(KDocumentViewer)
Q_INTERFACES(Okular::ViewerInterface)
friend class PartTest;
public:
// Default constructor
......
......@@ -2,3 +2,6 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
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_QTTEST_LIBRARY} okularpart )
/***************************************************************************
* Copyright (C) 2013 by Albert Astals Cid <aacid@kde.org> *
* *
* 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 <qtest_kde.h>
#include "../part.h"
#include "../ui/toc.h"
#include <QTreeView>
namespace Okular
{
class PartTest
: public QObject
{
Q_OBJECT
private slots:
void testTOCReload();
};
void PartTest::testTOCReload()
{
QVariantList dummyArgs;
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
part.openDocument(KDESRCDIR "data/tocreload.pdf");
QCOMPARE(part.m_toc->expandedNodes().count(), 0);
part.m_toc->m_treeView->expandAll();
QCOMPARE(part.m_toc->expandedNodes().count(), 3);
part.reload();
qApp->processEvents();
QCOMPARE(part.m_toc->expandedNodes().count(), 3);
}
}
QTEST_KDEMAIN( Okular::PartTest, GUI )
#include "parttest.moc"
......@@ -14,6 +14,8 @@
#include "core/observer.h"
#include <QModelIndex>
#include "okular_part_export.h"
class QDomNode;
class QModelIndex;
class QTreeView;
......@@ -22,11 +24,14 @@ class TOCModel;
namespace Okular {
class Document;
class PartTest;
}
class TOC : public QWidget, public Okular::DocumentObserver
class OKULAR_PART_EXPORT TOC : public QWidget, public Okular::DocumentObserver
{
Q_OBJECT
friend class Okular::PartTest;
public:
TOC(QWidget *parent, Okular::Document *document);
~TOC();
......
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