Commit 7ec41df9 authored by Brad Hards's avatar Brad Hards

Add more unit tests for better coverage.

parent a92b1001
2005-12-06 Brad Hards <bradh@frogmouth.net>
* qt4/tests/check_metadata.cpp : add unit tests
for date, more linearization, page sizes, number of pages
2005-12-05 Brad Hards <bradh@frogmouth.net>
* qt4/tests/check_fonts.cpp (checkType3): Add another case to fonts
unit test
(checkTrueType): Add test for TrueType as well.
2005-12-04 Albert Astals Cid <aacid@kde.org>
......
......@@ -10,6 +10,7 @@ private slots:
void checkNoFonts();
void checkType1();
void checkType3();
void checkTrueType();
};
void TestFontsData::checkNoFonts()
......@@ -61,6 +62,29 @@ void TestFontsData::checkType3()
QCOMPARE( listOfFonts.at(1).isSubset(), false );
}
void TestFontsData::checkTrueType()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
QVERIFY( doc );
QList<Poppler::FontInfo> listOfFonts = doc->fonts();
QCOMPARE( listOfFonts.size(), 2 );
QCOMPARE( listOfFonts.at(0).name(), QString("Arial-BoldMT") );
QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::TrueType );
QCOMPARE( listOfFonts.at(0).typeName(), QString("TrueType") );
QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
QCOMPARE( listOfFonts.at(0).isSubset(), false );
QCOMPARE( listOfFonts.at(1).name(), QString("ArialMT") );
QCOMPARE( listOfFonts.at(1).type(), Poppler::FontInfo::TrueType );
QCOMPARE( listOfFonts.at(1).typeName(), QString("TrueType") );
QCOMPARE( listOfFonts.at(1).isEmbedded(), false );
QCOMPARE( listOfFonts.at(1).isSubset(), false );
}
QTEST_MAIN(TestFontsData)
#include "check_fonts.moc"
......@@ -9,7 +9,12 @@ class TestMetaData: public QObject
private slots:
void checkStrings_data();
void checkStrings();
void checkStrings2_data();
void checkStrings2();
void checkLinearised();
void checkNumPages();
void checkDate();
void checkPageSize();
void checkPortraitOrientation();
void checkLandscapeOrientation();
void checkUpsideDownOrientation();
......@@ -42,6 +47,29 @@ void TestMetaData::checkStrings()
QCOMPARE( doc->info(key), value );
}
void TestMetaData::checkStrings2_data()
{
QTest::addColumn<QString>("key");
QTest::addColumn<QString>("value");
QTest::newRow( "Title" ) << "Title" << "Malaga hotels";
QTest::newRow( "Author" ) << "Author" << "Brad Hards";
QTest::newRow( "Creator" ) << "Creator" << "Safari: cgpdftops CUPS filter";
QTest::newRow( "Producer" ) << "Producer" << "Acrobat Distiller 7.0 for Macintosh";
QTest::newRow( "Keywords" ) << "Keywords" << "First\rSecond\rthird";
}
void TestMetaData::checkStrings2()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
QVERIFY( doc );
QFETCH( QString, key );
QFETCH( QString, value );
QCOMPARE( doc->info(key), value );
}
void TestMetaData::checkLinearised()
{
Poppler::Document *doc;
......@@ -49,6 +77,11 @@ void TestMetaData::checkLinearised()
QVERIFY( doc );
QVERIFY( doc->isLinearized() );
doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
QVERIFY( doc );
QEXPECT_FAIL("", "We don't yet handle linearisation correctly", Continue);
QCOMPARE( doc->isLinearized(), false );
}
void TestMetaData::checkPortraitOrientation()
......@@ -60,6 +93,39 @@ void TestMetaData::checkPortraitOrientation()
QCOMPARE( doc->page(0)->orientation(), Poppler::Page::Portrait );
}
void TestMetaData::checkNumPages()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/doublepage.pdf");
QVERIFY( doc );
QCOMPARE( doc->numPages(), 2 );
doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
QVERIFY( doc );
QCOMPARE( doc->numPages(), 1 );
}
void TestMetaData::checkDate()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
QVERIFY( doc );
QCOMPARE( doc->date("ModDate"), QDateTime(QDate(2005, 12, 5), QTime(20,44,46) ) );
QCOMPARE( doc->date("CreationDate"), QDateTime(QDate(2005, 8, 13), QTime(11,12,11) ) );
}
void TestMetaData::checkPageSize()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
QVERIFY( doc );
QCOMPARE( doc->page(0)->pageSize(), QSize(595, 842) );
QCOMPARE( doc->page(0)->pageSizeF(), QSizeF(595.22, 842) );
}
void TestMetaData::checkLandscapeOrientation()
{
Poppler::Document *doc;
......
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