diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp index 812cd8f369..0116e546a0 100644 --- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp @@ -48,9 +48,7 @@ private slots: void bidiInvalidCursorNoMovement_data(); void bidiInvalidCursorNoMovement(); - void bidiCharacterTest_data(); void bidiCharacterTest(); - void bidiTest_data(); void bidiTest(); }; @@ -279,67 +277,6 @@ void tst_QComplexText::bidiCursor_PDF() QVERIFY(line.cursorToX(size) == line.cursorToX(size - 1)); } -void tst_QComplexText::bidiCharacterTest_data() -{ - QTest::addColumn("data"); - QTest::addColumn("paragraphDirection"); - QTest::addColumn>("resolvedLevels"); - QTest::addColumn>("visualOrder"); - - QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt"); - QFile f(testFile); - QVERIFY(f.exists()); - - f.open(QIODevice::ReadOnly); - - int linenum = 0; - while (!f.atEnd()) { - linenum++; - - QByteArray line = f.readLine().simplified(); - if (line.startsWith('#') || line.isEmpty()) - continue; - QVERIFY(!line.contains('#')); - - QList parts = line.split(';'); - QVERIFY(parts.size() == 5); - - QString data; - QList dataParts = parts.at(0).split(' '); - for (const auto &p : dataParts) { - bool ok; - data += QChar((ushort)p.toInt(&ok, 16)); - QVERIFY(ok); - } - - int paragraphDirection = parts.at(1).toInt(); -// int resolvedParagraphLevel = parts.at(2).toInt(); - - QVector resolvedLevels; - QList levelParts = parts.at(3).split(' '); - for (const auto &p : levelParts) { - if (p == "x") { - resolvedLevels += -1; - } else { - bool ok; - resolvedLevels += p.toInt(&ok); - QVERIFY(ok); - } - } - - QVector visualOrder; - QList orderParts = parts.at(4).split(' '); - for (const auto &p : orderParts) { - bool ok; - visualOrder += p.toInt(&ok); - QVERIFY(ok); - } - - const QByteArray nm = "line #" + QByteArray::number(linenum); - QTest::newRow(nm.constData()) << data << paragraphDirection << resolvedLevels << visualOrder; - } -} - static void testBidiString(const QString &data, int paragraphDirection, const QVector &resolvedLevels, const QVector &visualOrder) { Q_UNUSED(resolvedLevels); @@ -421,12 +358,59 @@ static void testBidiString(const QString &data, int paragraphDirection, const QV void tst_QComplexText::bidiCharacterTest() { - QFETCH(QString, data); - QFETCH(int, paragraphDirection); - QFETCH(QVector, resolvedLevels); - QFETCH(QVector, visualOrder); + QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt"); + QFile f(testFile); + QVERIFY(f.exists()); - testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); + f.open(QIODevice::ReadOnly); + + int linenum = 0; + while (!f.atEnd()) { + linenum++; + + QByteArray line = f.readLine().simplified(); + if (line.startsWith('#') || line.isEmpty()) + continue; + QVERIFY(!line.contains('#')); + + QList parts = line.split(';'); + QVERIFY(parts.size() == 5); + + QString data; + QList dataParts = parts.at(0).split(' '); + for (const auto &p : dataParts) { + bool ok; + data += QChar((ushort)p.toInt(&ok, 16)); + QVERIFY(ok); + } + + int paragraphDirection = parts.at(1).toInt(); +// int resolvedParagraphLevel = parts.at(2).toInt(); + + QVector resolvedLevels; + QList levelParts = parts.at(3).split(' '); + for (const auto &p : levelParts) { + if (p == "x") { + resolvedLevels += -1; + } else { + bool ok; + resolvedLevels += p.toInt(&ok); + QVERIFY(ok); + } + } + + QVector visualOrder; + QList orderParts = parts.at(4).split(' '); + for (const auto &p : orderParts) { + bool ok; + visualOrder += p.toInt(&ok); + QVERIFY(ok); + } + + const QByteArray nm = "line #" + QByteArray::number(linenum); + + testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); + } } ushort unicodeForDirection(const QByteArray &direction) @@ -466,13 +450,8 @@ ushort unicodeForDirection(const QByteArray &direction) Q_UNREACHABLE(); } -void tst_QComplexText::bidiTest_data() +void tst_QComplexText::bidiTest() { - QTest::addColumn("data"); - QTest::addColumn("paragraphDirection"); - QTest::addColumn>("resolvedLevels"); - QTest::addColumn>("visualOrder"); - QString testFile = QFINDTESTDATA("data/BidiTest.txt"); QFile f(testFile); QVERIFY(f.exists()); @@ -534,24 +513,13 @@ void tst_QComplexText::bidiTest_data() const QByteArray nm = "line #" + QByteArray::number(linenum); if (paragraphDirections & 1) - QTest::newRow((nm + " (Auto)").constData()) << data << 2 << resolvedLevels << visualOrder; + testBidiString(data, 2, resolvedLevels, visualOrder); if (paragraphDirections & 2) - QTest::newRow((nm + " (LTR)").constData()) << data << 0 << resolvedLevels << visualOrder; + testBidiString(data, 0, resolvedLevels, visualOrder); if (paragraphDirections & 4) - QTest::newRow((nm + " (RTL)").constData()) << data << 1 << resolvedLevels << visualOrder; + testBidiString(data, 1, resolvedLevels, visualOrder); } - -} - -void tst_QComplexText::bidiTest() -{ - QFETCH(QString, data); - QFETCH(int, paragraphDirection); - QFETCH(QVector, resolvedLevels); - QFETCH(QVector, visualOrder); - - testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); }