aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitrios Apostolou <jimis@qt.io>2020-01-14 15:56:31 +0100
committerDimitrios Apostolou <jimis@qt.io>2020-01-20 11:33:27 +0100
commitd2e589fab2b59995c622eda1e0d95c46b265dea0 (patch)
treeb75afbd674487cd8c6fca0bc3f1337ba2312b227
parent953e04346773beb5d10c3758a12aae5c82646ae1 (diff)
Fix printing of garbled UTF-8 characters from QML verify() statements
Messages that contain QtPositioning.coordinate are including the degree unicode symbol U+00B0. These were printed as garbage from QML tests that use the verify() function. This was caused by the message argument being encoded using toLatin1() on its conversion to const char *. This caused both garbled text and invalid XML output in the test runs, which in turn was causing coin's agent to fail while deserialising the test XML log. This was fixed by changing from toLatin1() to toUtf8(). Since testlib is receiving plain const char * arguments for the "description" argument, it was deemed correct to standardize on UTF-8 as the proper encoding for it, to avoid losing any information (QTBUG-81474). When it's output to the console it can be re-encoded depending on the system's locale, of course. Task-number: QTBUG-81474 Fixes: QTBUG-80527 Change-Id: I0f1fdb7d414d9dfd30d4638b00088c9502c339bd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/qmltest/quicktestresult.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp
index 49552e1901..cddf21c7ed 100644
--- a/src/qmltest/quicktestresult.cpp
+++ b/src/qmltest/quicktestresult.cpp
@@ -480,7 +480,7 @@ static QString qtestFixUrl(const QUrl &location)
void QuickTestResult::fail
(const QString &message, const QUrl &location, int line)
{
- QTestResult::addFailure(message.toLatin1().constData(),
+ QTestResult::addFailure(message.toUtf8().constData(),
qtestFixUrl(location).toLatin1().constData(), line);
}
@@ -493,7 +493,7 @@ bool QuickTestResult::verify
qtestFixUrl(location).toLatin1().constData(), line);
} else {
return QTestResult::verify
- (success, message.toLatin1().constData(), "",
+ (success, message.toUtf8().constData(), "",
qtestFixUrl(location).toLatin1().constData(), line);
}
}
@@ -601,7 +601,7 @@ bool QuickTestResult::compare
const QUrl &location, int line)
{
return QTestResult::compare
- (success, message.toLocal8Bit().constData(),
+ (success, message.toUtf8().constData(),
QTest::toString(val1.toString().toLatin1().constData()),
QTest::toString(val2.toString().toLatin1().constData()),
"", "",
@@ -611,7 +611,7 @@ bool QuickTestResult::compare
void QuickTestResult::skip
(const QString &message, const QUrl &location, int line)
{
- QTestResult::addSkip(message.toLatin1().constData(),
+ QTestResult::addSkip(message.toUtf8().constData(),
qtestFixUrl(location).toLatin1().constData(), line);
QTestResult::setSkipCurrentTest(true);
}
@@ -630,13 +630,13 @@ bool QuickTestResult::expectFailContinue
{
return QTestResult::expectFail
(tag.toLatin1().constData(),
- QTest::toString(comment.toLatin1().constData()),
+ QTest::toString(comment.toUtf8().constData()),
QTest::Continue, qtestFixUrl(location).toLatin1().constData(), line);
}
void QuickTestResult::warn(const QString &message, const QUrl &location, int line)
{
- QTestLog::warn(message.toLatin1().constData(), qtestFixUrl(location).toLatin1().constData(), line);
+ QTestLog::warn(message.toUtf8().constData(), qtestFixUrl(location).toLatin1().constData(), line);
}
void QuickTestResult::ignoreWarning(const QJSValue &message)
@@ -646,7 +646,7 @@ void QuickTestResult::ignoreWarning(const QJSValue &message)
QTestLog::ignoreMessage(QtWarningMsg, message.toVariant().toRegularExpression());
#endif
} else {
- QTestLog::ignoreMessage(QtWarningMsg, message.toString().toLatin1());
+ QTestLog::ignoreMessage(QtWarningMsg, message.toString().toUtf8());
}
}