From b23e72a772a5abfdf9784ab80db9a4d620137515 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 12 May 2014 17:05:36 -0700 Subject: Fix stateful handling of invalid UTF-8 straddling buffer borders When a UTF-8 sequences is too short, QUtf8Functions::fromUtf8 returns EndOfString. If the decoder is stateful, we must save the state and then restart it when more data is supplied. The new stateful decoder (8dd47e34b9b96ac27a99cdcf10b8aec506882fc2) mishandled the Error case by advancing the src pointer by a negative number, thus causing a buffer overflow (the issue of the task). And it also did not handle the len == 0 case properly, though neither did the older decoder. Task-number: QTBUG-38939 Change-Id: Ie03d7c55a04e51ee838ccdb3a01e5b989d8e67aa Reviewed-by: Kai Koehne Reviewed-by: Lars Knoll --- .../corelib/codecs/qtextcodec/tst_qtextcodec.cpp | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'tests') 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("buffer1"); + QTest::addColumn("buffer2"); + QTest::addColumn("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("codecName"); -- cgit v1.2.3 From 87152d3c89e25a01dab4f1e5852e7da7abf4e0b6 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Mon, 12 May 2014 10:07:09 +0200 Subject: QNX: Fix tst_qfileinfo Change-Id: Ia97a0c661d675e4f5ba800c32f8368583d58ee20 Reviewed-by: Sergio Ahumada --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests') 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) -- cgit v1.2.3 From 4f83102df0389ee9ae4bb974bb2e48723f52dbea Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Tue, 13 May 2014 16:30:18 +0200 Subject: QNX: Make QDateTime "daylightTransitions" auto test pass Change-Id: I8c68d15806c6ec39e98dddda86823d9b4e3a3169 Reviewed-by: John Layt --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3 From d16508a285a5423ae9a5034e969801bce74ffb98 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 12 May 2014 09:09:24 +0200 Subject: Fix crash when loading invalid font data in QRawFont When passing invalid data to QRawFont, we need to fail gracefully and mark the font as invalid, instead of crashing. This crashed because of different missing sanity checks in the Windows and FontConfig font databases. [ChangeLog][Text] Fixed crash when trying to load a font from invalid data. Task-number: QTBUG-37190 Change-Id: I62c81217ec7d873350b575c9d4ae8e6f0a939540 Reviewed-by: Michael Bruning Reviewed-by: Konstantin Ritt --- tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index ae6e450301..20bfaf99dd 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; @@ -939,6 +941,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) -- cgit v1.2.3 From 1b2614477f42825d95bbd7a4ebc6aa91fd82e1d9 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Tue, 13 May 2014 18:08:42 +0200 Subject: Fix accessibility auto test Prevent crash on platforms that don't support accessibility by skipping tests. Change-Id: I42ba44df3200e0abd62797c76a5c538fb1d2757c Reviewed-by: Frederik Gladhorn --- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 54c56eb18b..8b033efa4a 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); } -- cgit v1.2.3 From fa3d264b0bd70afa15a22811be369dc8b65267e6 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Thu, 15 May 2014 15:57:01 +0200 Subject: QNX: Fix tst_selftest GRAPHICS_ROOT and TZ environment variables are needed in child processes in order to successfully run the auto test selftests. Change-Id: I7befabd535b4c47b1e75acbe3d6158d0d9b811b3 Reviewed-by: Friedemann Kleint --- tests/auto/testlib/selftests/tst_selftests.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 8167a96eaa..9082561dc9 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -526,9 +526,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 -- cgit v1.2.3 From 1d7902a0caa77563d242e665e0a442e8afc6cf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 15 May 2014 16:21:39 +0000 Subject: Fix crash in QNetworkAccessManager. Recreating QCoreApplication could cause a crash in QNetworkAccessManager constructor. That was caused by an invalid shutdown detection introduced in f273d6fbc02055ff3999adc0df76360ca0670435. Task-number: QTBUG-36897 Change-Id: Ib5bba773a2a4fcde690a3a93680aef551aae3a5b Reviewed-by: Peter Hartmann --- tests/auto/network/bearer/bearer.pro | 1 + .../qnetworkconfigurationmanagerqappless.pro | 6 ++ .../tst_qnetworkconfigurationmanagerqappless.cpp | 73 ++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro create mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp (limited to 'tests') 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 +#include + +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(&testName); + QCoreApplication app(argc, argv); + QNetworkAccessManager qnam; + Q_UNUSED(app); + Q_UNUSED(qnam); + } + QVERIFY(true); +} + +QTEST_APPLESS_MAIN(tst_QNetworkConfigurationManager) +#include "tst_qnetworkconfigurationmanagerqappless.moc" -- cgit v1.2.3 From b8f96418ed625b4acd0f2584d1d9bc065321677c Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Tue, 13 May 2014 11:14:32 +0200 Subject: Skip some qsavefile auto tests Some of the QSaveFile tests are not applicable with root privileges. Change-Id: I1a22906c0b14acf144f1849719152dfe9d79f426 Reviewed-by: David Faure --- tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests') 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 #include -#if defined(Q_OS_UNIX) -# include // for geteuid -# include +#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS) +#include // 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"); -- cgit v1.2.3 From 1ea0d59c4a068b9bddab1a5161cc51f050c4a55d Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Tue, 13 May 2014 10:20:48 +0200 Subject: Skip tst_QLockFile::noPermissions QLockFile "noPermissions" test is not applicable with root privileges. Change-Id: I5779da524f24d0f1b9ef519d654856a6200da6bf Reviewed-by: David Faure --- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') 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 #include #include +#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS) +#include +#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 -- cgit v1.2.3 From c045cb950b3610278b4257712eca88d4e3ecf9fd Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 20 May 2014 14:43:27 +0200 Subject: Socks5 socket engine test: Disable UDP over Socks test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... because it fails on the new network test server. The Socks5 tests in QUdpSocket have already been disabled by commit aa3eaf9d2ec4927df51e7d773a66f68ec5e4fce9 . Task-number: QTBUG-35490 Change-Id: Ib062adb422ff6e5538f14d15a266d79c3bb53956 Reviewed-by: Richard J. Moore Reviewed-by: Tony Sarajärvi --- .../socket/qsocks5socketengine/tst_qsocks5socketengine.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'tests') 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); -- cgit v1.2.3 From ff31090d07cbbb6f67d259438939e810a0baf67f Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Fri, 28 Mar 2014 11:15:16 +0100 Subject: Cocoa: Do not process ampersands in menus twice. When syncing between QAction and native NSMenuItems, the ampersands (mnemonics) were removed twice. This lead to double ampersands being removed instead of replace with single ones. Task-number: QTBUG-37933 Change-Id: If1d9cd247b467472647b22b38460b44b03f13d82 Reviewed-by: Liang Qi --- tests/auto/widgets/widgets/qmenu/qmenu.pro | 5 +- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 23 +++++++++ tests/auto/widgets/widgets/qmenu/tst_qmenu_mac.mm | 59 +++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/auto/widgets/widgets/qmenu/tst_qmenu_mac.mm (limited to 'tests') 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("title"); + QTest::addColumn("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 + +#include +#include + +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); +} -- cgit v1.2.3 From 2983cb9531d47e5826540ca79e3066a8ed0db30c Mon Sep 17 00:00:00 2001 From: Axel Rasmussen Date: Tue, 15 Apr 2014 22:53:36 -0600 Subject: Fix broken QPlainTextDocumentLayout after removing chars This fixes an issue where, if characters were removed from several blocks in a single edit, the document layout would end up being corrupted since the document layout manager wouldn't re-layout the proper number of text blocks. Task-number: QTBUG-30051 Change-Id: Idf3a6f567120e6a5dbebf1f65f685d374219328a Reviewed-by: Konstantin Ritt Reviewed-by: Pierre Rossi --- .../widgets/qplaintextedit/tst_qplaintextedit.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests') 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" -- cgit v1.2.3