[poppler] poppler/qt4/tests: check_fonts.cpp, 1.2, 1.3 check_metadata.cpp, 1.2, 1.3

Brad Hards bradh at freedesktop.org
Tue Dec 6 01:58:09 PST 2005


Update of /cvs/poppler/poppler/qt4/tests
In directory gabe:/tmp/cvs-serv1155/qt4/tests

Modified Files:
	check_fonts.cpp check_metadata.cpp 
Log Message:
Add more unit tests for better coverage.



Index: check_fonts.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/check_fonts.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_fonts.cpp	4 Dec 2005 19:48:25 -0000	1.2
+++ check_fonts.cpp	6 Dec 2005 09:58:04 -0000	1.3
@@ -10,6 +10,7 @@
     void checkNoFonts();
     void checkType1();
     void checkType3();
+    void checkTrueType();
 };
 
 void TestFontsData::checkNoFonts()
@@ -61,6 +62,29 @@
     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"
 

Index: check_metadata.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/check_metadata.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_metadata.cpp	27 Nov 2005 01:33:51 -0000	1.2
+++ check_metadata.cpp	6 Dec 2005 09:58:04 -0000	1.3
@@ -9,7 +9,12 @@
 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 @@
     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 @@
     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 @@
     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;



More information about the poppler mailing list