diff options
Diffstat (limited to 'tests')
66 files changed, 426 insertions, 1316 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 9eb741edac..c9d1da8649 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,5 +1,9 @@ TEMPLATE = subdirs +# Tests with developer-build started failing on qemu-armv7/armv8 after commit +# b88acae7a8e773c307e44f84da037d01d19e60f7 in qt5. +boot2qt:qtConfig(private_tests): return() + SUBDIRS += \ corelib \ dbus \ diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index b33dec8a61..047130d5ea 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -49,7 +49,6 @@ private slots: void qConstructorFunction(); void qCoreAppStartupFunction(); void qCoreAppStartupFunctionRestart(); - void qAlignOf(); void integerForSize(); void qprintable(); void qprintable_data(); @@ -434,106 +433,6 @@ template <class T> struct AlignmentInStruct { T dummy; }; typedef int (*fun) (); typedef int (Empty::*memFun) (); -#define TEST_AlignOf(type, alignment) \ - do { \ - TEST_AlignOf_impl(type, alignment); \ - \ - TEST_AlignOf_impl(type &, alignment); \ - TEST_AlignOf_RValueRef(type &&, alignment); \ - \ - TEST_AlignOf_impl(type [5], alignment); \ - TEST_AlignOf_impl(type (&) [5], alignment); \ - \ - TEST_AlignOf_impl(AlignmentInStruct<type>, alignment); \ - \ - /* Some internal sanity validation, just for fun */ \ - TEST_AlignOf_impl(AlignmentInStruct<type [5]>, alignment); \ - TEST_AlignOf_impl(AlignmentInStruct<type &>, Q_ALIGNOF(void *)); \ - TEST_AlignOf_impl(AlignmentInStruct<type (&) [5]>, \ - Q_ALIGNOF(void *)); \ - TEST_AlignOf_RValueRef(AlignmentInStruct<type &&>, \ - Q_ALIGNOF(void *)); \ - } while (false) \ - /**/ - -#define TEST_AlignOf_RValueRef(type, alignment) \ - TEST_AlignOf_impl(type, alignment) - -#define TEST_AlignOf_impl(type, alignment) \ - do { \ - QCOMPARE(Q_ALIGNOF(type), size_t(alignment)); \ - /* Compare to native operator for compilers that support it, - otherwise... erm... check consistency! :-) */ \ - QCOMPARE(alignof(type), Q_ALIGNOF(type)); \ - } while (false) - /**/ - -void tst_QGlobal::qAlignOf() -{ - // Built-in types, except 64-bit integers and double - TEST_AlignOf(char, 1); - TEST_AlignOf(signed char, 1); - TEST_AlignOf(unsigned char, 1); - TEST_AlignOf(qint8, 1); - TEST_AlignOf(quint8, 1); - TEST_AlignOf(qint16, 2); - TEST_AlignOf(quint16, 2); - TEST_AlignOf(qint32, 4); - TEST_AlignOf(quint32, 4); - TEST_AlignOf(void *, sizeof(void *)); - - // Depends on platform and compiler, disabling test for now - // TEST_AlignOf(long double, 16); - - // Empty struct - TEST_AlignOf(Empty, 1); - - // Function pointers - TEST_AlignOf(fun, Q_ALIGNOF(void *)); - TEST_AlignOf(memFun, Q_ALIGNOF(void *)); - - - // 64-bit integers and double - TEST_AlignOf_impl(qint64, 8); - TEST_AlignOf_impl(quint64, 8); - TEST_AlignOf_impl(double, 8); - - TEST_AlignOf_impl(qint64 &, 8); - TEST_AlignOf_impl(quint64 &, 8); - TEST_AlignOf_impl(double &, 8); - - TEST_AlignOf_RValueRef(qint64 &&, 8); - TEST_AlignOf_RValueRef(quint64 &&, 8); - TEST_AlignOf_RValueRef(double &&, 8); - - // 32-bit x86 ABI idiosyncrasies -#if defined(Q_PROCESSOR_X86_32) && !defined(Q_OS_WIN) - TEST_AlignOf_impl(AlignmentInStruct<qint64>, 4); -#else - TEST_AlignOf_impl(AlignmentInStruct<qint64>, 8); -#endif - - TEST_AlignOf_impl(AlignmentInStruct<quint64>, Q_ALIGNOF(AlignmentInStruct<qint64>)); - TEST_AlignOf_impl(AlignmentInStruct<double>, Q_ALIGNOF(AlignmentInStruct<qint64>)); - - // 32-bit x86 ABI, Clang disagrees with gcc -#if !defined(Q_PROCESSOR_X86_32) || !defined(Q_CC_CLANG) || defined(Q_OS_ANDROID) - TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(qint64)); -#else - TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(AlignmentInStruct<qint64>)); -#endif - - TEST_AlignOf_impl(qint64 (&) [5], Q_ALIGNOF(qint64 [5])); - TEST_AlignOf_impl(quint64 [5], Q_ALIGNOF(quint64 [5])); - TEST_AlignOf_impl(quint64 (&) [5], Q_ALIGNOF(quint64 [5])); - TEST_AlignOf_impl(double [5], Q_ALIGNOF(double [5])); - TEST_AlignOf_impl(double (&) [5], Q_ALIGNOF(double [5])); -} - -#undef TEST_AlignOf -#undef TEST_AlignOf_RValueRef -#undef TEST_AlignOf_impl - void tst_QGlobal::integerForSize() { // compile-only test: diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 0597a7d521..744e047c45 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -116,7 +116,7 @@ static DWORD createSymbolicLink(const QString &symLinkName, const QString &targe reinterpret_cast<const wchar_t*>(nativeTarget.utf16()), flags) == FALSE) { result = GetLastError(); QTextStream(errorMessage) << "CreateSymbolicLink(" << nativeSymLinkName << ", " - << nativeTarget << ", 0x" << hex << flags << dec << ") failed with error " << result + << nativeTarget << ", 0x" << Qt::hex << flags << Qt::dec << ") failed with error " << result << ": " << qt_error_string(int(result)); } return result; diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test5 b/tests/auto/corelib/io/qfileselector/platforms/+mac/test5 deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+mac/test5 +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+osx/test4 b/tests/auto/corelib/io/qfileselector/platforms/+osx/test4 deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+osx/test4 +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+ios/test index e69de29bb2..e69de29bb2 100644 --- a/tests/auto/corelib/io/qfileselector/platforms/+mac/test +++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+ios/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+ios/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+ios/test deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+ios/test +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+macos/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+macos/test deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+macos/test +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/+macos/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/+macos/test deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/+macos/test +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/test deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/test +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/test deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/test +++ /dev/null diff --git a/tests/auto/corelib/io/qfileselector/platforms/+osx/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+macos/test index e69de29bb2..e69de29bb2 100644 --- a/tests/auto/corelib/io/qfileselector/platforms/+osx/test +++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+macos/test diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc index 54b2e0a0e2..f3b3ede575 100644 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc @@ -1,65 +1,51 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/"> - <file>extras/test</file> - <file>extras/test2</file> - <file>extras/+custom1/test</file> - <file>extras/+custom1/test3</file> - <file>extras/+custom2/test</file> - <file>extras/+custom3/test</file> - <file>extras/+custom3/+custom2/test</file> - <file>extras/+custom3/+custom4/test</file> - <file>extras/+custom3/+custom5/test</file> - <file>extras/+custom5/+custom3/test</file> - - <!-- platforms/test: deepest possible selection --> - <file>platforms/test</file> - <file>platforms/+unix/+android/test</file> - <file>platforms/+unix/+darwin/+mac/+ios/test</file> - <file>platforms/+unix/+darwin/+mac/+osx/+macos/test</file> - <file>platforms/+unix/+darwin/+mac/+osx/test</file> - <file>platforms/+unix/+darwin/+mac/test</file> - <file>platforms/+unix/+darwin/test</file> - <file>platforms/+unix/+haiku/test</file> - <file>platforms/+unix/+linux/test</file> - <file>platforms/+unix/+qnx/test</file> - <file>platforms/+unix/test</file> - <file>platforms/+windows/+wince/test</file> - <file>platforms/+windows/+winnt/test</file> - <file>platforms/+windows/+winrt/test</file> - <file>platforms/+windows/test</file> - <file>platforms/+android/test</file> - <file>platforms/+ios/test</file> - <file>platforms/+macos/test</file> - <file>platforms/+osx/test</file> - <file>platforms/+darwin/test</file> - <file>platforms/+mac/test</file> - <file>platforms/+haiku/test</file> - <file>platforms/+linux/test</file> - <file>platforms/+qnx/test</file> - <file>platforms/+wince/test</file> - <file>platforms/+winrt/test</file> - - <!-- platforms/test2: shallow selection for the deepest selector --> - <file>platforms/test2</file> - <file>platforms/+android/test2</file> - <file>platforms/+ios/test2</file> - <file>platforms/+macos/test2</file> - <file>platforms/+haiku/test2</file> - <file>platforms/+linux/test2</file> - <file>platforms/+qnx/test2</file> - <file>platforms/+wince/test2</file> - <file>platforms/+winnt/test2</file> - <file>platforms/+winrt/test2</file> - - <!-- platforms/test3: selection for the family only --> - <file>platforms/test3</file> - <file>platforms/+windows/test3</file> - <file>platforms/+unix/test3</file> - - <!-- platforms/test4 and 5: special cases for macOS --> - <file>platforms/test4</file> - <file>platforms/+osx/test4</file> - <file>platforms/test5</file> - <file>platforms/+mac/test5</file> -</qresource> +<RCC> + <qresource prefix="/"> + <file>extras/test</file> + <file>extras/test2</file> + <file>extras/+custom1/test</file> + <file>extras/+custom1/test3</file> + <file>extras/+custom2/test</file> + <file>extras/+custom3/test</file> + <file>extras/+custom3/+custom2/test</file> + <file>extras/+custom3/+custom4/test</file> + <file>extras/+custom3/+custom5/test</file> + <file>extras/+custom5/+custom3/test</file> + <file>platforms/test</file> + <file>platforms/+unix/+android/test</file> + <file>platforms/+unix/+darwin/test</file> + <file>platforms/+unix/+haiku/test</file> + <file>platforms/+unix/+linux/test</file> + <file>platforms/+unix/+qnx/test</file> + <file>platforms/+unix/test</file> + <file>platforms/+windows/+wince/test</file> + <file>platforms/+windows/+winnt/test</file> + <file>platforms/+windows/+winrt/test</file> + <file>platforms/+windows/test</file> + <file>platforms/+android/test</file> + <file>platforms/+ios/test</file> + <file>platforms/+macos/test</file> + <file>platforms/+darwin/test</file> + <file>platforms/+haiku/test</file> + <file>platforms/+linux/test</file> + <file>platforms/+qnx/test</file> + <file>platforms/+wince/test</file> + <file>platforms/+winrt/test</file> + <file>platforms/test2</file> + <file>platforms/+android/test2</file> + <file>platforms/+ios/test2</file> + <file>platforms/+macos/test2</file> + <file>platforms/+haiku/test2</file> + <file>platforms/+linux/test2</file> + <file>platforms/+qnx/test2</file> + <file>platforms/+wince/test2</file> + <file>platforms/+winnt/test2</file> + <file>platforms/+winrt/test2</file> + <file>platforms/test3</file> + <file>platforms/+windows/test3</file> + <file>platforms/+unix/test3</file> + <file>platforms/test4</file> + <file>platforms/test5</file> + <file>platforms/+unix/+darwin/+macos/test</file> + <file>platforms/+unix/+darwin/+ios/test</file> + </qresource> </RCC> diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index 11b1fdaeeb..bac7a69e0f 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -126,14 +126,6 @@ void tst_QFileSelector::basicTest_data() QTest::newRow("platform3") << QString(":/platforms/test3") << QStringList() << expectedPlatform3File; -#ifdef Q_OS_MACOS - // special case for compatibility code - QTest::newRow("osx-compat") << QString(":/platforms/test4") << QStringList() - << ":/platforms/+osx/test4"; - QTest::newRow("mac-compat") << QString(":/platforms/test5") << QStringList() - << ":/platforms/+mac/test5"; -#endif - QString resourceTestPath(":/extras/test"); QString custom1("custom1"); QTest::newRow("custom1-noselector") << resourceTestPath << QStringList() diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 0f07ba4bb2..c969e72c18 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -39,7 +39,9 @@ #include <QtCore/QDir> #include <QtCore/QThread> #include <QtCore/QSysInfo> -#include <QtGui/QKeySequence> +#if QT_CONFIG(shortcut) +# include <QtGui/QKeySequence> +#endif #include <QtCore> #include <QtGui> @@ -1364,6 +1366,7 @@ void tst_QSettings::testVariantTypes() dt.setOffsetFromUtc(3600); testVal("key14", dt, QDateTime, DateTime); +#if QT_CONFIG(shortcut) // We store key sequences as strings instead of binary variant blob, for improved // readability in the resulting format. if (format >= QSettings::InvalidFormat) { @@ -1373,6 +1376,7 @@ void tst_QSettings::testVariantTypes() QKeySequence(Qt::ControlModifier + Qt::Key_F1).toString(QKeySequence::NativeText), QString, String); } +#endif // QT_CONFIG(shortcut) #undef testVal } diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 12c29a6e13..2a4ee55fa8 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1024,9 +1024,9 @@ static void testConstructHelper() typedef typename MetaEnumToType<ID>::Type Type; QMetaType info(ID); int size = info.sizeOf(); - void *storage1 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage1 = qMallocAligned(size, alignof(Type)); void *actual1 = QMetaType::construct(ID, storage1, /*copy=*/0); - void *storage2 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage2 = qMallocAligned(size, alignof(Type)); void *actual2 = info.construct(storage2, /*copy=*/0); QCOMPARE(actual1, storage1); QCOMPARE(actual2, storage2); @@ -1178,9 +1178,9 @@ static void testConstructCopyHelper() QMetaType info(ID); int size = QMetaType::sizeOf(ID); QCOMPARE(info.sizeOf(), size); - void *storage1 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage1 = qMallocAligned(size, alignof(Type)); void *actual1 = QMetaType::construct(ID, storage1, expected); - void *storage2 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage2 = qMallocAligned(size, alignof(Type)); void *actual2 = info.construct(storage2, expected); QCOMPARE(actual1, storage1); QCOMPARE(actual2, storage2); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index a805bfb747..5b576fe154 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -81,9 +81,6 @@ private slots: void senderTest(); void declareInterface(); void qpointerResetBeforeDestroyedSignal(); -#ifndef QT_NO_USERDATA - void testUserData(); -#endif void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); @@ -2341,51 +2338,6 @@ void tst_QObject::declareInterface() } -#ifndef QT_NO_USERDATA -class CustomData : public QObjectUserData -{ -public: - int id; -}; - -void tst_QObject::testUserData() -{ - const int USER_DATA_COUNT = 100; - int user_data_ids[USER_DATA_COUNT]; - - // Register a few - for (int i=0; i<USER_DATA_COUNT; ++i) { - user_data_ids[i] = QObject::registerUserData(); - } - - // Randomize the table a bit - for (int i=0; i<100; ++i) { - int p1 = QRandomGenerator::global()->bounded(USER_DATA_COUNT); - int p2 = QRandomGenerator::global()->bounded(USER_DATA_COUNT); - - int tmp = user_data_ids[p1]; - user_data_ids[p1] = user_data_ids[p2]; - user_data_ids[p2] = tmp; - } - - // insert the user data into an object - QObject my_test_object; - for (int i=0; i<USER_DATA_COUNT; ++i) { - CustomData *data = new CustomData; - data->id = user_data_ids[i]; - my_test_object.setUserData(data->id, data); - } - - // verify that all ids and positions are matching - for (int i=0; i<USER_DATA_COUNT; ++i) { - int id = user_data_ids[i]; - CustomData *data = static_cast<CustomData *>(my_test_object.userData(id)); - QVERIFY(data != nullptr); - QCOMPARE(data->id, id); - } -} -#endif // QT_NO_USERDATA - class DestroyedListener : public QObject { Q_OBJECT @@ -6974,8 +6926,7 @@ void tst_QObject::noDeclarativeParentChangedOnDestruction() QObject *parent = new QObject; QObject *child = new QObject; - QAbstractDeclarativeDataImpl dummy; - dummy.ownedByQml1 = false; + QAbstractDeclarativeData dummy; QObjectPrivate::get(child)->declarativeData = &dummy; parentChangeCalled = false; diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 8197c386c5..d402e3f63b 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -2327,6 +2327,7 @@ void tst_QDataStream::setVersion() QDataStream latest; QFETCH(int, vers); +#if QT_CONFIG(shortcut) /* Test QKeySequence. */ @@ -2351,6 +2352,7 @@ void tst_QDataStream::setVersion() } QCOMPARE(deadbeef, 0xDEADBEEF); } +#endif // QT_CONFIG(shortcut) /* Test QPalette. diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index bef491d5f0..22ee7d17b7 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -237,28 +237,23 @@ template <typename T> struct TypeInStruct { T type; }; void tst_QAtomicInt::alignment() { -#ifdef Q_ALIGNOF - // this will cause a build error if the alignment isn't the same - char dummy1[Q_ALIGNOF(QBasicAtomicInt) == Q_ALIGNOF(TypeInStruct<int>) ? 1 : -1]; - char dummy2[Q_ALIGNOF(QAtomicInt) == Q_ALIGNOF(TypeInStruct<int>) ? 1 : -1]; - (void)dummy1; (void)dummy2; + Q_STATIC_ASSERT(alignof(QBasicAtomicInt) == alignof(TypeInStruct<int>)); + Q_STATIC_ASSERT(alignof(QBasicAtomicInt) == alignof(TypeInStruct<int>)); #ifdef Q_ATOMIC_INT32_IS_SUPPORTED - QCOMPARE(Q_ALIGNOF(QBasicAtomicInteger<int>), Q_ALIGNOF(TypeInStruct<int>)); + QCOMPARE(alignof(QBasicAtomicInteger<int>), alignof(TypeInStruct<int>)); #endif #ifdef Q_ATOMIC_INT16_IS_SUPPORTED - QCOMPARE(Q_ALIGNOF(QBasicAtomicInteger<short>), Q_ALIGNOF(TypeInStruct<short>)); + QCOMPARE(alignof(QBasicAtomicInteger<short>), alignof(TypeInStruct<short>)); #endif #ifdef Q_ATOMIC_INT8_IS_SUPPORTED - QCOMPARE(Q_ALIGNOF(QBasicAtomicInteger<char>), Q_ALIGNOF(TypeInStruct<char>)); + QCOMPARE(alignof(QBasicAtomicInteger<char>), alignof(TypeInStruct<char>)); #endif #ifdef Q_ATOMIC_INT64_IS_SUPPORTED - QCOMPARE(Q_ALIGNOF(QBasicAtomicInteger<qlonglong>), Q_ALIGNOF(TypeInStruct<qlonglong>)); -#endif - + QCOMPARE(alignof(QBasicAtomicInteger<qlonglong>), alignof(TypeInStruct<qlonglong>)); #endif } diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp index a699cf6202..9e12e7ccce 100644 --- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp @@ -108,11 +108,7 @@ void tst_QAtomicPointer::warningFree() void tst_QAtomicPointer::alignment() { -#ifdef Q_ALIGNOF - // this will cause a build error if the alignment isn't the same - char dummy[Q_ALIGNOF(QBasicAtomicPointer<void>) == Q_ALIGNOF(void*) ? 1 : -1]; - (void)dummy; -#endif + Q_STATIC_ASSERT(alignof(QBasicAtomicPointer<void>) == alignof(void*)); } void tst_QAtomicPointer::constructor() diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index e79a4dba29..a9adda2750 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -3214,9 +3214,7 @@ void tst_Collections::forwardDeclared() { typedef QSet<T1> C; C *x = 0; /* C::iterator i; */ C::const_iterator j; Q_UNUSED(x) } } -#if defined(Q_ALIGNOF) && defined(Q_DECL_ALIGN) - -class Q_DECL_ALIGN(4) Aligned4 +class alignas(4) Aligned4 { char i; public: @@ -3228,7 +3226,7 @@ public: inline bool operator<(const Aligned4 &other) const { return i < other.i; } friend inline int qHash(const Aligned4 &a) { return qHash(a.i); } }; -Q_STATIC_ASSERT(Q_ALIGNOF(Aligned4) % 4 == 0); +Q_STATIC_ASSERT(alignof(Aligned4) % 4 == 0); #if defined(Q_PROCESSOR_ARM) # if defined(Q_COMPILER_ALIGNAS) && defined(__BIGGEST_ALIGNMENT__) @@ -3242,7 +3240,7 @@ Q_STATIC_ASSERT(Q_ALIGNOF(Aligned4) % 4 == 0); # define BIGGEST_ALIGNMENT_TO_TEST 128 #endif -class Q_DECL_ALIGN(BIGGEST_ALIGNMENT_TO_TEST) AlignedBiggest +class alignas(BIGGEST_ALIGNMENT_TO_TEST) AlignedBiggest { char i; public: @@ -3254,7 +3252,7 @@ public: inline bool operator<(const AlignedBiggest &other) const { return i < other.i; } friend inline int qHash(const AlignedBiggest &a) { return qHash(a.i); } }; -Q_STATIC_ASSERT(Q_ALIGNOF(AlignedBiggest) % BIGGEST_ALIGNMENT_TO_TEST == 0); +Q_STATIC_ASSERT(alignof(AlignedBiggest) % BIGGEST_ALIGNMENT_TO_TEST == 0); template<typename C> void testVectorAlignment() @@ -3325,13 +3323,6 @@ void tst_Collections::alignment() testAssociativeContainerAlignment<QHash<AlignedBiggest, AlignedBiggest> >(); } -#else -void tst_Collections::alignment() -{ - QSKIP("Compiler doesn't support necessary extension keywords"); -} -#endif - #ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS template<template<class> class C> diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 25e2f21d03..12752e4d07 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -160,7 +160,7 @@ void tst_QArrayData::referenceCounting() void tst_QArrayData::sharedNullEmpty() { QArrayData *null = const_cast<QArrayData *>(QArrayData::shared_null); - QArrayData *empty = QArrayData::allocate(1, Q_ALIGNOF(QArrayData), 0); + QArrayData *empty = QArrayData::allocate(1, alignof(QArrayData), 0); QVERIFY(null->ref.isStatic()); QVERIFY(null->ref.isShared()); @@ -657,16 +657,16 @@ void tst_QArrayData::allocate_data() size_t objectSize; size_t alignment; } types[] = { - { "char", sizeof(char), Q_ALIGNOF(char) }, - { "short", sizeof(short), Q_ALIGNOF(short) }, - { "void *", sizeof(void *), Q_ALIGNOF(void *) } + { "char", sizeof(char), alignof(char) }, + { "short", sizeof(short), alignof(short) }, + { "void *", sizeof(void *), alignof(void *) } }; - QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0); + QArrayData *shared_empty = QArrayData::allocate(0, alignof(QArrayData), 0); QVERIFY(shared_empty); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) - QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable); + QArrayData *unsharable_empty = QArrayData::allocate(0, alignof(QArrayData), 0, QArrayData::Unsharable); QVERIFY(unsharable_empty); #endif @@ -709,7 +709,7 @@ void tst_QArrayData::allocate() // Minimum alignment that can be requested is that of QArrayData. // Typically, this alignment is sizeof(void *) and ensured by malloc. - size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + size_t minAlignment = qMax(alignment, alignof(QArrayData)); // Shared Empty QCOMPARE(QArrayData::allocate(objectSize, minAlignment, 0, @@ -749,11 +749,11 @@ void tst_QArrayData::reallocate() // Maximum alignment that can be requested is that of QArrayData, // otherwise, we can't use reallocate(). - Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData)); + Q_ASSERT(alignment <= alignof(QArrayData)); // Minimum alignment that can be requested is that of QArrayData. // Typically, this alignment is sizeof(void *) and ensured by malloc. - size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + size_t minAlignment = qMax(alignment, alignof(QArrayData)); int capacity = 10; Deallocator keeper(objectSize, minAlignment); @@ -808,7 +808,7 @@ void tst_QArrayData::alignment() // Minimum alignment that can be requested is that of QArrayData. // Typically, this alignment is sizeof(void *) and ensured by malloc. - size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + size_t minAlignment = qMax(alignment, alignof(QArrayData)); Deallocator keeper(sizeof(Unaligned), minAlignment); keeper.headers.reserve(100); @@ -826,7 +826,7 @@ void tst_QArrayData::alignment() // allocated together QVERIFY(data->offset >= qptrdiff(sizeof(QArrayData))); QVERIFY(data->offset <= qptrdiff(sizeof(QArrayData) - + minAlignment - Q_ALIGNOF(QArrayData))); + + minAlignment - alignof(QArrayData))); // Data is aligned QCOMPARE(quintptr(quintptr(data->data()) % alignment), quintptr(0u)); @@ -886,7 +886,7 @@ void tst_QArrayData::typedData() { Deallocator keeper(sizeof(char), - Q_ALIGNOF(QTypedArrayData<char>::AlignmentDummy)); + alignof(QTypedArrayData<char>::AlignmentDummy)); QArrayData *array = QTypedArrayData<char>::allocate(10); keeper.headers.append(array); @@ -906,7 +906,7 @@ void tst_QArrayData::typedData() { Deallocator keeper(sizeof(short), - Q_ALIGNOF(QTypedArrayData<short>::AlignmentDummy)); + alignof(QTypedArrayData<short>::AlignmentDummy)); QArrayData *array = QTypedArrayData<short>::allocate(10); keeper.headers.append(array); @@ -926,7 +926,7 @@ void tst_QArrayData::typedData() { Deallocator keeper(sizeof(double), - Q_ALIGNOF(QTypedArrayData<double>::AlignmentDummy)); + alignof(QTypedArrayData<double>::AlignmentDummy)); QArrayData *array = QTypedArrayData<double>::allocate(10); keeper.headers.append(array); diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index 05480c6dd2..5453d9de61 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -31,6 +31,7 @@ #include <qcoreapplication.h> #include <qmetatype.h> #include <QtTest/QtTest> +#include <QtCore/qregularexpression.h> #include <QtCore/qvariant.h> #include <QtDBus/QtDBus> #include <QtDBus/private/qdbus_symbols_p.h> @@ -451,14 +452,16 @@ void tst_QDBusInterface::introspectVirtualObject() QDBusMessage message = QDBusMessage::createMethodCall(con.baseService(), path, "org.freedesktop.DBus.Introspectable", "Introspect"); QDBusMessage reply = con.call(message, QDBus::Block, 5000); QVERIFY(reply.arguments().at(0).toString().contains( - QRegExp("<node>.*zitroneneis.*<interface name=") )); + QRegularExpression("<node>.*zitroneneis.*<interface name=", + QRegularExpression::DotMatchesEverythingOption))); QDBusMessage message2 = QDBusMessage::createMethodCall(con.baseService(), path + "/foo", "org.freedesktop.DBus.Introspectable", "Introspect"); QDBusMessage reply2 = con.call(message2, QDBus::Block, 5000); QVERIFY(reply2.arguments().at(0).toString().contains( - QRegExp("<node>.*<interface name=\"org.qtproject.QtDBus.VirtualObject\">" - ".*<method name=\"klingeling\" />\n" - ".*</interface>.*<interface name=") )); + QRegularExpression("<node>.*<interface name=\"org.qtproject.QtDBus.VirtualObject\">" + ".*<method name=\"klingeling\" />\n" + ".*</interface>.*<interface name=", + QRegularExpression::DotMatchesEverythingOption))); } void tst_QDBusInterface::callMethod() diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp index ec6bb8dcee..6287960457 100644 --- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp +++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp @@ -37,6 +37,8 @@ #include <qscreen.h> #include <limits.h> +#ifndef QT_NO_PICTURE + class tst_QPicture : public QObject { Q_OBJECT @@ -45,7 +47,6 @@ public: tst_QPicture(); private slots: - void getSetCheck(); void devType(); void paintingActive(); void boundingRect(); @@ -56,31 +57,6 @@ private slots: void boundaryValues(); }; -// Testing get/set functions -void tst_QPicture::getSetCheck() -{ - QPictureIO obj1; - // const QPicture & QPictureIO::picture() - // void QPictureIO::setPicture(const QPicture &) - // const char * QPictureIO::format() - // void QPictureIO::setFormat(const char *) - const char var2[] = "PNG"; - obj1.setFormat(var2); - QCOMPARE(var2, obj1.format()); - obj1.setFormat((char *)0); - // The format is stored internally in a QString, so return is always a valid char * - QVERIFY(QString(obj1.format()).isEmpty()); - - // const char * QPictureIO::parameters() - // void QPictureIO::setParameters(const char *) - const char var3[] = "Bogus data"; - obj1.setParameters(var3); - QCOMPARE(var3, obj1.parameters()); - obj1.setParameters((char *)0); - // The format is stored internally in a QString, so return is always a valid char * - QVERIFY(QString(obj1.parameters()).isEmpty()); -} - tst_QPicture::tst_QPicture() { } @@ -316,6 +292,7 @@ void tst_QPicture::boundaryValues() painter.end(); } - QTEST_MAIN(tst_QPicture) #include "tst_qpicture.moc" + +#endif // QT_NO_PICTURE diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 42135dae24..4d86b0f8f5 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -29,6 +29,11 @@ SUBDIRS=\ win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop +!qtConfig(shortcut): SUBDIRS -= \ + qkeysequence \ + qguimetatype \ + qguivariant + !qtHaveModule(widgets): SUBDIRS -= \ qmouseevent_modal \ qtouchevent diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp index 3ce65a6785..2645bb111e 100644 --- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp +++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -181,9 +181,13 @@ template<> struct TestValueFactory<QMetaType::QCursor> { static QCursor *create() { return new QCursor(Qt::WaitCursor); } }; #endif + +#if QT_CONFIG(shortcut) template<> struct TestValueFactory<QMetaType::QKeySequence> { static QKeySequence *create() { return new QKeySequence(QKeySequence::Close); } }; +#endif + template<> struct TestValueFactory<QMetaType::QPen> { static QPen *create() { return new QPen(Qt::DashDotDotLine); } }; @@ -312,30 +316,10 @@ void tst_QGuiMetaType::sizeOf() QCOMPARE(QMetaType::sizeOf(type), size); } -#ifndef Q_ALIGNOF -template<uint N> -struct RoundToNextHighestPowerOfTwo -{ -private: - enum { V1 = N-1 }; - enum { V2 = V1 | (V1 >> 1) }; - enum { V3 = V2 | (V2 >> 2) }; - enum { V4 = V3 | (V3 >> 4) }; - enum { V5 = V4 | (V4 >> 8) }; - enum { V6 = V5 | (V5 >> 16) }; -public: - enum { Value = V6 + 1 }; -}; -#endif - template<class T> struct TypeAlignment { -#ifdef Q_ALIGNOF - enum { Value = Q_ALIGNOF(T) }; -#else - enum { Value = RoundToNextHighestPowerOfTwo<sizeof(T)>::Value }; -#endif + enum { Value = alignof(T) }; }; void tst_QGuiMetaType::flags_data() diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index 87a47bd93b..6a928cac7a 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -64,8 +64,10 @@ public: private slots: void basicEventDelivery(); +#if QT_CONFIG(shortcut) void modifiers_data(); void modifiers(); +#endif }; tst_QKeyEvent::tst_QKeyEvent() @@ -128,6 +130,8 @@ static QByteArray modifiersTestRowName(const QString &keySequence) return result; } +#if QT_CONFIG(shortcut) + void tst_QKeyEvent::modifiers_data() { struct Modifier @@ -198,5 +202,7 @@ void tst_QKeyEvent::modifiers() } } +#endif // QT_CONFIG(shortcut) + QTEST_MAIN(tst_QKeyEvent) #include "tst_qkeyevent.moc" diff --git a/tests/auto/network/access/access.pro b/tests/auto/network/access/access.pro index b140b5e9f2..d2b4d97b21 100644 --- a/tests/auto/network/access/access.pro +++ b/tests/auto/network/access/access.pro @@ -7,7 +7,6 @@ SUBDIRS=\ qnetworkrequest \ qhttpnetworkconnection \ qnetworkreply \ - spdy \ qnetworkcachemetadata \ qftp \ qhttpnetworkreply \ diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 6f94692cb1..904cfd52b0 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -939,13 +939,6 @@ void tst_Http2::replyFinished() QVERIFY(http2Used.isValid()); QVERIFY(http2Used.toBool()); - const QVariant spdyUsed(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute)); - if (!spdyUsed.isValid() || spdyUsed.toBool()) - stopEventLoop(); - - QVERIFY(spdyUsed.isValid()); - QVERIFY(!spdyUsed.toBool()); - const QVariant code(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute)); if (!code.isValid() || !code.canConvert<int>() || code.value<int>() != 200) stopEventLoop(); diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 2a0651f96f..18450f1853 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -15,8 +15,6 @@ linux # QTBUG-71953 [getFromHttp] * !android !winrt -[getFromHttp:success-external] -* [getFromHttpIntoBuffer] osx [getFromHttpIntoBuffer2] diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 3bc6717d58..d7e35b77c0 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1914,10 +1914,6 @@ void tst_QNetworkReply::getFromHttp_data() << testDataDir + "/rfc3252.txt" << "http://" + QtNetworkSettings::httpServerName() + "/qtest/rfc3252.txt"; - QTest::newRow("success-external") - << testDataDir + "/rfc3252.txt" - << "http://www.ietf.org/rfc/rfc3252.txt"; - QTest::newRow("bigfile-internal") << testDataDir + "/bigfile" << "http://" + QtNetworkSettings::httpServerName() + "/qtest/bigfile"; diff --git a/tests/auto/network/access/spdy/BLACKLIST b/tests/auto/network/access/spdy/BLACKLIST deleted file mode 100644 index 5cf79327be..0000000000 --- a/tests/auto/network/access/spdy/BLACKLIST +++ /dev/null @@ -1,7 +0,0 @@ -[download] -opensuse-leap -[upload] -opensuse-leap -ubuntu-18.04 -b2qt - diff --git a/tests/auto/network/access/spdy/spdy.pro b/tests/auto/network/access/spdy/spdy.pro deleted file mode 100644 index cdbe60a19b..0000000000 --- a/tests/auto/network/access/spdy/spdy.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_spdy -SOURCES += tst_spdy.cpp - -QT = core core-private network network-private testlib - -win32:CONFIG += insignificant_test # QTBUG-47128 diff --git a/tests/auto/network/access/spdy/tst_spdy.cpp b/tests/auto/network/access/spdy/tst_spdy.cpp deleted file mode 100644 index f4a5976558..0000000000 --- a/tests/auto/network/access/spdy/tst_spdy.cpp +++ /dev/null @@ -1,693 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QtTest/QtTest> -#include <QtNetwork/QNetworkAccessManager> -#include <QtNetwork/QNetworkReply> -#include <QtNetwork/QHttpPart> -#include <QtNetwork/QHttpMultiPart> -#include <QtNetwork/QNetworkProxy> -#include <QtNetwork/QAuthenticator> -#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_OPENSSL) -#include <QtNetwork/private/qsslsocket_openssl_p.h> -#endif // QT_BUILD_INTERNAL && !QT_NO_OPENSSL - -#include "../../../network-settings.h" - -Q_DECLARE_METATYPE(QAuthenticator*) - -class tst_Spdy: public QObject -{ - Q_OBJECT - -public: - tst_Spdy(); - ~tst_Spdy(); - -private Q_SLOTS: - void initTestCase(); - void settingsAndNegotiation_data(); - void settingsAndNegotiation(); -#ifndef QT_NO_NETWORKPROXY - void download_data(); - void download(); -#endif // !QT_NO_NETWORKPROXY - void headerFields(); -#ifndef QT_NO_NETWORKPROXY - void upload_data(); - void upload(); - void errors_data(); - void errors(); -#endif // !QT_NO_NETWORKPROXY - void multipleRequests_data(); - void multipleRequests(); - -private: - QNetworkAccessManager m_manager; - int m_multipleRequestsCount; - int m_multipleRepliesFinishedCount; - const QString m_rfc3252FilePath; - -protected Q_SLOTS: - void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *authenticator); - void multipleRequestsFinishedSlot(); -}; - -tst_Spdy::tst_Spdy() - : m_rfc3252FilePath(QFINDTESTDATA("../qnetworkreply/rfc3252.txt")) -{ -#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) - qRegisterMetaType<QNetworkReply *>(); // for QSignalSpy - qRegisterMetaType<QAuthenticator *>(); - - connect(&m_manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), - this, SLOT(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *))); -#else - QSKIP("Qt built withouth OpenSSL, or the OpenSSL version is too old"); -#endif // defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ... -} - -tst_Spdy::~tst_Spdy() -{ -} - -void tst_Spdy::initTestCase() -{ - QVERIFY(!m_rfc3252FilePath.isEmpty()); - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); -} - -void tst_Spdy::settingsAndNegotiation_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<bool>("setAttribute"); - QTest::addColumn<bool>("enabled"); - QTest::addColumn<QByteArray>("expectedProtocol"); - QTest::addColumn<QByteArray>("expectedContent"); - - QTest::newRow("default-settings") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/cgi-bin/echo.cgi?1") - << false << false << QByteArray() - << QByteArray("1"); - - QTest::newRow("http-url") << QUrl("http://" + QtNetworkSettings::serverName() - + "/qtest/cgi-bin/echo.cgi?1") - << true << true << QByteArray() - << QByteArray("1"); - - QTest::newRow("spdy-disabled") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/cgi-bin/echo.cgi?1") - << true << false << QByteArray() - << QByteArray("1"); - -#ifndef QT_NO_OPENSSL - QTest::newRow("spdy-enabled") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/cgi-bin/echo.cgi?1") - << true << true << QByteArray(QSslConfiguration::NextProtocolSpdy3_0) - << QByteArray("1"); -#endif // QT_NO_OPENSSL -} - -void tst_Spdy::settingsAndNegotiation() -{ - QFETCH(QUrl, url); - QFETCH(bool, setAttribute); - QFETCH(bool, enabled); - - QNetworkRequest request(url); - - if (setAttribute) { - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, QVariant(enabled)); - } - - QNetworkReply *reply = m_manager.get(request); - reply->ignoreSslErrors(); - QSignalSpy metaDataChangedSpy(reply, SIGNAL(metaDataChanged())); - QSignalSpy readyReadSpy(reply, SIGNAL(readyRead())); - QSignalSpy finishedSpy(reply, SIGNAL(finished())); - - QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QSignalSpy finishedManagerSpy(&m_manager, SIGNAL(finished(QNetworkReply*))); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QFETCH(QByteArray, expectedProtocol); - -#ifndef QT_NO_OPENSSL - bool expectedSpdyUsed = (expectedProtocol == QSslConfiguration::NextProtocolSpdy3_0); - QCOMPARE(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(), expectedSpdyUsed); -#endif // QT_NO_OPENSSL - - QCOMPARE(metaDataChangedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - - int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - QCOMPARE(statusCode, 200); - - QByteArray content = reply->readAll(); - - QFETCH(QByteArray, expectedContent); - QCOMPARE(expectedContent, content); - -#ifndef QT_NO_OPENSSL - QSslConfiguration::NextProtocolNegotiationStatus expectedStatus = - (expectedProtocol.isEmpty()) - ? QSslConfiguration::NextProtocolNegotiationNone - : QSslConfiguration::NextProtocolNegotiationNegotiated; - QCOMPARE(reply->sslConfiguration().nextProtocolNegotiationStatus(), - expectedStatus); - - QCOMPARE(reply->sslConfiguration().nextNegotiatedProtocol(), expectedProtocol); -#endif // QT_NO_OPENSSL -} - -void tst_Spdy::proxyAuthenticationRequired(const QNetworkProxy &/*proxy*/, - QAuthenticator *authenticator) -{ - authenticator->setUser("qsockstest"); - authenticator->setPassword("password"); -} - -#ifndef QT_NO_NETWORKPROXY -void tst_Spdy::download_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QString>("fileName"); - QTest::addColumn<QNetworkProxy>("proxy"); - - QTest::newRow("mediumfile") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/rfc3252.txt") - << m_rfc3252FilePath - << QNetworkProxy(); - - QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::serverName()); - QString proxyserver = hostInfo.addresses().first().toString(); - - QTest::newRow("mediumfile-http-proxy") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/rfc3252.txt") - << m_rfc3252FilePath - << QNetworkProxy(QNetworkProxy::HttpProxy, proxyserver, 3128); - - QTest::newRow("mediumfile-http-proxy-auth") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/rfc3252.txt") - << m_rfc3252FilePath - << QNetworkProxy(QNetworkProxy::HttpProxy, - proxyserver, 3129); - - QTest::newRow("mediumfile-socks-proxy") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/rfc3252.txt") - << m_rfc3252FilePath - << QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyserver, 1080); - - QTest::newRow("mediumfile-socks-proxy-auth") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/rfc3252.txt") - << m_rfc3252FilePath - << QNetworkProxy(QNetworkProxy::Socks5Proxy, - proxyserver, 1081); - - QTest::newRow("bigfile") << QUrl("https://" + QtNetworkSettings::serverName() - + "/qtest/bigfile") - << QFINDTESTDATA("../qnetworkreply/bigfile") - << QNetworkProxy(); -} - -void tst_Spdy::download() -{ - QFETCH(QUrl, url); - QFETCH(QString, fileName); - QFETCH(QNetworkProxy, proxy); - - QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - - if (proxy.type() != QNetworkProxy::DefaultProxy) { - m_manager.setProxy(proxy); - } - QNetworkReply *reply = m_manager.get(request); - reply->ignoreSslErrors(); - QSignalSpy metaDataChangedSpy(reply, SIGNAL(metaDataChanged())); - QSignalSpy downloadProgressSpy(reply, SIGNAL(downloadProgress(qint64, qint64))); - QSignalSpy readyReadSpy(reply, SIGNAL(readyRead())); - QSignalSpy finishedSpy(reply, SIGNAL(finished())); - - QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QSignalSpy finishedManagerSpy(&m_manager, SIGNAL(finished(QNetworkReply*))); - QSignalSpy proxyAuthRequiredSpy(&m_manager, SIGNAL( - proxyAuthenticationRequired(const QNetworkProxy &, - QAuthenticator *))); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(finishedManagerSpy.count(), 1); - QCOMPARE(metaDataChangedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QVERIFY(downloadProgressSpy.count() > 0); - QVERIFY(readyReadSpy.count() > 0); - - QVERIFY(proxyAuthRequiredSpy.count() <= 1); - - QCOMPARE(reply->error(), QNetworkReply::NoError); - QCOMPARE(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(), true); - QCOMPARE(reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool(), true); - QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - QFile file(fileName); - QVERIFY(file.open(QIODevice::ReadOnly)); - - qint64 contentLength = reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(); - qint64 expectedContentLength = file.bytesAvailable(); - QCOMPARE(contentLength, expectedContentLength); - - QByteArray expectedContent = file.readAll(); - QByteArray content = reply->readAll(); - QCOMPARE(content, expectedContent); - - reply->deleteLater(); - m_manager.setProxy(QNetworkProxy()); // reset -} -#endif // !QT_NO_NETWORKPROXY - -void tst_Spdy::headerFields() -{ - QUrl url(QUrl("https://" + QtNetworkSettings::serverName())); - QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - - QNetworkReply *reply = m_manager.get(request); - reply->ignoreSslErrors(); - - QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(reply->rawHeader("Content-Type"), QByteArray("text/html")); - QVERIFY(reply->rawHeader("Content-Length").toInt() > 0); - QVERIFY(reply->rawHeader("server").contains("Apache")); - - QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader).toByteArray(), QByteArray("text/html")); - QVERIFY(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong() > 0); - QVERIFY(reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().isValid()); - QVERIFY(reply->header(QNetworkRequest::ServerHeader).toByteArray().contains("Apache")); -} - -static inline QByteArray md5sum(const QByteArray &data) -{ - return QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex().append('\n'); -} - -#ifndef QT_NO_NETWORKPROXY -void tst_Spdy::upload_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QByteArray>("data"); - QTest::addColumn<QByteArray>("uploadMethod"); - QTest::addColumn<QObject *>("uploadObject"); - QTest::addColumn<QByteArray>("md5sum"); - QTest::addColumn<QNetworkProxy>("proxy"); - - - // 1. test uploading of byte arrays - - QUrl md5Url("https://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi"); - - QByteArray data; - data = ""; - QObject *dummyObject = 0; - QTest::newRow("empty") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) << QNetworkProxy(); - - data = "This is a normal message."; - QTest::newRow("generic") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) << QNetworkProxy(); - - data = "This is a message to show that Qt rocks!\r\n\n"; - QTest::newRow("small") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) << QNetworkProxy(); - - data = QByteArray("abcd\0\1\2\abcd",12); - QTest::newRow("with-nul") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) << QNetworkProxy(); - - data = QByteArray(4097, '\4'); - QTest::newRow("4k+1") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data)<< QNetworkProxy(); - - QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::serverName()); - QString proxyserver = hostInfo.addresses().first().toString(); - - QTest::newRow("4k+1-with-http-proxy") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) - << QNetworkProxy(QNetworkProxy::HttpProxy, proxyserver, 3128); - - QTest::newRow("4k+1-with-http-proxy-auth") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) - << QNetworkProxy(QNetworkProxy::HttpProxy, - proxyserver, 3129); - - QTest::newRow("4k+1-with-socks-proxy") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyserver, 1080); - - QTest::newRow("4k+1-with-socks-proxy-auth") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, - proxyserver, 1081); - - data = QByteArray(128*1024+1, '\177'); - QTest::newRow("128k+1") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) << QNetworkProxy(); - - data = QByteArray(128*1024+1, '\177'); - QTest::newRow("128k+1-put") << md5Url << data << QByteArray("PUT") << dummyObject - << md5sum(data) << QNetworkProxy(); - - data = QByteArray(2*1024*1024+1, '\177'); - QTest::newRow("2MB+1") << md5Url << data << QByteArray("POST") << dummyObject - << md5sum(data) << QNetworkProxy(); - - - // 2. test uploading of files - - QFile *file = new QFile(m_rfc3252FilePath); - file->open(QIODevice::ReadOnly); - QTest::newRow("file-26K") << md5Url << QByteArray() << QByteArray("POST") - << static_cast<QObject *>(file) - << QByteArray("b3e32ac459b99d3f59318f3ac31e4bee\n") << QNetworkProxy(); - - QFile *file2 = new QFile(QFINDTESTDATA("../qnetworkreply/image1.jpg")); - file2->open(QIODevice::ReadOnly); - QTest::newRow("file-1MB") << md5Url << QByteArray() << QByteArray("POST") - << static_cast<QObject *>(file2) - << QByteArray("87ef3bb319b004ba9e5e9c9fa713776e\n") << QNetworkProxy(); - - - // 3. test uploading of multipart - - QUrl multiPartUrl("https://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/multipart.cgi"); - - QHttpPart imagePart31; - imagePart31.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); - imagePart31.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage1\"")); - imagePart31.setRawHeader("Content-Location", "http://my.test.location.tld"); - imagePart31.setRawHeader("Content-ID", "my@id.tld"); - QFile *file31 = new QFile(QFINDTESTDATA("../qnetworkreply/image1.jpg")); - file31->open(QIODevice::ReadOnly); - imagePart31.setBodyDevice(file31); - QHttpMultiPart *imageMultiPart3 = new QHttpMultiPart(QHttpMultiPart::FormDataType); - imageMultiPart3->append(imagePart31); - file31->setParent(imageMultiPart3); - QHttpPart imagePart32; - imagePart32.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); - imagePart32.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage2\"")); - QFile *file32 = new QFile(QFINDTESTDATA("../qnetworkreply/image2.jpg")); - file32->open(QIODevice::ReadOnly); - imagePart32.setBodyDevice(file31); // check that resetting works - imagePart32.setBodyDevice(file32); - imageMultiPart3->append(imagePart32); - file32->setParent(imageMultiPart3); - QHttpPart imagePart33; - imagePart33.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); - imagePart33.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage3\"")); - QFile *file33 = new QFile(QFINDTESTDATA("../qnetworkreply/image3.jpg")); - file33->open(QIODevice::ReadOnly); - imagePart33.setBodyDevice(file33); - imageMultiPart3->append(imagePart33); - file33->setParent(imageMultiPart3); - QByteArray expectedData = "content type: multipart/form-data; boundary=\"" - + imageMultiPart3->boundary(); - expectedData.append("\"\nkey: testImage1, value: 87ef3bb319b004ba9e5e9c9fa713776e\n" - "key: testImage2, value: 483761b893f7fb1bd2414344cd1f3dfb\n" - "key: testImage3, value: ab0eb6fd4fcf8b4436254870b4513033\n"); - - QTest::newRow("multipart-3images") << multiPartUrl << QByteArray() << QByteArray("POST") - << static_cast<QObject *>(imageMultiPart3) << expectedData - << QNetworkProxy(); -} - -void tst_Spdy::upload() -{ - QFETCH(QUrl, url); - QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - - QFETCH(QByteArray, data); - QFETCH(QByteArray, uploadMethod); - QFETCH(QObject *, uploadObject); - QFETCH(QNetworkProxy, proxy); - - if (proxy.type() != QNetworkProxy::DefaultProxy) { - m_manager.setProxy(proxy); - } - - QNetworkReply *reply; - QHttpMultiPart *multiPart = 0; - - if (uploadObject) { - // upload via device - if (QIODevice *device = qobject_cast<QIODevice *>(uploadObject)) { - reply = m_manager.post(request, device); - } else if ((multiPart = qobject_cast<QHttpMultiPart *>(uploadObject))) { - reply = m_manager.post(request, multiPart); - } else { - QFAIL("got unknown upload device"); - } - } else { - // upload via byte array - if (uploadMethod == "PUT") { - reply = m_manager.put(request, data); - } else { - reply = m_manager.post(request, data); - } - } - - reply->ignoreSslErrors(); - QSignalSpy metaDataChangedSpy(reply, SIGNAL(metaDataChanged())); - QSignalSpy uploadProgressSpy(reply, SIGNAL(uploadProgress(qint64, qint64))); - QSignalSpy readyReadSpy(reply, SIGNAL(readyRead())); - QSignalSpy finishedSpy(reply, SIGNAL(finished())); - - QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QSignalSpy finishedManagerSpy(&m_manager, SIGNAL(finished(QNetworkReply*))); - - QTestEventLoop::instance().enterLoop(20); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(finishedManagerSpy.count(), 1); - QCOMPARE(metaDataChangedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QVERIFY(uploadProgressSpy.count() > 0); - QVERIFY(readyReadSpy.count() > 0); - - QCOMPARE(reply->error(), QNetworkReply::NoError); - QCOMPARE(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(), true); - QCOMPARE(reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool(), true); - QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - qint64 contentLength = reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(); - if (!multiPart) // script to test multiparts does not return a content length - QCOMPARE(contentLength, 33); // 33 bytes for md5 sums (including new line) - - QFETCH(QByteArray, md5sum); - QByteArray content = reply->readAll(); - QCOMPARE(content, md5sum); - - reply->deleteLater(); - if (uploadObject) - uploadObject->deleteLater(); - - m_manager.setProxy(QNetworkProxy()); // reset -} - -void tst_Spdy::errors_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QNetworkProxy>("proxy"); - QTest::addColumn<bool>("ignoreSslErrors"); - QTest::addColumn<int>("expectedReplyError"); - - QTest::newRow("http-404") << QUrl("https://" + QtNetworkSettings::serverName() + "/non-existent-url") - << QNetworkProxy() << true << int(QNetworkReply::ContentNotFoundError); - - QTest::newRow("ssl-errors") << QUrl("https://" + QtNetworkSettings::serverName()) - << QNetworkProxy() << false << int(QNetworkReply::SslHandshakeFailedError); - - QTest::newRow("host-not-found") << QUrl("https://this-host-does-not.exist") - << QNetworkProxy() - << true << int(QNetworkReply::HostNotFoundError); - - QTest::newRow("proxy-not-found") << QUrl("https://" + QtNetworkSettings::serverName()) - << QNetworkProxy(QNetworkProxy::HttpProxy, - "https://this-host-does-not.exist", 3128) - << true << int(QNetworkReply::HostNotFoundError); - - QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::serverName()); - QString proxyserver = hostInfo.addresses().first().toString(); - - QTest::newRow("proxy-unavailable") << QUrl("https://" + QtNetworkSettings::serverName()) - << QNetworkProxy(QNetworkProxy::HttpProxy, proxyserver, 10) - << true << int(QNetworkReply::UnknownNetworkError); - - QTest::newRow("no-proxy-credentials") << QUrl("https://" + QtNetworkSettings::serverName()) - << QNetworkProxy(QNetworkProxy::HttpProxy, proxyserver, 3129) - << true << int(QNetworkReply::ProxyAuthenticationRequiredError); -} - -void tst_Spdy::errors() -{ - QFETCH(QUrl, url); - QFETCH(QNetworkProxy, proxy); - QFETCH(bool, ignoreSslErrors); - QFETCH(int, expectedReplyError); - - QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - - disconnect(&m_manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), - 0, 0); - if (proxy.type() != QNetworkProxy::DefaultProxy) { - m_manager.setProxy(proxy); - } - QNetworkReply *reply = m_manager.get(request); - if (ignoreSslErrors) - reply->ignoreSslErrors(); - QSignalSpy finishedSpy(reply, SIGNAL(finished())); - QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); - - QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(errorSpy.count(), 1); - - QCOMPARE(reply->error(), static_cast<QNetworkReply::NetworkError>(expectedReplyError)); - - m_manager.setProxy(QNetworkProxy()); // reset - m_manager.clearAccessCache(); // e.g. to get an SSL error we need a new connection - connect(&m_manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), - this, SLOT(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), - Qt::UniqueConnection); // reset -} -#endif // !QT_NO_NETWORKPROXY - -void tst_Spdy::multipleRequests_data() -{ - QTest::addColumn<QList<QUrl> >("urls"); - - QString baseUrl = "https://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi?"; - QList<QUrl> urls; - for (int a = 1; a <= 50; ++a) - urls.append(QUrl(baseUrl + QLatin1String(QByteArray::number(a)))); - - QTest::newRow("one-request") << urls.mid(0, 1); - QTest::newRow("two-requests") << urls.mid(0, 2); - QTest::newRow("ten-requests") << urls.mid(0, 10); - QTest::newRow("twenty-requests") << urls.mid(0, 20); - QTest::newRow("fifty-requests") << urls; -} - -void tst_Spdy::multipleRequestsFinishedSlot() -{ - m_multipleRepliesFinishedCount++; - if (m_multipleRepliesFinishedCount == m_multipleRequestsCount) - QTestEventLoop::instance().exitLoop(); -} - -void tst_Spdy::multipleRequests() -{ - QFETCH(QList<QUrl>, urls); - m_multipleRequestsCount = urls.count(); - m_multipleRepliesFinishedCount = 0; - - QList<QNetworkReply *> replies; - QList<QSignalSpy *> metaDataChangedSpies; - QList<QSignalSpy *> readyReadSpies; - QList<QSignalSpy *> finishedSpies; - - foreach (const QUrl &url, urls) { - QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - QNetworkReply *reply = m_manager.get(request); - replies.append(reply); - reply->ignoreSslErrors(); - QObject::connect(reply, SIGNAL(finished()), this, SLOT(multipleRequestsFinishedSlot())); - QSignalSpy *metaDataChangedSpy = new QSignalSpy(reply, SIGNAL(metaDataChanged())); - metaDataChangedSpies << metaDataChangedSpy; - QSignalSpy *readyReadSpy = new QSignalSpy(reply, SIGNAL(readyRead())); - readyReadSpies << readyReadSpy; - QSignalSpy *finishedSpy = new QSignalSpy(reply, SIGNAL(finished())); - finishedSpies << finishedSpy; - } - - QSignalSpy finishedManagerSpy(&m_manager, SIGNAL(finished(QNetworkReply*))); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(finishedManagerSpy.count(), m_multipleRequestsCount); - - for (int a = 0; a < replies.count(); ++a) { - -#ifndef QT_NO_OPENSSL - QCOMPARE(replies.at(a)->sslConfiguration().nextProtocolNegotiationStatus(), - QSslConfiguration::NextProtocolNegotiationNegotiated); - QCOMPARE(replies.at(a)->sslConfiguration().nextNegotiatedProtocol(), - QByteArray(QSslConfiguration::NextProtocolSpdy3_0)); -#endif // QT_NO_OPENSSL - - QCOMPARE(replies.at(a)->error(), QNetworkReply::NoError); - QCOMPARE(replies.at(a)->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(), true); - QCOMPARE(replies.at(a)->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool(), true); - QCOMPARE(replies.at(a)->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - // using the echo script, a request to "echo.cgi?1" will return a body of "1" - QByteArray expectedContent = replies.at(a)->url().query().toUtf8(); - QByteArray content = replies.at(a)->readAll(); - QCOMPARE(expectedContent, content); - - QCOMPARE(metaDataChangedSpies.at(a)->count(), 1); - metaDataChangedSpies.at(a)->deleteLater(); - - QCOMPARE(finishedSpies.at(a)->count(), 1); - finishedSpies.at(a)->deleteLater(); - - QVERIFY(readyReadSpies.at(a)->count() > 0); - readyReadSpies.at(a)->deleteLater(); - - replies.at(a)->deleteLater(); - } -} - -QTEST_MAIN(tst_Spdy) - -#include "tst_spdy.moc" diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index de15f4c62d..78026665be 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -634,7 +634,7 @@ void tst_Compiler::cxx11_alignas() struct S { alignas(double) char c; }; - QCOMPARE(Q_ALIGNOF(S), Q_ALIGNOF(double)); + QCOMPARE(alignof(S), alignof(double)); #endif } @@ -1396,7 +1396,7 @@ void tst_Compiler::cxx11_unrestricted_unions() ~U() {} }; U u; - std::aligned_storage<sizeof(QString), Q_ALIGNOF(QString)> as; + std::aligned_storage<sizeof(QString), alignof(QString)> as; Q_UNUSED(u); Q_UNUSED(as); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 7d7fa6403b..82dc826db2 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -203,11 +203,15 @@ private slots: void applicationTest(); void mainWindowTest(); void subWindowTest(); +#if QT_CONFIG(shortcut) void buttonTest(); +#endif void scrollBarTest(); void tabTest(); void tabWidgetTest(); +#if QT_CONFIG(shortcut) void menuTest(); +#endif void spinBoxTest(); void doubleSpinBoxTest(); void textEditTest(); @@ -234,8 +238,10 @@ private slots: void dockWidgetTest(); void comboBoxTest(); void accessibleName(); +#if QT_CONFIG(shortcut) void labelTest(); void accelerators(); +#endif void bridgeTest(); protected slots: @@ -1026,6 +1032,8 @@ public Q_SLOTS: } }; +#if QT_CONFIG(shortcut) + void tst_QAccessibility::buttonTest() { QWidget window; @@ -1198,6 +1206,8 @@ void tst_QAccessibility::buttonTest() // test->release(); } +#endif // QT_CONFIG(shortcut) + void tst_QAccessibility::scrollBarTest() { QScrollBar *scrollBar = new QScrollBar(Qt::Horizontal); @@ -1407,6 +1417,8 @@ void tst_QAccessibility::tabWidgetTest() QTestAccessibility::clearEvents(); } +#if QT_CONFIG(shortcut) + void tst_QAccessibility::menuTest() { { @@ -1617,6 +1629,8 @@ void tst_QAccessibility::menuTest() QTestAccessibility::clearEvents(); } +#endif // QT_CONFIG(shortcut) + void tst_QAccessibility::spinBoxTest() { QSpinBox * const spinBox = new QSpinBox(); @@ -3629,6 +3643,8 @@ void tst_QAccessibility::comboBoxTest() QTestAccessibility::clearEvents(); } +#if QT_CONFIG(shortcut) + void tst_QAccessibility::labelTest() { QWidget *window = new QWidget; @@ -3729,6 +3745,8 @@ void tst_QAccessibility::accelerators() QTestAccessibility::clearEvents(); } +#endif // QT_CONFIG(shortcut) + #ifdef QT_SUPPORTS_IACCESSIBLE2 static IUnknown *queryIA2(IAccessible *acc, const IID &iid) { diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index 260ba12a97..9285d5b5da 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -91,7 +91,9 @@ private slots: void checkReason_BackTab(); void checkReason_Popup(); void checkReason_focusWidget(); +#if QT_CONFIG(shortcut) void checkReason_Shortcut(); +#endif void checkReason_ActiveWindow(); private: @@ -250,6 +252,8 @@ QT_BEGIN_NAMESPACE QT_END_NAMESPACE #endif +#if QT_CONFIG(shortcut) + void tst_QFocusEvent::checkReason_Shortcut() { initWidget(); @@ -288,6 +292,8 @@ void tst_QFocusEvent::checkReason_Shortcut() #endif } +#endif // QT_CONFIG(shortcut) + void tst_QFocusEvent::checkReason_focusWidget() { // This test checks that a widget doesn't loose diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 6091975acb..7fda59a29b 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -96,8 +96,9 @@ private slots: void task248107_backButton(); void task255350_fieldObjectDestroyed(); void taskQTBUG_25691_fieldObjectDestroyed2(); +#if QT_CONFIG(shortcut) void taskQTBUG_46894_nextButtonShortcut(); - +#endif /* Things that could be added: @@ -2703,6 +2704,8 @@ void tst_QWizard::taskQTBUG_25691_fieldObjectDestroyed2() ::taskQTBUG_25691_fieldObjectDestroyed2(); } +#if QT_CONFIG(shortcut) + void tst_QWizard::taskQTBUG_46894_nextButtonShortcut() { for (int i = 0; i < QWizard::NStyles; ++i) { @@ -2717,5 +2720,7 @@ void tst_QWizard::taskQTBUG_46894_nextButtonShortcut() } } +#endif // QT_CONFIG(shortcut) + QTEST_MAIN(tst_QWizard) #include "tst_qwizard.moc" diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 6d415952c9..0fb95b9f34 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -450,7 +450,9 @@ private slots: void modality_keyEvents(); void itemIsInFront(); void scenePosChange(); +#if QT_CONFIG(shortcut) void textItem_shortcuts(); +#endif void scroll(); void focusHandling_data(); void focusHandling(); @@ -10813,6 +10815,8 @@ void tst_QGraphicsItem::scenePosChange() QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); } +#if QT_CONFIG(shortcut) + void tst_QGraphicsItem::textItem_shortcuts() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) @@ -10852,6 +10856,8 @@ void tst_QGraphicsItem::textItem_shortcuts() QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); } +#endif // QT_CONFIG(shortcut) + void tst_QGraphicsItem::scroll() { // Create two overlapping rectangles in the scene: diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index d5813d64ff..bb098f32c2 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -1744,7 +1744,7 @@ void tst_QHeaderView::restoreQt4State() QCOMPARE(h2.length(), old_length); QCOMPARE(h2.saveState(), old_state); #else - QSKIP("Qt4 compatibility no longer needed in Qt6") + QSKIP("Qt4 compatibility no longer needed in Qt6"); #endif } diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 12b24798f4..1d0153213b 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -331,8 +331,10 @@ private slots: void selectColumn_data(); void selectColumn(); +#if QT_CONFIG(shortcut) void selectall_data(); void selectall(); +#endif void visualRect_data(); void visualRect(); @@ -1843,6 +1845,8 @@ void tst_QTableView::selectColumn() QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column); } +#if QT_CONFIG(shortcut) + void tst_QTableView::selectall_data() { QTest::addColumn<int>("rowCount"); @@ -1999,6 +2003,8 @@ void tst_QTableView::selectall() QCOMPARE(view.selectedIndexes().count(), 0); } +#endif // QT_CONFIG(shortcut) + void tst_QTableView::visualRect_data() { QTest::addColumn<int>("rowCount"); diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index af85a2bd13..5c5868e607 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -22,3 +22,6 @@ SUBDIRS=\ darwin:SUBDIRS -= \ # Uses native recognizers qgesturerecognizer \ + +!qtConfig(shortcut): SUBDIRS -= \ + qshortcut diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 1247f48dd0..66a82d512d 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -57,18 +57,24 @@ private slots: void setIconText(); void setUnknownFont(); void actionEvent(); +#if QT_CONFIG(shortcut) void setStandardKeys(); void alternateShortcuts(); void enabledVisibleInteraction(); void task200823_tooltip(); +#endif void task229128TriggeredSignalWithoutActiongroup(); void task229128TriggeredSignalWhenInActiongroup(); +#if QT_CONFIG(shortcut) void repeat(); +#endif void setData(); +#if QT_CONFIG(shortcut) void keysequence(); // QTBUG-53381 void disableShortcutsWithBlockedWidgets_data(); void disableShortcutsWithBlockedWidgets(); void shortcutFromKeyEvent(); // QTBUG-48325 +#endif private: QEvent::Type m_lastEventType; @@ -221,6 +227,8 @@ void tst_QAction::actionEvent() QCOMPARE(m_lastAction, &a); } +#if QT_CONFIG(shortcut) + //basic testing of standard keys void tst_QAction::setStandardKeys() { @@ -367,6 +375,8 @@ void tst_QAction::task200823_tooltip() QCOMPARE(action->toolTip(), ref); } +#endif // QT_CONFIG(shortcut) + void tst_QAction::task229128TriggeredSignalWithoutActiongroup() { // test without a group @@ -408,6 +418,8 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() QCOMPARE(actionSpy.count(), 1); } +#if QT_CONFIG(shortcut) + void tst_QAction::repeat() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -452,6 +464,8 @@ void tst_QAction::repeat() QCOMPARE(spy.count(), 2); } +#endif // QT_CONFIG(shortcut) + void tst_QAction::setData() // QTBUG-62006 { QAction act(nullptr); @@ -467,6 +481,8 @@ void tst_QAction::setData() // QTBUG-62006 QCOMPARE(spy.count(), 1); } +#if QT_CONFIG(shortcut) + void tst_QAction::disableShortcutsWithBlockedWidgets_data() { QTest::addColumn<Qt::ShortcutContext>("shortcutContext"); @@ -556,5 +572,7 @@ void tst_QAction::shortcutFromKeyEvent() QCOMPARE(testWidget.shortcutOverrideCount, 1); } +#endif // QT_CONFIG(shortcut) + QTEST_MAIN(tst_QAction) #include "tst_qaction.moc" diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index c6760000f4..45a35fe4f1 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -99,7 +99,9 @@ class tst_QFormLayout : public QObject private slots: void cleanup(); void rowCount(); +#if QT_CONFIG(shortcut) void buddies(); +#endif void getItemPosition(); void wrapping(); void spacing(); @@ -190,6 +192,8 @@ void tst_QFormLayout::rowCount() //TODO: remove items } +#if QT_CONFIG(shortcut) + void tst_QFormLayout::buddies() { QWidget w; @@ -218,6 +222,8 @@ void tst_QFormLayout::buddies() //TODO: empty label? } +#endif // QT_CONFIG(shortcut) + void tst_QFormLayout::getItemPosition() { QWidget w; @@ -687,17 +693,21 @@ void tst_QFormLayout::insertRow_QString_QWidget() layout->insertRow(-5, "&Name:", fld1); QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label1 != 0); +#if QT_CONFIG(shortcut) QCOMPARE(label1->buddy(), fld1); - +#endif layout->insertRow(0, "&Email:", fld2); QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label2 != 0); +#if QT_CONFIG(shortcut) QCOMPARE(label2->buddy(), fld2); - +#endif layout->insertRow(5, "&Age:", fld3); QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QVERIFY(label3 != 0); +#if QT_CONFIG(shortcut) QCOMPARE(label3->buddy(), fld3); +#endif } void tst_QFormLayout::insertRow_QString_QLayout() @@ -711,21 +721,27 @@ void tst_QFormLayout::insertRow_QString_QLayout() layout->insertRow(-5, "&Name:", fld1); QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label1 != 0); +#if QT_CONFIG(shortcut) QVERIFY(!label1->buddy()); +#endif QCOMPARE(layout->rowCount(), 1); layout->insertRow(0, "&Email:", fld2); QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label2 != 0); +#if QT_CONFIG(shortcut) QVERIFY(!label2->buddy()); +#endif QCOMPARE(layout->rowCount(), 2); layout->insertRow(5, "&Age:", fld3); QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QVERIFY(label3 != 0); +#if QT_CONFIG(shortcut) QVERIFY(!label3->buddy()); +#endif QCOMPARE(layout->rowCount(), 3); } diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp index eb108a40de..e5a891912f 100644 --- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp @@ -34,7 +34,9 @@ #include <qapplication.h> #include <qpainter.h> #include <qstyleoption.h> -#include <qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <qkeysequence.h> +#endif #include <qevent.h> #include <qgridlayout.h> #include <qabstractbutton.h> @@ -59,7 +61,9 @@ private slots: void setText(); void setIcon(); +#if QT_CONFIG(shortcut) void setShortcut(); +#endif void animateClick(); @@ -68,7 +72,9 @@ private slots: void isChecked(); void toggled(); void setEnabled(); +#if QT_CONFIG(shortcut) void shortcutEvents(); +#endif void stopRepeatTimer(); void mouseReleased(); // QTBUG-53244 @@ -164,8 +170,10 @@ void tst_QAbstractButton::init() testWidget->setEnabled( true ); testWidget->setDown( false ); testWidget->setAutoRepeat( false ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif toggle_count = 0; press_count = 0; @@ -336,17 +344,17 @@ void tst_QAbstractButton::setText() QCOMPARE( testWidget->text(), QString("simple") ); testWidget->setText("&ersand"); QCOMPARE( testWidget->text(), QString("&ersand") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+A")); #endif testWidget->setText("te&st"); QCOMPARE( testWidget->text(), QString("te&st") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+S")); #endif testWidget->setText("foo"); QCOMPARE( testWidget->text(), QString("foo") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence()); #endif } @@ -471,6 +479,7 @@ void tst_QAbstractButton::toggled() testWidget->setCheckable(false); } +#if QT_CONFIG(shortcut) void tst_QAbstractButton::setShortcut() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) @@ -502,6 +511,7 @@ void tst_QAbstractButton::setShortcut() // qDebug() << click_count; } +#endif // QT_CONFIG(shortcut) void tst_QAbstractButton::animateClick() { @@ -512,6 +522,8 @@ void tst_QAbstractButton::animateClick() QTRY_VERIFY( !testWidget->isDown() ); } +#if QT_CONFIG(shortcut) + void tst_QAbstractButton::shortcutEvents() { MyButton button; @@ -535,6 +547,8 @@ void tst_QAbstractButton::shortcutEvents() QCOMPARE(clickedSpy.count(), 3); } +#endif // QT_CONFIG(shortcut) + void tst_QAbstractButton::stopRepeatTimer() { MyButton button; diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index 0044d33c66..45a23984e0 100644 --- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -51,7 +51,9 @@ private slots: void getSetCheck(); void pressed(); +#if QT_CONFIG(shortcut) void setAccel(); +#endif void isCheckable(); void setDown(); void popupCrash(); @@ -133,8 +135,10 @@ void tst_QCommandLinkButton::init() testWidget->setText("Test"); testWidget->setDescription("Description text."); testWidget->setEnabled( true ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif resetCounters(); } @@ -327,6 +331,8 @@ void tst_QCommandLinkButton::toggled() QVERIFY( click_count == 1 ); } +#if QT_CONFIG(shortcut) + /* If we press an accelerator key we ONLY get a pressed signal and NOT a released or clicked signal. @@ -355,6 +361,8 @@ void tst_QCommandLinkButton::setAccel() QTest::qWait(200); } +#endif // QT_CONFIG(shortcut) + void tst_QCommandLinkButton::animateClick() { QVERIFY( !testWidget->isDown() ); diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index c293a4bdd2..c6de750482 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -166,7 +166,9 @@ private slots: void doubleDot(); +#if QT_CONFIG(shortcut) void undoRedo(); +#endif void valueFromTextAndValidate_data(); void valueFromTextAndValidate(); @@ -1025,6 +1027,8 @@ void tst_QDoubleSpinBox::doubleDot() QCOMPARE(spin.lineEdit()->cursorPosition(), 2); } +#if QT_CONFIG(shortcut) + void tst_QDoubleSpinBox::undoRedo() { //test undo/redo feature (in conjunction with the "undoRedoEnabled" property) @@ -1073,6 +1077,8 @@ void tst_QDoubleSpinBox::undoRedo() QVERIFY(!spin.lineEdit()->isRedoAvailable()); } +#endif // QT_CONFIG(shortcut) + struct task199226_DoubleSpinBox : public QDoubleSpinBox { task199226_DoubleSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {} diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index f599ac73c6..7760e12cca 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -68,7 +68,7 @@ private Q_SLOTS: void setText_data(); void setText(); void setTextFormat(); -#ifndef Q_OS_MAC +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) void setBuddy(); #endif void setNum(); @@ -88,8 +88,10 @@ private Q_SLOTS: void unicodeText_data(); void unicodeText(); +#if QT_CONFIG(shortcut) void mnemonic_data(); void mnemonic(); +#endif void selection(); #ifndef QT_NO_CONTEXTMENU @@ -116,6 +118,7 @@ void tst_QLabel::getSetCheck() obj1.setWordWrap(true); QCOMPARE(true, obj1.wordWrap()); +#if QT_CONFIG(shortcut) // QWidget * QLabel::buddy() // void QLabel::setBuddy(QWidget *) QWidget *var2 = new QWidget(); @@ -124,6 +127,7 @@ void tst_QLabel::getSetCheck() obj1.setBuddy((QWidget *)0); QCOMPARE((QWidget *)0, obj1.buddy()); delete var2; +#endif // QT_CONFIG(shortcut) // QMovie * QLabel::movie() // void QLabel::setMovie(QMovie *) @@ -153,7 +157,9 @@ void tst_QLabel::cleanupTestCase() void tst_QLabel::init() { testWidget->setTextFormat( Qt::AutoText ); +# if QT_CONFIG(shortcut) testWidget->setBuddy( 0 ); +#endif testWidget->setIndent( 0 ); testWidget->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); testWidget->setScaledContents( false ); @@ -169,7 +175,7 @@ void tst_QLabel::cleanup() } // Set buddy doesn't make much sense on OS X -#ifndef Q_OS_MAC +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) void tst_QLabel::setBuddy() { testWidget->hide(); @@ -204,7 +210,7 @@ void tst_QLabel::setBuddy() delete test_box; } -#endif +#endif // QT_CONFIG(shortcut) && !Q_OS_DARWIN void tst_QLabel::setText_data() { @@ -469,6 +475,8 @@ void tst_QLabel::unicodeText() testWidget->show(); } +#if QT_CONFIG(shortcut) + void tst_QLabel::mnemonic_data() { QTest::addColumn<QString>("text"); @@ -513,6 +521,8 @@ void tst_QLabel::mnemonic() QCOMPARE(d->shortcutCursor.selectedText(), expectedShortcutCursor); } +#endif // QT_CONFIG(shortcut) + void tst_QLabel::selection() { QLabel label; diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 5988987d0d..a8b68c18ca 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -56,7 +56,9 @@ #include <qsortfilterproxymodel.h> #include <qdebug.h> #include <qscreen.h> -#include <qshortcut.h> +#if QT_CONFIG(shortcut) +# include <qshortcut.h> +#endif #include "qcommonstyle.h" #include "qstyleoption.h" @@ -135,9 +137,11 @@ private slots: void clearInputMask(); +#if QT_CONFIG(shortcut) void keypress_inputMask_data(); void keypress_inputMask(); void keypress_inputMethod_inputMask(); +#endif void inputMaskAndValidator_data(); void inputMaskAndValidator(); @@ -219,7 +223,7 @@ private slots: void setSelection_data(); void setSelection(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void cut(); void cutWithoutSelection(); #endif @@ -299,8 +303,10 @@ private slots: void shouldShowPlaceholderText(); void QTBUG1266_setInputMaskEmittingTextEdited(); +#if QT_CONFIG(shortcut) void shortcutOverrideOnReadonlyLineEdit_data(); void shortcutOverrideOnReadonlyLineEdit(); +#endif void QTBUG59957_clearButtonLeftmostAction(); void QTBUG_60319_setInputMaskCheckImSurroundingText(); void testQuickSelectionWithMouse(); @@ -319,7 +325,9 @@ private: void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0); void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0); bool unselectingWithLeftOrRightChangesCursorPosition(); +#if QT_CONFIG(shortcut) void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey); +#endif QLineEdit *ensureTestWidget(); bool validInput; @@ -715,6 +723,8 @@ void tst_QLineEdit::clearInputMask() QCOMPARE(testWidget->inputMask(), QString()); } +#if QT_CONFIG(shortcut) + void tst_QLineEdit::keypress_inputMask_data() { QTest::addColumn<QString>("mask"); @@ -832,6 +842,8 @@ void tst_QLineEdit::keypress_inputMethod_inputMask() QCOMPARE(testWidget->text(), QStringLiteral("EE.EE.EE")); } +#endif // QT_CONFIG(shortcut) + void tst_QLineEdit::hasAcceptableInputMask_data() { QTest::addColumn<QString>("optionalMask"); @@ -1986,6 +1998,8 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo keys.addKeyClick(key, pressState); } +#if QT_CONFIG(shortcut) + void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key) { QKeySequence keyseq = QKeySequence(key); @@ -1993,6 +2007,8 @@ void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) ); } +#endif // QT_CONFIG(shortcut) + void tst_QLineEdit::cursorPosition() { QLineEdit *testWidget = ensureTestWidget(); @@ -3023,7 +3039,7 @@ void tst_QLineEdit::setSelection() QCOMPARE(testWidget->cursorPosition(), expectedCursor); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_QLineEdit::cut() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -3124,7 +3140,7 @@ void tst_QLineEdit::cutWithoutSelection() QCOMPARE(clipboard->text(), origText.left(selectionLength)); } -#endif // !QT_NO_CLIPBOARD +#endif // QT_CONFIG(clipboard) && QT_CONFIG(shortcut) class InputMaskValidator : public QValidator { @@ -3969,7 +3985,9 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() le.setReadOnly(true); QAction action(QString::fromLatin1("hello"), &le); +#if QT_CONFIG(shortcut) action.setShortcut(QString::fromLatin1("p")); +#endif QSignalSpy spy(&action, SIGNAL(triggered())); le.addAction(&action); @@ -4704,6 +4722,8 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited() QCOMPARE(spy.count(), 0); } +#if QT_CONFIG(shortcut) + void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit_data() { QTest::addColumn<QKeySequence>("keySequence"); @@ -4763,6 +4783,8 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit() QCOMPARE(spy.count(), activationCount); } +#endif // QT_CONFIG(shortcut) + void tst_QLineEdit::QTBUG59957_clearButtonLeftmostAction() { #ifndef QT_BUILD_INTERNAL diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 9c40c0bd57..823084ee43 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -481,7 +481,7 @@ void tst_QMenu::overrideMenuAction() // On Mac and Windows CE, we need to create native key events to test menu // action activation, so skip this part of the test. -#if !defined(Q_OS_DARWIN) +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) QAction *aQuit = new QAction("Quit", &w); aQuit->setShortcut(QKeySequence("Ctrl+X")); m->addAction(aQuit); @@ -499,7 +499,7 @@ void tst_QMenu::overrideMenuAction() //test if the menu still pops out QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier); QTRY_VERIFY(m->isVisible()); -#endif +#endif // QT_CONFIG(shortcut) && !Q_OS_DARWIN delete aFileMenu; @@ -1706,10 +1706,13 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts() QSKIP("Window activation is not supported"); QAction *actionKamen = new QAction("Action Kamen"); +#if QT_CONFIG(shortcut) actionKamen->setShortcut(QKeySequence(QLatin1String("K"))); - +#endif QAction *actionJoe = new QAction("Action Joe"); +#if QT_CONFIG(shortcut) actionJoe->setShortcut(QKeySequence(QLatin1String("Ctrl+J"))); +#endif QMenu menu; menu.addAction(actionKamen); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index f2d4379453..8b372a78cf 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -232,19 +232,25 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) { connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); QMenu *menu = mb->addMenu(QStringLiteral("&accel")); QAction *action = menu->addAction(QStringLiteral("menu1") ); +#if QT_CONFIG(shortcut) action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); +#endif connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); result.menus << menu; result.actions << action; menu = mb->addMenu(QStringLiteral("accel1")); action = menu->addAction(QStringLiteral("&Open...") ); +#if QT_CONFIG(shortcut) action->setShortcut(Qt::Key_O); +#endif result.actions << action; action = menu->addAction(QStringLiteral("action")); +#if QT_CONFIG(shortcut) action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z)); +#endif result.actions << action; result.menus << menu; @@ -283,7 +289,9 @@ QAction *tst_QMenuBar::createCharacterAction(QMenu *menu, char lowerAscii) QAction *action = menu->addAction(text); action->setObjectName(text); action->setData(QVariant(int(lowerAscii))); +#if QT_CONFIG(shortcut) action->setShortcut(Qt::CTRL + (lowerAscii - 'a' + Qt::Key_A)); +#endif connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); return action; } @@ -318,7 +326,9 @@ TestMenu tst_QMenuBar::initComplexMenuBar(QMenuBar *mb) QAction *action = mb->addAction(QStringLiteral("M&enu 3")); action->setData(QVariant(3)); +#if QT_CONFIG(shortcut) action->setShortcut(Qt::ALT + Qt::Key_J); +#endif connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); result.actions << action; @@ -1422,7 +1432,9 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten() menubar.setNativeMenuBar(false); QMenu menu("menu1"); QAction *first = menubar.addMenu(&menu); +#if QT_CONFIG(shortcut) menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); +#endif centerOnScreen(&menubar); menubar.show(); QApplication::setActiveWindow(&menubar); diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 6f4838be7a..d0ed68c0c8 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -53,7 +53,9 @@ private slots: void getSetCheck(); void autoRepeat(); void pressed(); +#if QT_CONFIG(shortcut) void setAccel(); +#endif void isCheckable(); void setDown(); void popupCrash(); @@ -65,7 +67,9 @@ private slots: void defaultAndAutoDefault(); void sizeHint_data(); void sizeHint(); +#if QT_CONFIG(shortcut) void taskQTBUG_20191_shortcutWithKeypadModifer(); +#endif void emitReleasedAfterChange(); protected slots: @@ -125,8 +129,10 @@ void tst_QPushButton::init() testWidget->setDown( false ); testWidget->setText("Test"); testWidget->setEnabled( true ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif resetCounters(); } @@ -318,6 +324,8 @@ void tst_QPushButton::toggled() QVERIFY( click_count == 1 ); } +#if QT_CONFIG(shortcut) + /* If we press an accelerator key we ONLY get a pressed signal and NOT a released or clicked signal. @@ -349,6 +357,8 @@ void tst_QPushButton::setAccel() QTRY_VERIFY( !testWidget->isDown() ); } +#endif // QT_CONFIG(shortcut) + void tst_QPushButton::animateClick() { QVERIFY( !testWidget->isDown() ); @@ -571,6 +581,8 @@ void tst_QPushButton::sizeHint() } } +#if QT_CONFIG(shortcut) + void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() { // setup a dialog with two buttons @@ -617,6 +629,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QCOMPARE(spy2.count(), 1); } +#endif // QT_CONFIG(shortcut) + void tst_QPushButton::emitReleasedAfterChange() { QPushButton *button1 = new QPushButton("A"); diff --git a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp index 7123acfdc3..5c7d3bf1e9 100644 --- a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp +++ b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp @@ -44,12 +44,16 @@ public: virtual ~tst_QRadioButton(){}; private slots: +#if QT_CONFIG(shortcut) void task190739_focus(); +#endif void minimumSizeHint(); private: }; +#if QT_CONFIG(shortcut) + void tst_QRadioButton::task190739_focus() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -84,6 +88,7 @@ void tst_QRadioButton::task190739_focus() QVERIFY(!radio1.hasFocus()); } +#endif // QT_CONFIG(shortcut) void tst_QRadioButton::minimumSizeHint() { diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 30c57c73e5..b5d2e68118 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -47,7 +47,9 @@ #include <QLocale> #include <QDoubleSpinBox> #include <QVBoxLayout> -#include <QKeySequence> +#if QT_CONFIG(shortcut) +# include <QKeySequence> +#endif #include <QStackedWidget> #include <QDebug> #include <QStyleOptionSpinBox> @@ -173,7 +175,10 @@ private slots: void removeAll(); void startWithDash(); + +#if QT_CONFIG(shortcut) void undoRedo(); +#endif void specialValue(); void textFromValue(); @@ -1024,6 +1029,8 @@ void tst_QSpinBox::startWithDash() QCOMPARE(spin.text(), QString("0")); } +#if QT_CONFIG(shortcut) + void tst_QSpinBox::undoRedo() { //test undo/redo feature (in conjunction with the "undoRedoEnabled" property) @@ -1076,6 +1083,8 @@ void tst_QSpinBox::undoRedo() QVERIFY(!spin.lineEdit()->isRedoAvailable()); } +#endif // QT_CONFIG(shortcut) + void tst_QSpinBox::specialValue() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp index 4afb1c9751..1e71f92361 100644 --- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp @@ -40,7 +40,9 @@ #include <qwidgetaction.h> #include <qtoolbutton.h> #include <qlineedit.h> -#include <qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <qkeysequence.h> +#endif #include <qmenu.h> #include <qlabel.h> #include <private/qtoolbarextension_p.h> diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro index c6325aac15..66950fa85a 100644 --- a/tests/auto/widgets/widgets/widgets.pro +++ b/tests/auto/widgets/widgets/widgets.pro @@ -47,6 +47,9 @@ SUBDIRS=\ qtoolbox \ qtoolbutton \ +!qtConfig(shortcut): SUBDIRS -= \ + qkeysequenceedit + # The following tests depend on private API: !qtConfig(private_tests): SUBDIRS -= \ qabstractspinbox \ diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index b09a3447e3..901cadc34a 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -33,7 +33,7 @@ #include <QDebug> #include <QFile> #include <QList> -#include <QRegExp> +#include <QRegularExpression> #include <QTextStream> #include <QtTest/QtTest> #include <QtXml> @@ -437,10 +437,10 @@ void tst_QDom::save_data() QTest::addColumn<int>("indent"); QTest::addColumn<QString>("res"); - QTest::newRow( "01" ) << doc01 << 0 << QString(doc01).replace( QRegExp(" "), "" ); + QTest::newRow( "01" ) << doc01 << 0 << QString(doc01).replace( QRegularExpression(" "), "" ); QTest::newRow( "02" ) << doc01 << 1 << doc01; - QTest::newRow( "03" ) << doc01 << 2 << QString(doc01).replace( QRegExp(" "), " " ); - QTest::newRow( "04" ) << doc01 << 10 << QString(doc01).replace( QRegExp(" "), " " ); + QTest::newRow( "03" ) << doc01 << 2 << QString(doc01).replace( QRegularExpression(" "), " " ); + QTest::newRow( "04" ) << doc01 << 10 << QString(doc01).replace( QRegularExpression(" "), " " ); } void tst_QDom::save() diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp index eae752d99a..60c75ead4d 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp +++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp @@ -44,9 +44,19 @@ #include "qfilesystemiterator.h" +#if QT_HAS_INCLUDE(<filesystem>) && defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L +#define HAS_STD_FILESYSTEM +#endif + +#ifdef HAS_STD_FILESYSTEM +#include <filesystem> +#endif + class tst_qdiriterator : public QObject { Q_OBJECT + + void data(); private slots: void posix(); void posix_data() { data(); } @@ -54,7 +64,8 @@ private slots: void diriterator_data() { data(); } void fsiterator(); void fsiterator_data() { data(); } - void data(); + void stdRecursiveDirectoryIterator(); + void stdRecursiveDirectoryIterator_data() { data(); } }; @@ -235,6 +246,28 @@ void tst_qdiriterator::fsiterator() qDebug() << count; } +void tst_qdiriterator::stdRecursiveDirectoryIterator() +{ +#ifdef HAS_STD_FILESYSTEM + QFETCH(QByteArray, dirpath); + + int count = 0; + + QBENCHMARK { + int c = 0; + for (auto obj : std::filesystem::recursive_directory_iterator(dirpath.data())) { + if (obj.is_directory()) + continue; + c++; + } + count = c; + } + qDebug() << count; +#else + QSKIP("Not supported."); +#endif +} + QTEST_MAIN(tst_qdiriterator) #include "main.moc" diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro index 061b22a5d1..4b28946f18 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro @@ -3,6 +3,8 @@ TARGET = tst_bench_qdiriterator QT = core testlib CONFIG += release +# Enable c++17 support for std::filesystem +qtConfig(c++1z): CONFIG += c++17 SOURCES += main.cpp qfilesystemiterator.cpp HEADERS += qfilesystemiterator.h diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/main.cpp index 04ca69ad3b..918227f74e 100644 --- a/tests/benchmarks/corelib/kernel/qobject/main.cpp +++ b/tests/benchmarks/corelib/kernel/qobject/main.cpp @@ -51,8 +51,55 @@ private slots: void connect_disconnect_benchmark_data(); void connect_disconnect_benchmark(); void receiver_destroyed_benchmark(); + + void stdAllocator(); }; +class QObjectUsingStandardAllocator : public QObject +{ + Q_OBJECT +public: + QObjectUsingStandardAllocator() + { + } +}; + +template<class T> +inline void allocator() +{ + // We need to allocate certain amount of objects otherwise the new implementation + // may re-use the previous allocation, hiding the somehow high cost of allocation. It + // also helps us to reduce the noise ratio, which is high for memory allocation. + // + // The check depends on memory allocation performance, which is quite non-deterministic. + // When a new memory is requested, the new operator, depending on implementation, is trying + // to re-use existing, already allocated for the process memory. If there is not enough, it + // asks OS to give more. Of course the first case is faster then the second. In the same + // time, from an application perspective the first is also more likely. + // + // As a result, depending on which use-case one wants to test, it may be recommended to run this + // test in separation from others, to "force" expensive code path in the memory allocation. + // + // The time based results are heavily affected by background noise. One really needs to + // prepare OS (no other tasks, CPU and RAM reservations) to run this test, or use + // instruction counting which seems to be less fragile. + + const int count = 256 * 1024; + + QScopedPointer<T> objects[count]; + QBENCHMARK_ONCE { + for (int i = 0; i < count; ++i) + objects[i].reset(new T); + for (int i = 0; i < count; ++i) + objects[i].reset(); + } +} + +void QObjectBenchmark::stdAllocator() +{ + allocator<QObjectUsingStandardAllocator>(); +} + struct Functor { void operator()(){} }; diff --git a/tests/benchmarks/corelib/tools/qvector/outofline.cpp b/tests/benchmarks/corelib/tools/qvector/outofline.cpp index 76a4edaa10..7182a43008 100644 --- a/tests/benchmarks/corelib/tools/qvector/outofline.cpp +++ b/tests/benchmarks/corelib/tools/qvector/outofline.cpp @@ -54,7 +54,7 @@ QVector<double> mixedvector_fill_and_return_helper() std::vector<double> v(N); for (int i = 0; i != N; ++i) v[i] = i; - return QVector<double>::fromStdVector(v); + return QVector<double>(v.begin(), v.end()); } diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h index 16a911c63a..73d8620f10 100644 --- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h +++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h @@ -280,11 +280,7 @@ private: } static Q_DECL_CONSTEXPR int alignOfTypedData() { -#ifdef Q_ALIGNOF - return Q_ALIGNOF(AlignmentDummy); -#else - return sizeof(void *); -#endif + return alignof(AlignmentDummy); } public: diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp index 46bb1791b4..1f3f38eaaf 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp @@ -105,7 +105,7 @@ void qfile_vs_qnetworkaccessmanager::qnamFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } @@ -138,7 +138,7 @@ void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } @@ -167,7 +167,7 @@ void qfile_vs_qnetworkaccessmanager::qfileFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index c182ef7ebf..6dd7eaee6b 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -544,15 +544,10 @@ void tst_qnetworkreply::echoPerformance() void tst_qnetworkreply::preConnectEncrypted() { QFETCH(int, sleepTime); - QFETCH(QSslConfiguration, sslConfiguration); - bool spdyEnabled = !sslConfiguration.isNull(); - QString hostName = QLatin1String("www.google.com"); QNetworkAccessManager manager; QNetworkRequest request(QUrl("https://" + hostName)); - if (spdyEnabled) - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); // make sure we have a full request including // DNS lookup, TCP and SSL handshakes @@ -578,12 +573,7 @@ void tst_qnetworkreply::preConnectEncrypted() manager.clearAccessCache(); // now try to make the connection beforehand - if (spdyEnabled) { - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - manager.connectToHostEncrypted(hostName, 443, sslConfiguration); - } else { - manager.connectToHostEncrypted(hostName); - } + manager.connectToHostEncrypted(hostName); QTestEventLoop::instance().enterLoopMSecs(sleepTime); // now make another request and hopefully use the existing connection @@ -591,8 +581,6 @@ void tst_qnetworkreply::preConnectEncrypted() QNetworkReply *preConnectReply = normalResult.first; QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(preConnectReply->error() == QNetworkReply::NoError); - bool spdyWasUsed = preConnectReply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(); - QCOMPARE(spdyEnabled, spdyWasUsed); qint64 preConnectElapsed = preConnectResult.second; qDebug() << request.url().toString() << "full request:" << normalElapsed << "ms, pre-connect request:" << preConnectElapsed << "ms, difference:" @@ -605,27 +593,11 @@ void tst_qnetworkreply::preConnectEncrypted_data() { #ifndef QT_NO_OPENSSL QTest::addColumn<int>("sleepTime"); - QTest::addColumn<QSslConfiguration>("sslConfiguration"); - // start a new normal request after preconnecting is done - QTest::newRow("HTTPS-2secs") << 2000 << QSslConfiguration(); + QTest::newRow("HTTPS-2secs") << 2000; // start a new normal request while preconnecting is in-flight - QTest::newRow("HTTPS-100ms") << 100 << QSslConfiguration(); - - QSslConfiguration spdySslConf = QSslConfiguration::defaultConfiguration(); - QList<QByteArray> nextProtocols = QList<QByteArray>() - << QSslConfiguration::NextProtocolSpdy3_0 - << QSslConfiguration::NextProtocolHttp1_1; - spdySslConf.setAllowedNextProtocols(nextProtocols); - -#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) - // start a new SPDY request while preconnecting is done - QTest::newRow("SPDY-2secs") << 2000 << spdySslConf; - - // start a new SPDY request while preconnecting is in-flight - QTest::newRow("SPDY-100ms") << 100 << spdySslConf; -#endif // defined (QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ... + QTest::newRow("HTTPS-100ms") << 100; #endif // QT_NO_OPENSSL } diff --git a/tests/manual/dialogs/messageboxpanel.cpp b/tests/manual/dialogs/messageboxpanel.cpp index ef6731cd74..3c6a042e19 100644 --- a/tests/manual/dialogs/messageboxpanel.cpp +++ b/tests/manual/dialogs/messageboxpanel.cpp @@ -39,6 +39,8 @@ #include <QLineEdit> #include <QLabel> #include <QCheckBox> +#include <QRegularExpressionValidator> +#include <QRegularExpression> MessageBoxPanel::MessageBoxPanel(QWidget *parent) : QWidget(parent) ,m_iconComboBox(new QComboBox) @@ -80,7 +82,7 @@ MessageBoxPanel::MessageBoxPanel(QWidget *parent) : QWidget(parent) // buttons mask optionsLayout->addWidget(new QLabel(QString::fromLatin1("Message box button mask (in hex)"))); - m_validator = new QRegExpValidator(QRegExp("0[xX]?[0-9a-fA-F]+"), this); + m_validator = new QRegularExpressionValidator(QRegularExpression("0[xX]?[0-9a-fA-F]+"), this); m_buttonsMask->setMaxLength(10); m_buttonsMask->setValidator(m_validator); m_buttonsMask->setText(QString::fromLatin1("0x00300400")); diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp index afac7a7095..01bd30a854 100644 --- a/tests/manual/qnetworkreply/main.cpp +++ b/tests/manual/qnetworkreply/main.cpp @@ -58,9 +58,6 @@ private slots: void setSslConfiguration_data(); void setSslConfiguration(); void uploadToFacebook(); - void spdy_data(); - void spdy(); - void spdyMultipleRequestsPerHost(); void proxyAuthentication_data(); void proxyAuthentication(); void authentication(); @@ -290,126 +287,6 @@ void tst_qnetworkreply::uploadToFacebook() } } -void tst_qnetworkreply::spdy_data() -{ - QTest::addColumn<QString>("host"); - QTest::addColumn<bool>("setAttribute"); - QTest::addColumn<bool>("enabled"); - QTest::addColumn<QByteArray>("expectedProtocol"); - - QList<QString> hosts = QList<QString>() - << QStringLiteral("www.google.com") // sends SPDY and 30x redirect - << QStringLiteral("www.google.de") // sends SPDY and 200 OK - << QStringLiteral("mail.google.com") // sends SPDY and 200 OK - << QStringLiteral("www.youtube.com") // sends SPDY and 200 OK - << QStringLiteral("www.dropbox.com") // no SPDY, but NPN which selects HTTP - << QStringLiteral("www.facebook.com") // sends SPDY and 200 OK - << QStringLiteral("graph.facebook.com") // sends SPDY and 200 OK - << QStringLiteral("www.twitter.com") // sends SPDY and 30x redirect - << QStringLiteral("twitter.com") // sends SPDY and 200 OK - << QStringLiteral("api.twitter.com"); // sends SPDY and 200 OK - - foreach (const QString &host, hosts) { - QByteArray tag = host.toLocal8Bit(); - tag.append("-not-used"); - QTest::newRow(tag) - << QStringLiteral("https://") + host - << false - << false - << QByteArray(); - - tag = host.toLocal8Bit(); - tag.append("-disabled"); - QTest::newRow(tag) - << QStringLiteral("https://") + host - << true - << false - << QByteArray(); - - if (host != QStringLiteral("api.twitter.com")) { // they don't offer an API over HTTP - tag = host.toLocal8Bit(); - tag.append("-no-https-url"); - QTest::newRow(tag) - << QStringLiteral("http://") + host - << true - << true - << QByteArray(); - } - -#ifndef QT_NO_OPENSSL - tag = host.toLocal8Bit(); - tag.append("-enabled"); - QTest::newRow(tag) - << QStringLiteral("https://") + host - << true - << true - << (host == QStringLiteral("www.dropbox.com") - ? QByteArray(QSslConfiguration::NextProtocolHttp1_1) - : QByteArray(QSslConfiguration::NextProtocolSpdy3_0)); -#endif // QT_NO_OPENSSL - } -} - -void tst_qnetworkreply::spdy() -{ -#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) - - m_manager.clearAccessCache(); - - QFETCH(QString, host); - QUrl url(host); - QNetworkRequest request(url); - - QFETCH(bool, setAttribute); - QFETCH(bool, enabled); - if (setAttribute) { - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, QVariant(enabled)); - } - - QNetworkReply *reply = m_manager.get(request); - QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy metaDataChangedSpy(reply, SIGNAL(metaDataChanged())); - QSignalSpy readyReadSpy(reply, SIGNAL(readyRead())); - QSignalSpy finishedSpy(reply, SIGNAL(finished())); - QSignalSpy finishedManagerSpy(&m_manager, SIGNAL(finished(QNetworkReply*))); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QFETCH(QByteArray, expectedProtocol); - - bool expectedSpdyUsed = (expectedProtocol == QSslConfiguration::NextProtocolSpdy3_0); - QCOMPARE(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(), expectedSpdyUsed); - - QCOMPARE(metaDataChangedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(finishedManagerSpy.count(), 1); - - QUrl redirectUrl = reply->header(QNetworkRequest::LocationHeader).toUrl(); - QByteArray content = reply->readAll(); - - int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - QVERIFY(statusCode >= 200 && statusCode < 500); - if (statusCode == 200 || statusCode >= 400) { - QVERIFY(readyReadSpy.count() > 0); - QVERIFY(!content.isEmpty()); - } else if (statusCode >= 300 && statusCode < 400) { - QVERIFY(!redirectUrl.isEmpty()); - } - - QSslConfiguration::NextProtocolNegotiationStatus expectedStatus = - expectedProtocol.isNull() ? QSslConfiguration::NextProtocolNegotiationNone - : QSslConfiguration::NextProtocolNegotiationNegotiated; - QCOMPARE(reply->sslConfiguration().nextProtocolNegotiationStatus(), - expectedStatus); - - QCOMPARE(reply->sslConfiguration().nextNegotiatedProtocol(), expectedProtocol); -#else - QSKIP("Qt built withouth OpenSSL, or the OpenSSL version is too old"); -#endif // defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ... -} - void tst_qnetworkreply::spdyReplyFinished() { static int finishedCount = 0; @@ -419,85 +296,6 @@ void tst_qnetworkreply::spdyReplyFinished() QTestEventLoop::instance().exitLoop(); } -void tst_qnetworkreply::spdyMultipleRequestsPerHost() -{ -#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) - - QList<QNetworkRequest> requests; - requests - << QNetworkRequest(QUrl("https://www.facebook.com")) - << QNetworkRequest(QUrl("https://www.facebook.com/images/fb_icon_325x325.png")) - - << QNetworkRequest(QUrl("https://www.google.de")) - << QNetworkRequest(QUrl("https://www.google.de/preferences?hl=de")) - << QNetworkRequest(QUrl("https://www.google.de/intl/de/policies/?fg=1")) - << QNetworkRequest(QUrl("https://www.google.de/intl/de/about.html?fg=1")) - << QNetworkRequest(QUrl("https://www.google.de/services/?fg=1")) - << QNetworkRequest(QUrl("https://www.google.de/intl/de/ads/?fg=1")) - - << QNetworkRequest(QUrl("https://i1.ytimg.com/li/tnHdj3df7iM/default.jpg")) - << QNetworkRequest(QUrl("https://i1.ytimg.com/li/7Dr1BKwqctY/default.jpg")) - << QNetworkRequest(QUrl("https://i1.ytimg.com/li/hfZhJdhTqX8/default.jpg")) - << QNetworkRequest(QUrl("https://i1.ytimg.com/vi/14Nprh8163I/hqdefault.jpg")) - ; - QList<QNetworkReply *> replies; - QList<QSignalSpy *> metaDataChangedSpies; - QList<QSignalSpy *> readyReadSpies; - QList<QSignalSpy *> finishedSpies; - - QSignalSpy finishedManagerSpy(&m_manager, SIGNAL(finished(QNetworkReply*))); - - foreach (QNetworkRequest request, requests) { - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); - QNetworkReply *reply = m_manager.get(request); - QObject::connect(reply, SIGNAL(finished()), this, SLOT(spdyReplyFinished())); - replies << reply; - QSignalSpy *metaDataChangedSpy = new QSignalSpy(reply, SIGNAL(metaDataChanged())); - metaDataChangedSpies << metaDataChangedSpy; - QSignalSpy *readyReadSpy = new QSignalSpy(reply, SIGNAL(readyRead())); - readyReadSpies << readyReadSpy; - QSignalSpy *finishedSpy = new QSignalSpy(reply, SIGNAL(finished())); - finishedSpies << finishedSpy; - } - - QCOMPARE(requests.count(), replies.count()); - - QTestEventLoop::instance().enterLoop(15); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(finishedManagerSpy.count(), requests.count()); - - for (int a = 0; a < replies.count(); ++a) { - - QCOMPARE(replies.at(a)->sslConfiguration().nextProtocolNegotiationStatus(), - QSslConfiguration::NextProtocolNegotiationNegotiated); - QCOMPARE(replies.at(a)->sslConfiguration().nextNegotiatedProtocol(), - QByteArray(QSslConfiguration::NextProtocolSpdy3_0)); - - QCOMPARE(replies.at(a)->error(), QNetworkReply::NoError); - QCOMPARE(replies.at(a)->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool(), true); - QCOMPARE(replies.at(a)->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool(), true); - QCOMPARE(replies.at(a)->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - QByteArray content = replies.at(a)->readAll(); - QVERIFY(content.count() > 0); - - QCOMPARE(metaDataChangedSpies.at(a)->count(), 1); - metaDataChangedSpies.at(a)->deleteLater(); - - QCOMPARE(finishedSpies.at(a)->count(), 1); - finishedSpies.at(a)->deleteLater(); - - QVERIFY(readyReadSpies.at(a)->count() > 0); - readyReadSpies.at(a)->deleteLater(); - - replies.at(a)->deleteLater(); - } -#else - QSKIP("Qt built withouth OpenSSL, or the OpenSSL version is too old"); -#endif // defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ... -} - void tst_qnetworkreply::proxyAuthentication_data() { QTest::addColumn<QUrl>("url"); @@ -586,7 +384,7 @@ void tst_qnetworkreply::npnWithEmptyList() // QTBUG-40714 QUrl url(QStringLiteral("https://www.ossifrage.net/")); QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, QVariant(true)); + request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true)); QNetworkReply *reply = m_manager.get(request); QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); |