summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-07-15 13:30:38 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-07-15 13:40:31 (GMT)
commit4b1766efc6937e1448b2948a6cf61a5543edf75a (patch)
tree5582a6b278720fc96ade1691b92d17d77921d4b7
parent45a076ea0454a5a2836eb6c083f6f63ad06eca8c (diff)
downloadlibkolab-4b1766efc6937e1448b2948a6cf61a5543edf75a.tar.gz
Support for readonly tests.
-rw-r--r--tests/formattest.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index de8b321..fab018c 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -168,27 +168,34 @@ void FormatTest::testIncidence()
}
+enum TestMode {
+ ReadOnly,
+ ReadWrite
+};
+Q_DECLARE_METATYPE(TestMode);
+
void FormatTest::testContact_data()
{
QTest::addColumn<Kolab::Version>( "version" );
QTest::addColumn<Kolab::ObjectType>( "type" );
QTest::addColumn<QString>( "vcardFileName" );
QTest::addColumn<QString>( "mimeFileName" );
+ QTest::addColumn<TestMode>( "mode" );
- QTest::newRow( "v2contactSimple" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf.mime");
- QTest::newRow( "v2contactComplex" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf.mime");
- QTest::newRow( "v2contactAddress" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf.mime");
- QTest::newRow( "v2contactBug238996" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf.mime");
- QTest::newRow( "v2contactDisplayname" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf.mime");
- QTest::newRow( "v2contactEmails" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf.mime");
- QTest::newRow( "v2contactPhonenumbers" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf.mime");
- QTest::newRow( "v2contactPicture" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf.mime");
+ QTest::newRow( "v2contactSimple" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactComplex" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactAddress" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactBug238996" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactDisplayname" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactEmails" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactPhonenumbers" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf.mime") << ReadWrite;
+ QTest::newRow( "v2contactPicture" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf.mime") << ReadWrite;
//FIXME the following test fails because the vcard implementation always writes jpeg (which is lossy). The reference vcf file is therefore probably also not really useful
// QTest::newRow( "v2pictureJPGHorde" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/pictureJPGHorde.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/pictureJPGHorde.vcf.mime");
- QTest::newRow( "v3contactSimple" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf.mime");
- QTest::newRow( "v3contactComplex" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf.mime");
- QTest::newRow( "v3contactPng" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/png.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/png.vcf.mime");
+ QTest::newRow( "v3contactSimple" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf.mime") << ReadWrite;
+ QTest::newRow( "v3contactComplex" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf.mime") << ReadWrite;
+ QTest::newRow( "v3contactPng" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/readonly/png.vcf") << TESTFILEDIR+QString::fromLatin1("v3/readonly/png.vcf.mime") << ReadOnly;
}
bool comparePictureToReference(const QImage &picture)
@@ -220,6 +227,7 @@ void FormatTest::testContact()
QFETCH( Kolab::ObjectType, type );
QFETCH( QString, vcardFileName ); //To compare
QFETCH( QString, mimeFileName ); //For parsing
+ QFETCH( TestMode, mode ); //For parsing
//Parse mime message
bool ok = false;
@@ -259,16 +267,18 @@ void FormatTest::testContact()
QCOMPARE( realAddressee, convertedAddressee );
//Write
- Kolab::overrideTimestamp(Kolab::cDateTime(2012, 5, 5, 5,5,5, true));
- const KMime::Message::Ptr &convertedMime = Kolab::KolabObjectWriter::writeContact(realAddressee, version);
-
- if ( !compareMimeMessage( convertedMime, msg )) {
- QString expected = msg->encodedContent();
- normalizeMimemessage(expected);
- QString converted = convertedMime->encodedContent();
- normalizeMimemessage(converted);
- showDiff(expected, converted);
- QVERIFY( false );
+ if (mode == ReadWrite) {
+ Kolab::overrideTimestamp(Kolab::cDateTime(2012, 5, 5, 5,5,5, true));
+ const KMime::Message::Ptr &convertedMime = Kolab::KolabObjectWriter::writeContact(realAddressee, version);
+
+ if ( !compareMimeMessage( convertedMime, msg )) {
+ QString expected = msg->encodedContent();
+ normalizeMimemessage(expected);
+ QString converted = convertedMime->encodedContent();
+ normalizeMimemessage(converted);
+ showDiff(expected, converted);
+ QVERIFY( false );
+ }
}
QCOMPARE(Kolab::ErrorHandler::instance().error(), Kolab::ErrorHandler::Debug);
}