diff options
| -rw-r--r-- | CHANGELOG | 5 | ||||
| -rw-r--r-- | src/base/QXmppDataForm.cpp | 5 | ||||
| -rw-r--r-- | tests/tests.cpp | 28 | ||||
| -rw-r--r-- | tests/tests.h | 8 |
4 files changed, 43 insertions, 3 deletions
@@ -1,3 +1,8 @@ +QXmpp 0.6.0 (UNRELEASED) +------------------------ + + - Fix data form title/instructions XML serialization. + QXmpp 0.5.0 (Jul 18, 2012) -------------------------- diff --git a/src/base/QXmppDataForm.cpp b/src/base/QXmppDataForm.cpp index 6bb93668..ef6f7317 100644 --- a/src/base/QXmppDataForm.cpp +++ b/src/base/QXmppDataForm.cpp @@ -451,10 +451,9 @@ void QXmppDataForm::toXml(QXmlStreamWriter *writer) const /* form properties */ if (!d->title.isEmpty()) - writer->writeAttribute("title", d->title); + writer->writeTextElement("title", d->title); if (!d->instructions.isEmpty()) - writer->writeAttribute("instructions", d->instructions); - + writer->writeTextElement("instructions", d->instructions); foreach (const QXmppDataForm::Field &field, d->fields) { writer->writeStartElement("field"); diff --git a/tests/tests.cpp b/tests/tests.cpp index f824b938..223aecd9 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -962,6 +962,31 @@ void TestCodec::testTheoraEncoder() #endif } +void TestDataForm::testSimple() +{ + const QByteArray xml( + "<x xmlns=\"jabber:x:data\" type=\"form\">" + "<title>Search</title>" + "<instructions>Fill out this form to search for information!</instructions>" + "<field type=\"text-single\" var=\"search_request\">" + "<value/>" + "<required/>" + "</field>" + "</x>"); + + QXmppDataForm form; + parsePacket(form, xml); + + QCOMPARE(form.isNull(), false); + QCOMPARE(form.instructions(), QString("Fill out this form to search for information!")); + QCOMPARE(form.fields().size(), 1); + QCOMPARE(form.fields().at(0).type(), QXmppDataForm::Field::TextSingleField); + QCOMPARE(form.fields().at(0).isRequired(), true); + QCOMPARE(form.fields().at(0).key(), QString("search_request")); + + serializePacket(form, xml); +} + void TestJingle::testSession() { const QByteArray xml( @@ -1805,6 +1830,9 @@ int main(int argc, char *argv[]) TestCodec testCodec; errors += QTest::qExec(&testCodec); + TestDataForm testDataForm; + errors += QTest::qExec(&testDataForm); + TestJingle testJingle; errors += QTest::qExec(&testJingle); diff --git a/tests/tests.h b/tests/tests.h index b7f74f7a..b6f2b885 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -85,6 +85,14 @@ private slots: void testTheoraEncoder(); }; +class TestDataForm : public QObject +{ + Q_OBJECT + +private slots: + void testSimple(); +}; + class TestJingle : public QObject { Q_OBJECT |
