[poppler]
poppler/qt4/tests: .cvsignore, 1.8, 1.9 Makefile.am, 1.11,
1.12 check_dateConversion.cpp, NONE, 1.1 check_metadata.cpp,
1.4, 1.5
Brad Hards
bradh at freedesktop.org
Mon Dec 26 22:10:04 PST 2005
Update of /cvs/poppler/poppler/qt4/tests
In directory gabe:/tmp/cvs-serv12644/qt4/tests
Modified Files:
.cvsignore Makefile.am check_metadata.cpp
Added Files:
check_dateConversion.cpp
Log Message:
qt4/src/poppler-qt4.h and qt4/src/poppler-document.cc: add convertDate() function that
turns char* PDF date strings into QDateTime. This version handles
the timezone conversions. Refactored the existing date() method
to use it.
qt4/tests/check_dateConversion.cpp: unit tests for convertDate()
qt4/tests/check_metadata.cpp: update to reflect UTC.
qt4/tests/.cvsignore: suppress check_dateConversion
Index: .cvsignore
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/.cvsignore,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- .cvsignore 4 Dec 2005 10:45:26 -0000 1.8
+++ .cvsignore 27 Dec 2005 06:10:02 -0000 1.9
@@ -9,6 +9,7 @@
test-poppler-qt4
test-password-qt4
poppler-fonts
+check_dateConversion
check_fonts
check_metadata
check_permissions
Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile.am 4 Dec 2005 10:05:22 -0000 1.11
+++ Makefile.am 27 Dec 2005 06:10:02 -0000 1.12
@@ -46,14 +46,19 @@
if BUILD_POPPLER_QT4TESTS
TESTS = \
+ check_dateConversion \
check_fonts \
- check_metadata \
- check_permissions \
- check_pagemode \
+ check_metadata \
+ check_permissions \
+ check_pagemode \
check_pagelayout
check_PROGRAMS = $(TESTS)
+check_dateConversion_SOURCES = check_dateConversion.cpp
+check_dateConversion.$(OBJEXT): check_dateConversion.moc
+check_dateConversion_LDADD = $(UT_LDADDS)
+
check_fonts_SOURCES = check_fonts.cpp
check_fonts.$(OBJEXT): check_fonts.moc
check_fonts_LDADD = $(UT_LDADDS)
--- NEW FILE: check_dateConversion.cpp ---
#include <QtTest/QtTest>
Q_DECLARE_METATYPE(QDate)
Q_DECLARE_METATYPE(QTime)
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
class TestDateConv: public QObject
{
Q_OBJECT
private slots:
void checkDates_data();
void checkDates();
};
void TestDateConv::checkDates_data()
{
qRegisterMetaType<QDate>("QDate");
qRegisterMetaType<QTime>("QTime");
QTest::addColumn<QByteArray>("input");
QTest::addColumn<QDate>("day");
QTest::addColumn<QTime>("time");
// This is a typical case - all data provided
QTest::newRow("D:20040101121110")
<< QByteArray("D:20040101121110Z")
<< QDate( 2004, 1, 1)
<< QTime( 12, 11, 10);
// The D: is strongly recommended, but optional
QTest::newRow("20040101121110")
<< QByteArray("20040101121110Z")
<< QDate( 2004, 1, 1)
<< QTime( 12, 11, 10);
// Only the year is actually required
QTest::newRow("D:2006")
<< QByteArray("D:2006")
<< QDate( 2006, 1, 1)
<< QTime( 0, 0, 0);
QTest::newRow("D:200602")
<< QByteArray("D:200602")
<< QDate( 2006, 2, 1)
<< QTime( 0, 0, 0);
QTest::newRow("D:20060304")
<< QByteArray("D:20060304")
<< QDate( 2006, 3, 4)
<< QTime( 0, 0, 0);
QTest::newRow("D:2006030405")
<< QByteArray("D:2006030405")
<< QDate( 2006, 3, 4)
<< QTime( 5, 0, 0);
QTest::newRow("D:200603040512")
<< QByteArray("D:200603040512")
<< QDate( 2006, 3, 4)
<< QTime( 5, 12, 0);
// If the timezone isn't specified, I assume UTC
QTest::newRow("D:20060304051226")
<< QByteArray("D:20060304051226")
<< QDate( 2006, 3, 4)
<< QTime( 5, 12, 26);
// Check for real timezone conversions
QTest::newRow("D:20030131115258-04'00'")
<< QByteArray("D:20030131115258-04'00'")
<< QDate( 2003, 1, 31)
<< QTime( 15, 52, 58);
QTest::newRow("D:20030131115258+05'00'")
<< QByteArray("D:20030131115258+05'00'")
<< QDate( 2003, 1, 31)
<< QTime( 6, 52, 58);
// There are places that have non-hour offsets
// Yep, that means you Adelaide.
QTest::newRow("D:20030131115258+08'30'")
<< QByteArray("D:20030131115258+08'30'")
<< QDate( 2003, 1, 31)
<< QTime( 3, 22, 58);
QTest::newRow("D:20030131115258-08'30'")
<< QByteArray("D:20030131115258-08'30'")
<< QDate( 2003, 1, 31)
<< QTime( 20, 22, 58);
}
void TestDateConv::checkDates()
{
QFETCH(QByteArray, input);
QFETCH(QDate, day);
QFETCH(QTime, time);
QCOMPARE( Poppler::convertDate(input.data()), QDateTime(day, time, Qt::UTC) );
}
QTEST_MAIN(TestDateConv)
#include "check_dateConversion.moc"
Index: check_metadata.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/check_metadata.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- check_metadata.cpp 7 Dec 2005 08:31:09 -0000 1.4
+++ check_metadata.cpp 27 Dec 2005 06:10:02 -0000 1.5
@@ -129,8 +129,8 @@
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) ) );
+ QCOMPARE( doc->date("ModDate"), QDateTime(QDate(2005, 12, 5), QTime(9,44,46), Qt::UTC ) );
+ QCOMPARE( doc->date("CreationDate"), QDateTime(QDate(2005, 8, 13), QTime(1,12,11), Qt::UTC ) );
}
void TestMetaData::checkPageSize()
More information about the poppler
mailing list