Port badxml autotest to QMetaObjectBuilder

The meta-object format is going to change for Qt5. Use QMOB to
insulate the badxml test from such changes.

(It just so happens that the QFAIL("a failure") statement is still on
line 109 after the refactoring, so the expected_badxml.* files'
location tags did not have to be changed.)

Change-Id: I04421d13c4df71c8004fa71cafc4823a59079a41
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
(cherry picked from commit 12520e8300)
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
Kent Hansen 2012-02-17 22:45:08 +01:00 committed by Qt by Nokia
parent 91e20fff87
commit 57aba47cde
2 changed files with 16 additions and 16 deletions

View File

@ -1,5 +1,5 @@
SOURCES += tst_badxml.cpp
QT = core testlib
QT = core-private testlib
mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target

View File

@ -42,6 +42,7 @@
#include <QtCore/QCoreApplication>
#include <QtTest/QtTest>
#include <private/qmetaobjectbuilder_p.h>
/*
This test makes a testlog containing lots of characters which have a special meaning in
@ -73,27 +74,26 @@ class EmptyClass : public tst_BadXml
class tst_BadXmlSub : public tst_BadXml
{
public:
tst_BadXmlSub()
: className("tst_BadXml"), mo(0) {}
~tst_BadXmlSub() { qFree(mo); }
const QMetaObject* metaObject() const;
static char const* className;
QByteArray className;
private:
QMetaObject *mo;
};
char const* tst_BadXmlSub::className = "tst_BadXml";
const QMetaObject* tst_BadXmlSub::metaObject() const
{
const QMetaObject& empty = EmptyClass::staticMetaObject;
static QMetaObject mo = {
{ empty.d.superdata, empty.d.stringdata, empty.d.data, empty.d.extradata }
};
static char currentClassName[1024];
qstrcpy(currentClassName, className);
int len = qstrlen(className);
currentClassName[len] = 0;
currentClassName[len+1] = 0;
mo.d.stringdata = currentClassName;
return &mo;
if (!mo || (mo->className() != className)) {
qFree(mo);
QMetaObjectBuilder builder(&EmptyClass::staticMetaObject);
builder.setClassName(className);
const_cast<tst_BadXmlSub *>(this)->mo = builder.toMetaObject();
}
return mo;
}
/*