summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-05-22 07:44:45 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-05-22 07:46:17 +0200
commit508b95899d4764d879a01b3990e44ce849cd9abc (patch)
tree3dbb215480c98ee75b5aacc5e3d691e04d8ce8c8 /tests
parentf2891be00808c82f5069661d60d8727fe28774b7 (diff)
parent5d2939344eb8fbd3c2115f52a7a8d47365bdf820 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp96
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp9
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp8
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp17
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp14
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp11
-rw-r--r--tests/auto/network/bearer/bearer.pro1
-rw-r--r--tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro6
-rw-r--r--tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp73
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp14
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp2
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp6
-rw-r--r--tests/auto/widgets/widgets/qmenu/qmenu.pro5
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp23
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu_mac.mm59
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp45
16 files changed, 359 insertions, 30 deletions
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
index 12b81ee7d4..54e8f8c386 100644
--- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
@@ -80,6 +80,9 @@ private slots:
void utf8bom_data();
void utf8bom();
+ void utf8stateful_data();
+ void utf8stateful();
+
void utfHeaders_data();
void utfHeaders();
@@ -1611,6 +1614,99 @@ void tst_QTextCodec::utf8bom()
QCOMPARE(codec->toUnicode(data.constData(), data.length(), &state), result);
}
+void tst_QTextCodec::utf8stateful_data()
+{
+ QTest::addColumn<QByteArray>("buffer1");
+ QTest::addColumn<QByteArray>("buffer2");
+ QTest::addColumn<QString>("result"); // null QString indicates decoder error
+
+ // valid buffer continuations
+ QTest::newRow("1of2+valid") << QByteArray("\xc2") << QByteArray("\xa0") << "\xc2\xa0";
+ QTest::newRow("1of3+valid") << QByteArray("\xe0") << QByteArray("\xa0\x80") << "\xe0\xa0\x80";
+ QTest::newRow("2of3+valid") << QByteArray("\xe0\xa0") << QByteArray("\x80") << "\xe0\xa0\x80";
+ QTest::newRow("1of4+valid") << QByteArray("\360") << QByteArray("\220\210\203") << "\360\220\210\203";
+ QTest::newRow("2of4+valid") << QByteArray("\360\220") << QByteArray("\210\203") << "\360\220\210\203";
+ QTest::newRow("3of4+valid") << QByteArray("\360\220\210") << QByteArray("\203") << "\360\220\210\203";
+ QTest::newRow("1ofBom+valid") << QByteArray("\xef") << QByteArray("\xbb\xbf") << "";
+ QTest::newRow("2ofBom+valid") << QByteArray("\xef\xbb") << QByteArray("\xbf") << "";
+
+ // invalid continuation
+ QTest::newRow("1of2+invalid") << QByteArray("\xc2") << QByteArray("a") << QString();
+ QTest::newRow("1of3+invalid") << QByteArray("\xe0") << QByteArray("a") << QString();
+ QTest::newRow("2of3+invalid") << QByteArray("\xe0\xa0") << QByteArray("a") << QString();
+ QTest::newRow("1of4+invalid") << QByteArray("\360") << QByteArray("a") << QString();
+ QTest::newRow("2of4+invalid") << QByteArray("\360\220") << QByteArray("a") << QString();
+ QTest::newRow("3of4+invalid") << QByteArray("\360\220\210") << QByteArray("a") << QString();
+
+ // invalid: sequence too short (the empty second buffer causes a state reset)
+ QTest::newRow("1of2+empty") << QByteArray("\xc2") << QByteArray() << QString();
+ QTest::newRow("1of3+empty") << QByteArray("\xe0") << QByteArray() << QString();
+ QTest::newRow("2of3+empty") << QByteArray("\xe0\xa0") << QByteArray() << QString();
+ QTest::newRow("1of4+empty") << QByteArray("\360") << QByteArray() << QString();
+ QTest::newRow("2of4+empty") << QByteArray("\360\220") << QByteArray() << QString();
+ QTest::newRow("3of4+empty") << QByteArray("\360\220\210") << QByteArray() << QString();
+
+ // overlong sequence:
+ QTest::newRow("overlong-1of2") << QByteArray("\xc1") << QByteArray("\x81") << QString();
+ QTest::newRow("overlong-1of3") << QByteArray("\xe0") << QByteArray("\x81\x81") << QString();
+ QTest::newRow("overlong-2of3") << QByteArray("\xe0\x81") << QByteArray("\x81") << QString();
+ QTest::newRow("overlong-1of4") << QByteArray("\xf0") << QByteArray("\x80\x81\x81") << QString();
+ QTest::newRow("overlong-2of4") << QByteArray("\xf0\x80") << QByteArray("\x81\x81") << QString();
+ QTest::newRow("overlong-3of4") << QByteArray("\xf0\x80\x81") << QByteArray("\x81") << QString();
+
+ // out of range:
+ // leading byte 0xF4 can produce codepoints above U+10FFFF, which aren't valid
+ QTest::newRow("outofrange1-1of4") << QByteArray("\xf4") << QByteArray("\x90\x80\x80") << QString();
+ QTest::newRow("outofrange1-2of4") << QByteArray("\xf4\x90") << QByteArray("\x80\x80") << QString();
+ QTest::newRow("outofrange1-3of4") << QByteArray("\xf4\x90\x80") << QByteArray("\x80") << QString();
+ QTest::newRow("outofrange2-1of4") << QByteArray("\xf5") << QByteArray("\x90\x80\x80") << QString();
+ QTest::newRow("outofrange2-2of4") << QByteArray("\xf5\x90") << QByteArray("\x80\x80") << QString();
+ QTest::newRow("outofrange2-3of4") << QByteArray("\xf5\x90\x80") << QByteArray("\x80") << QString();
+ QTest::newRow("outofrange-1of5") << QByteArray("\xf8") << QByteArray("\x88\x80\x80\x80") << QString();
+ QTest::newRow("outofrange-2of5") << QByteArray("\xf8\x88") << QByteArray("\x80\x80\x80") << QString();
+ QTest::newRow("outofrange-3of5") << QByteArray("\xf8\x88\x80") << QByteArray("\x80\x80") << QString();
+ QTest::newRow("outofrange-4of5") << QByteArray("\xf8\x88\x80\x80") << QByteArray("\x80") << QString();
+ QTest::newRow("outofrange-1of6") << QByteArray("\xfc") << QByteArray("\x84\x80\x80\x80\x80") << QString();
+ QTest::newRow("outofrange-2of6") << QByteArray("\xfc\x84") << QByteArray("\x80\x80\x80\x80") << QString();
+ QTest::newRow("outofrange-3of6") << QByteArray("\xfc\x84\x80") << QByteArray("\x80\x80\x80") << QString();
+ QTest::newRow("outofrange-4of6") << QByteArray("\xfc\x84\x80\x80") << QByteArray("\x80\x80") << QString();
+ QTest::newRow("outofrange-5of6") << QByteArray("\xfc\x84\x80\x80\x80") << QByteArray("\x80") << QString();
+}
+
+void tst_QTextCodec::utf8stateful()
+{
+ QFETCH(QByteArray, buffer1);
+ QFETCH(QByteArray, buffer2);
+ QFETCH(QString, result);
+
+ QTextCodec *utf8codec = QTextCodec::codecForName("utf-8");
+ QVERIFY(utf8codec);
+
+ QTextCodec::ConverterState state;
+ memset(&state, 0, sizeof state);
+
+ QString decoded1 = utf8codec->toUnicode(buffer1, buffer1.size(), &state);
+ if (result.isNull()) {
+ // the decoder may have found an early error (invalidChars > 0):
+ // if it has, remainingChars == 0;
+ // if it hasn't, then it must have a state
+ QVERIFY2((state.remainingChars == 0) != (state.invalidChars == 0),
+ "remainingChars = " + QByteArray::number(state.remainingChars) +
+ "; invalidChars = " + QByteArray::number(state.invalidChars));
+ } else {
+ QVERIFY(state.remainingChars > 0);
+ QCOMPARE(state.invalidChars, 0);
+ }
+
+ QString decoded2 = utf8codec->toUnicode(buffer2, buffer2.size(), &state);
+ QCOMPARE(state.remainingChars, 0);
+ if (result.isNull()) {
+ QVERIFY(state.invalidChars > 0);
+ } else {
+ QCOMPARE(decoded1 + decoded2, result);
+ }
+}
+
void tst_QTextCodec::utfHeaders_data()
{
QTest::addColumn<QByteArray>("codecName");
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 6c147d68c8..8174cd942f 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -1073,10 +1073,8 @@ void tst_QFileInfo::fileTimes()
#endif
#if defined(Q_OS_WINCE)
QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue);
-#elif defined(Q_OS_BLACKBERRY)
- QEXPECT_FAIL("simple", "Blackberry OS uses the noatime filesystem option", Continue);
- QEXPECT_FAIL("longfile", "Blackberry OS uses the noatime filesystem option", Continue);
- QEXPECT_FAIL("longfile absolutepath", "Blackberry OS uses the noatime filesystem option", Continue);
+#elif defined(Q_OS_QNX)
+ QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue);
#endif
QVERIFY(fileInfo.lastRead() > beforeRead);
QVERIFY(fileInfo.lastModified() > beforeWrite);
@@ -1511,8 +1509,7 @@ void tst_QFileInfo::isWritable()
QVERIFY(fi.exists());
QVERIFY(!fi.isWritable());
#endif
-#if defined (Q_OS_BLACKBERRY)
- // The Blackberry filesystem is read-only
+#if defined (Q_OS_QNX) // On QNX /etc is usually on a read-only filesystem
QVERIFY(!QFileInfo("/etc/passwd").isWritable());
#elif defined (Q_OS_UNIX) && !defined(Q_OS_VXWORKS) // VxWorks does not have users/groups
if (::getuid() == 0)
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index fdb29b60d8..bd9e28beb5 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -44,6 +44,9 @@
#include <QtConcurrentRun>
#include <qlockfile.h>
#include <qtemporarydir.h>
+#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
+#include <unistd.h>
+#endif
class tst_QLockFile : public QObject
{
@@ -365,9 +368,12 @@ void tst_QLockFile::staleLockRace()
void tst_QLockFile::noPermissions()
{
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN)
// A readonly directory still allows us to create files, on Windows.
QSKIP("No permission testing on Windows");
+#elif defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
+ if (::geteuid() == 0)
+ QSKIP("Test is not applicable with root privileges");
#endif
// Restore permissions so that the QTemporaryDir cleanup can happen
class PermissionRestorer
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index 04c083e653..87bcfe572d 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -47,9 +47,8 @@
#include <qdir.h>
#include <qset.h>
-#if defined(Q_OS_UNIX)
-# include <unistd.h> // for geteuid
-# include <sys/types.h>
+#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
+#include <unistd.h> // for geteuid
#endif
#if defined(Q_OS_WIN)
@@ -199,6 +198,10 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir_data()
void tst_QSaveFile::transactionalWriteNoPermissionsOnDir()
{
#ifdef Q_OS_UNIX
+#if !defined(Q_OS_VXWORKS)
+ if (::geteuid() == 0)
+ QSKIP("Test is not applicable with root privileges");
+#endif
QFETCH(bool, directWriteFallback);
QTemporaryDir dir;
QVERIFY(dir.isValid());
@@ -253,6 +256,10 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir()
void tst_QSaveFile::transactionalWriteNoPermissionsOnFile()
{
+#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
+ if (::geteuid() == 0)
+ QSKIP("Test is not applicable with root privileges");
+#endif
// Setup an existing but readonly file
QTemporaryDir dir;
QVERIFY(dir.isValid());
@@ -299,6 +306,10 @@ void tst_QSaveFile::transactionalWriteCanceled()
void tst_QSaveFile::transactionalWriteErrorRenaming()
{
+#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
+ if (::geteuid() == 0)
+ QSKIP("Test is not applicable with root privileges");
+#endif
QTemporaryDir dir;
QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 8f9376f8b6..8559b8ab96 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -2549,7 +2549,7 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(msecBefore.isValid());
QCOMPARE(msecBefore.date(), QDate(2012, 10, 28));
QCOMPARE(msecBefore.time(), QTime(2, 59, 59, 999));
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(Q_OS_QNX)
// Win and Mac uses SecondOccurrence here
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_MAC
@@ -2571,7 +2571,7 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(afterTran.isValid());
QCOMPARE(afterTran.date(), QDate(2012, 10, 28));
QCOMPARE(afterTran.time(), QTime(2, 59, 59, 999));
-#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
+#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
// Linux mktime bug uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_UNIX
@@ -2629,7 +2629,7 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#ifndef Q_OS_MAC
+#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
// Linux mktime bug uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_MAC
@@ -2671,7 +2671,7 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#ifndef Q_OS_MAC
+#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
// Linux mktime bug uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_MAC
@@ -2713,7 +2713,7 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#ifndef Q_OS_MAC
+#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX)
// Linux mktime bug uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_MAC
@@ -2778,12 +2778,12 @@ void tst_QDateTime::daylightTransitions() const
test = test.addMSecs(msecsOneHour);
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC) || defined(Q_OS_QNX)
// Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_WIN
QCOMPARE(test.time(), QTime(3, 0, 0));
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC) || defined(Q_OS_QNX)
// Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_WIN
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
index 08c7148342..2c45b7d2ec 100644
--- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
@@ -99,6 +99,8 @@ private slots:
void rawFontSetPixelSize();
void multipleRawFontsFromData();
+
+ void rawFontFromInvalidData();
private:
QString testFont;
QString testFontBoldItalic;
@@ -942,6 +944,15 @@ void tst_QRawFont::multipleRawFontsFromData()
|| testFont.style() != (testFontBoldItalic.style()));
}
+void tst_QRawFont::rawFontFromInvalidData()
+{
+ QByteArray invalidData("foobar");
+ QRawFont font;
+ font.loadFromData(invalidData, 10, QFont::PreferDefaultHinting);
+
+ QVERIFY(!font.isValid());
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QRawFont)
diff --git a/tests/auto/network/bearer/bearer.pro b/tests/auto/network/bearer/bearer.pro
index 872a818e4c..6ce922eaf8 100644
--- a/tests/auto/network/bearer/bearer.pro
+++ b/tests/auto/network/bearer/bearer.pro
@@ -2,5 +2,6 @@ TEMPLATE=subdirs
SUBDIRS=\
qnetworkconfiguration \
qnetworkconfigurationmanager \
+ qnetworkconfigurationmanagerqappless \
qnetworksession \
diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro
new file mode 100644
index 0000000000..ad080910d7
--- /dev/null
+++ b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qnetworkconfigurationmanagerqappless
+SOURCES += tst_qnetworkconfigurationmanagerqappless.cpp
+HEADERS += ../qbearertestcommon.h
+
+QT = core network testlib
diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp
new file mode 100644
index 0000000000..eff2cb1642
--- /dev/null
+++ b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtNetwork/qnetworkaccessmanager.h>
+
+QT_USE_NAMESPACE
+
+class tst_QNetworkConfigurationManager : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void staticsInitialization();
+};
+
+void tst_QNetworkConfigurationManager::staticsInitialization()
+{
+ // This code should not crash. The test was introduced as
+ // a fix for https://bugreports.qt-project.org/browse/QTBUG-36897
+ for (int i = 0; i < 2; i++)
+ {
+ int argc = 1;
+ const char *testName = "tst_qnetworkconfigurationmanagerqappless";
+ char **argv = const_cast<char **>(&testName);
+ QCoreApplication app(argc, argv);
+ QNetworkAccessManager qnam;
+ Q_UNUSED(app);
+ Q_UNUSED(qnam);
+ }
+ QVERIFY(true);
+}
+
+QTEST_APPLESS_MAIN(tst_QNetworkConfigurationManager)
+#include "tst_qnetworkconfigurationmanagerqappless.moc"
diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
index ac391a1bcc..4a324b883a 100644
--- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -570,16 +570,10 @@ void tst_QSocks5SocketEngine::udpTest()
QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
// Bind #1
-#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
- {
- bool bindSuccessful = udpSocket.bind(QHostAddress("0.0.0.0"), 0);
- if (!bindSuccessful)
- QEXPECT_FAIL("", "QTBUG-23380: Fails on some Ubuntu 11.10 x64 configurations", Abort);
- QVERIFY(bindSuccessful);
- }
-#else
- QVERIFY(udpSocket.bind(QHostAddress("0.0.0.0"), 0));
-#endif
+ bool bindSuccessful = udpSocket.bind(QHostAddress("0.0.0.0"), 0);
+ if (!bindSuccessful)
+ QEXPECT_FAIL("", "QTBUG-23380 / QTBUG-35490: Fails on some Ubuntu 11.10 x64 configurations and on new network test server", Abort);
+ QVERIFY(bindSuccessful);
QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
QVERIFY(udpSocket.localPort() != 0);
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 9715375e95..9387574c68 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -315,6 +315,8 @@ void tst_QAccessibility::initTestCase()
{
QTestAccessibility::initialize();
QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration();
+ if (!pfIntegration->accessibility())
+ QSKIP("This platform does not support accessibility");
pfIntegration->accessibility()->setActive(true);
}
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index e73bdc5223..3e7262a7a0 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -531,9 +531,11 @@ static QProcessEnvironment processEnvironment()
const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment();
foreach (const QString &key, systemEnvironment.keys()) {
const bool useVariable = key == QLatin1String("PATH") || key == QLatin1String("QT_QPA_PLATFORM")
-#ifdef Q_OS_UNIX
+#if defined(Q_OS_QNX)
+ || key == QLatin1String("GRAPHICS_ROOT") || key == QLatin1String("TZ")
+#elif defined(Q_OS_UNIX)
|| key == QLatin1String("HOME") || key == QLatin1String("USER") // Required for X11 on openSUSE
-# ifndef Q_OS_MAC
+# if !defined(Q_OS_MAC)
|| key == QLatin1String("DISPLAY") || key == QLatin1String("XAUTHLOCALHOSTNAME")
|| key.startsWith(QLatin1String("XDG_"))
# endif // !Q_OS_MAC
diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro
index 9efd0302bf..7c1315afa8 100644
--- a/tests/auto/widgets/widgets/qmenu/qmenu.pro
+++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro
@@ -2,4 +2,7 @@ CONFIG += testcase
TARGET = tst_qmenu
QT += widgets testlib
SOURCES += tst_qmenu.cpp
-
+macx:{
+ OBJECTIVE_SOURCES += tst_qmenu_mac.mm
+ LIBS += -lobjc
+}
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index f7dff7bc57..b4be24f0e0 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -116,6 +116,10 @@ private slots:
void QTBUG30595_rtl_submenu();
void QTBUG20403_nested_popup_on_shortcut_trigger();
void QTBUG_10735_crashWithDialog();
+#ifdef Q_OS_MAC
+ void QTBUG_37933_ampersands_data();
+ void QTBUG_37933_ampersands();
+#endif
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -1025,5 +1029,24 @@ void tst_QMenu::QTBUG_10735_crashWithDialog()
menu.activateAction(0);
}
+#ifdef Q_OS_MAC
+void tst_QMenu::QTBUG_37933_ampersands_data()
+{
+ QTest::addColumn<QString>("title");
+ QTest::addColumn<QString>("visibleTitle");
+ QTest::newRow("simple") << QString("Test") << QString("Test");
+ QTest::newRow("ampersand") << QString("&Test") << QString("Test");
+ QTest::newRow("double_ampersand") << QString("&Test && more") << QString("Test & more");
+}
+
+void tst_qmenu_QTBUG_37933_ampersands();
+
+void tst_QMenu::QTBUG_37933_ampersands()
+{
+ // external in .mm file
+ tst_qmenu_QTBUG_37933_ampersands();
+}
+#endif
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu_mac.mm b/tests/auto/widgets/widgets/qmenu/tst_qmenu_mac.mm
new file mode 100644
index 0000000000..dd0597d1ae
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu_mac.mm
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#include <QMenu>
+#include <QTest>
+
+void tst_qmenu_QTBUG_37933_ampersands()
+{
+ QMenu m;
+ QFETCH(QString, title);
+ QFETCH(QString, visibleTitle);
+ m.addAction(title);
+
+ NSMenu* nativeMenu = m.toNSMenu();
+ Q_ASSERT(nativeMenu != 0);
+ NSMenuItem* item = [nativeMenu itemAtIndex:0];
+ Q_ASSERT(item != 0);
+ QCOMPARE(QString::fromUtf8([[item title] UTF8String]), visibleTitle);
+}
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 61eb390fd3..c47f7b1ff6 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -154,6 +154,7 @@ private slots:
void findBackwardWithRegExp();
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
+ void layoutAfterMultiLineRemove();
private:
void createSelection();
@@ -1567,5 +1568,49 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
}
#endif
+void tst_QPlainTextEdit::layoutAfterMultiLineRemove()
+{
+ ed->setVisible(true); // The widget must be visible to reproduce this bug.
+
+ QString contents;
+ for (int i = 0; i < 5; ++i)
+ contents.append("\ttest\n");
+
+ ed->setPlainText(contents);
+
+ /*
+ * Remove the tab from the beginning of lines 2-4, in an edit block. The
+ * edit block is required for the bug to be reproduced.
+ */
+
+ QTextCursor curs = ed->textCursor();
+ curs.movePosition(QTextCursor::Start);
+ curs.movePosition(QTextCursor::NextBlock);
+
+ curs.beginEditBlock();
+ for (int i = 0; i < 3; ++i) {
+ curs.deleteChar();
+ curs.movePosition(QTextCursor::NextBlock);
+ }
+ curs.endEditBlock();
+
+ /*
+ * Now, we're going to perform the following actions:
+ *
+ * - Move to the beginning of the document.
+ * - Move down three times - this should put us at the front of block 3.
+ * - Move to the end of the line.
+ *
+ * At this point, if the document layout is behaving correctly, we should
+ * still be positioned on block 3. Verify that this is the case.
+ */
+
+ curs.movePosition(QTextCursor::Start);
+ curs.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, 3);
+ curs.movePosition(QTextCursor::EndOfLine);
+
+ QCOMPARE(curs.blockNumber(), 3);
+}
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"