Commit b6490944 authored by Brad Hards's avatar Brad Hards

Switch the qt4/tests unittests to use QtTestLib.

parent 37258414
2005-09-03 Brad Hards <bradh@frogmouth.net>
* qt4/tests/ :
* configure.ac: switch qt4 unit tests to use QtTestLib, a more
capable system, and easier to maintain.
2005-09-02 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-page.cc: Apply Marcos rotation fix.
......
......@@ -396,6 +396,71 @@ fi
AM_CONDITIONAL(BUILD_POPPLER_QT4, test x$enable_poppler_qt4 = xyes)
have_qt4testlib=no
dnl ===================================================================
dnl Check whether the QtTestLib headers and libs are available.
dnl Adapted from Qt4 check above!
dnl ===================================================================
dnl We re-use much of the Qt4 environment.
dnl What to test
qt4test_test_include="QtTest/QtTest"
qt4test_test_la_library="libQtTest.la"
qt4test_test_library="libQtTest.so"
dnl Check for QtTestLib headers
AC_MSG_CHECKING([for QtTestLib headers])
qt4test_incdir="no"
for it in $qt4_incdirs ; do
if test -r "$it/$qt4test_test_include" ; then
qt4test_incdir="$it"
break
fi
done
AC_MSG_RESULT([$qt4test_incdir])
dnl Check for Qt4 libraries
AC_MSG_CHECKING([for QtTestLib libraries])
qt4test_libdir="no"
for qt4test_check in $qt4_libdirs ; do
if test -r "$qt4test_check/$qt4test_test_la_library" ; then
qt4test_libdir="$qt4test_check"
break
fi
if test -r "$qt4test_check/$qt4test_test_library" ; then
qt4test_libdir="$qt4test_check"
break
fi
done
AC_MSG_RESULT([$qt4test_libdir])
if test "x$qt4test_libdir" != "xno" ; then
if test "x$qt4test_incdir" != "xno" ; then
have_qt4testlib=yes;
fi
fi
dnl Set the variables
POPPLER_QTTEST_CXXFLAGS="-I$qt4test_incdir"
POPPLER_QTTEST_LIBS="-L$qt4test_libdir -lQtTest"
AC_SUBST(POPPLER_QTTEST_CXXFLAGS)
AC_SUBST(POPPLER_QTTEST_LIBS)
if test x$have_qt4testlib = xno ; then
AC_MSG_WARN([QtTestLib libraries not found])
fi
if test x$have_qt4testlib = xyes; then
enable_poppler_qt4testlib="yes"
else
enable_poppler_qt4testlib="no"
fi
AM_CONDITIONAL(BUILD_POPPLER_QT4TESTS, test x$enable_poppler_qt4testlib = xyes)
AC_ARG_ENABLE(gtk-test,
AC_HELP_STRING([--disable-gtk-test],
[Don't compile GTK+ test program.]),
......@@ -457,6 +522,7 @@ echo " splash output: $enable_splash_output"
echo " cairo output: $enable_cairo_output"
echo " qt wrapper: $enable_poppler_qt"
echo " qt4 wrapper: $enable_poppler_qt4"
echo " qt4 unittests: $enable_poppler_qt4testlib"
echo " glib wrapper: $enable_poppler_glib"
echo " use libjpeg: $enable_libjpeg"
echo " use zlib: $enable_zlib"
......@@ -2,22 +2,15 @@
.libs
*.la
*.lo
*.moc
Makefile
Makefile.in
stress-poppler-qt4
test-poppler-qt4
test-password-qt4
poppler-fonts
check_orientation
check_author
check_metadata
check_permissions
check_linearised
check_pagelayout_facing
check_pagelayout_none
check_pagelayout_single
check_pagemode_attach
check_pagemode_fullscreen
check_pagemode_none
check_pagemode_oc
check_pagemode_thumbs
check_version
check_pagelayout
check_pagemode
......@@ -2,13 +2,21 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/poppler \
-I$(top_srcdir)/qt4/src \
$(POPPLER_QT4_CXXFLAGS)
$(POPPLER_QT4_CXXFLAGS) \
$(POPPLER_QTTEST_CXXFLAGS)
LDADDS = \
$(top_builddir)/poppler/libpoppler.la \
$(top_builddir)/qt4/src/libpoppler-qt4.la \
$(POPPLER_QT4_LIBS)
UT_LDADDS = $(LDADDS) $(POPPLER_QTTEST_LIBS)
SUFFIXES: .moc
.cpp.moc:
moc -i $< -o $@
noinst_PROGRAMS = test-poppler-qt4 stress-poppler-qt4 \
poppler-fonts test-password-qt4
......@@ -18,6 +26,7 @@ test_poppler_qt4_SOURCES = \
test_poppler_qt4_LDADD = $(LDADDS)
test_password_qt4_SOURCES = \
test-password-qt4.cpp
......@@ -30,65 +39,31 @@ poppler_fonts_SOURCES = \
poppler_fonts_LDADD = $(LDADDS)
stress_poppler_qt4_SOURCES = \
stress-poppler-qt4.cpp
stress_poppler_qt4_LDADD = $(LDADDS)
if BUILD_POPPLER_QT4TESTS
TESTS = \
check_author \
check_orientation \
check_metadata \
check_permissions \
check_linearised \
check_pagemode_fullscreen \
check_pagemode_attach \
check_pagemode_none \
check_pagemode_thumbs \
check_pagemode_oc \
check_pagelayout_none \
check_pagelayout_single \
check_pagelayout_facing \
check_version
check_pagemode \
check_pagelayout
check_PROGRAMS = $(TESTS)
check_orientation_SOURCES = check_orientation.cpp
check_orientation_LDADD = $(LDADDS)
check_linearised_SOURCES = check_linearised.cpp
check_linearised_LDADD = $(LDADDS)
check_author_SOURCES = check_author.cpp
check_author_LDADD = $(LDADDS)
check_permissions_SOURCES = check_permissions.cpp
check_permissions_LDADD = $(LDADDS)
check_pagemode_fullscreen_SOURCES = check_pagemode_fullscreen.cpp
check_pagemode_fullscreen_LDADD = $(LDADDS)
check_pagemode_attach_SOURCES = check_pagemode_attach.cpp
check_pagemode_attach_LDADD = $(LDADDS)
check_pagemode_none_SOURCES = check_pagemode_none.cpp
check_pagemode_none_LDADD = $(LDADDS)
check_pagemode_thumbs_SOURCES = check_pagemode_thumbs.cpp
check_pagemode_thumbs_LDADD = $(LDADDS)
check_metadata_SOURCES = check_metadata.cpp check_metadata.moc
check_metadata_LDADD = $(UT_LDADDS)
check_pagemode_oc_SOURCES = check_pagemode_oc.cpp
check_pagemode_oc_LDADD = $(LDADDS)
check_pagemode_SOURCES = check_pagemode.cpp check_pagemode.moc
check_pagemode_LDADD = $(UT_LDADDS)
check_pagelayout_single_SOURCES = check_pagelayout_single.cpp
check_pagelayout_single_LDADD = $(LDADDS)
check_permissions_SOURCES = check_permissions.cpp check_permissions.moc
check_permissions_LDADD = $(UT_LDADDS)
check_pagelayout_none_SOURCES = check_pagelayout_none.cpp
check_pagelayout_none_LDADD = $(LDADDS)
check_pagelayout_SOURCES = check_pagelayout.cpp check_pagelayout.moc
check_pagelayout_LDADD = $(UT_LDADDS)
check_pagelayout_facing_SOURCES = check_pagelayout_facing.cpp
check_pagelayout_facing_LDADD = $(LDADDS)
endif
check_version_SOURCES = check_version.cpp
check_version_LDADD = $(LDADDS)
The unittests for the Qt4 bindings rely on the QtTestLib package, and
will not be built until this is installed. If you do not have it, then
you can download it from the Trolltech website.
Note that there are a range of ways in which you can run the tests:
1. "make check" will run all the tests.
2. You can run a single test by executing the applicable
executable. For example, you can run the PageMode tests by
"./check_pagemode"
3. You can run a single function within a single test by appending the
name of the function to the executable. For example, if you just want
to run the FullScreen test within the PageMode tests, you can
"./check_pagemode checkFullScreen". Run the executable with -functions
to get a list of all the functions.
4. You can run a single function with specific data by appending the
name of the function, followed by a colon, then the data label to the
executable. For example, to just do the Author check within the
metadata checks, you can "./check_metadata checkStrings:Author".
For a full list of options, run a executable with "-help".
Brad Hards
bradh@frogmouth.net
#include <stdlib.h>
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <ctype.h>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->info("Author") == QString("Brad Hards") ) )
{
exit(2);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
if (!doc)
{
exit(1);
}
// It is supposed to be linearised
if ( !(doc->isLinearized() ) )
{
exit(2);
}
exit(0);
}
#include <QtTest/QtTest>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
class TestMetaData: public QObject
{
Q_OBJECT
private slots:
void checkStrings_data(QtTestTable &t);
void checkStrings();
void checkLinearised();
void checkPortraitOrientation();
void checkLandscapeOrientation();
void checkUpsideDownOrientation();
void checkSeascapeOrientation();
void checkVersion();
};
void TestMetaData::checkStrings_data(QtTestTable &t)
{
t.defineElement( "QString", "key" );
t.defineElement( "QString", "value" );
*t.newData( "Author" ) << "Author" << "Brad Hards";
*t.newData( "Title" ) << "Title" << "Two pages";
*t.newData( "Subject" ) << "Subject"
<< "A two page layout for poppler testing";
*t.newData( "Keywords" ) << "Keywords" << "Qt4 bindings";
*t.newData( "Creator" ) << "Creator" << "iText: cgpdftops CUPS filter";
*t.newData( "Producer" ) << "Producer" << "Acrobat Distiller 7.0 for Macintosh";
}
void TestMetaData::checkStrings()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/doublepage.pdf");
VERIFY( doc );
FETCH( QString, key );
FETCH( QString, value );
COMPARE( doc->info(key), value );
}
void TestMetaData::checkLinearised()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
VERIFY( doc );
VERIFY( doc->isLinearized() );
}
void TestMetaData::checkPortraitOrientation()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
VERIFY( doc );
COMPARE( doc->page(0)->orientation(), Poppler::Page::Portrait );
}
void TestMetaData::checkLandscapeOrientation()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
VERIFY( doc );
COMPARE( doc->page(1)->orientation(), Poppler::Page::Landscape );
}
void TestMetaData::checkUpsideDownOrientation()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
VERIFY( doc );
COMPARE( doc->page(2)->orientation(), Poppler::Page::UpsideDown );
}
void TestMetaData::checkSeascapeOrientation()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
VERIFY( doc );
COMPARE( doc->page(3)->orientation(), Poppler::Page::Seascape );
}
void TestMetaData::checkVersion()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/doublepage.pdf");
VERIFY( doc );
COMPARE( doc->pdfVersion(), 1.6 );
}
QTTEST_MAIN(TestMetaData)
#include "check_metadata.moc"
#include <stdlib.h>
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <ctype.h>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/orientation.pdf");
if (!doc)
{
exit(1);
}
Poppler::Page *page = doc->page(0);
if ( !( page->orientation() == Poppler::Page::Portrait ) ) {
exit(2);
}
page = doc->page(1);
if ( !( page->orientation() == Poppler::Page::Landscape ) ) {
exit(3);
}
page = doc->page(2);
if ( !( page->orientation() == Poppler::Page::UpsideDown) ) {
exit(4);
}
page = doc->page(3);
if ( !( page->orientation() == Poppler::Page::Seascape ) ) {
exit(5);
}
exit(0);
}
#include <QtTest/QtTest>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
class TestPageLayout: public QObject
{
Q_OBJECT
private slots:
void checkNone();
void checkSingle();
void checkFacing();
};
void TestPageLayout::checkNone()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/UseNone.pdf");
VERIFY( doc );
COMPARE( doc->pageLayout(), Poppler::Document::NoLayout );
}
void TestPageLayout::checkSingle()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/FullScreen.pdf");
VERIFY( doc );
COMPARE( doc->pageLayout(), Poppler::Document::SinglePage );
}
void TestPageLayout::checkFacing()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/doublepage.pdf");
VERIFY( doc );
COMPARE( doc->pageLayout(), Poppler::Document::TwoPageRight );
}
QTTEST_MAIN(TestPageLayout)
#include "check_pagelayout.moc"
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/doublepage.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageLayout() == Poppler::Document::TwoPageRight ) )
{
exit(2);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/UseNone.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageLayout() == Poppler::Document::NoLayout ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/FullScreen.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageLayout() == Poppler::Document::SinglePage ) )
{
exit(1);
}
exit(0);
}
#include <QtTest/QtTest>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
class TestPageMode: public QObject
{
Q_OBJECT
private slots:
void checkNone();
void checkFullScreen();
void checkAttachments();
void checkThumbs();
void checkOC();
};
void TestPageMode::checkNone()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/UseNone.pdf");
VERIFY( doc );
COMPARE( doc->pageMode(), Poppler::Document::UseNone );
}
void TestPageMode::checkFullScreen()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/FullScreen.pdf");
VERIFY( doc );
COMPARE( doc->pageMode(), Poppler::Document::FullScreen );
}
void TestPageMode::checkAttachments()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/UseAttachments.pdf");
VERIFY( doc );
COMPARE( doc->pageMode(), Poppler::Document::UseAttach );
}
void TestPageMode::checkThumbs()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/UseThumbs.pdf");
VERIFY( doc );
COMPARE( doc->pageMode(), Poppler::Document::UseThumbs );
}
void TestPageMode::checkOC()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/UseOC.pdf");
VERIFY( doc );
COMPARE( doc->pageMode(), Poppler::Document::UseOC );
}
QTTEST_MAIN(TestPageMode)
#include "check_pagemode.moc"
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/UseAttachments.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageMode() == Poppler::Document::UseAttach ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/FullScreen.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageMode() == Poppler::Document::FullScreen ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/UseNone.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageMode() == Poppler::Document::UseNone ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/UseOC.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageMode() == Poppler::Document::UseOC ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
int main( int argc, char **argv )
{
QCoreApplication a( argc, argv ); // QApplication required!
Poppler::Document *doc = Poppler::Document::load("../../../test/unittestcases/UseThumbs.pdf");
if (!doc)
{
exit(1);
}
if ( !(doc->pageMode() == Poppler::Document::UseThumbs ) )
{
exit(1);
}
exit(0);
}
#include <QtCore/QtCore>
#include <QtTest/QtTest>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>