mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-01 05:33:33 +00:00
test to make sure the toc reload feature works
This commit is contained in:
parent
f40b42f8db
commit
5261272e45
33
okular_part_export.h
Normal file
33
okular_part_export.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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
|
6
part.h
6
part.h
|
@ -27,6 +27,8 @@
|
||||||
#include "kdocumentviewer.h"
|
#include "kdocumentviewer.h"
|
||||||
#include "interfaces/viewerinterface.h"
|
#include "interfaces/viewerinterface.h"
|
||||||
|
|
||||||
|
#include "okular_part_export.h"
|
||||||
|
|
||||||
#include <QtDBus/QtDBus>
|
#include <QtDBus/QtDBus>
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
|
@ -90,12 +92,14 @@ enum EmbedMode
|
||||||
* @author Wilco Greven <greven@kde.org>
|
* @author Wilco Greven <greven@kde.org>
|
||||||
* @version 0.2
|
* @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_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
|
Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
|
||||||
Q_INTERFACES(KDocumentViewer)
|
Q_INTERFACES(KDocumentViewer)
|
||||||
Q_INTERFACES(Okular::ViewerInterface)
|
Q_INTERFACES(Okular::ViewerInterface)
|
||||||
|
|
||||||
|
friend class PartTest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Default constructor
|
// Default constructor
|
||||||
|
|
|
@ -2,3 +2,6 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
|
||||||
|
|
||||||
kde4_add_unit_test( shelltest shelltest.cpp ../shell/shellutils.cpp )
|
kde4_add_unit_test( shelltest shelltest.cpp ../shell/shellutils.cpp )
|
||||||
target_link_libraries( shelltest ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} )
|
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 )
|
||||||
|
|
BIN
tests/data/tocreload.pdf
Normal file
BIN
tests/data/tocreload.pdf
Normal file
Binary file not shown.
44
tests/parttest.cpp
Normal file
44
tests/parttest.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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"
|
7
ui/toc.h
7
ui/toc.h
|
@ -14,6 +14,8 @@
|
||||||
#include "core/observer.h"
|
#include "core/observer.h"
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
#include "okular_part_export.h"
|
||||||
|
|
||||||
class QDomNode;
|
class QDomNode;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
@ -22,11 +24,14 @@ class TOCModel;
|
||||||
|
|
||||||
namespace Okular {
|
namespace Okular {
|
||||||
class Document;
|
class Document;
|
||||||
|
class PartTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TOC : public QWidget, public Okular::DocumentObserver
|
class OKULAR_PART_EXPORT TOC : public QWidget, public Okular::DocumentObserver
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
friend class Okular::PartTest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TOC(QWidget *parent, Okular::Document *document);
|
TOC(QWidget *parent, Okular::Document *document);
|
||||||
~TOC();
|
~TOC();
|
||||||
|
|
Loading…
Reference in a new issue