qtestcase.cpp: s/QString::fromLatin1/QLatin1String/ where viable
Now that QL1S has its own arg(), we can use that directly instead of going via QString before calling arg(). Only works in most cases, as the QL1S::arg() overload set is more limited. Change-Id: Ie4c566c5998538b1b8a953b1ba4481e0f1663bf7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
adad2a468d
commit
f3184770e2
@ -446,7 +446,7 @@ static void qPrintTestSlots(FILE *stream, const char *filter = nullptr)
|
||||
QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
|
||||
if (isValidSlot(sl)) {
|
||||
const QByteArray signature = sl.methodSignature();
|
||||
if (!filter || QString::fromLatin1(signature).contains(QLatin1String(filter), Qt::CaseInsensitive))
|
||||
if (!filter || QLatin1String(signature).contains(QLatin1String(filter), Qt::CaseInsensitive))
|
||||
fprintf(stream, "%s\n", signature.constData());
|
||||
}
|
||||
}
|
||||
@ -2379,7 +2379,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
else if (QTestLog::verboseLevel() >= 2) {
|
||||
const QString candidate = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QLatin1Char('/') + base);
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found relative to test binary [%2]; "
|
||||
QLatin1String("testdata %1 not found relative to test binary [%2]; "
|
||||
"checking next location").arg(base, candidate)),
|
||||
file, line);
|
||||
}
|
||||
@ -2390,13 +2390,13 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
const char *testObjectName = QTestResult::currentTestObjectName();
|
||||
if (testObjectName) {
|
||||
const QString testsPath = QLibraryInfo::path(QLibraryInfo::TestsPath);
|
||||
const QString candidate = QString::fromLatin1("%1/%2/%3")
|
||||
const QString candidate = QLatin1String("%1/%2/%3")
|
||||
.arg(testsPath, QFile::decodeName(testObjectName).toLower(), base);
|
||||
if (QFileInfo::exists(candidate)) {
|
||||
found = candidate;
|
||||
} else if (QTestLog::verboseLevel() >= 2) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found in tests install path [%2]; "
|
||||
QLatin1String("testdata %1 not found in tests install path [%2]; "
|
||||
"checking next location")
|
||||
.arg(base, QDir::toNativeSeparators(candidate))),
|
||||
file, line);
|
||||
@ -2416,12 +2416,12 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
}
|
||||
|
||||
const QString canonicalPath = srcdir.canonicalFilePath();
|
||||
const QString candidate = QString::fromLatin1("%1/%2").arg(canonicalPath, base);
|
||||
const QString candidate = QLatin1String("%1/%2").arg(canonicalPath, base);
|
||||
if (!canonicalPath.isEmpty() && QFileInfo::exists(candidate)) {
|
||||
found = candidate;
|
||||
} else if (QTestLog::verboseLevel() >= 2) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found relative to source path [%2]")
|
||||
QLatin1String("testdata %1 not found relative to source path [%2]")
|
||||
.arg(base, QDir::toNativeSeparators(candidate))),
|
||||
file, line);
|
||||
}
|
||||
@ -2429,12 +2429,12 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
|
||||
// 4. Try resources
|
||||
if (found.isEmpty()) {
|
||||
const QString candidate = QString::fromLatin1(":/%1").arg(base);
|
||||
const QString candidate = QLatin1String(":/%1").arg(base);
|
||||
if (QFileInfo::exists(candidate)) {
|
||||
found = candidate;
|
||||
} else if (QTestLog::verboseLevel() >= 2) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found in resources [%2]")
|
||||
QLatin1String("testdata %1 not found in resources [%2]")
|
||||
.arg(base, QDir::toNativeSeparators(candidate))),
|
||||
file, line);
|
||||
}
|
||||
@ -2447,7 +2447,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
found = candidate;
|
||||
} else if (QTestLog::verboseLevel() >= 2) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found in current directory [%2]")
|
||||
QLatin1String("testdata %1 not found in current directory [%2]")
|
||||
.arg(base, QDir::toNativeSeparators(candidate))),
|
||||
file, line);
|
||||
}
|
||||
@ -2460,7 +2460,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
found = candidate;
|
||||
} else if (QTestLog::verboseLevel() >= 2) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found in main source directory [%2]")
|
||||
QLatin1String("testdata %1 not found in main source directory [%2]")
|
||||
.arg(base, QDir::toNativeSeparators(candidate))),
|
||||
file, line);
|
||||
}
|
||||
@ -2473,7 +2473,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
found = candidate;
|
||||
} else if (QTestLog::verboseLevel() >= 2) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 not found in supplied source directory [%2]")
|
||||
QLatin1String("testdata %1 not found in supplied source directory [%2]")
|
||||
.arg(base, QDir::toNativeSeparators(candidate))),
|
||||
file, line);
|
||||
}
|
||||
@ -2482,11 +2482,11 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
|
||||
|
||||
if (found.isEmpty()) {
|
||||
QTestLog::warn(qPrintable(
|
||||
QString::fromLatin1("testdata %1 could not be located!").arg(base)),
|
||||
QLatin1String("testdata %1 could not be located!").arg(base)),
|
||||
file, line);
|
||||
} else if (QTestLog::verboseLevel() >= 1) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("testdata %1 was located at %2").arg(base, QDir::toNativeSeparators(found))),
|
||||
QLatin1String("testdata %1 was located at %2").arg(base, QDir::toNativeSeparators(found))),
|
||||
file, line);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user