From db39d34c691cf201830fe221ea72982071809247 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Fri, 3 Aug 2012 13:10:22 +0200 Subject: split vCard tests to their own file --- tests/vcard.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/vcard.cpp (limited to 'tests/vcard.cpp') diff --git a/tests/vcard.cpp b/tests/vcard.cpp new file mode 100644 index 00000000..f7145ae9 --- /dev/null +++ b/tests/vcard.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2008-2012 The QXmpp developers + * + * Author: + * Jeremy Lainé + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include "QXmppVCardIq.h" + +#include "tests.h" +#include "vcard.h" + +void tst_QXmppVCardIq::testVCard() +{ + const QByteArray xml( + "" + "" + "1983-09-14" + "foo.bar@example.com" + "Foo Bar!" + "FooBar" + "FooWizBaz" + "" + "image/png" + "" + "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA" + "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP" + "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC" + "" + "" + "" + ""); + + QXmppVCardIq vcard; + parsePacket(vcard, xml); + QCOMPARE(vcard.birthday(), QDate(1983, 9, 14)); + QCOMPARE(vcard.email(), QLatin1String("foo.bar@example.com")); + QCOMPARE(vcard.nickName(), QLatin1String("FooBar")); + QCOMPARE(vcard.fullName(), QLatin1String("Foo Bar!")); + QCOMPARE(vcard.firstName(), QLatin1String("Foo")); + QCOMPARE(vcard.middleName(), QLatin1String("Baz")); + QCOMPARE(vcard.lastName(), QLatin1String("Wiz")); + QCOMPARE(vcard.photo(), QByteArray::fromBase64( + "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA" + "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP" + "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC")); + QCOMPARE(vcard.photoType(), QLatin1String("image/png")); + serializePacket(vcard, xml); +} -- cgit v1.2.3