diff options
Diffstat (limited to 'tests')
32 files changed, 274 insertions, 98 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 30812700c5..b0cb59a012 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -89,12 +89,11 @@ class tst_QSettings : public QObject Q_OBJECT public: - tst_QSettings() : m_canWriteNativeSystemSettings(canWriteNativeSystemSettings()) {} + tst_QSettings(); public slots: void initTestCase(); - void init(); - void cleanup(); + void cleanup() { cleanupTestFiles(); } private slots: void getSetCheck(); void ctor_data(); @@ -166,6 +165,8 @@ private slots: void bom(); private: + void cleanupTestFiles(); + const bool m_canWriteNativeSystemSettings; }; @@ -181,39 +182,16 @@ void tst_QSettings::getSetCheck() QCOMPARE(true, obj1.fallbacksEnabled()); } -#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT) -static void removePath(const QString& _path) -{ - QString path = _path; - QDir dir(path); - if (!dir.exists()) - return; - QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot); - foreach(QString name, entries) { - QString absolute = path + name; - if (QFileInfo(absolute).isDir()) - removePath(absolute+"\\"); - else - QFile::remove(absolute); - } - dir.cdUp(); - if (path[path.size()-1] == '\\') - path = path.left(path.size()-1); - dir.rmdir(path.mid(path.lastIndexOf('\\')+1)); -} -#endif - -static QString settingsPath(const char *path = "") +static QString settingsPath(const char *path = Q_NULLPTR) { // Temporary path for files that are specified explicitly in the constructor. #ifndef Q_OS_WINRT - QString tempPath = QDir::tempPath(); + static const QString tempPath = QDir::tempPath() + QLatin1String("/tst_QSettings"); #else - QString tempPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); + static const QString tempPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + + QLatin1String("/tst_QSettings"); #endif - if (tempPath.endsWith(QLatin1Char('/'))) - tempPath.truncate(tempPath.size() - 1); - return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path)); + return path && *path ? tempPath + QLatin1Char('/') + QLatin1String(path) : tempPath; } static bool readCustom1File(QIODevice &device, QSettings::SettingsMap &map) @@ -283,6 +261,12 @@ static void populateWithFormats() QTest::newRow("custom2") << QSettings::CustomFormat2; } +tst_QSettings::tst_QSettings() + : m_canWriteNativeSystemSettings(canWriteNativeSystemSettings()) +{ + QStandardPaths::setTestModeEnabled(true); +} + void tst_QSettings::initTestCase() { if (!m_canWriteNativeSystemSettings) @@ -295,13 +279,19 @@ void tst_QSettings::initTestCase() ); QCOMPARE(custom1, QSettings::CustomFormat1); QCOMPARE(custom2, QSettings::CustomFormat2); + + cleanupTestFiles(); } -void tst_QSettings::init() +void tst_QSettings::cleanupTestFiles() { QSettings::setSystemIniPath(settingsPath("__system__")); QSettings::setUserIniPath(settingsPath("__user__")); + QDir settingsDir(settingsPath()); + if (settingsDir.exists()) + QVERIFY(settingsDir.removeRecursively()); + #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QSettings("HKEY_CURRENT_USER\\Software\\software.org", QSettings::NativeFormat).clear(); QSettings("HKEY_CURRENT_USER\\Software\\other.software.org", QSettings::NativeFormat).clear(); @@ -317,17 +307,7 @@ void tst_QSettings::init() QSettings("HKEY_LOCAL_MACHINE\\Software\\bat", QSettings::NativeFormat).clear(); QSettings("HKEY_LOCAL_MACHINE\\Software\\baz", QSettings::NativeFormat).clear(); } - if (QDir(settingsPath()).exists()) { -#if defined(Q_OS_WINCE) - removePath(settingsPath()); -#else - if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) - system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1()); - else - system(QString("deltree /Y %1").arg(settingsPath()).toLatin1()); -#endif - } -#elif defined(Q_OS_DARWIN) +#elif defined(Q_OS_DARWIN) || defined(Q_OS_WINRT) QSettings(QSettings::UserScope, "software.org", "KillerAPP").clear(); QSettings(QSettings::SystemScope, "software.org", "KillerAPP").clear(); QSettings(QSettings::UserScope, "other.software.org", "KillerAPP").clear(); @@ -338,31 +318,16 @@ void tst_QSettings::init() QSettings(QSettings::SystemScope, "other.software.org").clear(); #endif -#if !defined(Q_OS_WIN) - system(QString("chmod -R u+rw %1 2> /dev/null").arg(settingsPath()).toLatin1()); - system(QString("rm -fr %1 2> /dev/null").arg(settingsPath()).toLatin1()); -#endif + const QString foo(QLatin1String("foo")); #if defined(Q_OS_WINRT) - QSettings(QSettings::UserScope, "software.org", "KillerAPP").clear(); - QSettings(QSettings::SystemScope, "software.org", "KillerAPP").clear(); - QSettings(QSettings::UserScope, "other.software.org", "KillerAPP").clear(); - QSettings(QSettings::SystemScope, "other.software.org", "KillerAPP").clear(); - QSettings(QSettings::UserScope, "software.org").clear(); - QSettings(QSettings::SystemScope, "software.org").clear(); - QSettings(QSettings::UserScope, "other.software.org").clear(); - QSettings(QSettings::SystemScope, "other.software.org").clear(); - QSettings("foo", QSettings::NativeFormat).clear(); - removePath(settingsPath()); - QFile::remove(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/foo"); + QSettings(foo, QSettings::NativeFormat).clear(); + QFile fooFile(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QLatin1Char('/') + foo); #else - QFile::remove("foo"); + QFile fooFile(foo); #endif -} - -void tst_QSettings::cleanup() -{ - init(); + if (fooFile.exists()) + QVERIFY2(fooFile.remove(), qPrintable(fooFile.errorString())); } /* diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 532a53e5d3..24cde14459 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -163,6 +163,7 @@ private slots: void string_write_operator_ToDevice_data(); void string_write_operator_ToDevice(); void latin1String_write_operator_ToDevice(); + void stringref_write_operator_ToDevice(); // other void skipWhiteSpace_data(); @@ -2554,6 +2555,22 @@ void tst_QTextStream::latin1String_write_operator_ToDevice() QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length"); } +void tst_QTextStream::stringref_write_operator_ToDevice() +{ + QBuffer buf; + buf.open(QBuffer::WriteOnly); + QTextStream stream(&buf); + stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); + stream.setAutoDetectUnicode(true); + + const QString expected = "No explicit lengthExplicit length"; + + stream << expected.leftRef(18); + stream << expected.midRef(18); + stream.flush(); + QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length"); +} + // ------------------------------------------------------------------------------ void tst_QTextStream::useCase1() { diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/char/char.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char/char.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/char/char.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char/char.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/char16_t/char16_t.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char16_t/char16_t.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/char16_t/char16_t.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char16_t/char16_t.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/char32_t/char32_t.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char32_t/char32_t.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/char32_t/char32_t.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/char32_t/char32_t.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/int/int.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/int/int.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/int/int.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/int/int.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/long/long.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/long/long.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/long/long.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/long/long.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/qlonglong/qlonglong.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qlonglong/qlonglong.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/qlonglong/qlonglong.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qlonglong/qlonglong.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/qptrdiff/qptrdiff.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qptrdiff/qptrdiff.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/qptrdiff/qptrdiff.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qptrdiff/qptrdiff.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/quintptr/quintptr.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/quintptr/quintptr.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/quintptr/quintptr.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/quintptr/quintptr.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/qulonglong/qulonglong.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qulonglong/qulonglong.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/qulonglong/qulonglong.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/qulonglong/qulonglong.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/schar/schar.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/schar/schar.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/schar/schar.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/schar/schar.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/short/short.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/short/short.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/short/short.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/short/short.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/uchar/uchar.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uchar/uchar.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/uchar/uchar.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uchar/uchar.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/uint/uint.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uint/uint.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/uint/uint.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/uint/uint.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/ulong/ulong.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ulong/ulong.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/ulong/ulong.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ulong/ulong.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/ushort/ushort.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ushort/ushort.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/ushort/ushort.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/ushort/ushort.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/cxx11/wchar_t/wchar_t.pro b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/wchar_t/wchar_t.pro index 64401f0229..64401f0229 100644 --- a/tests/auto/corelib/thread/qatomicinteger/cxx11/wchar_t/wchar_t.pro +++ b/tests/auto/corelib/thread/qatomicinteger/no-cxx11/wchar_t/wchar_t.pro diff --git a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri index fd4387b188..29e9464a4d 100644 --- a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri +++ b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pri @@ -3,9 +3,9 @@ TYPE = $$basename(_PRO_FILE_PWD_) dn = $$dirname(_PRO_FILE_PWD_) FORCE = $$basename(dn) -equals(FORCE, cxx11) { - suffix = Cxx11_$$TYPE - DEFINES += QT_ATOMIC_FORCE_CXX11 +equals(FORCE, no-cxx11) { + suffix = NoCxx11_$$TYPE + DEFINES += QT_ATOMIC_FORCE_NO_CXX11 } else: equals(FORCE, gcc) { suffix = Gcc_$$TYPE DEFINES += QT_ATOMIC_FORCE_GCC diff --git a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro index 58e5b157bd..9d929e649e 100644 --- a/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro +++ b/tests/auto/corelib/thread/qatomicinteger/qatomicinteger.pro @@ -19,22 +19,22 @@ SUBDIRS=\ contains(QT_CONFIG, c++11)|msvc: SUBDIRS +=\ - cxx11/char \ - cxx11/char16_t \ - cxx11/char32_t \ - cxx11/int \ - cxx11/long \ - cxx11/qlonglong \ - cxx11/qptrdiff \ - cxx11/quintptr \ - cxx11/qulonglong \ - cxx11/schar \ - cxx11/short \ - cxx11/uchar \ - cxx11/uint \ - cxx11/ulong \ - cxx11/ushort \ - cxx11/wchar_t \ + no-cxx11/char \ + no-cxx11/char16_t \ + no-cxx11/char32_t \ + no-cxx11/int \ + no-cxx11/long \ + no-cxx11/qlonglong \ + no-cxx11/qptrdiff \ + no-cxx11/quintptr \ + no-cxx11/qulonglong \ + no-cxx11/schar \ + no-cxx11/short \ + no-cxx11/uchar \ + no-cxx11/uint \ + no-cxx11/ulong \ + no-cxx11/ushort \ + no-cxx11/wchar_t \ # The GCC-style atomics only support 32-bit and pointer-sized but add diff --git a/tests/auto/corelib/tools/qlatin1string/.gitignore b/tests/auto/corelib/tools/qlatin1string/.gitignore new file mode 100644 index 0000000000..dddf56b2df --- /dev/null +++ b/tests/auto/corelib/tools/qlatin1string/.gitignore @@ -0,0 +1 @@ +tst_qlatin1string diff --git a/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro b/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro new file mode 100644 index 0000000000..219afa661b --- /dev/null +++ b/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro @@ -0,0 +1,8 @@ +CONFIG += testcase parallel_test +TARGET = tst_qlatin1string +QT = core testlib +SOURCES = tst_qlatin1string.cpp +DEFINES += QT_NO_CAST_TO_ASCII +contains(QT_CONFIG,c++11): CONFIG += c++11 c++14 + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp new file mode 100644 index 0000000000..290c9fc12a --- /dev/null +++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QString> + +class tst_QLatin1String : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void nullString(); + void emptyString(); +}; + +void tst_QLatin1String::nullString() +{ + // default ctor + { + QLatin1String l1; + QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR)); + QCOMPARE(l1.size(), 0); + + QString s = l1; + QVERIFY(s.isNull()); + } + + // from nullptr + { + const char *null = Q_NULLPTR; + QLatin1String l1(null); + QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR)); + QCOMPARE(l1.size(), 0); + + QString s = l1; + QVERIFY(s.isNull()); + } + + // from null QByteArray + { + const QByteArray null; + QVERIFY(null.isNull()); + + QLatin1String l1(null); + QEXPECT_FAIL("", "null QByteArrays become non-null QLatin1Strings...", Continue); + QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(Q_NULLPTR)); + QCOMPARE(l1.size(), 0); + + QString s = l1; + QEXPECT_FAIL("", "null QByteArrays become non-null QLatin1Strings become non-null QStrings...", Continue); + QVERIFY(s.isNull()); + } +} + +void tst_QLatin1String::emptyString() +{ + { + const char *empty = ""; + QLatin1String l1(empty); + QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(empty)); + QCOMPARE(l1.size(), 0); + + QString s = l1; + QVERIFY(s.isEmpty()); + QVERIFY(!s.isNull()); + } + + { + const char *notEmpty = "foo"; + QLatin1String l1(notEmpty, 0); + QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(notEmpty)); + QCOMPARE(l1.size(), 0); + + QString s = l1; + QVERIFY(s.isEmpty()); + QVERIFY(!s.isNull()); + } + + { + const QByteArray empty = ""; + QLatin1String l1(empty); + QCOMPARE(static_cast<const void*>(l1.data()), static_cast<const void*>(empty.constData())); + QCOMPARE(l1.size(), 0); + + QString s = l1; + QVERIFY(s.isEmpty()); + QVERIFY(!s.isNull()); + } +} + + + +QTEST_APPLESS_MAIN(tst_QLatin1String) + +#include "tst_qlatin1string.moc" diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 33c8eb303a..edaa00098e 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -902,6 +902,7 @@ void tst_QLocale::long_long_conversion() void tst_QLocale::long_long_conversion_extra() { QLocale l(QLocale::C); + l.setNumberOptions(0); QCOMPARE(l.toString((qlonglong)1), QString("1")); QCOMPARE(l.toString((qlonglong)12), QString("12")); QCOMPARE(l.toString((qlonglong)123), QString("123")); @@ -1613,20 +1614,20 @@ void tst_QLocale::numberOptions() bool ok; QLocale locale(QLocale::C); - QCOMPARE(locale.numberOptions(), 0); - QCOMPARE(locale.toInt(QString("12,345"), &ok), 12345); + QCOMPARE(locale.numberOptions(), QLocale::OmitGroupSeparator); + QCOMPARE(locale.toInt(QString("12345"), &ok), 12345); QVERIFY(ok); QCOMPARE(locale.toInt(QString("12345"), &ok), 12345); QVERIFY(ok); - QCOMPARE(locale.toString(12345), QString("12,345")); + QCOMPARE(locale.toString(12345), QString("12345")); - locale.setNumberOptions(QLocale::OmitGroupSeparator); - QCOMPARE(locale.numberOptions(), QLocale::OmitGroupSeparator); + locale.setNumberOptions(0); + QCOMPARE(locale.numberOptions(), 0); QCOMPARE(locale.toInt(QString("12,345"), &ok), 12345); QVERIFY(ok); QCOMPARE(locale.toInt(QString("12345"), &ok), 12345); QVERIFY(ok); - QCOMPARE(locale.toString(12345), QString("12345")); + QCOMPARE(locale.toString(12345), QString("12,345")); locale.setNumberOptions(QLocale::RejectGroupSeparator); QCOMPARE(locale.numberOptions(), QLocale::RejectGroupSeparator); @@ -2035,10 +2036,10 @@ void tst_QLocale::standaloneMonthName() void tst_QLocale::currency() { const QLocale c(QLocale::C); - QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1,234")); - QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1,234")); - QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1,234.56")); - QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1,234.56")); + QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1234")); + QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1234")); + QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1234.56")); + QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1234.56")); const QLocale en_US("en_US"); QCOMPARE(en_US.toCurrencyString(qulonglong(1234)), QString("$1,234")); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 6b84fa367b..a1e6a1d1b1 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -6256,14 +6256,15 @@ void tst_QString::arg_locale() QLocale l(QLocale::English, QLocale::UnitedKingdom); QString str("*%L1*%L2*"); - QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123,456*1,234.56*")); QLocale::setDefault(l); + QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123,456*1,234.56*")); l.setNumberOptions(QLocale::OmitGroupSeparator); QLocale::setDefault(l); QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123456*1234.56*")); QLocale::setDefault(QLocale::C); + QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123456*1234.56*")); } diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 9024a1a1bb..f9e1c454e7 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -24,6 +24,7 @@ SUBDIRS=\ qhash \ qhash_strictiterators \ qhashfunctions \ + qlatin1string \ qline \ qlinkedlist \ qlist \ diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index fa1b68b4f9..c113b7cd60 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -513,6 +513,8 @@ class tst_Moc : public QObject Q_PROPERTY(QString member4 MEMBER sMember NOTIFY member4Changed) Q_PROPERTY(QString member5 MEMBER sMember NOTIFY member5Changed) Q_PROPERTY(QString member6 MEMBER sConst CONSTANT) + Q_PROPERTY(QString sub1 MEMBER (sub.m_string)) + Q_PROPERTY(QString sub2 READ (sub.string) WRITE (sub.setString)) public: inline tst_Moc() : sConst("const") {} @@ -626,6 +628,13 @@ private: QString sMember; const QString sConst; PrivatePropertyTest *pPPTest; + + struct { + QString m_string; + void setString(const QString &s) { m_string = s; } + QString string() { return m_string; } + } sub; + }; void tst_Moc::initTestCase() @@ -1883,12 +1892,19 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro."); - QTest::newRow("QTBUG-46210: crash on invalid macro") - << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45);") + QTest::newRow("Invalid macro definition") + << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45, 42, 39);") << QStringList() << 1 << QString("IGNORE_ALL_STDOUT") << QString(":2: Error: '#' is not followed by a macro parameter"); + + QTest::newRow("QTBUG-46210: crash on invalid macro invocation") + << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c\n Foo(45);") + << QStringList() + << 1 + << QString("IGNORE_ALL_STDOUT") + << QString(":2: Error: Macro invoked with too few parameters for a use of '#'"); } void tst_Moc::warnings() @@ -2037,6 +2053,10 @@ void tst_Moc::memberProperties_data() << 1 << "blub5" << "blub5Changed(const QString&)" << "mno" << true << "mno"; QTest::newRow("private MEMBER property with CONSTANT") << 1 << "blub6" << "" << "test" << false << "const"; + QTest::newRow("sub1") + << 0 << "sub1" << "" << "helloSub1" << true << "helloSub1"; + QTest::newRow("sub2") + << 0 << "sub2" << "" << "helloSub2" << true << "helloSub2"; } void tst_Moc::memberProperties() diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index c85ac101d4..34cd9a55fc 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -239,6 +239,8 @@ private slots: void testStreamWithHide(); void testStylePosition(); + void sizeHintCrash(); + protected: void setupTestData(bool use_reset_model = false); void additionalInit(); @@ -2886,5 +2888,15 @@ void tst_QHeaderView::testStylePosition() QCOMPARE(proxy.lastPosition, QStyleOptionHeader::OnlyOneSection); } +void tst_QHeaderView::sizeHintCrash() +{ + QTreeView treeView; + QStandardItemModel *model = new QStandardItemModel(&treeView); + model->appendRow(new QStandardItem("QTBUG-48543")); + treeView.setModel(model); + treeView.header()->sizeHintForColumn(0); + treeView.header()->sizeHintForRow(0); +} + QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 4e0cc9edf1..51176d8195 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -191,6 +191,7 @@ private slots: void fixedMinMaxSize(); #if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) void replaceMenuBarWhileMaximized(); + void closeOnDoubleClick_data(); void closeOnDoubleClick(); #endif void setFont(); @@ -1795,9 +1796,23 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized() QVERIFY(!subWindow->maximizedSystemMenuIconWidget()); } +void tst_QMdiSubWindow::closeOnDoubleClick_data() +{ + QTest::addColumn<int>("actionIndex"); + QTest::addColumn<bool>("expectClosed"); + + QTest::newRow("close") << 1 << true; + QTest::newRow("disabled-restore-action") << 0 << false; // QTBUG-48493 +} + void tst_QMdiSubWindow::closeOnDoubleClick() { + QFETCH(int, actionIndex); + QFETCH(bool, expectClosed); + QMdiArea mdiArea; + mdiArea.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); QPointer<QMdiSubWindow> subWindow = mdiArea.addSubWindow(new QWidget); mdiArea.show(); QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); @@ -1809,12 +1824,13 @@ void tst_QMdiSubWindow::closeOnDoubleClick() QVERIFY(systemMenu); QVERIFY(systemMenu->isVisible()); - sendMouseDoubleClick(systemMenu, QPoint(10, 10)); + const QRect actionGeometry = systemMenu->actionGeometry(systemMenu->actions().at(actionIndex)); + sendMouseDoubleClick(systemMenu, actionGeometry.center()); if (qApp->activePopupWidget() == static_cast<QWidget *>(systemMenu)) systemMenu->hide(); qApp->processEvents(); - QVERIFY(!subWindow || !subWindow->isVisible()); QVERIFY(!systemMenu || !systemMenu->isVisible()); + QCOMPARE(subWindow.isNull() || !subWindow->isVisible(), expectClosed); } #endif diff --git a/tests/manual/highdpi/highdpi.qrc b/tests/manual/highdpi/highdpi.qrc index 10efac44fa..0e33ed33d7 100644 --- a/tests/manual/highdpi/highdpi.qrc +++ b/tests/manual/highdpi/highdpi.qrc @@ -2,6 +2,7 @@ <qresource prefix="/"> <file>qticon16.png</file> <file>qticon16@2x.png</file> + <file>qticon16@3x.png</file> <file>qticon32.png</file> <file>qticon32@2x.png</file> <file>qticon64.png</file> diff --git a/tests/manual/highdpi/qticon16@3x.png b/tests/manual/highdpi/qticon16@3x.png Binary files differnew file mode 100644 index 0000000000..de92658241 --- /dev/null +++ b/tests/manual/highdpi/qticon16@3x.png diff --git a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp index 04c9b3f72c..2792f6f1a3 100644 --- a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp +++ b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp @@ -61,6 +61,7 @@ QOpenGLTextureBlitWindow::QOpenGLTextureBlitWindow() m_context->makeCurrent(this); m_blitter.create(); + qDebug("GL_TEXTURE_EXTERNAL_OES support: %d", m_blitter.supportsExternalOESTarget()); } void QOpenGLTextureBlitWindow::render() @@ -132,6 +133,12 @@ void QOpenGLTextureBlitWindow::render() m_blitter.setSwizzleRB(false); m_blitter.release(); + if (m_blitter.supportsExternalOESTarget()) { + // Cannot do much testing here, just verify that bind and release work, meaning that the program is present. + m_blitter.bind(0x8D65); + m_blitter.release(); + } + m_context->swapBuffers(this); } |