summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-05-03 15:43:10 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-03 16:11:58 +0200
commit6dac3f18941bd2d66218ec43f08e4fb9be869c63 (patch)
treef2664c9f31d5046f38a1403f46eb0fc162d5242c /tests/auto/corelib
parentb4dabb9e50ce26469b0b7d71e168463abf727334 (diff)
parent1e49914fee099c4c0d634743326b50ad02e6c8f1 (diff)
Merge "Merge remote-tracking branch 'origin/api_changes'" into refs/staging/master
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qlogging/app/main.cpp7
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp48
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp28
-rw-r--r--tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp2
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp9
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp30
6 files changed, 61 insertions, 63 deletions
diff --git a/tests/auto/corelib/global/qlogging/app/main.cpp b/tests/auto/corelib/global/qlogging/app/main.cpp
index dfa52315c7..2f5a975e43 100644
--- a/tests/auto/corelib/global/qlogging/app/main.cpp
+++ b/tests/auto/corelib/global/qlogging/app/main.cpp
@@ -51,8 +51,15 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
app.setApplicationName("tst_qlogging");
+ qSetMessagePattern("[%{type}] %{message}");
+
qDebug("qDebug");
qWarning("qWarning");
qCritical("qCritical");
+
+ qSetMessagePattern(QString());
+
+ qDebug("qDebug2");
+
return 0;
}
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index aaec46fe64..5474b9aa3b 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -73,13 +73,13 @@ int s_line;
const char *s_function;
static QString s_message;
-void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const char *msg)
+void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
s_type = type;
s_file = context.file;
s_line = context.line;
s_function = context.function;
- s_message = QString::fromLocal8Bit(msg);
+ s_message = msg;
}
void customMsgHandler(QtMsgType type, const char *msg)
@@ -101,7 +101,7 @@ void tst_qmessagehandler::initTestCase()
void tst_qmessagehandler::cleanup()
{
qInstallMsgHandler(0);
- qInstallMessageHandler(0);
+ qInstallMessageHandler((QtMessageHandler)0);
s_type = QtFatalMsg;
s_file = 0;
s_line = 0;
@@ -117,7 +117,7 @@ void tst_qmessagehandler::defaultHandler()
void tst_qmessagehandler::installMessageHandler()
{
- QMessageHandler oldHandler = qInstallMessageHandler(customMessageHandler);
+ QtMessageHandler oldHandler = qInstallMessageHandler(customMessageHandler);
qDebug("installMessageHandler"); int line = __LINE__;
@@ -127,7 +127,7 @@ void tst_qmessagehandler::installMessageHandler()
QCOMPARE(s_function, Q_FUNC_INFO);
QCOMPARE(s_line, line);
- QMessageHandler myHandler = qInstallMessageHandler(oldHandler);
+ QtMessageHandler myHandler = qInstallMessageHandler(oldHandler);
QCOMPARE((void*)myHandler, (void*)customMessageHandler);
}
@@ -630,13 +630,16 @@ void tst_qmessagehandler::cleanupFuncinfo()
void tst_qmessagehandler::qMessagePattern()
{
QProcess process;
+ const QString appExe = m_appDir + "/app";
+ //
+ // test QT_MESSAGE_PATTERN
+ //
QStringList environment = QProcess::systemEnvironment();
// %{file} is tricky because of shadow builds
environment.prepend("QT_MESSAGE_PATTERN=\"%{type} %{appname} %{line} %{function} %{message}\"");
process.setEnvironment(environment);
- QString appExe = m_appDir + "/app";
process.start(appExe);
QVERIFY2(process.waitForStarted(), qPrintable(
QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
@@ -649,9 +652,10 @@ void tst_qmessagehandler::qMessagePattern()
QVERIFY(output.contains("debug 45 T::T static constructor"));
// we can't be sure whether the QT_MESSAGE_PATTERN is already destructed
QVERIFY(output.contains("static destructor"));
- QVERIFY(output.contains("debug tst_qlogging 54 main qDebug"));
- QVERIFY(output.contains("warning tst_qlogging 55 main qWarning"));
- QVERIFY(output.contains("critical tst_qlogging 56 main qCritical"));
+ QVERIFY(output.contains("debug tst_qlogging 56 main qDebug"));
+ QVERIFY(output.contains("warning tst_qlogging 57 main qWarning"));
+ QVERIFY(output.contains("critical tst_qlogging 58 main qCritical"));
+ QVERIFY(output.contains("debug tst_qlogging 62 main qDebug2"));
environment = QProcess::systemEnvironment();
environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{message}\"");
@@ -668,6 +672,32 @@ void tst_qmessagehandler::qMessagePattern()
QVERIFY(output.contains("QT_MESSAGE_PATTERN: Unknown placeholder %{unknown}"));
QVERIFY(output.contains("PREFIX: qDebug"));
+
+ //
+ // test qSetMessagePattern
+ //
+ QMutableListIterator<QString> iter(environment);
+ while (iter.hasNext()) {
+ if (iter.next().startsWith("QT_MESSAGE_PATTERN"))
+ iter.remove();
+ }
+ process.setEnvironment(environment);
+
+ process.start(appExe);
+ QVERIFY2(process.waitForStarted(), qPrintable(
+ QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
+ process.waitForFinished();
+
+ output = process.readAllStandardError();
+ //qDebug() << output;
+ QByteArray expected = "static constructor\n"
+ "[debug] qDebug\n"
+ "[warning] qWarning\n"
+ "[critical] qCritical\n";
+#ifdef Q_OS_WIN
+ output.replace("\r\n", "\n");
+#endif
+ QCOMPARE(QString::fromLatin1(output), QString::fromLatin1(expected));
}
QTEST_MAIN(tst_qmessagehandler)
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 12f7e28a1d..035c781e4a 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -74,12 +74,12 @@ void tst_QDebug::assignment() const
}
static QtMsgType s_msgType;
-static QByteArray s_msg;
+static QString s_msg;
static QByteArray s_file;
static int s_line;
static QByteArray s_function;
-static void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const char *msg)
+static void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
s_msg = msg;
s_msgType = type;
@@ -94,7 +94,7 @@ static void myMessageHandler(QtMsgType type, const QMessageLogContext &context,
class MessageHandlerSetter
{
public:
- MessageHandlerSetter(QMessageHandler newMessageHandler)
+ MessageHandlerSetter(QtMessageHandler newMessageHandler)
: oldMessageHandler(qInstallMessageHandler(newMessageHandler))
{ }
@@ -104,7 +104,7 @@ public:
}
private:
- QMessageHandler oldMessageHandler;
+ QtMessageHandler oldMessageHandler;
};
/*! \internal
@@ -116,7 +116,7 @@ void tst_QDebug::warningWithoutDebug() const
{ qWarning() << "A qWarning() message"; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtWarningMsg);
- QCOMPARE(QString::fromLatin1(s_msg.data()), QString::fromLatin1("A qWarning() message "));
+ QCOMPARE(s_msg, QString::fromLatin1("A qWarning() message "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -131,7 +131,7 @@ void tst_QDebug::criticalWithoutDebug() const
{ qCritical() << "A qCritical() message"; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtCriticalMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("A qCritical() message "));
+ QCOMPARE(s_msg, QString::fromLatin1("A qCritical() message "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -143,7 +143,7 @@ void tst_QDebug::debugWithBool() const
{ qDebug() << false << true; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("false true "));
+ QCOMPARE(s_msg, QString::fromLatin1("false true "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -161,7 +161,7 @@ void tst_QDebug::veryLongWarningMessage() const
}
QString file = __FILE__; int line = __LINE__ - 2; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtWarningMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("Test output:\n")+test+QString::fromLatin1("\nend"));
+ QCOMPARE(s_msg, QString::fromLatin1("Test output:\n")+test+QString::fromLatin1("\nend"));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -178,7 +178,7 @@ void tst_QDebug::qDebugQStringRef() const
{ qDebug() << inRef; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"input\" "));
+ QCOMPARE(s_msg, QString::fromLatin1("\"input\" "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -192,7 +192,7 @@ void tst_QDebug::qDebugQStringRef() const
{ qDebug() << inRef; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"\" "));
+ QCOMPARE(s_msg, QString::fromLatin1("\"\" "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -205,7 +205,7 @@ void tst_QDebug::qDebugQLatin1String() const
{ qDebug() << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3); }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"foo\" \"\" \"bar\" "));
+ QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -214,11 +214,11 @@ void tst_QDebug::qDebugQLatin1String() const
void tst_QDebug::defaultMessagehandler() const
{
MessageHandlerSetter mhs(0);
- QMessageHandler defaultMessageHandler1 = qInstallMessageHandler(0);
- QMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler);
+ QtMessageHandler defaultMessageHandler1 = qInstallMessageHandler((QtMessageHandler)0);
+ QtMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler);
bool same = (*defaultMessageHandler1 == *defaultMessageHandler2);
QVERIFY(same);
- QMessageHandler messageHandler = qInstallMessageHandler(0);
+ QtMessageHandler messageHandler = qInstallMessageHandler((QtMessageHandler)0);
same = (*messageHandler == *myMessageHandler);
QVERIFY(same);
}
diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
index f9a6bae087..dc9fc19a21 100644
--- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
+++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
@@ -97,7 +97,7 @@ void tst_QMimeData::colorData() const
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), red);
// change, verify
- mimeData.setColorData(Qt::blue);
+ mimeData.setColorData(QColor(Qt::blue));
QVERIFY(mimeData.hasColor());
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), blue);
}
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 869eaf45b7..569e448d88 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -237,8 +237,6 @@ private slots:
void saveLoadCustomTypes();
- void globalColor();
-
void variantMap();
void variantHash();
@@ -2510,13 +2508,6 @@ void tst_QVariant::url()
QCOMPARE(v3.toString(), str);
}
-void tst_QVariant::globalColor()
-{
- QVariant variant(Qt::blue);
- QVERIFY(variant.type() == QVariant::Color);
- QVERIFY(qvariant_cast<QColor>(variant) == QColor(Qt::blue));
-}
-
void tst_QVariant::variantMap()
{
QMap<QString, QVariant> map;
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 2badbc2133..d0f82a38b7 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -107,21 +107,6 @@ void runScenario()
QCOMPARE(r, r3);
#endif
- {
- static const QStaticStringData<12> literalData = {
- Q_STATIC_STRING_DATA_HEADER_INITIALIZER(12),
- { 's', 'o', 'm', 'e', ' ', 'l', 'i', 't', 'e', 'r', 'a', 'l' }
- };
- static QStringDataPtr literal = { literalData.data_ptr() };
-
- r = literal;
- QCOMPARE(r, string);
- r = r Q literal;
- QCOMPARE(r, r2);
- r = literal Q literal;
- QCOMPARE(r, r2);
- }
-
#ifndef QT_NO_CAST_FROM_ASCII
r = string P LITERAL;
QCOMPARE(r, r2);
@@ -226,21 +211,6 @@ void runScenario()
QCOMPARE(r, ba);
}
- {
- static const QStaticByteArrayData<12> literalData = {
- Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(12),
- { 's', 'o', 'm', 'e', ' ', 'l', 'i', 't', 'e', 'r', 'a', 'l' }
- };
- static QByteArrayDataPtr literal = { literalData.data_ptr() };
-
- QByteArray ba = literal;
- QCOMPARE(ba, QByteArray(LITERAL));
- ba = ba Q literal;
- QCOMPARE(ba, QByteArray(LITERAL LITERAL));
- ba = literal Q literal;
- QCOMPARE(ba, QByteArray(LITERAL LITERAL));
- }
-
//operator QString +=
{
QString str = QString::fromUtf8(UTF8_LITERAL);