Fixes to the qdom autotest

Don't rely on a black list of codecs for the serialization
test. This breaks badly when new codecs get added to Qt
(e.g. through ICU). Instead use a white list of known
codecs that can encode/decode the test data.

Change-Id: I1dc55a25e852198bb935f070a4a21e8369f56268
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2012-07-30 09:26:03 +02:00 committed by Qt by Nokia
parent 6c8f8ff1b0
commit 1ee272568b
3 changed files with 14 additions and 147 deletions

View File

@ -1,135 +0,0 @@
apple roman
arabic
asmo-708
big5
big5-0
big5-eten
big5-hkscs
big5hkscs-0
cp1250
cp1251
cp1252
cp1253
cp1254
cp1255
cp1256
cp1257
cp1258
cp819
cp850
cp866
cp874
cp936
cp949
cp950
cshproman8
csibm866
csisolatin1
csisolatin2
csisolatin3
csisolatin4
csisolatin5
csisolatin6
csisolatinarabic
csisolatincyrillic
csisolatingreek
csisolatinhebrew
cskoi8r
cspc850multilingual
cyrillic
ecma-114
ecma-118
euc-jp
euc-kr
gb18030-0
gb2312
gb2312.1980-0
gbk
gbk-0
greek
hebrew
hp-roman8
ibm819
ibm850
ibm866
ibm874
iscii-bng
iscii-dev
iscii-gjr
iscii-knd
iscii-mlm
iscii-ori
iscii-pnj
iscii-tlg
iscii-tml
iso-2022-jp
iso-8859-1
iso-8859-10
iso-8859-10:1992
iso 8859-11
iso-8859-13
iso-8859-14
iso-8859-15
iso-8859-16
iso-8859-2
iso-8859-3
iso-8859-4
iso-8859-5
iso-8859-6
iso-8859-6-i
iso-8859-7
iso-8859-8
iso 8859-8-i
iso-8859-9
iso-celtic
iso-ir-100
iso-ir-101
iso-ir-109
iso-ir-110
iso-ir-126
iso-ir-127
iso-ir-138
iso-ir-144
iso-ir-148
iso-ir-157
iso-ir-199
iso-ir-226
jis7
jisx0201*-0
jisx0208*-0
koi8-r
koi8-ru
koi8-u
ksc5601.1987-0
latin1
latin10
latin2
latin3
latin4
latin5
latin6
latin8
latin9
macintosh
macroman
ms936
ms_kanji
mulelao-1
roman8
shift_jis
sjis
system
tis-620
tscii
windows-1250
windows-1251
windows-1252
windows-1253
windows-1254
windows-1255
windows-1256
windows-1257
windows-1258
windows-936
winsami2
ws2

View File

@ -0,0 +1,6 @@
utf-8
utf-16
utf-16be
utf-16le
utf-32
gb18030

View File

@ -140,7 +140,7 @@ private:
static bool isDeepEqual(const QDomNode &n1, const QDomNode &n2);
static bool isFakeXMLDeclaration(const QDomNode &node);
QList<QByteArray> m_excludedCodecs;
QList<QByteArray> m_testCodecs;
};
Q_DECLARE_METATYPE(QList<QVariant>)
@ -473,15 +473,17 @@ void tst_QDom::save()
void tst_QDom::initTestCase()
{
QString testFile = QFINDTESTDATA("testdata/excludedCodecs.txt");
QString testFile = QFINDTESTDATA("testdata/testCodecs.txt");
if (testFile.isEmpty())
QFAIL("Cannot find testdata/excludedCodecs.txt");
QFAIL("Cannot find testdata/testCodecs.txt");
QFile file(testFile);
QVERIFY(file.open(QIODevice::ReadOnly|QIODevice::Text));
QByteArray codecName;
m_excludedCodecs = file.readAll().split('\n');
m_testCodecs = file.readAll().split('\n');
if (m_testCodecs.last().isEmpty())
m_testCodecs.removeLast();
}
@ -497,14 +499,9 @@ void tst_QDom::saveWithSerialization() const
// Read the document
QVERIFY(doc.setContent(&f));
const QList<QByteArray> codecs(QTextCodec::availableCodecs());
QByteArray codecName;
foreach(codecName, codecs) {
/* Avoid codecs that can't handle the files we have. */
if(m_excludedCodecs.contains(codecName.toLower()))
continue;
foreach (codecName, m_testCodecs) {
/* Write out doc in the specified codec. */
QByteArray storage;
@ -513,8 +510,7 @@ void tst_QDom::saveWithSerialization() const
QTextStream s(&writeDevice);
QTextCodec *codec = QTextCodec::codecForName(codecName);
QVERIFY2(codec, qPrintable(QString::fromLatin1("Failed to load codec %1, even though it was in QTextCodec::availableCodecs()")
.arg(QString::fromLatin1(codecName.constData()))));
QVERIFY2(codec, qPrintable(QString::fromLatin1("Failed to load codec %1").arg(QString::fromLatin1(codecName.constData()))));
s.setCodec(codec);
doc.save(s, 0, QDomNode::EncodingFromTextStream);