Reduce amount of log output of the qcomplextext autotest

Writing out one test result per line in the test data files is
excessive and only bloats the log, given that this algorithm
is rarely changed.

Task-number: QTQAINFRA-2037
Change-Id: Ib9e568c7ded73d45e4b64671e97d5581a74f8f93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2018-06-30 19:03:48 +02:00 committed by Liang Qi
parent 35e005bc4f
commit e75e4b39b7

View File

@ -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<QString>("data");
QTest::addColumn<int>("paragraphDirection");
QTest::addColumn<QVector<int>>("resolvedLevels");
QTest::addColumn<QVector<int>>("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<QByteArray> parts = line.split(';');
QVERIFY(parts.size() == 5);
QString data;
QList<QByteArray> 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<int> resolvedLevels;
QList<QByteArray> 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<int> visualOrder;
QList<QByteArray> 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<int> &resolvedLevels, const QVector<int> &visualOrder)
{
Q_UNUSED(resolvedLevels);
@ -421,13 +358,60 @@ static void testBidiString(const QString &data, int paragraphDirection, const QV
void tst_QComplexText::bidiCharacterTest()
{
QFETCH(QString, data);
QFETCH(int, paragraphDirection);
QFETCH(QVector<int>, resolvedLevels);
QFETCH(QVector<int>, 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<QByteArray> parts = line.split(';');
QVERIFY(parts.size() == 5);
QString data;
QList<QByteArray> 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<int> resolvedLevels;
QList<QByteArray> 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<int> visualOrder;
QList<QByteArray> 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<QString>("data");
QTest::addColumn<int>("paragraphDirection");
QTest::addColumn<QVector<int>>("resolvedLevels");
QTest::addColumn<QVector<int>>("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<int>, resolvedLevels);
QFETCH(QVector<int>, visualOrder);
testBidiString(data, paragraphDirection, resolvedLevels, visualOrder);
}