diff options
Diffstat (limited to 'tests/auto/corelib')
359 files changed, 4645 insertions, 9431 deletions
diff --git a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp index deea511a5f..5530eb8e07 100644 --- a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp +++ b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index 1502e5c8d2..3abd851c89 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 755de9d0b8..2fdf1de9c8 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index 68ada06669..9b8b6b37e0 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index c8688c89f6..534dec8160 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 3751816dbc..63a4de5ac9 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp b/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp index b7e1015a13..0c88c73d41 100644 --- a/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp +++ b/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp b/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp index 934f9f904b..978a026e8d 100644 --- a/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index b6dcd3ed63..7daed397d5 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -47,7 +47,6 @@ #include <qtextdocument.h> #include <time.h> #include <qprocess.h> -#include <QtConcurrentMap> #include <QThreadPool> class tst_QTextCodec : public QObject @@ -55,9 +54,7 @@ class tst_QTextCodec : public QObject Q_OBJECT private slots: -#ifndef QT_NO_CONCURRENT void threadSafety(); -#endif void toUnicode_data(); void toUnicode(); @@ -1939,48 +1936,75 @@ void tst_QTextCodec::toLocal8Bit() } #endif -static QByteArray loadAndConvert(const QByteArray &codecName) +class LoadAndConvert: public QRunnable { - QTextCodec *c = QTextCodec::codecForName(codecName); - if (!c) { - qWarning() << "WARNING" << codecName << "not found?"; - return QByteArray(); +public: + LoadAndConvert(const QByteArray &source, QByteArray *destination) + : codecName(source), target(destination) + {} + QByteArray codecName; + QByteArray *target; + void run() + { + QTextCodec *c = QTextCodec::codecForName(codecName); + if (!c) { + qWarning() << "WARNING" << codecName << "not found?"; + return; + } + QString str = QString::fromLatin1(codecName); + QByteArray b = c->fromUnicode(str); + c->toUnicode(b); + *target = codecName; } - QString str = QString::fromLatin1(codecName); - QByteArray b = c->fromUnicode(str); - c->toUnicode(b); - return codecName; -} +}; -static int loadAndConvertMIB(int mib) +class LoadAndConvertMIB: public QRunnable { - QTextCodec *c = QTextCodec::codecForMib(mib); - if (!c) { - qWarning() << "WARNING" << mib << "not found?"; - return 0; +public: + LoadAndConvertMIB(int mib, int *target) + : mib(mib), target(target) + {} + int mib; + int *target; + void run() + { + QTextCodec *c = QTextCodec::codecForMib(mib); + if (!c) { + qWarning() << "WARNING" << mib << "not found?"; + return; + } + QString str = QString::number(mib); + QByteArray b = c->fromUnicode(str); + c->toUnicode(b); + *target = mib; } - QString str = QString::number(mib); - QByteArray b = c->fromUnicode(str); - c->toUnicode(b); - return mib; -} +}; -#ifndef QT_NO_CONCURRENT void tst_QTextCodec::threadSafety() { QList<QByteArray> codecList = QTextCodec::availableCodecs(); QList<int> mibList = QTextCodec::availableMibs(); QThreadPool::globalInstance()->setMaxThreadCount(12); - QFuture<QByteArray> res = QtConcurrent::mapped(codecList, loadAndConvert); + QVector<QByteArray> res; + res.resize(codecList.size()); + for (int i = 0; i < codecList.size(); ++i) { + QThreadPool::globalInstance()->start(new LoadAndConvert(codecList.at(i), &res[i])); + } - QFuture<int> res2 = QtConcurrent::mapped(mibList, loadAndConvertMIB); + QVector<int> res2; + res2.resize(mibList.size()); + for (int i = 0; i < mibList.size(); ++i) { + QThreadPool::globalInstance()->start(new LoadAndConvertMIB(mibList.at(i), &res2[i])); + } + + // wait for all threads to finish working + QThreadPool::globalInstance()->waitForDone(); - QCOMPARE(res.results(), codecList); - QCOMPARE(res2.results(), mibList); + QCOMPARE(res.toList(), codecList); + QCOMPARE(res2.toList(), mibList); } -#endif void tst_QTextCodec::invalidNames() { diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index f6ff8b2208..69b91683d4 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/concurrent/concurrent.pro b/tests/auto/corelib/concurrent/concurrent.pro deleted file mode 100644 index 6541b0ce42..0000000000 --- a/tests/auto/corelib/concurrent/concurrent.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qfuture \ - qfuturesynchronizer \ - qfuturewatcher \ - qtconcurrentfilter \ - qtconcurrentiteratekernel \ - qtconcurrentmap \ - qtconcurrentresultstore \ - qtconcurrentrun \ - qtconcurrentthreadengine \ - qthreadpool - diff --git a/tests/auto/corelib/concurrent/qfuture/.gitignore b/tests/auto/corelib/concurrent/qfuture/.gitignore deleted file mode 100644 index 77c055c874..0000000000 --- a/tests/auto/corelib/concurrent/qfuture/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qfuture diff --git a/tests/auto/corelib/concurrent/qfuture/qfuture.pro b/tests/auto/corelib/concurrent/qfuture/qfuture.pro deleted file mode 100644 index 517871ab5d..0000000000 --- a/tests/auto/corelib/concurrent/qfuture/qfuture.pro +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qfuture -QT = core-private testlib -SOURCES = tst_qfuture.cpp -DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/corelib/concurrent/qfuture/tst_qfuture.cpp b/tests/auto/corelib/concurrent/qfuture/tst_qfuture.cpp deleted file mode 100644 index 53694100ba..0000000000 --- a/tests/auto/corelib/concurrent/qfuture/tst_qfuture.cpp +++ /dev/null @@ -1,1438 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QCoreApplication> -#include <QDebug> - -#define QFUTURE_TEST - -#include <QtTest/QtTest> -#include <qfuture.h> -#include <qfuturewatcher.h> -#include <qtconcurrentresultstore.h> -#include <qtconcurrentexception.h> -#include <private/qfutureinterface_p.h> - -using namespace QtConcurrent; - -// COM interface macro. -#if defined(Q_OS_WIN) && defined(interface) -# undef interface -#endif - -class tst_QFuture: public QObject -{ - Q_OBJECT -private slots: - void resultStore(); - void future(); - void futureInterface(); - void refcounting(); - void cancel(); - void statePropagation(); - void multipleResults(); - void indexedResults(); - void progress(); - void progressText(); - void resultsAfterFinished(); - void resultsAsList(); - void implicitConversions(); - void iterators(); - void pause(); - void throttling(); - void voidConversions(); -#ifndef QT_NO_EXCEPTIONS - void exceptions(); - void nestedExceptions(); -#endif -}; - -void tst_QFuture::resultStore() -{ - int int0 = 0; - int int1 = 1; - int int2 = 2; - - { - ResultStore<int> store; - QVERIFY(store.begin() == store.end()); - QVERIFY(store.resultAt(0) == store.end()); - QVERIFY(store.resultAt(1) == store.end()); - } - - - { - ResultStoreBase store; - store.addResult(-1, &int0); // note to self: adding a pointer to the stack here is ok since - store.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does. - ResultIteratorBase it = store.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != store.begin()); - QVERIFY(it != store.end()); - - ++it; - QVERIFY(it != store.begin()); - QVERIFY(it == store.end()); - } - - QVector<int> vec0 = QVector<int>() << 2 << 3; - QVector<int> vec1 = QVector<int>() << 4 << 5; - - { - ResultStoreBase store; - store.addResults(-1, &vec0, 2, 2); - store.addResults(-1, &vec1, 2, 2); - ResultIteratorBase it = store.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 2); - - ++it; - QCOMPARE(it.resultIndex(), 3); - - ++it; - QVERIFY(it == store.end()); - } - { - ResultStoreBase store; - store.addResult(-1, &int0); - store.addResults(-1, &vec1, 2, 2); - store.addResult(-1, &int1); - - ResultIteratorBase it = store.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 2); - QVERIFY(it != store.end()); - ++it; - QCOMPARE(it.resultIndex(), 3); - QVERIFY(it != store.end()); - ++it; - QVERIFY(it == store.end()); - - QCOMPARE(store.resultAt(0).resultIndex(), 0); - QCOMPARE(store.resultAt(1).resultIndex(), 1); - QCOMPARE(store.resultAt(2).resultIndex(), 2); - QCOMPARE(store.resultAt(3).resultIndex(), 3); - QCOMPARE(store.resultAt(4), store.end()); - } - { - ResultStore<int> store; - store.addResult(-1, &int0); - store.addResults(-1, &vec0); - store.addResult(-1, &int1); - - ResultIteratorBase it = store.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 2); - QVERIFY(it != store.end()); - ++it; - QCOMPARE(it.resultIndex(), 3); - QVERIFY(it != store.end()); - ++it; - QVERIFY(it == store.end()); - - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(3).value(), int1); - } - { - ResultStore<int> store; - store.addResult(-1, &int0); - store.addResults(-1, &vec0); - store.addResult(200, &int1); - - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(200).value(), int1); - } - - { - ResultStore<int> store; - store.addResult(1, &int1); - store.addResult(0, &int0); - store.addResult(-1, &int2); - - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), int1); - QCOMPARE(store.resultAt(2).value(), int2); - } - - { - ResultStore<int> store; - QCOMPARE(store.contains(0), false); - QCOMPARE(store.contains(1), false); - QCOMPARE(store.contains(INT_MAX), false); - } - - { - // Test filter mode, where "gaps" in the result array aren't allowed. - ResultStore<int> store; - store.setFilterMode(true); - - store.addResult(0, &int0); - QCOMPARE(store.contains(0), true); - - store.addResult(2, &int2); // add result at index 2 - QCOMPARE(store.contains(2), false); // but 1 is missing, so this 2 won't be reported yet. - - store.addResult(1, &int1); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), true); // 2 should be visible now. - - store.addResult(4, &int0); - store.addResult(5, &int0); - store.addResult(7, &int0); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(7), false); - - store.addResult(3, &int0); // adding 3 makes 4 and 5 visible - QCOMPARE(store.contains(4), true); - QCOMPARE(store.contains(5), true); - QCOMPARE(store.contains(7), false); - - store.addResult(6, &int0); // adding 6 makes 7 visible - - QCOMPARE(store.contains(6), true); - QCOMPARE(store.contains(7), true); - QCOMPARE(store.contains(8), false); - } - - { - // test canceled results - ResultStore<int> store; - store.setFilterMode(true); - - store.addResult(0, &int0); - QCOMPARE(store.contains(0), true); - - store.addResult(2, &int0); - QCOMPARE(store.contains(2), false); - - store.addCanceledResult(1); // report no result at 1 - - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), true); // 2 gets renamed to 1 - QCOMPARE(store.contains(2), false); - - store.addResult(3, &int0); - QCOMPARE(store.contains(2), true); //3 gets renamed to 2 - - store.addResult(6, &int0); - store.addResult(7, &int0); - QCOMPARE(store.contains(3), false); - - store.addCanceledResult(4); - store.addCanceledResult(5); - - QCOMPARE(store.contains(3), true); //6 gets renamed to 3 - QCOMPARE(store.contains(4), true); //7 gets renamed to 4 - - store.addResult(8, &int0); - QCOMPARE(store.contains(5), true); //8 gets renamed to 4 - - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - } - - { - // test addResult return value - ResultStore<int> store; - store.setFilterMode(true); - - store.addResult(0, &int0); - QCOMPARE(store.count(), 1); // result 0 becomes available - QCOMPARE(store.contains(0), true); - - store.addResult(2, &int0); - QCOMPARE(store.count(), 1); - QCOMPARE(store.contains(2), false); - - store.addCanceledResult(1); - QCOMPARE(store.count(), 2); // result 2 is renamed to 1 and becomes available - - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), false); - - store.addResult(3, &int0); - QCOMPARE(store.count(), 3); - QCOMPARE(store.contains(2), true); - - store.addResult(6, &int0); - QCOMPARE(store.count(), 3); - store.addResult(7, &int0); - QCOMPARE(store.count(), 3); - QCOMPARE(store.contains(3), false); - - store.addCanceledResult(4); - store.addCanceledResult(5); - QCOMPARE(store.count(), 5); // 6 and 7 is renamed to 3 and 4 and becomes available - - QCOMPARE(store.contains(3), true); - QCOMPARE(store.contains(4), true); - - store.addResult(8, &int0); - QCOMPARE(store.contains(5), true); - QCOMPARE(store.count(), 6); - - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - } - - { - // test resultCount in non-filtered mode. It should always be possible - // to iterate through the results 0 to resultCount. - ResultStore<int> store; - store.addResult(0, &int0); - - QCOMPARE(store.count(), 1); - - store.addResult(2, &int0); - - QCOMPARE(store.count(), 1); - - store.addResult(1, &int0); - QCOMPARE(store.count(), 3); - } - - { - ResultStore<int> store; - store.addResult(2, &int0); - QCOMPARE(store.count(), 0); - - store.addResult(1, &int0); - QCOMPARE(store.count(), 0); - - store.addResult(0, &int0); - QCOMPARE(store.count(), 3); - } - - { - ResultStore<int> store; - store.addResults(2, &vec1); - QCOMPARE(store.count(), 0); - - store.addResult(1, &int0); - QCOMPARE(store.count(), 0); - - store.addResult(0, &int0); - QCOMPARE(store.count(), 4); - } - - { - ResultStore<int> store; - store.addResults(2, &vec1); - QCOMPARE(store.count(), 0); - - store.addResults(0, &vec0); - QCOMPARE(store.count(), 4); - } - { - ResultStore<int> store; - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addResults(0, &vec0); - QCOMPARE(store.count(), 2); - - store.addResult(2, &int0); - QCOMPARE(store.count(), 5); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addResults(0, &vec0); - QCOMPARE(store.count(), 2); - - store.addCanceledResult(2); - QCOMPARE(store.count(), 4); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addCanceledResults(0, 3); - QCOMPARE(store.count(), 2); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addCanceledResults(0, 3); - QCOMPARE(store.count(), 2); // results at 3 and 4 become available at index 0, 1 - - store.addResult(5, &int0); - QCOMPARE(store.count(), 3);// result 5 becomes available at index 2 - } - - { - ResultStore<int> store; - store.addResult(1, &int0); - store.addResult(3, &int0); - store.addResults(6, &vec0); - QCOMPARE(store.contains(0), false); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), false); - QCOMPARE(store.contains(3), true); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(6), true); - QCOMPARE(store.contains(7), true); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResult(1, &int0); - store.addResult(3, &int0); - store.addResults(6, &vec0); - QCOMPARE(store.contains(0), false); - QCOMPARE(store.contains(1), false); - QCOMPARE(store.contains(2), false); - QCOMPARE(store.contains(3), false); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - - store.addCanceledResult(0); - store.addCanceledResult(2); - store.addCanceledResults(4, 2); - - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), true); - QCOMPARE(store.contains(3), true); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - } - { - ResultStore<int> store; - store.setFilterMode(true); - store.addCanceledResult(0); - QCOMPARE(store.contains(0), false); - - store.addResult(1, &int0); - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), false); - } -} - -void tst_QFuture::future() -{ - // default constructors - QFuture<int> intFuture; - intFuture.waitForFinished(); - QFuture<QString> stringFuture; - stringFuture.waitForFinished(); - QFuture<void> voidFuture; - voidFuture.waitForFinished(); - QFuture<void> defaultVoidFuture; - defaultVoidFuture.waitForFinished(); - - // copy constructor - QFuture<int> intFuture2(intFuture); - QFuture<void> voidFuture2(defaultVoidFuture); - - // assigmnent operator - intFuture2 = QFuture<int>(); - voidFuture2 = QFuture<void>(); - - // state - QCOMPARE(intFuture2.isStarted(), true); - QCOMPARE(intFuture2.isFinished(), true); -} - -class IntResult : public QFutureInterface<int> -{ -public: - QFuture<int> run() - { - this->reportStarted(); - QFuture<int> future = QFuture<int>(this); - - int res = 10; - reportFinished(&res); - return future; - } -}; - -int value = 10; - -class VoidResult : public QFutureInterfaceBase -{ -public: - QFuture<void> run() - { - this->reportStarted(); - QFuture<void> future = QFuture<void>(this); - reportFinished(); - return future; - } -}; - -void tst_QFuture::futureInterface() -{ - { - QFuture<void> future; - { - QFutureInterface<void> i; - i.reportStarted(); - future = i.future(); - i.reportFinished(); - } - } - { - QFuture<int> future; - { - QFutureInterface<int> i; - i.reportStarted(); - i.reportResult(10); - future = i.future(); - i.reportFinished(); - } - QCOMPARE(future.resultAt(0), 10); - } - - { - QFuture<int> intFuture; - - QCOMPARE(intFuture.isStarted(), true); - QCOMPARE(intFuture.isFinished(), true); - - IntResult result; - - result.reportStarted(); - intFuture = result.future(); - - QCOMPARE(intFuture.isStarted(), true); - QCOMPARE(intFuture.isFinished(), false); - - result.reportFinished(&value); - - QCOMPARE(intFuture.isStarted(), true); - QCOMPARE(intFuture.isFinished(), true); - - int e = intFuture.result(); - - QCOMPARE(intFuture.isStarted(), true); - QCOMPARE(intFuture.isFinished(), true); - QCOMPARE(intFuture.isCanceled(), false); - - QCOMPARE(e, value); - intFuture.waitForFinished(); - - IntResult intAlgo; - intFuture = intAlgo.run(); - QFuture<int> intFuture2(intFuture); - QCOMPARE(intFuture.result(), value); - QCOMPARE(intFuture2.result(), value); - intFuture.waitForFinished(); - - VoidResult a; - a.run().waitForFinished(); - } -} - -template <typename T> -void testRefCounting() -{ - QFutureInterface<T> interface; - QCOMPARE(interface.d->refCount.load(), 1); - - { - interface.reportStarted(); - - QFuture<T> f = interface.future(); - QCOMPARE(interface.d->refCount.load(), 2); - - QFuture<T> f2(f); - QCOMPARE(interface.d->refCount.load(), 3); - - QFuture<T> f3; - f3 = f2; - QCOMPARE(interface.d->refCount.load(), 4); - - interface.reportFinished(0); - QCOMPARE(interface.d->refCount.load(), 4); - } - - QCOMPARE(interface.d->refCount.load(), 1); -} - -void tst_QFuture::refcounting() -{ - testRefCounting<int>(); -} - -void tst_QFuture::cancel() -{ - { - QFuture<void> f; - QFutureInterface<void> result; - - result.reportStarted(); - f = result.future(); - QVERIFY(f.isCanceled() == false); - result.reportCanceled(); - QVERIFY(f.isCanceled()); - result.reportFinished(); - QVERIFY(f.isCanceled()); - f.waitForFinished(); - QVERIFY(f.isCanceled()); - } - - // Cancel from the QFuture side and test if the result - // interface detects it. - { - QFutureInterface<void> result; - - QFuture<void> f; - QVERIFY(f.isStarted() == true); - - result.reportStarted(); - f = result.future(); - - QVERIFY(f.isStarted() == true); - - QVERIFY(result.isCanceled() == false); - f.cancel(); - - QVERIFY(result.isCanceled()); - - result.reportFinished(); - } - - // Test that finished futures can be canceled. - { - QFutureInterface<void> result; - - QFuture<void> f; - QVERIFY(f.isStarted() == true); - - result.reportStarted(); - f = result.future(); - - QVERIFY(f.isStarted() == true); - - result.reportFinished(); - - f.cancel(); - - QVERIFY(result.isCanceled()); - QVERIFY(f.isCanceled()); - } - - // Results reported after canceled is called should not be propagated. - { - - QFutureInterface<int> futureInterface; - futureInterface.reportStarted(); - QFuture<int> f = futureInterface.future(); - - int result = 0; - futureInterface.reportResult(&result); - result = 1; - futureInterface.reportResult(&result); - f.cancel(); - result = 2; - futureInterface.reportResult(&result); - result = 3; - futureInterface.reportResult(&result); - futureInterface.reportFinished(); - QCOMPARE(f.results(), QList<int>()); - } -} - -void tst_QFuture::statePropagation() -{ - QFuture<void> f1; - QFuture<void> f2; - - QCOMPARE(f1.isStarted(), true); - - QFutureInterface<void> result; - result.reportStarted(); - f1 = result.future(); - - f2 = f1; - - QCOMPARE(f2.isStarted(), true); - - result.reportCanceled(); - - QCOMPARE(f2.isStarted(), true); - QCOMPARE(f2.isCanceled(), true); - - QFuture<void> f3 = f2; - - QCOMPARE(f3.isStarted(), true); - QCOMPARE(f3.isCanceled(), true); - - result.reportFinished(); - - QCOMPARE(f2.isStarted(), true); - QCOMPARE(f2.isCanceled(), true); - - QCOMPARE(f3.isStarted(), true); - QCOMPARE(f3.isCanceled(), true); -} - -/* - Tests that a QFuture can return multiple results. -*/ -void tst_QFuture::multipleResults() -{ - IntResult a; - a.reportStarted(); - QFuture<int> f = a.future(); - - QFuture<int> copy = f; - int result; - - result = 1; - a.reportResult(&result); - QCOMPARE(f.resultAt(0), 1); - - result = 2; - a.reportResult(&result); - QCOMPARE(f.resultAt(1), 2); - - result = 3; - a.reportResult(&result); - - result = 4; - a.reportFinished(&result); - - QCOMPARE(f.results(), QList<int>() << 1 << 2 << 3 << 4); - - // test foreach - QList<int> fasit = QList<int>() << 1 << 2 << 3 << 4; - { - QList<int> results; - foreach(int result, f) - results.append(result); - QCOMPARE(results, fasit); - } - { - QList<int> results; - foreach(int result, copy) - results.append(result); - QCOMPARE(results, fasit); - } -} - -/* - Test out-of-order result reporting using indexes -*/ -void tst_QFuture::indexedResults() -{ - { - QFutureInterface<QChar> Interface; - QFuture<QChar> f; - QVERIFY(f.isStarted() == true); - - Interface.reportStarted(); - f = Interface.future(); - - QVERIFY(f.isStarted() == true); - - QChar result; - - result = 'B'; - Interface.reportResult(&result, 1); - - QCOMPARE(f.resultAt(1), result); - - result = 'A'; - Interface.reportResult(&result, 0); - QCOMPARE(f.resultAt(0), result); - - result = 'C'; - Interface.reportResult(&result); // no index - QCOMPARE(f.resultAt(2), result); - - Interface.reportFinished(); - - QCOMPARE(f.results(), QList<QChar>() << 'A' << 'B' << 'C'); - } - - { - // Test result reporting with a missing result in the middle - QFutureInterface<int> Interface; - Interface.reportStarted(); - QFuture<int> f = Interface.future(); - int result; - - result = 0; - Interface.reportResult(&result, 0); - QVERIFY(f.isResultReadyAt(0)); - QCOMPARE(f.resultAt(0), 0); - - result = 3; - Interface.reportResult(&result, 3); - QVERIFY(f.isResultReadyAt(3)); - QCOMPARE(f.resultAt(3), 3); - - result = 2; - Interface.reportResult(&result, 2); - QVERIFY(f.isResultReadyAt(2)); - QCOMPARE(f.resultAt(2), 2); - - result = 4; - Interface.reportResult(&result); // no index - QVERIFY(f.isResultReadyAt(4)); - QCOMPARE(f.resultAt(4), 4); - - Interface.reportFinished(); - - QCOMPARE(f.results(), QList<int>() << 0 << 2 << 3 << 4); - } -} - -void tst_QFuture::progress() -{ - QFutureInterface<QChar> result; - QFuture<QChar> f; - - QCOMPARE (f.progressValue(), 0); - - result.reportStarted(); - f = result.future(); - - QCOMPARE (f.progressValue(), 0); - - result.setProgressValue(50); - - QCOMPARE (f.progressValue(), 50); - - result.reportFinished(); - - QCOMPARE (f.progressValue(), 50); -} - -void tst_QFuture::progressText() -{ - QFutureInterface<void> i; - i.reportStarted(); - QFuture<void> f = i.future(); - - QCOMPARE(f.progressText(), QLatin1String("")); - i.setProgressValueAndText(1, QLatin1String("foo")); - QCOMPARE(f.progressText(), QLatin1String("foo")); - i.reportFinished(); -} - -/* - Test that results reported after finished are ignored. -*/ -void tst_QFuture::resultsAfterFinished() -{ - { - IntResult a; - a.reportStarted(); - QFuture<int> f = a.future(); - int result; - - QCOMPARE(f.resultCount(), 0); - - result = 1; - a.reportResult(&result); - QCOMPARE(f.resultAt(0), 1); - - a.reportFinished(); - - QCOMPARE(f.resultAt(0), 1); - QCOMPARE(f.resultCount(), 1); - result = 2; - a.reportResult(&result); - QCOMPARE(f.resultCount(), 1); - } - // cancel it - { - IntResult a; - a.reportStarted(); - QFuture<int> f = a.future(); - int result; - - QCOMPARE(f.resultCount(), 0); - - result = 1; - a.reportResult(&result); - QCOMPARE(f.resultAt(0), 1); - QCOMPARE(f.resultCount(), 1); - - a.reportCanceled(); - - QCOMPARE(f.resultAt(0), 1); - QCOMPARE(f.resultCount(), 1); - - result = 2; - a.reportResult(&result); - a.reportFinished(); - } -} - -void tst_QFuture::resultsAsList() -{ - IntResult a; - a.reportStarted(); - QFuture<int> f = a.future(); - - int result; - result = 1; - a.reportResult(&result); - result = 2; - a.reportResult(&result); - - a.reportFinished(); - - QList<int> results = f.results(); - QCOMPARE(results, QList<int>() << 1 << 2); -} - -/* - Test that QFuture<T> can be implicitly converted to T -*/ -void tst_QFuture::implicitConversions() -{ - QFutureInterface<QString> iface; - iface.reportStarted(); - - QFuture<QString> f(&iface); - - const QString input("FooBar 2000"); - iface.reportFinished(&input); - - const QString result = f; - QCOMPARE(result, input); - QCOMPARE(QString(f), input); - QCOMPARE(static_cast<QString>(f), input); -} - -void tst_QFuture::iterators() -{ - { - QFutureInterface<int> e; - e.reportStarted(); - QFuture<int> f = e.future(); - - int result; - result = 1; - e.reportResult(&result); - result = 2; - e.reportResult(&result); - result = 3; - e.reportResult(&result); - e.reportFinished(); - - QList<int> results; - QFutureIterator<int> i(f); - while (i.hasNext()) { - results.append(i.next()); - } - - QCOMPARE(results, f.results()); - - QFuture<int>::const_iterator i1 = f.begin(), i2 = i1 + 1; - QFuture<int>::const_iterator c1 = i1, c2 = c1 + 1; - - QVERIFY(i1 == i1); - QVERIFY(i1 == c1); - QVERIFY(c1 == i1); - QVERIFY(c1 == c1); - QVERIFY(i2 == i2); - QVERIFY(i2 == c2); - QVERIFY(c2 == i2); - QVERIFY(c2 == c2); - - QVERIFY(i1 != i2); - QVERIFY(i1 != c2); - QVERIFY(c1 != i2); - QVERIFY(c1 != c2); - QVERIFY(i2 != i1); - QVERIFY(i2 != c1); - QVERIFY(c2 != i1); - QVERIFY(c2 != c1); - - int x1 = *i1; - Q_UNUSED(x1); - int x2 = *i2; - Q_UNUSED(x2); - int y1 = *c1; - Q_UNUSED(y1); - int y2 = *c2; - Q_UNUSED(y2); - } - - { - QFutureInterface<QString> e; - e.reportStarted(); - QFuture<QString> f = e.future(); - - e.reportResult(QString("one")); - e.reportResult(QString("two")); - e.reportResult(QString("three")); - e.reportFinished(); - - QList<QString> results; - QFutureIterator<QString> i(f); - while (i.hasNext()) { - results.append(i.next()); - } - - QCOMPARE(results, f.results()); - - QFuture<QString>::const_iterator i1 = f.begin(), i2 = i1 + 1; - QFuture<QString>::const_iterator c1 = i1, c2 = c1 + 1; - - QVERIFY(i1 == i1); - QVERIFY(i1 == c1); - QVERIFY(c1 == i1); - QVERIFY(c1 == c1); - QVERIFY(i2 == i2); - QVERIFY(i2 == c2); - QVERIFY(c2 == i2); - QVERIFY(c2 == c2); - - QVERIFY(i1 != i2); - QVERIFY(i1 != c2); - QVERIFY(c1 != i2); - QVERIFY(c1 != c2); - QVERIFY(i2 != i1); - QVERIFY(i2 != c1); - QVERIFY(c2 != i1); - QVERIFY(c2 != c1); - - QString x1 = *i1; - QString x2 = *i2; - QString y1 = *c1; - QString y2 = *c2; - - QCOMPARE(x1, y1); - QCOMPARE(x2, y2); - - int i1Size = i1->size(); - int i2Size = i2->size(); - int c1Size = c1->size(); - int c2Size = c2->size(); - - QCOMPARE(i1Size, c1Size); - QCOMPARE(i2Size, c2Size); - } - - { - const int resultCount = 20; - - QFutureInterface<int> e; - e.reportStarted(); - QFuture<int> f = e.future(); - - for (int i = 0; i < resultCount; ++i) { - e.reportResult(i); - } - - e.reportFinished(); - - { - QFutureIterator<int> it(f); - QFutureIterator<int> it2(it); - } - - { - QFutureIterator<int> it(f); - - for (int i = 0; i < resultCount - 1; ++i) { - QVERIFY(it.hasNext()); - QCOMPARE(it.peekNext(), i); - QCOMPARE(it.next(), i); - } - - QVERIFY(it.hasNext()); - QCOMPARE(it.peekNext(), resultCount - 1); - QCOMPARE(it.next(), resultCount - 1); - QVERIFY(it.hasNext() == false); - } - - { - QFutureIterator<int> it(f); - QVERIFY(it.hasNext()); - it.toBack(); - QVERIFY(it.hasNext() == false); - it.toFront(); - QVERIFY(it.hasNext()); - } - } -} - -class SignalSlotObject : public QObject -{ -Q_OBJECT -public: - SignalSlotObject() - : finishedCalled(false), - canceledCalled(false), - rangeBegin(0), - rangeEnd(0) { } - -public slots: - void finished() - { - finishedCalled = true; - } - - void canceled() - { - canceledCalled = true; - } - - void resultReady(int index) - { - results.insert(index); - } - - void progressRange(int begin, int end) - { - rangeBegin = begin; - rangeEnd = end; - } - - void progress(int progress) - { - reportedProgress.insert(progress); - } -public: - bool finishedCalled; - bool canceledCalled; - QSet<int> results; - int rangeBegin; - int rangeEnd; - QSet<int> reportedProgress; -}; - -void tst_QFuture::pause() -{ - QFutureInterface<void> Interface; - - Interface.reportStarted(); - QFuture<void> f = Interface.future(); - - QVERIFY(Interface.isPaused() == false); - f.pause(); - QVERIFY(Interface.isPaused() == true); - f.resume(); - QVERIFY(Interface.isPaused() == false); - f.togglePaused(); - QVERIFY(Interface.isPaused() == true); - f.togglePaused(); - QVERIFY(Interface.isPaused() == false); - - Interface.reportFinished(); -} - -const int resultCount = 1000; - -class ResultObject : public QObject -{ -Q_OBJECT -public slots: - void resultReady(int) - { - - } -public: -}; - -// Test that that the isPaused() on future result interface returns true -// if we report a lot of results that are not handled. -void tst_QFuture::throttling() -{ - { - QFutureInterface<void> i; - - i.reportStarted(); - QFuture<void> f = i.future(); - - QVERIFY(i.isThrottled() == false); - - i.setThrottled(true); - QVERIFY(i.isThrottled()); - - i.setThrottled(false); - QVERIFY(i.isThrottled() == false); - - i.setThrottled(true); - QVERIFY(i.isThrottled()); - - i.reportFinished(); - } -} - -void tst_QFuture::voidConversions() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> intFuture(&iface); - - int value = 10; - iface.reportFinished(&value); - - QFuture<void> voidFuture(intFuture); - voidFuture = intFuture; - - QVERIFY(voidFuture == intFuture); -} - - -#ifndef QT_NO_EXCEPTIONS - -QFuture<void> createExceptionFuture() -{ - QFutureInterface<void> i; - i.reportStarted(); - QFuture<void> f = i.future(); - - Exception e; - i.reportException(e); - i.reportFinished(); - return f; -} - -QFuture<int> createExceptionResultFuture() -{ - QFutureInterface<int> i; - i.reportStarted(); - QFuture<int> f = i.future(); - int r = 0; - i.reportResult(r); - - Exception e; - i.reportException(e); - i.reportFinished(); - return f; -} - -class DerivedException : public Exception -{ -public: - void raise() const { throw *this; } - Exception *clone() const { return new DerivedException(*this); } -}; - -QFuture<void> createDerivedExceptionFuture() -{ - QFutureInterface<void> i; - i.reportStarted(); - QFuture<void> f = i.future(); - - DerivedException e; - i.reportException(e); - i.reportFinished(); - return f; -} - -void tst_QFuture::exceptions() -{ - // test throwing from waitForFinished - { - QFuture<void> f = createExceptionFuture(); - bool caught = false; - try { - f.waitForFinished(); - } catch (Exception &) { - caught = true; - } - QVERIFY(caught); - } - - // test result() - { - QFuture<int> f = createExceptionResultFuture(); - bool caught = false; - try { - f.result(); - } catch (Exception &) { - caught = true; - } - QVERIFY(caught); - } - - // test result() and destroy - { - bool caught = false; - try { - createExceptionResultFuture().result(); - } catch (Exception &) { - caught = true; - } - QVERIFY(caught); - } - - // test results() - { - QFuture<int> f = createExceptionResultFuture(); - bool caught = false; - try { - f.results(); - } catch (Exception &) { - caught = true; - } - QVERIFY(caught); - } - - // test foreach - { - QFuture<int> f = createExceptionResultFuture(); - bool caught = false; - try { - foreach (int e, f.results()) { - Q_UNUSED(e); - QFAIL("did not get exception"); - } - } catch (Exception &) { - caught = true; - } - QVERIFY(caught); - } - - // catch derived exceptions - { - bool caught = false; - try { - createDerivedExceptionFuture().waitForFinished(); - } catch (Exception &) { - caught = true; - } - QVERIFY(caught); - } - - { - bool caught = false; - try { - createDerivedExceptionFuture().waitForFinished(); - } catch (DerivedException &) { - caught = true; - } - QVERIFY(caught); - } -} - -class MyClass -{ -public: - ~MyClass() - { - QFuture<void> f = createExceptionFuture(); - try { - f.waitForFinished(); - } catch (Exception &) { - caught = true; - } - } - static bool caught; -}; - -bool MyClass::caught = false; - -// This is a regression test for QTBUG-18149. where QFuture did not throw -// exceptions if called from destructors when the stack was already unwinding -// due to an exception having been thrown. -void tst_QFuture::nestedExceptions() -{ - try { - MyClass m; - Q_UNUSED(m); - throw 0; - } catch (int) {} - - QVERIFY(MyClass::caught); -} - -#endif // QT_NO_EXCEPTIONS - -QTEST_MAIN(tst_QFuture) -#include "tst_qfuture.moc" diff --git a/tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro b/tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro deleted file mode 100644 index b36560b4ba..0000000000 --- a/tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qfuturesynchronizer -QT = core testlib -SOURCES = tst_qfuturesynchronizer.cpp diff --git a/tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp b/tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp deleted file mode 100644 index a2145ca04f..0000000000 --- a/tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest> - -#include <QtCore/qfuturesynchronizer.h> -#include <QtCore/qfuture.h> - -class tst_QFutureSynchronizer : public QObject -{ - Q_OBJECT - - -private Q_SLOTS: - void construction(); - void addFuture(); - void cancelOnWait(); - void clearFutures(); - void futures(); - void setFuture(); - void waitForFinished(); -}; - - -void tst_QFutureSynchronizer::construction() -{ - - QFuture<void> future; - QFutureSynchronizer<void> synchronizer; - QFutureSynchronizer<void> synchronizerWithFuture(future); - - QCOMPARE(synchronizer.futures().size(), 0); - QCOMPARE(synchronizerWithFuture.futures().size(), 1); -} - -void tst_QFutureSynchronizer::addFuture() -{ - QFutureSynchronizer<void> synchronizer; - - synchronizer.addFuture(QFuture<void>()); - QFuture<void> future; - synchronizer.addFuture(future); - synchronizer.addFuture(future); - - QCOMPARE(synchronizer.futures().size(), 3); -} - -void tst_QFutureSynchronizer::cancelOnWait() -{ - QFutureSynchronizer<void> synchronizer; - QVERIFY(!synchronizer.cancelOnWait()); - synchronizer.setCancelOnWait(true); - QVERIFY(synchronizer.cancelOnWait()); - synchronizer.setCancelOnWait(false); - QVERIFY(!synchronizer.cancelOnWait()); - synchronizer.setCancelOnWait(true); - QVERIFY(synchronizer.cancelOnWait()); -} - -void tst_QFutureSynchronizer::clearFutures() -{ - QFutureSynchronizer<void> synchronizer; - synchronizer.clearFutures(); - QVERIFY(synchronizer.futures().isEmpty()); - - synchronizer.addFuture(QFuture<void>()); - QFuture<void> future; - synchronizer.addFuture(future); - synchronizer.addFuture(future); - synchronizer.clearFutures(); - QVERIFY(synchronizer.futures().isEmpty()); -} - -void tst_QFutureSynchronizer::futures() -{ - QFutureSynchronizer<void> synchronizer; - - QList<QFuture<void> > futures; - for (int i=0; i<100; i++) { - QFuture<void> future; - futures.append(future); - synchronizer.addFuture(future); - } - - QCOMPARE(futures, synchronizer.futures()); -} - -void tst_QFutureSynchronizer::setFuture() -{ - QFutureSynchronizer<void> synchronizer; - - for (int i=0; i<100; i++) { - synchronizer.addFuture(QFuture<void>()); - } - QCOMPARE(synchronizer.futures().size(), 100); - - QFuture<void> future; - synchronizer.setFuture(future); - QCOMPARE(synchronizer.futures().size(), 1); - QCOMPARE(synchronizer.futures().first(), future); -} - -void tst_QFutureSynchronizer::waitForFinished() -{ - QFutureSynchronizer<void> synchronizer; - - for (int i=0; i<100; i++) { - synchronizer.addFuture(QFuture<void>()); - } - synchronizer.waitForFinished(); - const QList<QFuture<void> > futures = synchronizer.futures(); - - for (int i=0; i<100; i++) { - QVERIFY(futures.at(i).isFinished()); - } -} - -QTEST_MAIN(tst_QFutureSynchronizer) - -#include "tst_qfuturesynchronizer.moc" diff --git a/tests/auto/corelib/concurrent/qfuturewatcher/.gitignore b/tests/auto/corelib/concurrent/qfuturewatcher/.gitignore deleted file mode 100644 index 1d778431c5..0000000000 --- a/tests/auto/corelib/concurrent/qfuturewatcher/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qfuturewatcher diff --git a/tests/auto/corelib/concurrent/qfuturewatcher/qfuturewatcher.pro b/tests/auto/corelib/concurrent/qfuturewatcher/qfuturewatcher.pro deleted file mode 100644 index ae98fed3d9..0000000000 --- a/tests/auto/corelib/concurrent/qfuturewatcher/qfuturewatcher.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qfuturewatcher -QT = core-private testlib -SOURCES = tst_qfuturewatcher.cpp diff --git a/tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp deleted file mode 100644 index 4fad31b5c9..0000000000 --- a/tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp +++ /dev/null @@ -1,945 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QCoreApplication> -#include <QDebug> -#include <QtTest/QtTest> - -#include <qfuture.h> -#include <qfuturewatcher.h> -#include <qtconcurrentrun.h> -#include <qtconcurrentmap.h> -#include <private/qfutureinterface_p.h> - -using namespace QtConcurrent; - -#include <QtTest/QtTest> - -//#define PRINT - -class tst_QFutureWatcher: public QObject -{ - Q_OBJECT -private slots: - void startFinish(); - void progressValueChanged(); - void canceled(); - void resultAt(); - void resultReadyAt(); - void futureSignals(); - void watchFinishedFuture(); - void watchCanceledFuture(); - void disconnectRunningFuture(); - void tooMuchProgress(); - void progressText(); - void sharedFutureInterface(); - void changeFuture(); - void cancelEvents(); - void pauseEvents(); - void finishedState(); - void throttling(); - void incrementalMapResults(); - void incrementalFilterResults(); - void qfutureSynchronizer(); - void warnRace(); -}; - -void sleeper() -{ - QTest::qSleep(100); -} - -void tst_QFutureWatcher::startFinish() -{ - QFutureWatcher<void> futureWatcher; - - QSignalSpy startedSpy(&futureWatcher, SIGNAL(started())); - QSignalSpy finishedSpy(&futureWatcher, SIGNAL(finished())); - - QVERIFY(startedSpy.isValid()); - QVERIFY(finishedSpy.isValid()); - - futureWatcher.setFuture(QtConcurrent::run(sleeper)); - QTest::qWait(10); // spin the event loop to deliver queued signals. - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); - futureWatcher.future().waitForFinished(); - QTest::qWait(10); - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); -} - -void mapSleeper(int &) -{ - QTest::qSleep(100); -} - -QSet<int> progressValues; -QSet<QString> progressTexts; -QMutex mutex; -class ProgressObject : public QObject -{ -Q_OBJECT -public slots: - void printProgress(int); - void printText(const QString &text); - void registerProgress(int); - void registerText(const QString &text); -}; - -void ProgressObject::printProgress(int progress) -{ - qDebug() << "thread" << QThread::currentThread() << "reports progress" << progress; -} - -void ProgressObject::printText(const QString &text) -{ - qDebug() << "thread" << QThread::currentThread() << "reports progress text" << text; -} - -void ProgressObject::registerProgress(int progress) -{ - QTest::qSleep(1); - progressValues.insert(progress); -} - -void ProgressObject::registerText(const QString &text) -{ - QTest::qSleep(1); - progressTexts.insert(text); -} - - -QList<int> createList(int listSize) -{ - QList<int> list; - for (int i = 0; i < listSize; ++i) { - list.append(i); - } - return list; -} - -void tst_QFutureWatcher::progressValueChanged() -{ -#ifdef PRINT - qDebug() << "main thread" << QThread::currentThread(); -#endif - - progressValues.clear(); - const int listSize = 20; - QList<int> list = createList(listSize); - - QFutureWatcher<void> futureWatcher; - ProgressObject progressObject; - QObject::connect(&futureWatcher, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); -#ifdef PRINT - QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &progressObject, SLOT(printProgress(int)), Qt::DirectConnection ); -#endif - QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &progressObject, SLOT(registerProgress(int))); - - futureWatcher.setFuture(QtConcurrent::map(list, mapSleeper)); - - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - futureWatcher.disconnect(); - QVERIFY(progressValues.contains(0)); - QVERIFY(progressValues.contains(listSize)); -} - -class CancelObject : public QObject -{ -Q_OBJECT -public: - bool wasCanceled; - CancelObject() : wasCanceled(false) {}; -public slots: - void cancel(); -}; - -void CancelObject::cancel() -{ -#ifdef PRINT - qDebug() << "thread" << QThread::currentThread() << "reports canceled"; -#endif - wasCanceled = true; -} - -void tst_QFutureWatcher::canceled() -{ - const int listSize = 20; - QList<int> list = createList(listSize); - - QFutureWatcher<void> futureWatcher; - QFuture<void> future; - CancelObject cancelObject; - - QObject::connect(&futureWatcher, SIGNAL(canceled()), &cancelObject, SLOT(cancel())); - QObject::connect(&futureWatcher, SIGNAL(canceled()), - &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - - future = QtConcurrent::map(list, mapSleeper); - futureWatcher.setFuture(future); - futureWatcher.cancel(); - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QVERIFY(future.isCanceled()); - QVERIFY(cancelObject.wasCanceled); - futureWatcher.disconnect(); - future.waitForFinished(); -} - -class IntTask : public RunFunctionTask<int> -{ -public: - void runFunctor() - { - result = 10; - } -}; - -void tst_QFutureWatcher::resultAt() -{ - QFutureWatcher<int> futureWatcher; - futureWatcher.setFuture((new IntTask())->start()); - futureWatcher.waitForFinished(); - QCOMPARE(futureWatcher.result(), 10); - QCOMPARE(futureWatcher.resultAt(0), 10); -} - -void tst_QFutureWatcher::resultReadyAt() -{ - QFutureWatcher<int> futureWatcher; - QObject::connect(&futureWatcher, SIGNAL(resultReadyAt(int)), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - - QFuture<int> future = (new IntTask())->start(); - futureWatcher.setFuture(future); - - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!QTestEventLoop::instance().timeout()); - - // Setting the future again should give us another signal. - // (this is to prevent the race where the task associated - // with the future finishes before setFuture is called.) - futureWatcher.setFuture(QFuture<int>()); - futureWatcher.setFuture(future); - - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!QTestEventLoop::instance().timeout()); -} - -class SignalSlotObject : public QObject -{ -Q_OBJECT - -signals: - void cancel(); - -public slots: - void started() - { - qDebug() << "started called"; - } - - void finished() - { - qDebug() << "finished called"; - } - - void canceled() - { - qDebug() << "canceled called"; - } - -#ifdef PRINT - void resultReadyAt(int index) - { - qDebug() << "result" << index << "ready"; - } -#else - void resultReadyAt(int) { } -#endif - void progressValueChanged(int progress) - { - qDebug() << "progress" << progress; - } - - void progressRangeChanged(int min, int max) - { - qDebug() << "progress range" << min << max; - } - -}; - -void tst_QFutureWatcher::futureSignals() -{ - { - QFutureInterface<int> a; - QFutureWatcher<int> f; - - SignalSlotObject object; -#ifdef PRINT - connect(&f, SIGNAL(finished()), &object, SLOT(finished())); - connect(&f, SIGNAL(progressValueChanged(int)), &object, SLOT(progressValueChanged(int))); -#endif - // must connect to resultReadyAt so that the watcher can detect the connection - // (QSignalSpy does not trigger it.) - connect(&f, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - a.reportStarted(); - f.setFuture(a.future()); - - QSignalSpy progressSpy(&f, SIGNAL(progressValueChanged(int))); - QVERIFY(progressSpy.isValid()); - const int progress = 1; - a.setProgressValue(progress); - QTest::qWait(10); - QCOMPARE(progressSpy.count(), 2); - QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0); - QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1); - - QSignalSpy finishedSpy(&f, SIGNAL(finished())); - QSignalSpy resultReadySpy(&f, SIGNAL(resultReadyAt(int))); - - QVERIFY(finishedSpy.isValid()); - QVERIFY(resultReadySpy.isValid()); - - const int result = 10; - a.reportResult(&result); - QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 1); - a.reportFinished(&result); - QTest::qWait(10); - - QCOMPARE(resultReadySpy.count(), 2); - QCOMPARE(resultReadySpy.takeFirst().at(0).toInt(), 0); // check the index - QCOMPARE(resultReadySpy.takeFirst().at(0).toInt(), 1); - - QCOMPARE(finishedSpy.count(), 1); - } -} - -void tst_QFutureWatcher::watchFinishedFuture() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> f = iface.future(); - - int value = 100; - iface.reportFinished(&value); - - QFutureWatcher<int> watcher; - - SignalSlotObject object; -#ifdef PRINT - connect(&watcher, SIGNAL(started()), &object, SLOT(started())); - connect(&watcher, SIGNAL(canceled()), &object, SLOT(canceled())); - connect(&watcher, SIGNAL(finished()), &object, SLOT(finished())); - connect(&watcher, SIGNAL(progressValueChanged(int)), &object, SLOT(progressValueChanged(int))); - connect(&watcher, SIGNAL(progressRangeChanged(int, int)), &object, SLOT(progressRangeChanged(int, int))); -#endif - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - - QSignalSpy startedSpy(&watcher, SIGNAL(started())); - QSignalSpy finishedSpy(&watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QSignalSpy canceledSpy(&watcher, SIGNAL(canceled())); - - QVERIFY(startedSpy.isValid()); - QVERIFY(finishedSpy.isValid()); - QVERIFY(resultReadySpy.isValid()); - QVERIFY(canceledSpy.isValid()); - - watcher.setFuture(f); - QTest::qWait(10); - - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(resultReadySpy.count(), 1); - QCOMPARE(canceledSpy.count(), 0); -} - -void tst_QFutureWatcher::watchCanceledFuture() -{ - QFuture<int> f; - QFutureWatcher<int> watcher; - - SignalSlotObject object; -#ifdef PRINT - connect(&watcher, SIGNAL(started()), &object, SLOT(started())); - connect(&watcher, SIGNAL(canceled()), &object, SLOT(canceled())); - connect(&watcher, SIGNAL(finished()), &object, SLOT(finished())); - connect(&watcher, SIGNAL(progressValueChanged(int)), &object, SLOT(progressValueChanged(int))); - connect(&watcher, SIGNAL(progressRangeChanged(int, int)), &object, SLOT(progressRangeChanged(int, int))); -#endif - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - - QSignalSpy startedSpy(&watcher, SIGNAL(started())); - QSignalSpy finishedSpy(&watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QSignalSpy canceledSpy(&watcher, SIGNAL(canceled())); - - QVERIFY(startedSpy.isValid()); - QVERIFY(finishedSpy.isValid()); - QVERIFY(resultReadySpy.isValid()); - QVERIFY(canceledSpy.isValid()); - - watcher.setFuture(f); - QTest::qWait(10); - - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(resultReadySpy.count(), 0); - QCOMPARE(canceledSpy.count(), 1); -} - -void tst_QFutureWatcher::disconnectRunningFuture() -{ - QFutureInterface<int> a; - a.reportStarted(); - - QFuture<int> f = a.future(); - QFutureWatcher<int> *watcher = new QFutureWatcher<int>(); - watcher->setFuture(f); - - SignalSlotObject object; - connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - - QSignalSpy finishedSpy(watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(watcher, SIGNAL(resultReadyAt(int))); - - QVERIFY(finishedSpy.isValid()); - QVERIFY(resultReadySpy.isValid()); - - const int result = 10; - a.reportResult(&result); - QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 1); - - delete watcher; - - a.reportResult(&result); - QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 1); - - a.reportFinished(&result); - QTest::qWait(10); - QCOMPARE(finishedSpy.count(), 0); -} - -const int maxProgress = 100000; -class ProgressEmitterTask : public RunFunctionTask<void> -{ -public: - void runFunctor() - { - setProgressRange(0, maxProgress); - for (int p = 0; p <= maxProgress; ++p) - setProgressValue(p); - } -}; - -void tst_QFutureWatcher::tooMuchProgress() -{ - progressValues.clear(); - ProgressObject o; - - QFutureWatcher<void> f; - QObject::connect(&f, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); -#ifdef PRINT - QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(printProgress(int))); -#endif - QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(registerProgress(int))); - f.setFuture((new ProgressEmitterTask())->start()); - - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(progressValues.contains(maxProgress)); -} - -template <typename T> -class ProgressTextTask : public RunFunctionTask<T> -{ -public: - void runFunctor() - { - this->setProgressValueAndText(1, QLatin1String("Foo 1")); - - while (this->isProgressUpdateNeeded() == false) - QTest::qSleep(1); - this->setProgressValueAndText(2, QLatin1String("Foo 2")); - - while (this->isProgressUpdateNeeded() == false) - QTest::qSleep(1); - this->setProgressValueAndText(3, QLatin1String("Foo 3")); - - while (this->isProgressUpdateNeeded() == false) - QTest::qSleep(1); - this->setProgressValueAndText(4, QLatin1String("Foo 4")); - } -}; - -void tst_QFutureWatcher::progressText() -{ - { // instantiate API for T=int and T=void. - ProgressTextTask<int> a; - ProgressTextTask<void> b; - } - { - progressValues.clear(); - progressTexts.clear(); - QFuture<int> f = ((new ProgressTextTask<int>())->start()); - QFutureWatcher<int> watcher; - ProgressObject o; - QObject::connect(&watcher, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); -#ifdef PRINT - QObject::connect(&watcher, SIGNAL(progressValueChanged(int)), &o, SLOT(printProgress(int))); - QObject::connect(&watcher, SIGNAL(progressTextChanged(const QString &)), &o, SLOT(printText(const QString &))); -#endif - QObject::connect(&watcher, SIGNAL(progressValueChanged(int)), &o, SLOT(registerProgress(int))); - QObject::connect(&watcher, SIGNAL(progressTextChanged(const QString &)), &o, SLOT(registerText(const QString &))); - - watcher.setFuture(f); - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - - QCOMPARE(f.progressText(), QLatin1String("Foo 4")); - QCOMPARE(f.progressValue(), 4); - QVERIFY(progressValues.contains(1)); - QVERIFY(progressValues.contains(2)); - QVERIFY(progressValues.contains(3)); - QVERIFY(progressValues.contains(4)); - QVERIFY(progressTexts.contains(QLatin1String("Foo 1"))); - QVERIFY(progressTexts.contains(QLatin1String("Foo 2"))); - QVERIFY(progressTexts.contains(QLatin1String("Foo 3"))); - QVERIFY(progressTexts.contains(QLatin1String("Foo 4"))); - } -} - -template <typename T> -void callInterface(T &obj) -{ - obj.progressValue(); - obj.progressMinimum(); - obj.progressMaximum(); - obj.progressText(); - - obj.isStarted(); - obj.isFinished(); - obj.isRunning(); - obj.isCanceled(); - obj.isPaused(); - - obj.cancel(); - obj.pause(); - obj.resume(); - obj.togglePaused(); - obj.waitForFinished(); - - const T& objConst = obj; - objConst.progressValue(); - objConst.progressMinimum(); - objConst.progressMaximum(); - objConst.progressText(); - - objConst.isStarted(); - objConst.isFinished(); - objConst.isRunning(); - objConst.isCanceled(); - objConst.isPaused(); -} - -template <typename T> -void callInterface(const T &obj) -{ - obj.result(); - obj.resultAt(0); -} - - -// QFutureWatcher and QFuture has a similar interface. Test -// that the functions we want ot have in both are actually -// there. -void tst_QFutureWatcher::sharedFutureInterface() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> intFuture = iface.future(); - - int value = 0; - iface.reportFinished(&value); - - QFuture<void> voidFuture; - QFutureWatcher<int> intWatcher; - intWatcher.setFuture(intFuture); - QFutureWatcher<void> voidWatcher; - - callInterface(intFuture); - callInterface(voidFuture); - callInterface(intWatcher); - callInterface(voidWatcher); - - callInterface(intFuture); - callInterface(intWatcher); -} - -void tst_QFutureWatcher::changeFuture() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> a = iface.future(); - - int value = 0; - iface.reportFinished(&value); - - QFuture<int> b; - - QFutureWatcher<int> watcher; - - SignalSlotObject object; - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QVERIFY(resultReadySpy.isValid()); - - watcher.setFuture(a); // Watch 'a' which will genere a resultReady event. - watcher.setFuture(b); // But oh no! we're switching to another future - QTest::qWait(10); // before the event gets delivered. - - QCOMPARE(resultReadySpy.count(), 0); - - watcher.setFuture(a); - watcher.setFuture(b); - watcher.setFuture(a); // setting it back gets us one event, not two. - QTest::qWait(10); - - QCOMPARE(resultReadySpy.count(), 1); -} - -// Test that events aren't delivered from canceled futures -void tst_QFutureWatcher::cancelEvents() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> a = iface.future(); - - int value = 0; - iface.reportFinished(&value); - - QFutureWatcher<int> watcher; - - SignalSlotObject object; - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QVERIFY(resultReadySpy.isValid()); - - watcher.setFuture(a); - watcher.cancel(); - - QTest::qWait(10); - - QCOMPARE(resultReadySpy.count(), 0); -} - -// Tests that events from paused futures are saved and -// delivered on resume. -void tst_QFutureWatcher::pauseEvents() -{ - { - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> a = iface.future(); - - int value = 0; - iface.reportFinished(&value); - - QFutureWatcher<int> watcher; - - SignalSlotObject object; - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QVERIFY(resultReadySpy.isValid()); - - watcher.setFuture(a); - watcher.pause(); - - QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 0); - - watcher.resume(); - QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 1); - } - { - QFutureInterface<int> iface; - iface.reportStarted(); - - QFuture<int> a = iface.future(); - - int value = 0; - iface.reportFinished(&value); - - QFutureWatcher<int> watcher; - - SignalSlotObject object; - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QVERIFY(resultReadySpy.isValid()); - - watcher.setFuture(a); - a.pause(); - - QFuture<int> b; - watcher.setFuture(b); // If we watch b instead, resuming a - a.resume(); // should give us no results. - - QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 0); - } -} - -// Test that the finished state for the watcher gets -// set when the finished event is delivered. -// This means it will lag the finished state for the future, -// but makes it more useful. -void tst_QFutureWatcher::finishedState() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - QFuture<int> future = iface.future(); - QFutureWatcher<int> watcher; - - watcher.setFuture(future); - QTest::qWait(10); - - iface.reportFinished(); - QVERIFY(future.isFinished()); - QVERIFY(watcher.isFinished() == false); - - QTest::qWait(10); - QVERIFY(watcher.isFinished()); -} - -/* - Verify that throttling kicks in if you report a lot of results, - and that it clears when the result events are processed. -*/ -void tst_QFutureWatcher::throttling() -{ - QFutureInterface<int> iface; - iface.reportStarted(); - QFuture<int> future = iface.future(); - QFutureWatcher<int> watcher; - watcher.setFuture(future); - - QVERIFY(iface.isThrottled() == false); - - for (int i = 0; i < 1000; ++i) { - int result = 0; - iface.reportResult(result); - } - - QVERIFY(iface.isThrottled() == true); - - QTest::qWait(100); // process events. - - QVERIFY(iface.isThrottled() == false); - - iface.reportFinished(); -} - -int mapper(const int &i) -{ - return i; -} - -class ResultReadyTester : public QObject -{ -Q_OBJECT -public: - ResultReadyTester(QFutureWatcher<int> *watcher) - :m_watcher(watcher), filter(false), ok(true), count(0) - { - - } -public slots: - void resultReadyAt(int index) - { - ++count; - if (m_watcher->future().isResultReadyAt(index) == false) - ok = false; - if (!filter && m_watcher->future().resultAt(index) != index) - ok = false; - if (filter && m_watcher->future().resultAt(index) != index * 2 + 1) - ok = false; - } -public: - QFutureWatcher<int> *m_watcher; - bool filter; - bool ok; - int count; -}; - -void tst_QFutureWatcher::incrementalMapResults() -{ - QFutureWatcher<int> watcher; - - SignalSlotObject object; -#ifdef PRINT - connect(&watcher, SIGNAL(finished()), &object, SLOT(finished())); - connect(&watcher, SIGNAL(progressValueChanged(int)), &object, SLOT(progressValueChanged(int))); - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); -#endif - - QObject::connect(&watcher, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - ResultReadyTester resultReadyTester(&watcher); - connect(&watcher, SIGNAL(resultReadyAt(int)), &resultReadyTester, SLOT(resultReadyAt(int))); - - const int count = 10000; - QList<int> ints; - for (int i = 0; i < count; ++i) - ints << i; - - QFuture<int> future = QtConcurrent::mapped(ints, mapper); - watcher.setFuture(future); - - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(resultReadyTester.count, count); - QVERIFY(resultReadyTester.ok); - QVERIFY(watcher.isFinished()); - future.waitForFinished(); -} - -bool filterer(int i) -{ - return (i % 2); -} - -void tst_QFutureWatcher::incrementalFilterResults() -{ - QFutureWatcher<int> watcher; - - SignalSlotObject object; -#ifdef PRINT - connect(&watcher, SIGNAL(finished()), &object, SLOT(finished())); - connect(&watcher, SIGNAL(progressValueChanged(int)), &object, SLOT(progressValueChanged(int))); - connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); -#endif - - QObject::connect(&watcher, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - - ResultReadyTester resultReadyTester(&watcher); - resultReadyTester.filter = true; - connect(&watcher, SIGNAL(resultReadyAt(int)), &resultReadyTester, SLOT(resultReadyAt(int))); - - const int count = 10000; - QList<int> ints; - for (int i = 0; i < count; ++i) - ints << i; - - QFuture<int> future = QtConcurrent::filtered(ints, filterer); - watcher.setFuture(future); - - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(resultReadyTester.count, count / 2); - QVERIFY(resultReadyTester.ok); - QVERIFY(watcher.isFinished()); - future.waitForFinished(); -} - -void tst_QFutureWatcher::qfutureSynchronizer() -{ - int taskCount = 1000; - QTime t; - t.start(); - - { - QFutureSynchronizer<void> sync; - - sync.setCancelOnWait(true); - for (int i = 0; i < taskCount; ++i) { - sync.addFuture(run(sleeper)); - } - } - - // Test that we're not running each task. - QVERIFY(t.elapsed() < taskCount * 10); -} - -class DummyObject : public QObject { - Q_OBJECT -public slots: - void dummySlot() {} -public: - static void function(QMutex *m) - { - QMutexLocker lock(m); - } -}; - -void tst_QFutureWatcher::warnRace() -{ -#ifndef Q_OS_MAC //I don't know why it is not working on mac -#ifndef QT_NO_DEBUG - QTest::ignoreMessage(QtWarningMsg, "QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); -#endif -#endif - QFutureWatcher<void> watcher; - DummyObject object; - QMutex mutex; - mutex.lock(); - - QFuture<void> future = QtConcurrent::run(DummyObject::function, &mutex); - watcher.setFuture(future); - QTRY_VERIFY(future.isStarted()); - connect(&watcher, SIGNAL(finished()), &object, SLOT(dummySlot())); - mutex.unlock(); - future.waitForFinished(); -} - -QTEST_MAIN(tst_QFutureWatcher) -#include "tst_qfuturewatcher.moc" diff --git a/tests/auto/corelib/concurrent/qtconcurrentfilter/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentfilter/.gitignore deleted file mode 100644 index f93d27e009..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentfilter/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtconcurrentfilter diff --git a/tests/auto/corelib/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro b/tests/auto/corelib/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro deleted file mode 100644 index f783455b2e..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qtconcurrentfilter -QT = core testlib -SOURCES = tst_qtconcurrentfilter.cpp -DEFINES += QT_STRICT_ITERATORS - -CONFIG += insignificant_test # See QTBUG-20688 diff --git a/tests/auto/corelib/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/corelib/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp deleted file mode 100644 index 272d8514ef..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ /dev/null @@ -1,1543 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtconcurrentfilter.h> -#include <QCoreApplication> -#include <QList> -#include <QLinkedList> -#include <QtTest/QtTest> - -#include "../qtconcurrentmap/functions.h" - -class tst_QtConcurrentFilter : public QObject -{ - Q_OBJECT - -private slots: -#ifdef QT_NO_CONCURRENT_FILTER - void initTestCase(); -#else - void filter(); - void filtered(); - void filteredReduced(); - void resultAt(); - void incrementalResults(); - void noDetach(); -#ifndef QT_NO_STL - void stlContainers(); -#endif -#endif -}; - -#ifdef QT_NO_CONCURRENT_FILTER -void tst_QtConcurrentFilter::initTestCase() -{ - QSKIP("This test is skipped for gcc 3.x"); -} - -#else - -void tst_QtConcurrentFilter::filter() -{ - // functor - { - QList<int> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::filter(list, KeepEvenIntegers()).waitForFinished(); - QCOMPARE(list, QList<int>() << 2 << 4); - } - { - QList<int> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(list, KeepEvenIntegers()); - QCOMPARE(list, QList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, KeepEvenIntegers()).waitForFinished(); - QCOMPARE(linkedList, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, KeepEvenIntegers()); - QCOMPARE(linkedList, QLinkedList<int>() << 2 << 4); - } - { - QVector<int> vector; - vector << 1 << 2 << 3 << 4; - QtConcurrent::filter(vector, KeepEvenIntegers()).waitForFinished(); - QCOMPARE(vector, QVector<int>() << 2 << 4); - } - { - QVector<int> vector; - vector << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(vector, KeepEvenIntegers()); - QCOMPARE(vector, QVector<int>() << 2 << 4); - } - - - // function - { - QList<int> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::filter(list, keepEvenIntegers).waitForFinished(); - QCOMPARE(list, QList<int>() << 2 << 4); - } - { - QList<int> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(list, keepEvenIntegers); - QCOMPARE(list, QList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, keepEvenIntegers).waitForFinished(); - QCOMPARE(linkedList, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, keepEvenIntegers); - QCOMPARE(linkedList, QLinkedList<int>() << 2 << 4); - } - - // bound function - { - QList<int> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::filter(list, keepEvenIntegers).waitForFinished(); - QCOMPARE(list, QList<int>() << 2 << 4); - } - { - QList<int> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(list, keepEvenIntegers); - QCOMPARE(list, QList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, keepEvenIntegers).waitForFinished(); - QCOMPARE(linkedList, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, keepEvenIntegers); - QCOMPARE(linkedList, QLinkedList<int>() << 2 << 4); - } - - // member - { - QList<Number> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::filter(list, &Number::isEven).waitForFinished(); - QCOMPARE(list, QList<Number>() << 2 << 4); - } - { - QList<Number> list; - list << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(list, &Number::isEven); - QCOMPARE(list, QList<Number>() << 2 << 4); - } - { - QLinkedList<Number> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, &Number::isEven).waitForFinished(); - QCOMPARE(linkedList, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, &Number::isEven); - QCOMPARE(linkedList, QLinkedList<Number>() << 2 << 4); - } -} - -void tst_QtConcurrentFilter::filtered() -{ - QList<int> list; - list << 1 << 2 << 3 << 4; - - // functor - { - QFuture<int> f = QtConcurrent::filtered(list, KeepEvenIntegers()); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(list.begin(), list.end(), KeepEvenIntegers()); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(list.constBegin(), - list.constEnd(), - KeepEvenIntegers()); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered(list, KeepEvenIntegers()); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered<QList<int> >(list.begin(), - list.end(), - KeepEvenIntegers()); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered<QList<int> >(list.constBegin(), - list.constEnd(), - KeepEvenIntegers()); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - - { - QVector<int> vector; - vector << 1 << 2 << 3 << 4; - QVector<int> vector2 = QtConcurrent::blockingFiltered(vector, KeepEvenIntegers()); - QCOMPARE(vector2, QVector<int>() << 2 << 4); - } - { - QVector<int> vector; - vector << 1 << 2 << 3 << 4; - QFuture<int> f = QtConcurrent::filtered(vector, KeepEvenIntegers()); - QCOMPARE(f.results(), QList<int>() << 2 << 4); - } - - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered(linkedList, KeepEvenIntegers()); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QFuture<int> f = QtConcurrent::filtered(linkedList, KeepEvenIntegers()); - QCOMPARE(f.results(), QList<int>() << 2 << 4); - } - - // function - { - QFuture<int> f = QtConcurrent::filtered(list, keepEvenIntegers); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(list.begin(), list.end(), keepEvenIntegers); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(list.constBegin(), - list.constEnd(), - keepEvenIntegers); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered(list, keepEvenIntegers); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered<QList<int> >(list.begin(), - list.end(), - keepEvenIntegers); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered<QList<int> >(list.constBegin(), - list.constEnd(), - keepEvenIntegers); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - - // bound function - { - QFuture<int> f = QtConcurrent::filtered(list, keepEvenIntegers); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(list.begin(), list.end(), keepEvenIntegers); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(list.constBegin(), - list.constEnd(), - keepEvenIntegers); - QList<int> list2 = f.results(); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered(list, keepEvenIntegers); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered<QList<int> >(list.begin(), - list.end(), - keepEvenIntegers); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFiltered<QList<int> >(list.constBegin(), - list.constEnd(), - keepEvenIntegers); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - - // const member function - { - QList<Number> integers; - integers << 1 << 2 << 3 << 4; - QFuture<Number> f = QtConcurrent::filtered(integers, &Number::isEven); - QList<Number> list2 = f.results(); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> integers; - integers << 1 << 2 << 3 << 4; - QFuture<Number> f = QtConcurrent::filtered(integers.begin(), - integers.end(), - &Number::isEven); - QList<Number> list2 = f.results(); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> integers; - integers << 1 << 2 << 3 << 4; - QFuture<Number> f = QtConcurrent::filtered(integers.constBegin(), - integers.constEnd(), - &Number::isEven); - QList<Number> list2 = f.results(); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> integers; - integers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::blockingFiltered(integers, &Number::isEven); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> integers; - integers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::blockingFiltered<QList<Number> >(integers.begin(), - integers.end(), - &Number::isEven); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> integers; - integers << 1 << 2 << 3 << 4; - QList<Number> list2 = - QtConcurrent::blockingFiltered<QList<Number> >(integers.constBegin(), - integers.constEnd(), - &Number::isEven); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - - // same thing on linked lists - - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - - // functor - { - QFuture<int> f = QtConcurrent::filtered(linkedList, KeepEvenIntegers()); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers()); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers()); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered(linkedList, KeepEvenIntegers()); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<int> >(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers()); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<int> >(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers()); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - - // function - { - QFuture<int> f = QtConcurrent::filtered(linkedList, keepEvenIntegers); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(linkedList.begin(), - linkedList.end(), - keepEvenIntegers); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered(linkedList, keepEvenIntegers); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<int> >(linkedList.begin(), - linkedList.end(), - keepEvenIntegers); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<int> >(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - - // bound function - { - QFuture<int> f = QtConcurrent::filtered(linkedList, keepEvenIntegers); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(linkedList.begin(), - linkedList.end(), - keepEvenIntegers); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QFuture<int> f = QtConcurrent::filtered(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers); - QList<int> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered(linkedList, keepEvenIntegers); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<int> >(linkedList.begin(), - linkedList.end(), - keepEvenIntegers); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<int> >(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - - // const member function - { - QLinkedList<Number> integers; - integers << 1 << 2 << 3 << 4; - QFuture<Number> f = QtConcurrent::filtered(integers, &Number::isEven); - QList<Number> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<Number>() << 2 << 4); - } - { - QLinkedList<Number> integers; - integers << 1 << 2 << 3 << 4; - QFuture<Number> f = QtConcurrent::filtered(integers.begin(), - integers.end(), - &Number::isEven); - QList<Number> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<Number>() << 2 << 4); - } - { - QLinkedList<Number> integers; - integers << 1 << 2 << 3 << 4; - QFuture<Number> f = QtConcurrent::filtered(integers.constBegin(), - integers.constEnd(), - &Number::isEven); - QList<Number> linkedList2 = f.results(); - QCOMPARE(linkedList2, QList<Number>() << 2 << 4); - } - { - QLinkedList<Number> integers; - integers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::blockingFiltered(integers, &Number::isEven); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> integers; - integers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::blockingFiltered<QLinkedList<Number> >(integers.begin(), - integers.end(), - &Number::isEven); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> integers; - integers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = - QtConcurrent::blockingFiltered<QLinkedList<Number> >(integers.constBegin(), - integers.constEnd(), - &Number::isEven); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } -} - -void tst_QtConcurrentFilter::filteredReduced() -{ - QList<int> list; - list << 1 << 2 << 3 << 4; - QList<Number> numberList; - numberList << 1 << 2 << 3 << 4; - - // functor-functor - { - int sum = QtConcurrent::filteredReduced<int>(list, KeepEvenIntegers(), IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(list, keepEvenIntegers, intSumReduce); - QCOMPARE(sum2, 6); - } - { - QVector<int> vector; - vector << 1 << 2 << 3 << 4; - int sum = QtConcurrent::filteredReduced<int>(vector, KeepEvenIntegers(), IntSumReduce()); - QCOMPARE(sum, 6); - } - - { - int sum = QtConcurrent::filteredReduced<int>(list.begin(), - list.end(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(list.begin(), - list.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(list.constBegin(), - list.constEnd(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(list, KeepEvenIntegers(), IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(list, keepEvenIntegers, intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(list.begin(), - list.end(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(list.begin(), - list.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(list.constBegin(), - list.constEnd(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - - // function-functor - { - int sum = QtConcurrent::filteredReduced<int>(list, keepEvenIntegers, IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(list.begin(), - list.end(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(list, keepEvenIntegers, IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(list.begin(), - list.end(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - - // functor-function - { - int sum = QtConcurrent::filteredReduced(list, KeepEvenIntegers(), intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(list.begin(), - list.end(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(list.constBegin(), - list.constEnd(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(list, KeepEvenIntegers(), intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(list.begin(), - list.end(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(list.constBegin(), - list.constEnd(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - - // function-function - { - int sum = QtConcurrent::filteredReduced(list, keepEvenIntegers, intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(list.begin(), - list.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(list, keepEvenIntegers, intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(list.begin(), - list.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - - // functor-member - { - QList<int> list2 = QtConcurrent::filteredReduced(list, KeepEvenIntegers(), &QList<int>::push_back, QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::filteredReduced(list.begin(), - list.end(), - KeepEvenIntegers(), - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::filteredReduced(list.constBegin(), - list.constEnd(), - KeepEvenIntegers(), - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFilteredReduced(list, KeepEvenIntegers(), &QList<int>::push_back, QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFilteredReduced(list.begin(), - list.end(), - KeepEvenIntegers(), - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFilteredReduced(list.constBegin(), - list.constEnd(), - KeepEvenIntegers(), - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - - // member-functor - { - int sum = QtConcurrent::filteredReduced<int>(numberList, &Number::isEven, NumberSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(QList<Number>(numberList), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(numberList.begin(), - numberList.end(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(numberList.constBegin(), - numberList.constEnd(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(numberList, &Number::isEven, NumberSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(QList<Number>(numberList), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(numberList.begin(), - numberList.end(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(numberList.constBegin(), - numberList.constEnd(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - - // member-member - { - QList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::filteredReduced(numbers, - &Number::isEven, - &QList<Number>::push_back, QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::filteredReduced(numbers.begin(), - numbers.end(), - &Number::isEven, - &QList<Number>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::filteredReduced(numbers.constBegin(), - numbers.constEnd(), - &Number::isEven, - &QList<Number>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::blockingFilteredReduced(numbers, - &Number::isEven, - &QList<Number>::push_back, QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::blockingFilteredReduced(numbers.begin(), - numbers.end(), - &Number::isEven, - &QList<Number>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - { - QList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QList<Number> list2 = QtConcurrent::blockingFilteredReduced(numbers.constBegin(), - numbers.constEnd(), - &Number::isEven, - &QList<Number>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<Number>() << 2 << 4); - } - - // function-member - { - QList<int> list2 = QtConcurrent::filteredReduced(list, keepEvenIntegers, &QList<int>::push_back, QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::filteredReduced(list.begin(), - list.end(), - keepEvenIntegers, - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::filteredReduced(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFilteredReduced(list, keepEvenIntegers, &QList<int>::push_back, QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFilteredReduced(list.begin(), - list.end(), - keepEvenIntegers, - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - { - QList<int> list2 = QtConcurrent::blockingFilteredReduced(list.constBegin(), - list.constEnd(), - keepEvenIntegers, - &QList<int>::push_back, - QtConcurrent::OrderedReduce); - QCOMPARE(list2, QList<int>() << 2 << 4); - } - - // member-function - { - int sum = QtConcurrent::filteredReduced(numberList, &Number::isEven, numberSumReduce); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced(QList<Number>(numberList), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced(numberList.begin(), - numberList.end(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(numberList, &Number::isEven, numberSumReduce); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced(QList<Number>(numberList), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(numberList.begin(), - numberList.end(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - - // same as above on linked lists - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3 << 4; - QLinkedList<Number> numberLinkedList; - numberLinkedList << 1 << 2 << 3 << 4; - - // functor-functor - { - int sum = QtConcurrent::filteredReduced<int>(linkedList, KeepEvenIntegers(), IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(linkedList, keepEvenIntegers, intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(linkedList, KeepEvenIntegers(), IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(linkedList, keepEvenIntegers, intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers(), - IntSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum2, 6); - } - - // function-functor - { - int sum = QtConcurrent::filteredReduced<int>(linkedList, keepEvenIntegers, IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(linkedList, keepEvenIntegers, IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - IntSumReduce()); - QCOMPARE(sum, 6); - } - - // functor-function - { - int sum = QtConcurrent::filteredReduced(linkedList, KeepEvenIntegers(), intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(linkedList, KeepEvenIntegers(), intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers(), - intSumReduce); - QCOMPARE(sum, 6); - } - - // function-function - { - int sum = QtConcurrent::filteredReduced(linkedList, keepEvenIntegers, intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(linkedList, keepEvenIntegers, intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - intSumReduce); - QCOMPARE(sum, 6); - } - - // functor-member - { - QLinkedList<int> linkedList2 = QtConcurrent::filteredReduced(linkedList, KeepEvenIntegers(), &QLinkedList<int>::append, QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::filteredReduced(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers(), - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::filteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers(), - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFilteredReduced(linkedList, KeepEvenIntegers(), &QLinkedList<int>::append, QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFilteredReduced(linkedList.begin(), - linkedList.end(), - KeepEvenIntegers(), - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFilteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - KeepEvenIntegers(), - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - - // member-functor - { - int sum = QtConcurrent::filteredReduced<int>(numberLinkedList, &Number::isEven, NumberSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced<int>(QLinkedList<Number>(numberLinkedList), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(numberLinkedList.begin(), - numberLinkedList.end(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced<int>(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(numberLinkedList, &Number::isEven, NumberSumReduce()); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced<int>(QLinkedList<Number>(numberLinkedList), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(numberLinkedList.begin(), - numberLinkedList.end(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced<int>(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::isEven, - NumberSumReduce()); - QCOMPARE(sum, 6); - } - - // member-member - { - QLinkedList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::filteredReduced(numbers, - &Number::isEven, - &QLinkedList<Number>::append, QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::filteredReduced(numbers.begin(), - numbers.end(), - &Number::isEven, - &QLinkedList<Number>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::filteredReduced(numbers.constBegin(), - numbers.constEnd(), - &Number::isEven, - &QLinkedList<Number>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::blockingFilteredReduced(numbers, - &Number::isEven, - &QLinkedList<Number>::append, QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::blockingFilteredReduced(numbers.begin(), - numbers.end(), - &Number::isEven, - &QLinkedList<Number>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - { - QLinkedList<Number> numbers; - numbers << 1 << 2 << 3 << 4; - QLinkedList<Number> linkedList2 = QtConcurrent::blockingFilteredReduced(numbers.constBegin(), - numbers.constEnd(), - &Number::isEven, - &QLinkedList<Number>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<Number>() << 2 << 4); - } - - // function-member - { - QLinkedList<int> linkedList2 = QtConcurrent::filteredReduced(linkedList, keepEvenIntegers, &QLinkedList<int>::append, QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::filteredReduced(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::filteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFilteredReduced(linkedList, keepEvenIntegers, &QLinkedList<int>::append, QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFilteredReduced(linkedList.begin(), - linkedList.end(), - keepEvenIntegers, - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingFilteredReduced(linkedList.constBegin(), - linkedList.constEnd(), - keepEvenIntegers, - &QLinkedList<int>::append, - QtConcurrent::OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4); - } - - // member-function - { - int sum = QtConcurrent::filteredReduced(numberLinkedList, &Number::isEven, numberSumReduce); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::filteredReduced(QLinkedList<Number>(numberLinkedList), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::filteredReduced(numberLinkedList.begin(), - numberLinkedList.end(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::filteredReduced(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(numberLinkedList, &Number::isEven, numberSumReduce); - QCOMPARE(sum, 6); - - int sum2 = QtConcurrent::blockingFilteredReduced(QLinkedList<Number>(numberLinkedList), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum2, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(numberLinkedList.begin(), - numberLinkedList.end(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - { - int sum = QtConcurrent::blockingFilteredReduced(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::isEven, - numberSumReduce); - QCOMPARE(sum, 6); - } - - // ### the same as above, with an initial result value -} - -bool filterfn(int i) -{ - return (i % 2); -} - -void tst_QtConcurrentFilter::resultAt() -{ - - QList<int> ints; - for (int i=0; i < 1000; ++i) - ints << i; - - QFuture<int> future = QtConcurrent::filtered(ints, filterfn); - future.waitForFinished(); - - - for (int i = 0; i < future.resultCount(); ++i) { - QCOMPARE(future.resultAt(i), ints.at(i * 2 + 1)); - } - -} - -bool waitFilterfn(const int &i) -{ - QTest::qWait(1); - return (i % 2); -} - -void tst_QtConcurrentFilter::incrementalResults() -{ - const int count = 200; - QList<int> ints; - for (int i=0; i < count; ++i) - ints << i; - - QFuture<int> future = QtConcurrent::filtered(ints, waitFilterfn); - - QList<int> results; - - while (future.isFinished() == false) { - for (int i = 0; i < future.resultCount(); ++i) { - results += future.resultAt(i); - } - QTest::qWait(1); - } - - QCOMPARE(future.isFinished(), true); - QCOMPARE(future.resultCount(), count / 2); - QCOMPARE(future.results().count(), count / 2); -} - -void tst_QtConcurrentFilter::noDetach() -{ - { - QList<int> l = QList<int>() << 1; - QVERIFY(l.isDetached()); - - QList<int> ll = l; - QVERIFY(l.isDetached() == false); - - QtConcurrent::filtered(l, waitFilterfn).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::blockingFiltered(l, waitFilterfn); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::filteredReduced(l, waitFilterfn, intSumReduce).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::filter(l, waitFilterfn).waitForFinished(); - QVERIFY(l.isDetached() == true); - QVERIFY(ll.isDetached() == true); - } - { - const QList<int> l = QList<int>() << 1; - QVERIFY(l.isDetached()); - - const QList<int> ll = l; - QVERIFY(l.isDetached() == false); - - QtConcurrent::filtered(l, waitFilterfn).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::filteredReduced(l, waitFilterfn, intSumReduce).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - } -} - -#ifndef QT_NO_STL -void tst_QtConcurrentFilter::stlContainers() -{ - std::vector<int> vector; - vector.push_back(1); - vector.push_back(2); - - std::vector<int> vector2 = QtConcurrent::blockingFiltered(vector, waitFilterfn); - QCOMPARE(vector2.size(), (std::vector<int>::size_type)(1)); - QCOMPARE(vector2[0], 1); - - std::list<int> list; - list.push_back(1); - list.push_back(2); - - std::list<int> list2 = QtConcurrent::blockingFiltered(list, waitFilterfn); - QCOMPARE(list2.size(), (std::list<int>::size_type)(1)); - QCOMPARE(*list2.begin(), 1); - - QtConcurrent::filtered(list, waitFilterfn).waitForFinished(); - QtConcurrent::filtered(vector, waitFilterfn).waitForFinished(); - QtConcurrent::filtered(vector.begin(), vector.end(), waitFilterfn).waitForFinished(); - - QtConcurrent::blockingFilter(list, waitFilterfn); - QCOMPARE(list2.size(), (std::list<int>::size_type)(1)); - QCOMPARE(*list2.begin(), 1); -} -#endif - -#endif - -QTEST_MAIN(tst_QtConcurrentFilter) -#include "tst_qtconcurrentfilter.moc" diff --git a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/.gitignore deleted file mode 100644 index ac5dec4db6..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtconcurrentiteratekernel diff --git a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro deleted file mode 100644 index e876c86725..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qtconcurrentiteratekernel -QT = core testlib -SOURCES = tst_qtconcurrentiteratekernel.cpp diff --git a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp deleted file mode 100644 index 16f61513eb..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QThread> - -struct TestIterator -{ - TestIterator(int i) - :i(i) { } - - int operator-(const TestIterator &other) - { - return i - other.i; - } - - TestIterator& operator++() - { - ++i; - return *this; - } - - bool operator!=(const TestIterator &other) const - { - return i != other.i; - } - - int i; -}; - -#include <qiterator.h> -#ifndef QT_NO_STL -namespace std { -template <> -struct iterator_traits<TestIterator> -{ - typedef random_access_iterator_tag iterator_category; -}; - -int distance(TestIterator &a, TestIterator &b) -{ - return b - a; -} - -} -#endif - -#include <qtconcurrentiteratekernel.h> -#include <QtTest/QtTest> - -using namespace QtConcurrent; - -class tst_QtConcurrentIterateKernel: public QObject -{ - Q_OBJECT -private slots: - // "for" iteration tests: - void instantiate(); - void cancel(); - void stresstest(); - void noIterations(); - void throttling(); -#ifndef QT_NO_STL - void blockSize(); - void multipleResults(); -#endif -}; - -QAtomicInt iterations; -class PrintFor : public IterateKernel<TestIterator, void> -{ -public: - PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); } - bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) - { - iterations.fetchAndAddRelaxed(end - begin); -#ifdef PRINT - qDebug() << QThread::currentThread() << "iteration" << begin << "to" << end << "(exclusive)"; -#endif - return false; - } - bool runIteration(TestIterator it, int index , void *result) - { - return runIterations(it, index, index + 1, result); - } - -}; - -class SleepPrintFor : public IterateKernel<TestIterator, void> -{ -public: - SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); } - inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) - { - QTest::qSleep(200); - iterations.fetchAndAddRelaxed(end - begin); -#ifdef PRINT - qDebug() << QThread::currentThread() << "iteration" << begin << "to" << end << "(exclusive)"; -#endif - return false; - } - bool runIteration(TestIterator it, int index , void *result) - { - return runIterations(it, index, index + 1, result); - } -}; - - -void tst_QtConcurrentIterateKernel::instantiate() -{ - startThreadEngine(new PrintFor(0, 40)).startBlocking(); - QCOMPARE(iterations.load(), 40); -} - -void tst_QtConcurrentIterateKernel::cancel() -{ - { - QFuture<void> f = startThreadEngine(new SleepPrintFor(0, 40)).startAsynchronously(); - f.cancel(); - f.waitForFinished(); - QVERIFY(f.isCanceled()); - QVERIFY(iterations.load() <= QThread::idealThreadCount()); // the threads might run one iteration each before they are canceled. - } -} - -QAtomicInt counter; -class CountFor : public IterateKernel<TestIterator, void> -{ -public: - CountFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); } - inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) - { - counter.fetchAndAddRelaxed(end - begin); - return false; - } - bool runIteration(TestIterator it, int index , void *result) - { - return runIterations(it, index, index + 1, result); - } -}; - -void tst_QtConcurrentIterateKernel::stresstest() -{ - const int iterations = 1000; - const int times = 50; - for (int i = 0; i < times; ++i) { - counter.store(0); - CountFor f(0, iterations); - f.startBlocking(); - QCOMPARE(counter.load(), iterations); - } -} - -void tst_QtConcurrentIterateKernel::noIterations() -{ - const int times = 20000; - for (int i = 0; i < times; ++i) - startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking(); -} - -QMutex threadsMutex; -QSet<QThread *> threads; -class ThrottleFor : public IterateKernel<TestIterator, void> -{ -public: - // this class throttles between iterations 100 and 200, - // and then records how many threads that run between - // iterations 140 and 160. - ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); throttling = false; } - inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) - { - if (200 >= begin && 200 < end) { - throttling = false; - } - - iterations.fetchAndAddRelaxed(end - begin); - - QThread *thread = QThread::currentThread(); - - if (begin > 140 && end < 160) { - QMutexLocker locker(&threadsMutex); - threads.insert(thread); - } - - if (100 >= begin && 100 < end) { - throttling = true; - } - - QTest::qWait(1); - - return false; - } - bool runIteration(TestIterator it, int index , void *result) - { - return runIterations(it, index, index + 1, result); - } - - bool shouldThrottleThread() - { - const int load = iterations.load(); - return (load > 100 && load < 200); - } - bool throttling; -}; - -void tst_QtConcurrentIterateKernel::throttling() -{ - const int totalIterations = 400; - iterations.store(0); - - threads.clear(); - - ThrottleFor f(0, totalIterations); - f.startBlocking(); - - QCOMPARE(iterations.load(), totalIterations); - - - QCOMPARE(threads.count(), 1); -} - - -int peakBlockSize = 0; -class BlockSizeRecorder : public IterateKernel<TestIterator, void> -{ -public: - BlockSizeRecorder(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { } - inline bool runIterations(TestIterator, int begin, int end, void *) - { - peakBlockSize = qMax(peakBlockSize, end - begin); - return false; - } -}; - -// Missing stl iterators prevent correct block size calculation. -#ifndef QT_NO_STL -void tst_QtConcurrentIterateKernel::blockSize() -{ - const int expectedMinimumBlockSize = 1024 / QThread::idealThreadCount(); - BlockSizeRecorder(0, 10000).startBlocking(); - if (peakBlockSize < expectedMinimumBlockSize) - qDebug() << "block size" << peakBlockSize; - QVERIFY(peakBlockSize >= expectedMinimumBlockSize); -} -#endif - -class MultipleResultsFor : public IterateKernel<TestIterator, int> -{ -public: - MultipleResultsFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, int>(begin, end) { } - inline bool runIterations(TestIterator, int begin, int end, int *results) - { - for (int i = begin; i < end; ++i) - results[i - begin] = i; - return true; - } -}; - -// Missing stl iterators prevent correct summation. -#ifndef QT_NO_STL -void tst_QtConcurrentIterateKernel::multipleResults() -{ - QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously(); - QCOMPARE(f.results().count() , 10); - QCOMPARE(f.resultAt(0), 0); - QCOMPARE(f.resultAt(5), 5); - QCOMPARE(f.resultAt(9), 9); - f.waitForFinished(); -} -#endif - -QTEST_MAIN(tst_QtConcurrentIterateKernel) - -#include "tst_qtconcurrentiteratekernel.moc" diff --git a/tests/auto/corelib/concurrent/qtconcurrentmap/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentmap/.gitignore deleted file mode 100644 index f1c563e979..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentmap/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtconcurrentmap diff --git a/tests/auto/corelib/concurrent/qtconcurrentmap/functions.h b/tests/auto/corelib/concurrent/qtconcurrentmap/functions.h deleted file mode 100644 index ebca462676..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentmap/functions.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef FUNCTIONS_H -#define FUNCTIONS_H - -bool keepEvenIntegers(const int &x) -{ - return (x & 1) == 0; -} - -class KeepEvenIntegers -{ -public: - bool operator()(const int &x) - { - return (x & 1) == 0; - } -}; - -class Number -{ - int n; - -public: - Number() - : n(0) - { } - - Number(int n) - : n(n) - { } - - void multiplyBy2() - { - n *= 2; - } - - Number multipliedBy2() const - { - return n * 2; - } - - bool isEven() const - { - return (n & 1) == 0; - } - - int toInt() const - { - return n; - } - - QString toString() const - { - return QString::number(n); - } - - bool operator==(const Number &other) const - { - return n == other.n; - } -}; - -void intSumReduce(int &sum, int x) -{ - sum += x; -} - -class IntSumReduce -{ -public: - void operator()(int &sum, int x) - { - sum += x; - } -}; - -void numberSumReduce(int &sum, const Number &x) -{ - sum += x.toInt(); -} - -class NumberSumReduce -{ -public: - void operator()(int &sum, const Number &x) - { - sum += x.toInt(); - } -}; - -#endif diff --git a/tests/auto/corelib/concurrent/qtconcurrentmap/qtconcurrentmap.pro b/tests/auto/corelib/concurrent/qtconcurrentmap/qtconcurrentmap.pro deleted file mode 100644 index b4f5cbc565..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentmap/qtconcurrentmap.pro +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qtconcurrentmap -QT = core testlib -SOURCES = tst_qtconcurrentmap.cpp -DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/corelib/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/corelib/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp deleted file mode 100644 index df74c028d3..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ /dev/null @@ -1,2426 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtconcurrentmap.h> -#include <qtconcurrentexception.h> - -#include <qdebug.h> -#include <QThread> - -#include <QtTest/QtTest> - -#include "functions.h" - -Q_DECLARE_METATYPE(QVector<int>); -Q_DECLARE_METATYPE(QVector<double>); -Q_DECLARE_METATYPE(QVector<QString>); -Q_DECLARE_METATYPE(QList<int>); -Q_DECLARE_METATYPE(QList<double>); -Q_DECLARE_METATYPE(QList<QString>); - -class tst_QtConcurrentMap: public QObject -{ - Q_OBJECT -private slots: -#ifdef QT_NO_CONCURRENT_MAP - void initTestCase() -#else - void map(); - void blocking_map(); - void mapped(); - void blocking_mapped(); - void mappedReduced(); - void blocking_mappedReduced(); - void assignResult(); - void functionOverloads(); -#ifndef QT_NO_EXCEPTIONS - void exceptions(); -#endif - void incrementalResults(); - void noDetach(); -#ifndef QT_NO_STL - void stlContainers(); -#endif - void qFutureAssignmentLeak(); - void stressTest(); -public slots: - void throttling(); -#endif -}; - -#ifdef QT_NO_CONCURRENT_FILTER -void tst_QtConcurrentFilter::initTestCase() -{ - QSKIP("This test is skipped for gcc 3.x"); -} - -#else - -using namespace QtConcurrent; - -void multiplyBy2Immutable(int x) -{ - x *= 2; -} - -class MultiplyBy2Immutable -{ -public: - void operator()(int x) - { - x *= 2; - } -}; - -void multiplyBy2InPlace(int &x) -{ - x *= 2; -} - -class MultiplyBy2InPlace -{ -public: - void operator()(int &x) - { - x *= 2; - } -}; - -Q_DECLARE_METATYPE(QList<Number>); - -void tst_QtConcurrentMap::map() -{ - // functors take arguments by reference, modifying the sequence in place - { - QList<int> list; - list << 1 << 2 << 3; - - // functor - QtConcurrent::map(list, MultiplyBy2InPlace()).waitForFinished(); - QCOMPARE(list, QList<int>() << 2 << 4 << 6); - QtConcurrent::map(list.begin(), list.end(), MultiplyBy2InPlace()).waitForFinished(); - QCOMPARE(list, QList<int>() << 4 << 8 << 12); - - // function - QtConcurrent::map(list, multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QList<int>() << 8 << 16 << 24); - QtConcurrent::map(list.begin(), list.end(), multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QList<int>() << 16 << 32 << 48); - - // bound function - QtConcurrent::map(list, multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QList<int>() << 32 << 64 << 96); - QtConcurrent::map(list.begin(), list.end(), multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QList<int>() << 64 << 128 << 192); - - // member function - QList<Number> numberList; - numberList << 1 << 2 << 3; - QtConcurrent::map(numberList, &Number::multiplyBy2).waitForFinished(); - QCOMPARE(numberList, QList<Number>() << 2 << 4 << 6); - QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); - QCOMPARE(numberList, QList<Number>() << 4 << 8 << 12); - -#ifdef Q_COMPILER_LAMBDA - // lambda - QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); - QCOMPARE(list, QList<int>() << 128 << 256 << 384); - QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); - QCOMPARE(list, QList<int>() << 256 << 512 << 768); -#endif - - } - - // functors don't take arguments by reference, making these no-ops - { - QList<int> list; - list << 1 << 2 << 3; - - // functor - QtConcurrent::map(list, MultiplyBy2Immutable()).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::map(list.begin(), list.end(), MultiplyBy2Immutable()).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - // function - QtConcurrent::map(list, multiplyBy2Immutable).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - // bound function - QtConcurrent::map(list, multiplyBy2Immutable).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - -#ifdef Q_COMPILER_LAMBDA - // lambda - QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); -#endif - } - - // Linked lists and forward iterators - { - QLinkedList<int> list; - list << 1 << 2 << 3; - - // functor - QtConcurrent::map(list, MultiplyBy2InPlace()).waitForFinished(); - QCOMPARE(list, QLinkedList<int>() << 2 << 4 << 6); - QtConcurrent::map(list.begin(), list.end(), MultiplyBy2InPlace()).waitForFinished(); - QCOMPARE(list, QLinkedList<int>() << 4 << 8 << 12); - - // function - QtConcurrent::map(list, multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QLinkedList<int>() << 8 << 16 << 24); - QtConcurrent::map(list.begin(), list.end(), multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QLinkedList<int>() << 16 << 32 << 48); - - // bound function - QtConcurrent::map(list, multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QLinkedList<int>() << 32 << 64 << 96); - QtConcurrent::map(list.begin(), list.end(), multiplyBy2InPlace).waitForFinished(); - QCOMPARE(list, QLinkedList<int>() << 64 << 128 << 192); - - // member function - QLinkedList<Number> numberList; - numberList << 1 << 2 << 3; - QtConcurrent::map(numberList, &Number::multiplyBy2).waitForFinished(); - QCOMPARE(numberList, QLinkedList<Number>() << 2 << 4 << 6); - QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); - QCOMPARE(numberList, QLinkedList<Number>() << 4 << 8 << 12); - } - -#if 0 - // not allowed: map() with immutable sequences makes no sense - { - const QList<int> list = QList<int>() << 1 << 2 << 3; - - QtConcurrent::map(list, MultiplyBy2Immutable()); - QtConcurrent::map(list, multiplyBy2Immutable); - QtConcurrent::map(list, multiplyBy2Immutable); - } -#endif - -#if 0 - // not allowed: in place modification of a temp copy (since temp copy goes out of scope) - { - QList<int> list; - list << 1 << 2 << 3; - - QtConcurrent::map(QList<int>(list), MultiplyBy2InPlace()); - QtConcurrent::map(QList<int>(list), multiplyBy2); - QtConcurrent::map(QList<int>(list), multiplyBy2InPlace); - - QList<Number> numberList; - numberList << 1 << 2 << 3; - QtConcurrent::map(QList<Number>(numberList), &Number::multiplyBy2); - } -#endif - -#if 0 - // not allowed: map() on a const list, where functors try to modify the items in the list - { - const QList<int> list = QList<int>() << 1 << 2 << 3;; - - QtConcurrent::map(list, MultiplyBy2InPlace()); - QtConcurrent::map(list, multiplyBy2InPlace); - QtConcurrent::map(list, multiplyBy2InPlace); - - const QList<Number> numberList = QList<Number>() << 1 << 2 << 3; - QtConcurrent::map(numberList, &Number::multiplyBy2); - } -#endif -} - -void tst_QtConcurrentMap::blocking_map() -{ - // functors take arguments by reference, modifying the sequence in place - { - QList<int> list; - list << 1 << 2 << 3; - - // functor - QtConcurrent::blockingMap(list, MultiplyBy2InPlace()); - QCOMPARE(list, QList<int>() << 2 << 4 << 6); - QtConcurrent::blockingMap(list.begin(), list.end(), MultiplyBy2InPlace()); - QCOMPARE(list, QList<int>() << 4 << 8 << 12); - - // function - QtConcurrent::blockingMap(list, multiplyBy2InPlace); - QCOMPARE(list, QList<int>() << 8 << 16 << 24); - QtConcurrent::blockingMap(list.begin(), list.end(), multiplyBy2InPlace); - QCOMPARE(list, QList<int>() << 16 << 32 << 48); - - // bound function - QtConcurrent::blockingMap(list, multiplyBy2InPlace); - QCOMPARE(list, QList<int>() << 32 << 64 << 96); - QtConcurrent::blockingMap(list.begin(), list.end(), multiplyBy2InPlace); - QCOMPARE(list, QList<int>() << 64 << 128 << 192); - - // member function - QList<Number> numberList; - numberList << 1 << 2 << 3; - QtConcurrent::blockingMap(numberList, &Number::multiplyBy2); - QCOMPARE(numberList, QList<Number>() << 2 << 4 << 6); - QtConcurrent::blockingMap(numberList.begin(), numberList.end(), &Number::multiplyBy2); - QCOMPARE(numberList, QList<Number>() << 4 << 8 << 12); - } - - // functors don't take arguments by reference, making these no-ops - { - QList<int> list; - list << 1 << 2 << 3; - - // functor - QtConcurrent::blockingMap(list, MultiplyBy2Immutable()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::blockingMap(list.begin(), list.end(), MultiplyBy2Immutable()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - // function - QtConcurrent::blockingMap(list, multiplyBy2Immutable); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::blockingMap(list.begin(), list.end(), multiplyBy2Immutable); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - // bound function - QtConcurrent::blockingMap(list, multiplyBy2Immutable); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QtConcurrent::blockingMap(list.begin(), list.end(), multiplyBy2Immutable); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - } - - // Linked lists and forward iterators - { - QLinkedList<int> list; - list << 1 << 2 << 3; - - // functor - QtConcurrent::blockingMap(list, MultiplyBy2InPlace()); - QCOMPARE(list, QLinkedList<int>() << 2 << 4 << 6); - QtConcurrent::blockingMap(list.begin(), list.end(), MultiplyBy2InPlace()); - QCOMPARE(list, QLinkedList<int>() << 4 << 8 << 12); - - // function - QtConcurrent::blockingMap(list, multiplyBy2InPlace); - QCOMPARE(list, QLinkedList<int>() << 8 << 16 << 24); - QtConcurrent::blockingMap(list.begin(), list.end(), multiplyBy2InPlace); - QCOMPARE(list, QLinkedList<int>() << 16 << 32 << 48); - - // bound function - QtConcurrent::blockingMap(list, multiplyBy2InPlace); - QCOMPARE(list, QLinkedList<int>() << 32 << 64 << 96); - QtConcurrent::blockingMap(list.begin(), list.end(), multiplyBy2InPlace); - QCOMPARE(list, QLinkedList<int>() << 64 << 128 << 192); - - // member function - QLinkedList<Number> numberList; - numberList << 1 << 2 << 3; - QtConcurrent::blockingMap(numberList, &Number::multiplyBy2); - QCOMPARE(numberList, QLinkedList<Number>() << 2 << 4 << 6); - QtConcurrent::blockingMap(numberList.begin(), numberList.end(), &Number::multiplyBy2); - QCOMPARE(numberList, QLinkedList<Number>() << 4 << 8 << 12); - } - -#if 0 - // not allowed: map() with immutable sequences makes no sense - { - const QList<int> list = QList<int>() << 1 << 2 << 3; - - QtConcurrent::blockingMap(list, MultiplyBy2Immutable()); - QtConcurrent::blockkng::map(list, multiplyBy2Immutable); - QtConcurrent::blockingMap(list, multiplyBy2Immutable); - } -#endif - -#if 0 - // not allowed: in place modification of a temp copy (since temp copy goes out of scope) - { - QList<int> list; - list << 1 << 2 << 3; - - QtConcurrent::blockingMap(QList<int>(list), MultiplyBy2InPlace()); - QtConcurrent::blockingMap(QList<int>(list), multiplyBy2); - QtConcurrent::blockingMap(QList<int>(list), multiplyBy2InPlace); - - QList<Number> numberList; - numberList << 1 << 2 << 3; - QtConcurrent::blockingMap(QList<Number>(numberList), &Number::multiplyBy2); - } -#endif - -#if 0 - // not allowed: map() on a const list, where functors try to modify the items in the list - { - const QList<int> list = QList<int>() << 1 << 2 << 3;; - - QtConcurrent::blockingMap(list, MultiplyBy2InPlace()); - QtConcurrent::blockingMap(list, multiplyBy2InPlace); - QtConcurrent::blockingMap(list, multiplyBy2InPlace); - - const QList<Number> numberList = QList<Number>() << 1 << 2 << 3; - QtConcurrent::blockingMap(numberList, &Number::multiplyBy2); - } -#endif -} - -int multiplyBy2(int x) -{ - int y = x * 2; - return y; -} - -class MultiplyBy2 -{ -public: - typedef int result_type; - - int operator()(int x) const - { - int y = x * 2; - return y; - } -}; - -double intToDouble(int x) -{ - return double(x); -} - -class IntToDouble -{ -public: - typedef double result_type; - - double operator()(int x) const - { - return double(x); - } -}; - -int stringToInt(const QString &string) -{ - return string.toInt(); -} - -class StringToInt -{ -public: - typedef int result_type; - - int operator()(const QString &string) const - { - return string.toInt(); - } -}; - -void tst_QtConcurrentMap::mapped() -{ - QList<int> list; - list << 1 << 2 << 3; - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3; - QList<Number> numberList; - numberList << 1 << 2 << 3; - QLinkedList<Number> numberLinkedList; - numberLinkedList << 1 << 2 << 3; - - // functor - { - QList<int> list2 = QtConcurrent::mapped(list, MultiplyBy2()).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::mapped(list.constBegin(), - list.constEnd(), - MultiplyBy2()).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::mapped(QList<int>(list), MultiplyBy2()).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - { - QList<int> list2 = QtConcurrent::mapped(linkedList, MultiplyBy2()).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - MultiplyBy2()).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = - QtConcurrent::mapped(QLinkedList<int>(linkedList), MultiplyBy2()).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - - // function - { - QList<int> list2 = QtConcurrent::mapped(list, multiplyBy2).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::mapped(list.constBegin(), - list.constEnd(), - multiplyBy2).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::mapped(QList<int>(list), multiplyBy2).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - { - QList<int> list2 = QtConcurrent::mapped(linkedList, multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = - QtConcurrent::mapped(QLinkedList<int>(linkedList), multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - - // bound function - { - QList<int> list2 = QtConcurrent::mapped(list, multiplyBy2).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::mapped(list.constBegin(), - list.constEnd(), - multiplyBy2).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::mapped(QList<int>(list), multiplyBy2).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - { - QList<int> list2 = QtConcurrent::mapped(linkedList, multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::mapped(QLinkedList<int>(linkedList), multiplyBy2) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - - // const member function - { - QList<Number> numberList2 = QtConcurrent::mapped(numberList, &Number::multipliedBy2) - .results(); - QCOMPARE(numberList, QList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList2, QList<Number>() << 2 << 4 << 6); - - QList<Number> numberList3 = QtConcurrent::mapped(numberList.constBegin(), - numberList.constEnd(), - &Number::multipliedBy2) - .results(); - QCOMPARE(numberList, QList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList3, QList<Number>() << 2 << 4 << 6); - - QList<Number> numberList4 = QtConcurrent::mapped(QList<Number>(numberList), - &Number::multipliedBy2) - .results(); - QCOMPARE(numberList, QList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList4, QList<Number>() << 2 << 4 << 6); - } - { - QList<Number> numberList2 = QtConcurrent::mapped(numberLinkedList, &Number::multipliedBy2) - .results(); - QCOMPARE(numberLinkedList, QLinkedList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList2, QList<Number>() << 2 << 4 << 6); - - QList<Number> numberList3 = QtConcurrent::mapped(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::multipliedBy2) - .results(); - QCOMPARE(numberLinkedList, QLinkedList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList3, QList<Number>() << 2 << 4 << 6); - - QList<Number> numberList4 = QtConcurrent::mapped(QLinkedList<Number>(numberLinkedList), - &Number::multipliedBy2) - .results(); - QCOMPARE(numberLinkedList, QLinkedList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList4, QList<Number>() << 2 << 4 << 6); - } - - // change the value_type, same container - - // functor - { - QList<double> list2 = QtConcurrent::mapped(list, IntToDouble()).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::mapped(list.constBegin(), - list.constEnd(), - IntToDouble()) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list4 = QtConcurrent::mapped(QList<int>(list), - IntToDouble()) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - { - QList<double> list2 = QtConcurrent::mapped(linkedList, IntToDouble()).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - IntToDouble()) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list4 = QtConcurrent::mapped(QLinkedList<int>(linkedList), - IntToDouble()) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - - // function - { - QList<double> list2 = QtConcurrent::mapped(list, intToDouble).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::mapped(list.constBegin(), - list.constEnd(), - intToDouble) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list4 = QtConcurrent::mapped(QList<int>(list), intToDouble).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - { - QList<double> list2 = QtConcurrent::mapped(linkedList, intToDouble).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list4 = QtConcurrent::mapped(QLinkedList<int>(linkedList), intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - - // bound function - { - QList<double> list2 = QtConcurrent::mapped(list, intToDouble).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::mapped(list.constBegin(), - list.constEnd(), - intToDouble) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - - QList<double> list4 = QtConcurrent::mapped(QList<int>(list), - intToDouble) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - { - QList<double> list2 = QtConcurrent::mapped(linkedList, intToDouble).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - - QList<double> list4 = QtConcurrent::mapped(QLinkedList<int>(linkedList), - intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - - // const member function - { - QList<QString> list2 = QtConcurrent::mapped(numberList, &Number::toString).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<QString>() << "1" << "2" << "3"); - - QList<QString> list3 = QtConcurrent::mapped(numberList.constBegin(), - numberList.constEnd(), - &Number::toString) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<QString>() << "1" << "2" << "3"); - - QList<QString> list4 = QtConcurrent::mapped(QList<Number>(numberList), &Number::toString) - .results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<QString>() << "1" << "2" << "3"); - } - { - QList<QString> list2 = QtConcurrent::mapped(numberLinkedList, &Number::toString).results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<QString>() << "1" << "2" << "3"); - - QList<QString> list3 = QtConcurrent::mapped(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toString) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<QString>() << "1" << "2" << "3"); - - QList<QString> list4 = QtConcurrent::mapped(QLinkedList<Number>(numberLinkedList), - &Number::toString) - .results(); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<QString>() << "1" << "2" << "3"); - } - - // change the value_type - { - QList<QString> strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::mapped(strings, StringToInt()).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::mapped(strings.constBegin(), - strings.constEnd(), - StringToInt()) - .results(); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - { - QList<QString> strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::mapped(strings, stringToInt).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::mapped(strings.constBegin(), - strings.constEnd(), - stringToInt).results(); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - - { - QList<int> numberList2 = QtConcurrent::mapped(numberList, &Number::toInt).results(); - QCOMPARE(numberList2, QList<int>() << 1 << 2 << 3); - - QList<int> numberList3 = QtConcurrent::mapped(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt) - .results(); - QCOMPARE(numberList3, QList<int>() << 1 << 2 << 3); - } - - // change the value_type from QStringList - { - QStringList strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::mapped(strings, StringToInt()).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::mapped(strings.constBegin(), - strings.constEnd(), - StringToInt()) - .results(); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - { - QStringList strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::mapped(strings, stringToInt).results(); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::mapped(strings.constBegin(), - strings.constEnd(), - stringToInt) - .results(); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } -} - -void tst_QtConcurrentMap::blocking_mapped() -{ - QList<int> list; - list << 1 << 2 << 3; - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3; - QList<Number> numberList; - numberList << 1 << 2 << 3; - QLinkedList<Number> numberLinkedList; - numberLinkedList << 1 << 2 << 3; - - // functor - { - QList<int> list2 = QtConcurrent::blockingMapped(list, MultiplyBy2()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::blockingMapped<QList<int> >(list.constBegin(), - list.constEnd(), - MultiplyBy2()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::blockingMapped(QList<int>(list), MultiplyBy2()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingMapped(linkedList, MultiplyBy2()); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4 << 6); - - QLinkedList<int> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<int> >(linkedList.constBegin(), - linkedList.constEnd(), - MultiplyBy2()); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 2 << 4 << 6); - - QLinkedList<int> linkedList4 = QtConcurrent::blockingMapped(QLinkedList<int>(linkedList), MultiplyBy2()); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 2 << 4 << 6); - } - - // function - { - QList<int> list2 = QtConcurrent::blockingMapped(list, multiplyBy2); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::blockingMapped<QList<int> >(list.constBegin(), - list.constEnd(), - multiplyBy2); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::blockingMapped(QList<int>(list), multiplyBy2); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingMapped(linkedList, multiplyBy2); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4 << 6); - - QLinkedList<int> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<int> >(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 2 << 4 << 6); - - QLinkedList<int> linkedList4 = QtConcurrent::blockingMapped(QLinkedList<int>(linkedList), multiplyBy2); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 2 << 4 << 6); - } - - // bound function - { - QList<int> list2 = QtConcurrent::blockingMapped(list, multiplyBy2); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 2 << 4 << 6); - - QList<int> list3 = QtConcurrent::blockingMapped<QList<int> >(list.constBegin(), - list.constEnd(), - multiplyBy2); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 2 << 4 << 6); - - QList<int> list4 = QtConcurrent::blockingMapped(QList<int>(list), multiplyBy2); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 2 << 4 << 6); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingMapped(linkedList, multiplyBy2); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 2 << 4 << 6); - - QLinkedList<int> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<int> >(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 2 << 4 << 6); - - QLinkedList<int> linkedList4 = QtConcurrent::blockingMapped(QLinkedList<int>(linkedList), multiplyBy2); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 2 << 4 << 6); - } - - // const member function - { - QList<Number> numberList2 = QtConcurrent::blockingMapped(numberList, &Number::multipliedBy2); - QCOMPARE(numberList, QList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList2, QList<Number>() << 2 << 4 << 6); - - QList<Number> numberList3 = QtConcurrent::blockingMapped<QList<Number> >(numberList.constBegin(), - numberList.constEnd(), - &Number::multipliedBy2); - QCOMPARE(numberList, QList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList3, QList<Number>() << 2 << 4 << 6); - - QList<Number> numberList4 = QtConcurrent::blockingMapped(QList<Number>(numberList), - &Number::multipliedBy2); - QCOMPARE(numberList, QList<Number>() << 1 << 2 << 3); - QCOMPARE(numberList4, QList<Number>() << 2 << 4 << 6); - } - { - QLinkedList<Number> numberLinkedList2 = QtConcurrent::blockingMapped(numberLinkedList, &Number::multipliedBy2); - QCOMPARE(numberLinkedList, QLinkedList<Number>() << 1 << 2 << 3); - QCOMPARE(numberLinkedList2, QLinkedList<Number>() << 2 << 4 << 6); - - QLinkedList<Number> numberLinkedList3 = QtConcurrent::blockingMapped<QLinkedList<Number> >(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::multipliedBy2); - QCOMPARE(numberLinkedList, QLinkedList<Number>() << 1 << 2 << 3); - QCOMPARE(numberLinkedList3, QLinkedList<Number>() << 2 << 4 << 6); - - QLinkedList<Number> numberLinkedList4 = QtConcurrent::blockingMapped(QLinkedList<Number>(numberLinkedList), - &Number::multipliedBy2); - QCOMPARE(numberLinkedList, QLinkedList<Number>() << 1 << 2 << 3); - QCOMPARE(numberLinkedList4, QLinkedList<Number>() << 2 << 4 << 6); - } - - // change the value_type, same container - - // functor - { - QList<double> list2 = QtConcurrent::blockingMapped<QList<double> >(list, IntToDouble()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::blockingMapped<QList<double> >(list.constBegin(), - list.constEnd(), - IntToDouble()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list4 = QtConcurrent::blockingMapped<QList<double> >(QList<int>(list), - IntToDouble()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - { - QLinkedList<double> linkedList2 = QtConcurrent::blockingMapped<QLinkedList<double> >(linkedList, IntToDouble()); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - - QLinkedList<double> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<double> >(linkedList.constBegin(), - linkedList.constEnd(), - IntToDouble()); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - - QLinkedList<double> linkedList4 = QtConcurrent::blockingMapped<QLinkedList<double> >(QLinkedList<int>(linkedList), - IntToDouble()); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - } - - // function - { - QList<double> list2 = QtConcurrent::blockingMapped<QList<double> >(list, intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::blockingMapped<QList<double> >(list.constBegin(), - list.constEnd(), - intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list4 = QtConcurrent::blockingMapped<QList<double> >(QList<int>(list), intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - { - QLinkedList<double> linkedList2 = QtConcurrent::blockingMapped<QLinkedList<double> >(linkedList, intToDouble); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - - QLinkedList<double> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<double> >(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - - QLinkedList<double> linkedList4 = QtConcurrent::blockingMapped<QLinkedList<double> >(QLinkedList<int>(linkedList), intToDouble); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - } - - // bound function - { - QList<double> list2 = QtConcurrent::blockingMapped<QList<double> >(list, intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<double>() << 1.0 << 2.0 << 3.0); - - QList<double> list3 = QtConcurrent::blockingMapped<QList<double> >(list.constBegin(), - list.constEnd(), - intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<double>() << 1.0 << 2.0 << 3.0); - - - QList<double> list4 = QtConcurrent::blockingMapped<QList<double> >(QList<int>(list), - intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<double>() << 1.0 << 2.0 << 3.0); - } - { - QLinkedList<double> linkedList2 = QtConcurrent::blockingMapped<QLinkedList<double> >(linkedList, intToDouble); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - - QLinkedList<double> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<double> >(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - - - QLinkedList<double> linkedList4 = QtConcurrent::blockingMapped<QLinkedList<double> >(QLinkedList<int>(linkedList), - intToDouble); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<double>() << 1.0 << 2.0 << 3.0); - } - - // const member function - { - QList<QString> list2 = - QtConcurrent::blockingMapped<QList<QString> >(numberList, &Number::toString); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<QString>() << "1" << "2" << "3"); - - QList<QString> list3 = QtConcurrent::blockingMapped<QList<QString> >(numberList.constBegin(), - numberList.constEnd() - , &Number::toString); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<QString>() << "1" << "2" << "3"); - - QList<QString> list4 = - QtConcurrent::blockingMapped<QList<QString> >(QList<Number>(numberList), &Number::toString); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<QString>() << "1" << "2" << "3"); - } - { - QLinkedList<QString> linkedList2 = - QtConcurrent::blockingMapped<QLinkedList<QString> >(numberLinkedList, &Number::toString); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<QString>() << "1" << "2" << "3"); - - QLinkedList<QString> linkedList3 = QtConcurrent::blockingMapped<QLinkedList<QString> >(numberLinkedList.constBegin(), - numberLinkedList.constEnd() - , &Number::toString); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<QString>() << "1" << "2" << "3"); - - QLinkedList<QString> linkedList4 = - QtConcurrent::blockingMapped<QLinkedList<QString> >(QLinkedList<Number>(numberLinkedList), &Number::toString); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<QString>() << "1" << "2" << "3"); - } - - // change the value_type - { - QList<QString> strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::blockingMapped(strings, StringToInt()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::blockingMapped<QList<int> >(strings.constBegin(), - strings.constEnd(), - StringToInt()); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - { - QList<QString> strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::blockingMapped(strings, stringToInt); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::blockingMapped<QList<int> >(strings.constBegin(), - strings.constEnd(), - stringToInt); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - - { - QList<int> numberList2 = QtConcurrent::blockingMapped(numberList, &Number::toInt); - QCOMPARE(numberList2, QList<int>() << 1 << 2 << 3); - - QList<int> numberList3 = QtConcurrent::blockingMapped<QList<int> >(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt); - QCOMPARE(numberList3, QList<int>() << 1 << 2 << 3); - } - - // change the value_type from QStringList - { - QStringList strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::blockingMapped(strings, StringToInt()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::blockingMapped<QList<int> >(strings.constBegin(), - strings.constEnd(), - StringToInt()); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - { - QStringList strings = QStringList() << "1" << "2" << "3"; - QList<int> list = QtConcurrent::blockingMapped(strings, stringToInt); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - - QList<int> list2 = QtConcurrent::blockingMapped<QList<int> >(strings.constBegin(), - strings.constEnd(), - stringToInt); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - } - - // functor - { - QVector<double> list2 = QtConcurrent::blockingMapped<QVector<double> >(list, IntToDouble()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QVector<double>() << 1.0 << 2.0 << 3.0); - - QVector<double> list3 = QtConcurrent::blockingMapped<QVector<double> >(list.constBegin(), - list.constEnd(), - IntToDouble()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QVector<double>() << 1.0 << 2.0 << 3.0); - - QVector<double> list4 = QtConcurrent::blockingMapped<QVector<double> >(QList<int>(list), - IntToDouble()); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QVector<double>() << 1.0 << 2.0 << 3.0); - - QStringList strings = QStringList() << "1" << "2" << "3"; - QVector<int> list5 = QtConcurrent::blockingMapped<QVector<int> >(strings, StringToInt()); - QCOMPARE(list5, QVector<int>() << 1 << 2 << 3); - - QVector<int> list6 = QtConcurrent::blockingMapped<QVector<int> >(strings.constBegin(), - strings.constEnd(), - StringToInt()); - QCOMPARE(list6, QVector<int>() << 1 << 2 << 3); - - QVector<int> list7 = QtConcurrent::blockingMapped<QVector<int> >(QStringList(strings), - StringToInt()); - QCOMPARE(list7, QVector<int>() << 1 << 2 << 3); - } - - // function - { - QVector<double> list2 = QtConcurrent::blockingMapped<QVector<double> >(list, intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QVector<double>() << 1.0 << 2.0 << 3.0); - - QVector<double> list3 = QtConcurrent::blockingMapped<QVector<double> >(list.constBegin(), - list.constEnd(), - intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QVector<double>() << 1.0 << 2.0 << 3.0); - - QVector<double> list4 = QtConcurrent::blockingMapped<QVector<double> >(QList<int>(list), - intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QVector<double>() << 1.0 << 2.0 << 3.0); - - QStringList strings = QStringList() << "1" << "2" << "3"; - QVector<int> list5 = QtConcurrent::blockingMapped<QVector<int> >(strings, stringToInt); - QCOMPARE(list5, QVector<int>() << 1 << 2 << 3); - - QVector<int> list6 = QtConcurrent::blockingMapped<QVector<int> >(strings.constBegin(), - strings.constEnd(), - stringToInt); - QCOMPARE(list6, QVector<int>() << 1 << 2 << 3); - - QVector<int> list7 = QtConcurrent::blockingMapped<QVector<int> >(QStringList(strings), - stringToInt); - QCOMPARE(list7, QVector<int>() << 1 << 2 << 3); - } - - // bound function - { - QVector<double> list2 = QtConcurrent::blockingMapped<QVector<double> >(list, intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QVector<double>() << 1.0 << 2.0 << 3.0); - - QVector<double> list3 = QtConcurrent::blockingMapped<QVector<double> >(QList<int>(list), intToDouble); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QVector<double>() << 1.0 << 2.0 << 3.0); - - QStringList strings = QStringList() << "1" << "2" << "3"; - QVector<int> list4 = QtConcurrent::blockingMapped<QVector<int> >(strings, stringToInt); - QCOMPARE(list4, QVector<int>() << 1 << 2 << 3); - - QVector<int> list5 = QtConcurrent::blockingMapped<QVector<int> >(QStringList(strings), stringToInt); - QCOMPARE(list5, QVector<int>() << 1 << 2 << 3); - } - - // const member function - { - QVector<QString> list2 = QtConcurrent::blockingMapped<QVector<QString> >(numberList, &Number::toString); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QVector<QString>() << "1" << "2" << "3"); - - QVector<QString> list3 = - QtConcurrent::blockingMapped<QVector<QString> >(QList<Number>(numberList), &Number::toString); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QVector<QString>() << "1" << "2" << "3"); - - // not allowed: const member function where all arguments have default values -#if 0 - QStringList strings = QStringList() << "1" << "2" << "3"; - QVector<int> list4 = QtConcurrent::blockingMapped<QVector<int> >(strings, &QString::toInt); - QCOMPARE(list4, QVector<int>() << 1 << 2 << 3); - - QVector<int> list5 = QtConcurrent::blockingMapped<QVector<int> >(QStringList(strings), &QString::toInt); - QCOMPARE(list5, QVector<int>() << 1 << 2 << 3); -#endif - } -} - -int intSquare(int x) -{ - return x * x; -} - -class IntSquare -{ -public: - typedef int result_type; - - int operator()(int x) - { - return x * x; - } -}; - -void tst_QtConcurrentMap::mappedReduced() -{ - QList<int> list; - list << 1 << 2 << 3; - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3; - QList<Number> numberList; - numberList << 1 << 2 << 3; - QLinkedList<Number> numberLinkedList; - numberLinkedList << 1 << 2 << 3; - - // test Q_DECLARE_OPERATORS_FOR_FLAGS - QtConcurrent::ReduceOptions opt = (QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce); - QVERIFY(opt); - - // functor-functor - { - int sum = QtConcurrent::mappedReduced<int>(list, IntSquare(), IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced<int>(list.constBegin(), - list.constEnd(), - IntSquare(), - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced<int>(QList<int>(list), IntSquare(), IntSumReduce()); - QCOMPARE(sum3, 14); - - int sum4 = QtConcurrent::mappedReduced<int>(list, intSquare, intSumReduce); - QCOMPARE(sum4, 14); - int sum5 = QtConcurrent::mappedReduced<int>(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum5, 14); - - int sum6 = QtConcurrent::mappedReduced<int>(QList<int>(list), - intSquare, - intSumReduce); - QCOMPARE(sum6, 14); - } - { - int sum = QtConcurrent::mappedReduced<int>(linkedList, IntSquare(), IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - IntSquare(), - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced<int>(QLinkedList<int>(linkedList), IntSquare(), IntSumReduce()); - QCOMPARE(sum3, 14); - - int sum4 = QtConcurrent::mappedReduced<int>(linkedList, intSquare, intSumReduce); - QCOMPARE(sum4, 14); - int sum5 = QtConcurrent::mappedReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum5, 14); - - int sum6 = QtConcurrent::mappedReduced<int>(QLinkedList<int>(linkedList), - intSquare, - intSumReduce); - QCOMPARE(sum6, 14); - } - - // function-functor - { - int sum = QtConcurrent::mappedReduced<int>(list, intSquare, IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced<int>(list.constBegin(), - list.constEnd(), - intSquare, - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced<int>(QList<int>(list), intSquare, IntSumReduce()); - QCOMPARE(sum3, 14); - } - { - int sum = QtConcurrent::mappedReduced<int>(linkedList, intSquare, IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced<int>(QLinkedList<int>(linkedList), intSquare, IntSumReduce()); - QCOMPARE(sum3, 14); - } - - // functor-function - { - int sum = QtConcurrent::mappedReduced(list, IntSquare(), intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QList<int>(list), IntSquare(), intSumReduce); - QCOMPARE(sum3, 14); - } - { - int sum = QtConcurrent::mappedReduced(linkedList, IntSquare(), intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - IntSquare(), - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QLinkedList<int>(linkedList), IntSquare(), intSumReduce); - QCOMPARE(sum3, 14); - } - - // function-function - { - int sum = QtConcurrent::mappedReduced(list, intSquare, intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QList<int>(list), intSquare, intSumReduce); - QCOMPARE(sum3, 14); - } - { - int sum = QtConcurrent::mappedReduced(linkedList, intSquare, intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QLinkedList<int>(linkedList), intSquare, intSumReduce); - QCOMPARE(sum3, 14); - } - - // functor-member - { - QList<int> list2 = QtConcurrent::mappedReduced(list, - IntSquare(), - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 1 << 4 << 9); - - QList<int> list3 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 1 << 4 << 9); - - QList<int> list4 = QtConcurrent::mappedReduced(QList<int>(list), - IntSquare(), - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 1 << 4 << 9); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::mappedReduced(linkedList, - IntSquare(), - &QLinkedList<int>::push_back, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList3 = QtConcurrent::mappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - IntSquare(), - &QLinkedList<int>::push_back, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList4 = QtConcurrent::mappedReduced(QLinkedList<int>(linkedList), - IntSquare(), - &QLinkedList<int>::push_back, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 1 << 4 << 9); - } - - // member-functor - { - int sum = QtConcurrent::mappedReduced<int>(numberList, &Number::toInt, IntSumReduce()); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::mappedReduced<int>(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::mappedReduced<int>(QList<Number>(numberList), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum3, 6); - } - { - int sum = QtConcurrent::mappedReduced<int>(numberLinkedList, &Number::toInt, IntSumReduce()); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::mappedReduced<int>(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::mappedReduced<int>(QLinkedList<Number>(numberLinkedList), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum3, 6); - } - - // member-member - { - QList<int> list2 = QtConcurrent::mappedReduced(numberList, - &Number::toInt, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - - QList<int> list3 = QtConcurrent::mappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list3, QList<int>() << 1 << 2 << 3); - - QList<int> list4 = QtConcurrent::mappedReduced(QList<Number>(numberList), - &Number::toInt, - &QList<int>::push_back, OrderedReduce); - QCOMPARE(list4, QList<int>() << 1 << 2 << 3); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::mappedReduced(numberLinkedList, - &Number::toInt, - &QLinkedList<int>::push_back, - OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 1 << 2 << 3); - - QLinkedList<int> linkedList3 = QtConcurrent::mappedReduced(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toInt, - &QLinkedList<int>::push_back, - OrderedReduce); - QCOMPARE(linkedList3, QLinkedList<int>() << 1 << 2 << 3); - - QLinkedList<int> linkedList4 = QtConcurrent::mappedReduced(QLinkedList<Number>(numberLinkedList), - &Number::toInt, - &QLinkedList<int>::push_back, OrderedReduce); - QCOMPARE(linkedList4, QLinkedList<int>() << 1 << 2 << 3); - } - - // function-member - { - QList<int> list2 = QtConcurrent::mappedReduced(list, - intSquare, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 1 << 4 << 9); - - QList<int> list3 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 1 << 4 << 9); - - QList<int> list4 = QtConcurrent::mappedReduced(QList<int>(list), - intSquare, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 1 << 4 << 9); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::mappedReduced(linkedList, - intSquare, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList3 = QtConcurrent::mappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList4 = QtConcurrent::mappedReduced(QLinkedList<int>(linkedList), - intSquare, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 1 << 4 << 9); - } - - // member-function - { - int sum = QtConcurrent::mappedReduced(numberList, - &Number::toInt, - intSumReduce); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::mappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - intSumReduce); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::mappedReduced(QList<Number>(numberList), - &Number::toInt, - intSumReduce); - QCOMPARE(sum3, 6); - } - { - int sum = QtConcurrent::mappedReduced(numberLinkedList, - &Number::toInt, - intSumReduce); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::mappedReduced(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toInt, - intSumReduce); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::mappedReduced(QLinkedList<Number>(numberLinkedList), - &Number::toInt, - intSumReduce); - QCOMPARE(sum3, 6); - } - - // linked lists - { - - QLinkedList<int> list; - list << 1 << 2 << 3; - - QLinkedList<Number> numberList; - numberList << 1 << 2 << 3; - - int sum = QtConcurrent::mappedReduced<int>(list, IntSquare(), IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced<int>(list.constBegin(), - list.constEnd(), - IntSquare(), - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced<int>(QLinkedList<int>(list), IntSquare(), IntSumReduce()); - QCOMPARE(sum3, 14); - - int sum4 = QtConcurrent::mappedReduced<int>(list, intSquare, intSumReduce); - QCOMPARE(sum4, 14); - int sum5 = QtConcurrent::mappedReduced<int>(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum5, 14); - - int sum6 = QtConcurrent::mappedReduced<int>(QLinkedList<int>(list), - intSquare, - intSumReduce); - QCOMPARE(sum6, 14); - } - - // ### the same as above, with an initial result value -} - -void tst_QtConcurrentMap::blocking_mappedReduced() -{ - QList<int> list; - list << 1 << 2 << 3; - QLinkedList<int> linkedList; - linkedList << 1 << 2 << 3; - QList<Number> numberList; - numberList << 1 << 2 << 3; - QLinkedList<Number> numberLinkedList; - numberLinkedList << 1 << 2 << 3; - - // functor-functor - { - int sum = QtConcurrent::blockingMappedReduced<int>(list, IntSquare(), IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced<int>(list.constBegin(), - list.constEnd(), - IntSquare(), - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QList<int>(list), IntSquare(), IntSumReduce()); - QCOMPARE(sum3, 14); - - int sum4 = QtConcurrent::blockingMappedReduced<int>(list, intSquare, intSumReduce); - QCOMPARE(sum4, 14); - int sum5 = QtConcurrent::blockingMappedReduced<int>(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum5, 14); - - int sum6 = QtConcurrent::blockingMappedReduced<int>(QList<int>(list), - intSquare, - intSumReduce); - QCOMPARE(sum6, 14); - } - { - int sum = QtConcurrent::blockingMappedReduced<int>(linkedList, IntSquare(), IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - IntSquare(), - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QLinkedList<int>(linkedList), IntSquare(), IntSumReduce()); - QCOMPARE(sum3, 14); - - int sum4 = QtConcurrent::blockingMappedReduced<int>(linkedList, intSquare, intSumReduce); - QCOMPARE(sum4, 14); - int sum5 = QtConcurrent::blockingMappedReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum5, 14); - - int sum6 = QtConcurrent::blockingMappedReduced<int>(QLinkedList<int>(linkedList), - intSquare, - intSumReduce); - QCOMPARE(sum6, 14); - } - - // function-functor - { - int sum = QtConcurrent::blockingMappedReduced<int>(list, intSquare, IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced<int>(list.constBegin(), - list.constEnd(), - intSquare, - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QList<int>(list), intSquare, IntSumReduce()); - QCOMPARE(sum3, 14); - } - { - int sum = QtConcurrent::blockingMappedReduced<int>(linkedList, intSquare, IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced<int>(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QLinkedList<int>(linkedList), intSquare, IntSumReduce()); - QCOMPARE(sum3, 14); - } - - // functor-function - { - int sum = QtConcurrent::blockingMappedReduced(list, IntSquare(), intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QList<int>(list), IntSquare(), intSumReduce); - QCOMPARE(sum3, 14); - } - { - int sum = QtConcurrent::blockingMappedReduced(linkedList, IntSquare(), intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - IntSquare(), - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QLinkedList<int>(linkedList), IntSquare(), intSumReduce); - QCOMPARE(sum3, 14); - } - - // function-function - { - int sum = QtConcurrent::blockingMappedReduced(list, intSquare, intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QList<int>(list), intSquare, intSumReduce); - QCOMPARE(sum3, 14); - } - { - int sum = QtConcurrent::blockingMappedReduced(linkedList, intSquare, intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QLinkedList<int>(linkedList), intSquare, intSumReduce); - QCOMPARE(sum3, 14); - } - - // functor-member - { - QList<int> list2 = QtConcurrent::blockingMappedReduced(list, - IntSquare(), - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 1 << 4 << 9); - - QList<int> list3 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 1 << 4 << 9); - - QList<int> list4 = QtConcurrent::blockingMappedReduced(QList<int>(list), - IntSquare(), - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 1 << 4 << 9); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingMappedReduced(linkedList, - IntSquare(), - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList3 = QtConcurrent::blockingMappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - IntSquare(), - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList4 = QtConcurrent::blockingMappedReduced(QLinkedList<int>(linkedList), - IntSquare(), - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 1 << 4 << 9); - } - - // member-functor - { - int sum = QtConcurrent::blockingMappedReduced<int>(numberList, &Number::toInt, - IntSumReduce()); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::blockingMappedReduced<int>(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QList<Number>(numberList), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum3, 6); - } - { - int sum = QtConcurrent::blockingMappedReduced<int>(numberLinkedList, &Number::toInt, IntSumReduce()); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::blockingMappedReduced<int>(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QLinkedList<Number>(numberLinkedList), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum3, 6); - } - - // member-member - { - QList<int> list2 = QtConcurrent::blockingMappedReduced(numberList, - &Number::toInt, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list2, QList<int>() << 1 << 2 << 3); - - QList<int> list3 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list3, QList<int>() << 1 << 2 << 3); - - QList<int> list4 = QtConcurrent::blockingMappedReduced(QList<Number>(numberList), - &Number::toInt, - &QList<int>::push_back, OrderedReduce); - QCOMPARE(list4, QList<int>() << 1 << 2 << 3); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingMappedReduced(numberLinkedList, - &Number::toInt, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList2, QLinkedList<int>() << 1 << 2 << 3); - - QLinkedList<int> linkedList3 = QtConcurrent::blockingMappedReduced(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toInt, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList3, QLinkedList<int>() << 1 << 2 << 3); - - QLinkedList<int> linkedList4 = QtConcurrent::blockingMappedReduced(QLinkedList<Number>(numberLinkedList), - &Number::toInt, - &QLinkedList<int>::append, OrderedReduce); - QCOMPARE(linkedList4, QLinkedList<int>() << 1 << 2 << 3); - } - - // function-member - { - QList<int> list2 = QtConcurrent::blockingMappedReduced(list, - intSquare, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list2, QList<int>() << 1 << 4 << 9); - - QList<int> list3 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list3, QList<int>() << 1 << 4 << 9); - - QList<int> list4 = QtConcurrent::blockingMappedReduced(QList<int>(list), - intSquare, - &QList<int>::push_back, - OrderedReduce); - QCOMPARE(list, QList<int>() << 1 << 2 << 3); - QCOMPARE(list4, QList<int>() << 1 << 4 << 9); - } - { - QLinkedList<int> linkedList2 = QtConcurrent::blockingMappedReduced(linkedList, - intSquare, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList3 = QtConcurrent::blockingMappedReduced(linkedList.constBegin(), - linkedList.constEnd(), - intSquare, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList<int>() << 1 << 4 << 9); - - QLinkedList<int> linkedList4 = QtConcurrent::blockingMappedReduced(QLinkedList<int>(linkedList), - intSquare, - &QLinkedList<int>::append, - OrderedReduce); - QCOMPARE(linkedList, QLinkedList<int>() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList<int>() << 1 << 4 << 9); - } - - // member-function - { - int sum = QtConcurrent::blockingMappedReduced(numberList, - &Number::toInt, - intSumReduce); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - intSumReduce); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::blockingMappedReduced(QList<Number>(numberList), - &Number::toInt, - intSumReduce); - QCOMPARE(sum3, 6); - } - { - int sum = QtConcurrent::blockingMappedReduced(numberLinkedList, - &Number::toInt, - intSumReduce); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::blockingMappedReduced(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toInt, - intSumReduce); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::blockingMappedReduced(QLinkedList<Number>(numberLinkedList), - &Number::toInt, - intSumReduce); - QCOMPARE(sum3, 6); - } - - // linked lists - { - - QLinkedList<int> list; - list << 1 << 2 << 3; - - QLinkedList<Number> numberList; - numberList << 1 << 2 << 3; - - int sum = QtConcurrent::blockingMappedReduced<int>(list, IntSquare(), IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced<int>(list.constBegin(), - list.constEnd(), - IntSquare(), - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced<int>(QLinkedList<int>(list), IntSquare(), IntSumReduce()); - QCOMPARE(sum3, 14); - - int sum4 = QtConcurrent::blockingMappedReduced<int>(list, intSquare, intSumReduce); - QCOMPARE(sum4, 14); - int sum5 = QtConcurrent::blockingMappedReduced<int>(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum5, 14); - - int sum6 = QtConcurrent::blockingMappedReduced<int>(QLinkedList<int>(list), - intSquare, - intSumReduce); - QCOMPARE(sum6, 14); - } - - // ### the same as above, with an initial result value -} - -int sleeper(int val) -{ - QTest::qSleep(100); - return val; -} - -void tst_QtConcurrentMap::assignResult() -{ - const QList<int> startList = QList<int>() << 0 << 1 << 2; - QList<int> list = QtConcurrent::blockingMapped(startList, sleeper); - QCOMPARE(list.at(0), 0); - QCOMPARE(list.at(1), 1); -} - -int fnConst(const int &i) -{ - return i; -} - -int fn(int &i) -{ - return i; -} - -QString changeTypeConst(const int &) -{ - return QString(); -} - -QString changeType(int &) -{ - return QString(); -} - -int changeTypeQStringListConst(const QStringList &) -{ - return 0; -} - -int changeTypeQStringList(QStringList &) -{ - return 0; -} - -class MemFnTester -{ -public: - MemFnTester() {} - - MemFnTester fn() - { - return MemFnTester(); - } - - MemFnTester fnConst() const - { - return MemFnTester(); - } - - QString changeType() - { - return QString(); - } - - QString changeTypeConst() const - { - return QString(); - } -}; - -Q_DECLARE_METATYPE(QVector<MemFnTester>); -Q_DECLARE_METATYPE(QList<MemFnTester>); - -void tst_QtConcurrentMap::functionOverloads() -{ - QList<int> intList; - const QList<int> constIntList; - QList<MemFnTester> classList; - const QList<MemFnTester> constMemFnTesterList; - - QtConcurrent::mapped(intList, fnConst); - QtConcurrent::mapped(constIntList, fnConst); - QtConcurrent::mapped(classList, &MemFnTester::fnConst); - QtConcurrent::mapped(constMemFnTesterList, &MemFnTester::fnConst); - - QtConcurrent::blockingMapped<QVector<int> >(intList, fnConst); - QtConcurrent::blockingMapped<QVector<int> >(constIntList, fnConst); - QtConcurrent::blockingMapped<QVector<MemFnTester> >(classList, &MemFnTester::fnConst); - QtConcurrent::blockingMapped<QVector<MemFnTester> >(constMemFnTesterList, &MemFnTester::fnConst); - - QtConcurrent::blockingMapped<QList<QString> >(intList, changeTypeConst); - QtConcurrent::blockingMapped<QList<QString> >(constIntList, changeTypeConst); - QtConcurrent::blockingMapped<QList<QString> >(classList, &MemFnTester::changeTypeConst); - QtConcurrent::blockingMapped<QList<QString> >(constMemFnTesterList, &MemFnTester::changeTypeConst); - - QStringList stringList; - const QStringList constStringList; - // QtConcurrent::map(stringList, changeTypeQStringListConst); - // QtConcurrent::map(intList, changeTypeNonConst); - // QList<QString>(QtConcurrent::map(constStringList, changeTypeQStringList)); - // QtConcurrent::map(classList, &MemFnTester::changeType); - // QtConcurrent::map(classList, &MemFnTester::changeTypeConst); - // QtConcurrent::map(constMemFnTesterList, &MemFnTester::changeTypeConst); -} - -QAtomicInt currentInstanceCount; -QAtomicInt peakInstanceCount; -class InstanceCounter -{ -public: - inline InstanceCounter() - { currentInstanceCount.fetchAndAddRelaxed(1); updatePeak(); } - inline ~InstanceCounter() - { currentInstanceCount.fetchAndAddRelaxed(-1);} - inline InstanceCounter(const InstanceCounter &) - { currentInstanceCount.fetchAndAddRelaxed(1); updatePeak(); } - - void updatePeak() - { - forever { - const int localPeak = peakInstanceCount.load(); - const int localCurrent = currentInstanceCount.load(); - if (localCurrent <= localPeak) - break; - if (peakInstanceCount.testAndSetOrdered(localPeak, localCurrent)) - break; - } - } -}; - -InstanceCounter slowMap(const InstanceCounter &in) -{ - QTest::qSleep(2); - return in; -} - -InstanceCounter fastMap(const InstanceCounter &in) -{ - QTest::qSleep(rand() % 2 + 1); - return in; -} - -void slowReduce(int &result, const InstanceCounter&) -{ - QTest::qSleep(rand() % 4 + 1); - ++result; -} - -void fastReduce(int &result, const InstanceCounter&) -{ - ++result; -} - -void tst_QtConcurrentMap::throttling() -{ - const int itemcount = 100; - const int allowedTemporaries = QThread::idealThreadCount() * 40; - - { - currentInstanceCount.store(0); - peakInstanceCount.store(0); - - QList<InstanceCounter> instances; - for (int i = 0; i < itemcount; ++i) - instances.append(InstanceCounter()); - - QCOMPARE(currentInstanceCount.load(), itemcount); - - int results = QtConcurrent::blockingMappedReduced(instances, slowMap, fastReduce); - QCOMPARE(results, itemcount); - QCOMPARE(currentInstanceCount.load(), itemcount); - QVERIFY(peakInstanceCount.load() < itemcount + allowedTemporaries); - } - - { - QCOMPARE(currentInstanceCount.load(), 0); - peakInstanceCount.store(0); - - QList<InstanceCounter> instances; - for (int i = 0; i < itemcount; ++i) - instances.append(InstanceCounter()); - - QCOMPARE(currentInstanceCount.load(), itemcount); - int results = QtConcurrent::blockingMappedReduced(instances, fastMap, slowReduce); - - QCOMPARE(results, itemcount); - QCOMPARE(currentInstanceCount.load(), itemcount); - QVERIFY(peakInstanceCount.load() < itemcount + allowedTemporaries); - } -} - -#ifndef QT_NO_EXCEPTIONS -void throwMapper(int &e) -{ - Q_UNUSED(e); - throw QtConcurrent::Exception(); -} - -void tst_QtConcurrentMap::exceptions() -{ - bool caught = false; - try { - QList<int> list = QList<int>() << 1 << 2 << 3; - QtConcurrent::map(list, throwMapper).waitForFinished(); - } catch (const Exception &) { - caught = true; - } - if (!caught) - QFAIL("did not get exception"); -} -#endif - -int mapper(const int &i) -{ - QTest::qWait(1); - return i; -} - -void tst_QtConcurrentMap::incrementalResults() -{ - const int count = 200; - QList<int> ints; - for (int i=0; i < count; ++i) - ints << i; - - QFuture<int> future = QtConcurrent::mapped(ints, mapper); - - QList<int> results; - - while (future.isFinished() == false) { - for (int i = 0; i < future.resultCount(); ++i) { - results += future.resultAt(i); - } - - QTest::qWait(1); - } - - QCOMPARE(future.isFinished(), true); - QCOMPARE(future.resultCount(), count); - QCOMPARE(future.results().count(), count); -} - -/* - Test that mapped does not cause deep copies when holding - references to Qt containers. -*/ -void tst_QtConcurrentMap::noDetach() -{ - { - QList<int> l = QList<int>() << 1; - QVERIFY(l.isDetached()); - - QList<int> ll = l; - QVERIFY(l.isDetached() == false); - - QtConcurrent::mapped(l, mapper).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::mappedReduced(l, mapper, intSumReduce).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::map(l, multiplyBy2Immutable).waitForFinished(); - QVERIFY(l.isDetached() == true); - QVERIFY(ll.isDetached() == true); - } - { - const QList<int> l = QList<int>() << 1; - QVERIFY(l.isDetached()); - - const QList<int> ll = l; - QVERIFY(l.isDetached() == false); - - QtConcurrent::mapped(l, mapper).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - - QtConcurrent::mappedReduced(l, mapper, intSumReduce).waitForFinished(); - - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); - } - -} - -#ifndef QT_NO_STL -void tst_QtConcurrentMap::stlContainers() -{ - std::vector<int> vector; - vector.push_back(1); - vector.push_back(2); - - std::vector<int> vector2 = QtConcurrent::blockingMapped<std::vector<int> >(vector, mapper); - QCOMPARE(vector2.size(), (std::vector<int>::size_type)(2)); - - std::list<int> list; - list.push_back(1); - list.push_back(2); - - std::list<int> list2 = QtConcurrent::blockingMapped<std::list<int> >(list, mapper); - QCOMPARE(list2.size(), (std::vector<int>::size_type)(2)); - - QtConcurrent::mapped(list, mapper).waitForFinished(); - - QtConcurrent::blockingMap(list, multiplyBy2Immutable); -} -#endif - -InstanceCounter ic_fn(const InstanceCounter & ic) -{ - return InstanceCounter(ic); -}; - -// Verify that held results are deleted when a future is -// assigned over with operator == -void tst_QtConcurrentMap::qFutureAssignmentLeak() -{ - currentInstanceCount.store(0); - peakInstanceCount.store(0); - QFuture<InstanceCounter> future; - { - QList<InstanceCounter> list; - for (int i=0;i<1000;++i) - list += InstanceCounter(); - future = QtConcurrent::mapped(list, ic_fn); - future.waitForFinished(); - - future = QtConcurrent::mapped(list, ic_fn); - future.waitForFinished(); - - future = QtConcurrent::mapped(list, ic_fn); - future.waitForFinished(); - } - - QCOMPARE(currentInstanceCount.load(), 1000); - future = QFuture<InstanceCounter>(); - QCOMPARE(currentInstanceCount.load(), 0); -} - -inline void increment(int &num) -{ - ++num; -} - -inline int echo(const int &num) -{ - return num; -} - -void add(int &result, const int &sum) -{ - result += sum; -} - -void tst_QtConcurrentMap::stressTest() -{ - const int listSize = 1000; - const int sum = (listSize - 1) * (listSize / 2); - QList<int> list; - - - for (int i = 0; i < listSize; ++i) { - list.append(i); - } - - for (int i =0 ; i < 100; ++i) { - QList<int> result = QtConcurrent::blockingMapped(list, echo); - for (int j = 0; j < listSize; ++j) - QCOMPARE(result.at(j), j); - } - - for (int i = 0 ; i < 100; ++i) { - int result = QtConcurrent::blockingMappedReduced(list, echo, add); - QCOMPARE(result, sum); - } - - for (int i = 0 ; i < 100; ++i) { - QtConcurrent::map(list, increment).waitForFinished(); - for (int j = 0; j < listSize; ++j) - QCOMPARE(list.at(j), i + j + 1); - } -} - -#endif - -QTEST_MAIN(tst_QtConcurrentMap) -#include "tst_qtconcurrentmap.moc" diff --git a/tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro b/tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro deleted file mode 100644 index e93fc587a7..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qtconcurrentresultstore -QT = core-private testlib -SOURCES = tst_qtconcurrentresultstore.cpp -DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp b/tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp deleted file mode 100644 index 980fc6c282..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp +++ /dev/null @@ -1,490 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> - -#include <qtconcurrentresultstore.h> - -using namespace QtConcurrent; - -class tst_QtConcurrentResultStore : public QObject -{ - Q_OBJECT -public slots: - void init(); -private slots: - void construction(); - void iterators(); - void addResult(); - void addResults(); - void resultIndex(); - void resultAt(); - void contains(); - void filterMode(); - void addCanceledResult(); - void count(); -private: - int int0; - int int1; - int int2; - QVector<int> vec0; - QVector<int> vec1; -}; - -void tst_QtConcurrentResultStore::init() -{ - int0 = 0; - int1 = 1; - int2 = 2; - vec0 = QVector<int>() << 2 << 3; - vec1 = QVector<int>() << 4 << 5; -} - -void tst_QtConcurrentResultStore::construction() -{ - ResultStore<int> store; - QCOMPARE(store.count(), 0); -} - -void tst_QtConcurrentResultStore::iterators() -{ - { - ResultStore<int> store; - QVERIFY(store.begin() == store.end()); - QVERIFY(store.resultAt(0) == store.end()); - QVERIFY(store.resultAt(1) == store.end()); - } - { - ResultStoreBase storebase; - storebase.addResult(-1, &int0); // note to self: adding a pointer to the stack here is ok since - storebase.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does. - ResultIteratorBase it = storebase.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == storebase.begin()); - QVERIFY(it != storebase.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != storebase.begin()); - QVERIFY(it != storebase.end()); - - ++it; - QVERIFY(it != storebase.begin()); - QVERIFY(it == storebase.end()); - } -} - -void tst_QtConcurrentResultStore::addResult() -{ - { - // test addResult return value - ResultStore<int> store; - store.setFilterMode(true); - - QCOMPARE(store.addResult(0, &int0), 0); - QCOMPARE(store.count(), 1); // result 0 becomes available - QCOMPARE(store.contains(0), true); - - QCOMPARE(store.addResult(2, &int0), 2); - QCOMPARE(store.count(), 1); - QCOMPARE(store.contains(2), false); - - QCOMPARE(store.addCanceledResult(1), 1); - QCOMPARE(store.count(), 2); // result 2 is renamed to 1 and becomes available - - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), false); - - QCOMPARE(store.addResult(3, &int0), 3); - QCOMPARE(store.count(), 3); - QCOMPARE(store.contains(2), true); - - QCOMPARE(store.addResult(6, &int0), 6); - QCOMPARE(store.count(), 3); - QCOMPARE(store.addResult(7, &int0), 7); - QCOMPARE(store.count(), 3); - QCOMPARE(store.contains(3), false); - - QCOMPARE(store.addCanceledResult(4), 4); - QCOMPARE(store.addCanceledResult(5), 5); - QCOMPARE(store.count(), 5); // 6 and 7 is renamed to 3 and 4 and becomes available - - QCOMPARE(store.contains(3), true); - QCOMPARE(store.contains(4), true); - - QCOMPARE(store.addResult(8, &int0), 8); - QCOMPARE(store.contains(5), true); - QCOMPARE(store.count(), 6); - - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - } -} - -void tst_QtConcurrentResultStore::addResults() -{ - - ResultStoreBase store; - store.addResults(-1, &vec0, 2, 2); - store.addResults(-1, &vec1, 2, 2); - ResultIteratorBase it = store.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 2); - - ++it; - QCOMPARE(it.resultIndex(), 3); - - ++it; - QVERIFY(it == store.end()); -} - -void tst_QtConcurrentResultStore::resultIndex() -{ - ResultStore<int> store; - store.addResult(-1, &int0); - store.addResults(-1, &vec0); - store.addResult(-1, &int1); - - ResultIteratorBase it = store.begin(); - QCOMPARE(it.resultIndex(), 0); - QVERIFY(it == store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 1); - QVERIFY(it != store.begin()); - QVERIFY(it != store.end()); - - ++it; - QCOMPARE(it.resultIndex(), 2); - QVERIFY(it != store.end()); - ++it; - QCOMPARE(it.resultIndex(), 3); - QVERIFY(it != store.end()); - ++it; - QVERIFY(it == store.end()); - - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(3).value(), int1); -} - -void tst_QtConcurrentResultStore::resultAt() -{ - { - ResultStore<int> store; - store.addResult(-1, &int0); - store.addResults(-1, &vec0); - store.addResult(200, &int1); - - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(200).value(), int1); - } - { - ResultStore<int> store; - store.addResult(1, &int1); - store.addResult(0, &int0); - store.addResult(-1, &int2); - - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), int1); - QCOMPARE(store.resultAt(2).value(), int2); - } -} - -void tst_QtConcurrentResultStore::contains() -{ - { - ResultStore<int> store; - QCOMPARE(store.contains(0), false); - QCOMPARE(store.contains(1), false); - QCOMPARE(store.contains(INT_MAX), false); - store.addResult(1, &int1); - QVERIFY(store.contains(int1)); - store.addResult(0, &int0); - QVERIFY(store.contains(int0)); - store.addResult(-1, &int2); - QVERIFY(store.contains(int2)); - } - { - ResultStore<int> store; - store.addResult(1, &int0); - store.addResult(3, &int0); - store.addResults(6, &vec0); - QCOMPARE(store.contains(0), false); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), false); - QCOMPARE(store.contains(3), true); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(6), true); - QCOMPARE(store.contains(7), true); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResult(1, &int0); - store.addResult(3, &int0); - store.addResults(6, &vec0); - QCOMPARE(store.contains(0), false); - QCOMPARE(store.contains(1), false); - QCOMPARE(store.contains(2), false); - QCOMPARE(store.contains(3), false); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - - store.addCanceledResult(0); - store.addCanceledResult(2); - store.addCanceledResults(4, 2); - - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), true); - QCOMPARE(store.contains(3), true); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); - } - { - ResultStore<int> store; - store.setFilterMode(true); - store.addCanceledResult(0); - QCOMPARE(store.contains(0), false); - - store.addResult(1, &int0); - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), false); - } -} - -void tst_QtConcurrentResultStore::filterMode() -{ - // Test filter mode, where "gaps" in the result array aren't allowed. - ResultStore<int> store; - QCOMPARE(store.filterMode(), false); - store.setFilterMode(true); - QVERIFY(store.filterMode()); - - store.addResult(0, &int0); - QCOMPARE(store.contains(0), true); - - store.addResult(2, &int2); // add result at index 2 - QCOMPARE(store.contains(2), false); // but 1 is missing, so this 2 won't be reported yet. - - store.addResult(1, &int1); - QCOMPARE(store.contains(1), true); - QCOMPARE(store.contains(2), true); // 2 should be visible now. - - store.addResult(4, &int0); - store.addResult(5, &int0); - store.addResult(7, &int0); - QCOMPARE(store.contains(4), false); - QCOMPARE(store.contains(5), false); - QCOMPARE(store.contains(7), false); - - store.addResult(3, &int0); // adding 3 makes 4 and 5 visible - QCOMPARE(store.contains(4), true); - QCOMPARE(store.contains(5), true); - QCOMPARE(store.contains(7), false); - - store.addResult(6, &int0); // adding 6 makes 7 visible - - QCOMPARE(store.contains(6), true); - QCOMPARE(store.contains(7), true); - QCOMPARE(store.contains(8), false); -} - -void tst_QtConcurrentResultStore::addCanceledResult() -{ - // test canceled results - ResultStore<int> store; - store.setFilterMode(true); - - store.addResult(0, &int0); - QCOMPARE(store.contains(0), true); - - store.addResult(2, &int0); - QCOMPARE(store.contains(2), false); - - store.addCanceledResult(1); // report no result at 1 - - QCOMPARE(store.contains(0), true); - QCOMPARE(store.contains(1), true); // 2 gets renamed to 1 - QCOMPARE(store.contains(2), false); - - store.addResult(3, &int0); - QCOMPARE(store.contains(2), true); //3 gets renamed to 2 - - store.addResult(6, &int0); - store.addResult(7, &int0); - QCOMPARE(store.contains(3), false); - - store.addCanceledResult(4); - store.addCanceledResult(5); - - QCOMPARE(store.contains(3), true); //6 gets renamed to 3 - QCOMPARE(store.contains(4), true); //7 gets renamed to 4 - - store.addResult(8, &int0); - QCOMPARE(store.contains(5), true); //8 gets renamed to 4 - - QCOMPARE(store.contains(6), false); - QCOMPARE(store.contains(7), false); -} - -void tst_QtConcurrentResultStore::count() -{ - { - // test resultCount in non-filtered mode. It should always be possible - // to iterate through the results 0 to resultCount. - ResultStore<int> store; - store.addResult(0, &int0); - - QCOMPARE(store.count(), 1); - - store.addResult(2, &int0); - - QCOMPARE(store.count(), 1); - - store.addResult(1, &int0); - QCOMPARE(store.count(), 3); - } - - { - ResultStore<int> store; - store.addResult(2, &int0); - QCOMPARE(store.count(), 0); - - store.addResult(1, &int0); - QCOMPARE(store.count(), 0); - - store.addResult(0, &int0); - QCOMPARE(store.count(), 3); - } - - { - ResultStore<int> store; - store.addResults(2, &vec1); - QCOMPARE(store.count(), 0); - - store.addResult(1, &int0); - QCOMPARE(store.count(), 0); - - store.addResult(0, &int0); - QCOMPARE(store.count(), 4); - } - - { - ResultStore<int> store; - store.addResults(2, &vec1); - QCOMPARE(store.count(), 0); - - store.addResults(0, &vec0); - QCOMPARE(store.count(), 4); - } - { - ResultStore<int> store; - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addResults(0, &vec0); - QCOMPARE(store.count(), 2); - - store.addResult(2, &int0); - QCOMPARE(store.count(), 5); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addResults(0, &vec0); - QCOMPARE(store.count(), 2); - - store.addCanceledResult(2); - QCOMPARE(store.count(), 4); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addCanceledResults(0, 3); - QCOMPARE(store.count(), 2); - } - - { - ResultStore<int> store; - store.setFilterMode(true); - store.addResults(3, &vec1); - QCOMPARE(store.count(), 0); - - store.addCanceledResults(0, 3); - QCOMPARE(store.count(), 2); // results at 3 and 4 become available at index 0, 1 - - store.addResult(5, &int0); - QCOMPARE(store.count(), 3);// result 5 becomes available at index 2 - } -} - -QTEST_MAIN(tst_QtConcurrentResultStore) -#include "tst_qtconcurrentresultstore.moc" diff --git a/tests/auto/corelib/concurrent/qtconcurrentrun/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentrun/.gitignore deleted file mode 100644 index d7a8334ec4..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentrun/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtconcurrentrun diff --git a/tests/auto/corelib/concurrent/qtconcurrentrun/qtconcurrentrun.pro b/tests/auto/corelib/concurrent/qtconcurrentrun/qtconcurrentrun.pro deleted file mode 100644 index d4f130fecd..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentrun/qtconcurrentrun.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qtconcurrentrun -QT = core testlib -SOURCES = tst_qtconcurrentrun.cpp diff --git a/tests/auto/corelib/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/corelib/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp deleted file mode 100644 index 96f705d00b..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtconcurrentrun.h> -#include <qfuture.h> -#include <QString> -#include <QtTest/QtTest> - -using namespace QtConcurrent; - -class tst_QtConcurrentRun: public QObject -{ - Q_OBJECT -private slots: - void runLightFunction(); - void runHeavyFunction(); - void returnValue(); - void functionObject(); - void memberFunctions(); - void implicitConvertibleTypes(); - void runWaitLoop(); - void recursive(); -#ifndef QT_NO_EXCEPTIONS - void exceptions(); -#endif - void functor(); - void lambda(); -}; - -void light() -{ - qDebug("in function"); - qDebug("done function"); -} - -void heavy() -{ - qDebug("in function"); - QString str; - for (int i = 0; i < 1000000; ++i) - str.append("a"); - qDebug("done function"); -} - - -void tst_QtConcurrentRun::runLightFunction() -{ - qDebug("starting function"); - QFuture<void> future = run(light); - qDebug("waiting"); - future.waitForFinished(); - qDebug("done"); -} - -void tst_QtConcurrentRun::runHeavyFunction() -{ - qDebug("starting function"); - QFuture<void> future = run(heavy); - qDebug("waiting"); - future.waitForFinished(); - qDebug("done"); -} - -int returnInt0() -{ - return 10; -} - -int returnInt1(int i) -{ - return i; -} - -class A -{ -public: - int member0() { return 10; } - int member1(int in) { return in; } - - typedef int result_type; - int operator()() { return 10; } - int operator()(int in) { return in; } -}; - -class AConst -{ -public: - int member0() const { return 10; } - int member1(int in) const { return in; } - - typedef int result_type; - int operator()() const { return 10; } - int operator()(int in) const { return in; } -}; - -void tst_QtConcurrentRun::returnValue() -{ - QFuture<int> f; - - f = run(returnInt0); - QCOMPARE(f.result(), 10); - - A a; - f = run(&a, &A::member0); - QCOMPARE(f.result(), 10); - - f = run(&a, &A::member1, 20); - QCOMPARE(f.result(), 20); - - f = run(a, &A::member0); - QCOMPARE(f.result(), 10); - - f = run(a, &A::member1, 20); - QCOMPARE(f.result(), 20); - - f = run(a); - QCOMPARE(f.result(), 10); - - f = run(&a); - QCOMPARE(f.result(), 10); - - f = run(a, 20); - QCOMPARE(f.result(), 20); - - f = run(&a, 20); - QCOMPARE(f.result(), 20); - - const AConst aConst = AConst(); - f = run(&aConst, &AConst::member0); - QCOMPARE(f.result(), 10); - - f = run(&aConst, &AConst::member1, 20); - QCOMPARE(f.result(), 20); - - f = run(aConst, &AConst::member0); - QCOMPARE(f.result(), 10); - - f = run(aConst, &AConst::member1, 20); - QCOMPARE(f.result(), 20); - - f = run(aConst); - QCOMPARE(f.result(), 10); - - f = run(&aConst); - QCOMPARE(f.result(), 10); - - f = run(aConst, 20); - QCOMPARE(f.result(), 20); - - f = run(&aConst, 20); - QCOMPARE(f.result(), 20); -} - -struct TestClass -{ - void foo() { } - typedef void result_type; - void operator()() { } - void operator()(int) { } - void fooInt(int){ }; -}; - -struct TestConstClass -{ - void foo() const { } - typedef void result_type; - void operator()() const { } - void operator()(int) const { } - void fooInt(int) const { }; -}; - -void tst_QtConcurrentRun::functionObject() -{ - QFuture<void> f; - TestClass c; - - f = run(c); - f = run(&c); - f = run(c, 10); - f = run(&c, 10); - - const TestConstClass cc = TestConstClass(); - f = run(cc); - f = run(&cc); - f = run(cc, 10); - f = run(&cc, 10); -} - - -void tst_QtConcurrentRun::memberFunctions() -{ - TestClass c; - - run(c, &TestClass::foo).waitForFinished(); - run(&c, &TestClass::foo).waitForFinished(); - run(c, &TestClass::fooInt, 10).waitForFinished(); - run(&c, &TestClass::fooInt, 10).waitForFinished(); - - const TestConstClass cc = TestConstClass(); - run(cc, &TestConstClass::foo).waitForFinished(); - run(&cc, &TestConstClass::foo).waitForFinished(); - run(cc, &TestConstClass::fooInt, 10).waitForFinished(); - run(&cc, &TestConstClass::fooInt, 10).waitForFinished(); -} - - -void doubleFunction(double) -{ - -} - -void stringConstRefFunction(const QString &) -{ - -} - -void stringRefFunction(QString &) -{ - -} - -void stringFunction(QString) -{ - -} - -void stringIntFunction(QString) -{ - -} - - -void tst_QtConcurrentRun::implicitConvertibleTypes() -{ - double d; - run(doubleFunction, d).waitForFinished(); - int i; - run(doubleFunction, d).waitForFinished(); - run(doubleFunction, i).waitForFinished(); - run(doubleFunction, 10).waitForFinished(); - run(stringFunction, QLatin1String("Foo")).waitForFinished(); - run(stringConstRefFunction, QLatin1String("Foo")).waitForFinished(); - QString string; - run(stringRefFunction, string).waitForFinished(); -} - -void fn() { } - -void tst_QtConcurrentRun::runWaitLoop() -{ - for (int i = 0; i < 1000; ++i) - run(fn).waitForFinished(); -} - -QAtomicInt count; - -void recursiveRun(int level) -{ - count.ref(); - if (--level > 0) { - QFuture<void> f1 = run(recursiveRun, level); - QFuture<void> f2 = run(recursiveRun, level); - f1.waitForFinished(); - f2.waitForFinished(); - } -} - -int recursiveResult(int level) -{ - count.ref(); - if (--level > 0) { - QFuture<int> f1 = run(recursiveResult, level); - QFuture<int> f2 = run(recursiveResult, level); - return f1.result() + f2.result(); - } - return 1; -} - -void tst_QtConcurrentRun::recursive() -{ - int levels = 15; - - for (int i = 0; i < QThread::idealThreadCount(); ++i) { - count.store(0); - QThreadPool::globalInstance()->setMaxThreadCount(i); - recursiveRun(levels); - QCOMPARE(count.load(), (int)pow(2.0, levels) - 1); - } - - for (int i = 0; i < QThread::idealThreadCount(); ++i) { - count.store(0); - QThreadPool::globalInstance()->setMaxThreadCount(i); - recursiveResult(levels); - QCOMPARE(count.load(), (int)pow(2.0, levels) - 1); - } -} - -int e; -void vfn0() -{ - ++e; -} - -int fn0() -{ - return 1; -} - -void vfn1(double) -{ - ++e; -} - -int fn1(int) -{ - return 1; -} - -void vfn2(double, int *) -{ - ++e; -} - -int fn2(double, int *) -{ - return 1; -} - - -#ifndef QT_NO_EXCEPTIONS -void throwFunction() -{ - throw QtConcurrent::Exception(); -} - -int throwFunctionReturn() -{ - throw QtConcurrent::Exception(); - return 0; -} - -void tst_QtConcurrentRun::exceptions() -{ - bool caught = false; - try { - QtConcurrent::run(throwFunction).waitForFinished(); - } catch (Exception &e) { - caught = true; - } - if (!caught) - QFAIL("did not get exception"); - - caught = false; - try { - QtConcurrent::run(throwFunctionReturn).waitForFinished(); - } catch (Exception &e) { - caught = true; - } - if (!caught) - QFAIL("did not get exception"); -} -#endif - -struct Functor { - int operator()() { return 42; } - double operator()(double a, double b) { return a/b; } - int operator()(int a, int b) { return a/b; } - void operator()(int) { } - void operator()(int, int, int) { } - void operator()(int, int, int, int) { } - void operator()(int, int, int, int, int) { } - void operator()(int, int, int, int, int, int) { } -}; - -// This tests functor without result_type; decltype need to be supported by the compiler. -void tst_QtConcurrentRun::functor() -{ -#ifndef Q_COMPILER_DECLTYPE - QSKIP("Compiler does not support decltype"); -#else - Functor f; - { - QFuture<int> fut = QtConcurrent::run(f); - QCOMPARE(fut.result(), 42); - } - { - QFuture<double> fut = QtConcurrent::run(f, 8.5, 1.8); - QCOMPARE(fut.result(), (8.5/1.8)); - } - { - QFuture<int> fut = QtConcurrent::run(f, 19, 3); - QCOMPARE(fut.result(), int(19/3)); - } - { - QtConcurrent::run(f, 1).waitForFinished(); - QtConcurrent::run(f, 1,2).waitForFinished(); - QtConcurrent::run(f, 1,2,3).waitForFinished(); - QtConcurrent::run(f, 1,2,3,4).waitForFinished(); - QtConcurrent::run(f, 1,2,3,4,5).waitForFinished(); - } -#endif -} - -void tst_QtConcurrentRun::lambda() -{ -#ifndef Q_COMPILER_LAMBDA - QSKIP("Compiler does not support lambda"); -#else - QCOMPARE(QtConcurrent::run([](){ return 45; }).result(), 45); - QCOMPARE(QtConcurrent::run([](int a){ return a+15; }, 12).result(), 12+15); - QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); - QCOMPARE(QtConcurrent::run([](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); - -#ifdef Q_COMPILER_INITIALIZER_LISTS - { - QString str { "Hello World Foo" }; - QFuture<QStringList> f1 = QtConcurrent::run([&](){ return str.split(' '); }); - auto r = f1.result(); - QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); - } -#endif -#endif -} - -QTEST_MAIN(tst_QtConcurrentRun) -#include "tst_qtconcurrentrun.moc" diff --git a/tests/auto/corelib/concurrent/qtconcurrentthreadengine/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/.gitignore deleted file mode 100644 index a2e2896246..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentthreadengine/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtconcurrentthreadengine diff --git a/tests/auto/corelib/concurrent/qtconcurrentthreadengine/qtconcurrentthreadengine.pro b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/qtconcurrentthreadengine.pro deleted file mode 100644 index 536ccc3ea5..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentthreadengine/qtconcurrentthreadengine.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qtconcurrentthreadengine -QT = core testlib -SOURCES = tst_qtconcurrentthreadengine.cpp diff --git a/tests/auto/corelib/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp deleted file mode 100644 index 858faa6eab..0000000000 --- a/tests/auto/corelib/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtconcurrentthreadengine.h> -#include <qtconcurrentexception.h> -#include <QThread> -#include <QtTest/QtTest> - -using namespace QtConcurrent; - -class tst_QtConcurrentThreadEngine: public QObject -{ - Q_OBJECT -private slots: - void runDirectly(); - void result(); - void runThroughStarter(); - void cancel(); - void throttle(); - void threadCount(); - void multipleResults(); - void stresstest(); - void cancelQueuedSlowUser(); -#ifndef QT_NO_EXCEPTIONS - void exceptions(); -#endif -}; - - -class PrintUser : public ThreadEngine<void> -{ -public: - ThreadFunctionResult threadFunction() - { - QTest::qSleep(50); - QTest::qSleep(100); - return ThreadFinished; - } -}; - -void tst_QtConcurrentThreadEngine::runDirectly() -{ - { - PrintUser engine; - engine.startSingleThreaded(); - engine.startBlocking(); - } - { - PrintUser *engine = new PrintUser(); - QFuture<void> f = engine->startAsynchronously(); - f.waitForFinished(); - } -} - -class StringResultUser : public ThreadEngine<QString> -{ -public: - typedef QString ResultType; - StringResultUser() - : done(false) { } - - bool shouldStartThread() - { - return !done; - } - - ThreadFunctionResult threadFunction() - { - done = true; - return ThreadFinished; - } - - QString *result() - { - foo = "Foo"; - return &foo; - } - QString foo; - bool done; -}; - -void tst_QtConcurrentThreadEngine::result() -{ - StringResultUser engine; - QCOMPARE(*engine.startBlocking(), QString("Foo")); -} - -class VoidResultUser : public ThreadEngine<void> -{ -public: - bool shouldStartThread() - { - return !done; - } - - ThreadFunctionResult threadFunction() - { - done = true; - return ThreadFinished; - } - - void *result() - { - return 0; - } - bool done; -}; - -void tst_QtConcurrentThreadEngine::runThroughStarter() -{ - { - ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser()); - QFuture<QString> f = starter.startAsynchronously(); - QCOMPARE(f.result(), QString("Foo")); - } - - { - ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser()); - QString str = starter.startBlocking(); - QCOMPARE(str, QString("Foo")); - } -} - -class CancelUser : public ThreadEngine<void> -{ -public: - void *result() - { - return 0; - } - - ThreadFunctionResult threadFunction() - { - while (this->isCanceled() == false) - { - QTest::qSleep(10); - } - return ThreadFinished; - } -}; - -void tst_QtConcurrentThreadEngine::cancel() -{ - { - CancelUser *engine = new CancelUser(); - QFuture<void> f = engine->startAsynchronously(); - f.cancel(); - f.waitForFinished(); - } - { - CancelUser *engine = new CancelUser(); - QFuture<void> f = engine->startAsynchronously(); - QTest::qSleep(10); - f.cancel(); - f.waitForFinished(); - } -} - -QAtomicInt count; -class ThrottleAlwaysUser : public ThreadEngine<void> -{ -public: - ThrottleAlwaysUser() - { - count.store(initialCount = 100); - finishing = false; - } - - bool shouldStartThread() - { - return !finishing; - } - - ThreadFunctionResult threadFunction() - { - forever { - const int local = count.load(); - if (local == 0) { - finishing = true; - return ThreadFinished; - } - - if (count.testAndSetOrdered(local, local - 1)) - break; - } - return ThrottleThread; - } - - bool finishing; - int initialCount; -}; - -// Test that a user task with a thread function that always -// want to be throttled still completes. The thread engine -// should make keep one thread running at all times. -void tst_QtConcurrentThreadEngine::throttle() -{ - const int repeats = 10; - for (int i = 0; i < repeats; ++i) { - QFuture<void> f = (new ThrottleAlwaysUser())->startAsynchronously(); - f.waitForFinished(); - QCOMPARE(count.load(), 0); - } - - for (int i = 0; i < repeats; ++i) { - ThrottleAlwaysUser t; - t.startBlocking(); - QCOMPARE(count.load(), 0); - } -} - -QSet<QThread *> threads; -QMutex mutex; -class ThreadCountUser : public ThreadEngine<void> -{ -public: - ThreadCountUser(bool finishImmediately = false) - { - threads.clear(); - finishing = finishImmediately; - } - - bool shouldStartThread() - { - return !finishing; - } - - ThreadFunctionResult threadFunction() - { - { - QMutexLocker lock(&mutex); - threads.insert(QThread::currentThread()); - } - QTest::qSleep(10); - finishing = true; - return ThreadFinished; - } - - bool finishing; -}; - -void tst_QtConcurrentThreadEngine::threadCount() -{ - QSKIP("QTBUG-23333: This test is unstable"); - - const int repeats = 10; - for (int i = 0; i < repeats; ++i) { - ThreadCountUser t; - t.startBlocking(); - QCOMPARE(threads.count(), QThreadPool::globalInstance()->maxThreadCount() + 1); // +1 for the main thread. - - (new ThreadCountUser())->startAsynchronously().waitForFinished(); - QCOMPARE(threads.count(), QThreadPool::globalInstance()->maxThreadCount()); - } - - // Set the finish flag immediately, this should give us one thread only. - for (int i = 0; i < repeats; ++i) { - ThreadCountUser t(true /*finishImmediately*/); - t.startBlocking(); - QCOMPARE(threads.count(), 1); - - (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished(); - QCOMPARE(threads.count(), 1); - } -} - -class MultipleResultsUser : public ThreadEngine<int> -{ -public: - bool shouldStartThread() - { - return false; - } - - ThreadFunctionResult threadFunction() - { - for (int i = 0; i < 10; ++i) - this->reportResult(&i); - return ThreadFinished; - } -}; - - -void tst_QtConcurrentThreadEngine::multipleResults() -{ - MultipleResultsUser *engine = new MultipleResultsUser(); - QFuture<int> f = engine->startAsynchronously(); - QCOMPARE(f.results().count() , 10); - QCOMPARE(f.resultAt(0), 0); - QCOMPARE(f.resultAt(5), 5); - QCOMPARE(f.resultAt(9), 9); - f.waitForFinished(); -} - - -class NoThreadsUser : public ThreadEngine<void> -{ -public: - bool shouldStartThread() - { - return false; - } - - ThreadFunctionResult threadFunction() - { - return ThreadFinished; - } - - void *result() - { - return 0; - } -}; - -void tst_QtConcurrentThreadEngine::stresstest() -{ - const int times = 20000; - - for (int i = 0; i < times; ++i) { - VoidResultUser *engine = new VoidResultUser(); - engine->startAsynchronously().waitForFinished(); - } - - for (int i = 0; i < times; ++i) { - VoidResultUser *engine = new VoidResultUser(); - engine->startAsynchronously(); - } - - for (int i = 0; i < times; ++i) { - VoidResultUser *engine = new VoidResultUser(); - engine->startAsynchronously().waitForFinished(); - } -} - -const int sleepTime = 20; -class SlowUser : public ThreadEngine<void> -{ -public: - bool shouldStartThread() { return false; } - ThreadFunctionResult threadFunction() { QTest::qSleep(sleepTime); return ThreadFinished; } -}; - -void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser() -{ - const int times = 100; - - QTime t; - t.start(); - - { - QList<QFuture<void> > futures; - for (int i = 0; i < times; ++i) { - SlowUser *engine = new SlowUser(); - futures.append(engine->startAsynchronously()); - } - - foreach(QFuture<void> future, futures) - future.cancel(); - } - - QVERIFY(t.elapsed() < (sleepTime * times) / 2); -} - -#ifndef QT_NO_EXCEPTIONS - -class QtConcurrentExceptionThrower : public ThreadEngine<void> -{ -public: - QtConcurrentExceptionThrower(QThread *blockThread = 0) - { - this->blockThread = blockThread; - } - - ThreadFunctionResult threadFunction() - { - QTest::qSleep(50); - throw QtConcurrent::Exception(); - return ThreadFinished; - } - QThread *blockThread; -}; - -class UnrelatedExceptionThrower : public ThreadEngine<void> -{ -public: - UnrelatedExceptionThrower(QThread *blockThread = 0) - { - this->blockThread = blockThread; - } - - ThreadFunctionResult threadFunction() - { - QTest::qSleep(50); - throw int(); - return ThreadFinished; - } - QThread *blockThread; -}; - -void tst_QtConcurrentThreadEngine::exceptions() -{ - // Asynchronous mode: - { - bool caught = false; - try { - QtConcurrentExceptionThrower *e = new QtConcurrentExceptionThrower(); - QFuture<void> f = e->startAsynchronously(); - f.waitForFinished(); - } catch (const Exception &) { - caught = true; - } - QVERIFY2(caught, "did not get exception"); - } - - // Blocking mode: - // test throwing the exception from a worker thread. - { - bool caught = false; - try { - QtConcurrentExceptionThrower e(QThread::currentThread()); - e.startBlocking(); - } catch (const Exception &) { - caught = true; - } - QVERIFY2(caught, "did not get exception"); - } - - // test throwing the exception from the main thread (different code path) - { - bool caught = false; - try { - QtConcurrentExceptionThrower e(0); - e.startBlocking(); - } catch (const Exception &) { - caught = true; - } - QVERIFY2(caught, "did not get exception"); - } - - // Asynchronous mode: - { - bool caught = false; - try { - UnrelatedExceptionThrower *e = new UnrelatedExceptionThrower(); - QFuture<void> f = e->startAsynchronously(); - f.waitForFinished(); - } catch (const QtConcurrent::UnhandledException &) { - caught = true; - } - QVERIFY2(caught, "did not get exception"); - } - - // Blocking mode: - // test throwing the exception from a worker thread. - { - bool caught = false; - try { - UnrelatedExceptionThrower e(QThread::currentThread()); - e.startBlocking(); - } catch (const QtConcurrent::UnhandledException &) { - caught = true; - } - QVERIFY2(caught, "did not get exception"); - } - - // test throwing the exception from the main thread (different code path) - { - bool caught = false; - try { - UnrelatedExceptionThrower e(0); - e.startBlocking(); - } catch (const QtConcurrent::UnhandledException &) { - caught = true; - } - QVERIFY2(caught, "did not get exception"); - } -} - -#endif - -QTEST_MAIN(tst_QtConcurrentThreadEngine) - -#include "tst_qtconcurrentthreadengine.moc" diff --git a/tests/auto/corelib/corelib.pro b/tests/auto/corelib/corelib.pro index 84eb3f284c..4f284ac21e 100644 --- a/tests/auto/corelib/corelib.pro +++ b/tests/auto/corelib/corelib.pro @@ -2,10 +2,10 @@ TEMPLATE=subdirs SUBDIRS=\ animation \ codecs \ - concurrent \ global \ io \ itemmodels \ + json \ kernel \ plugin \ statemachine \ @@ -13,4 +13,3 @@ SUBDIRS=\ tools \ xml -!contains(QT_CONFIG, concurrent): SUBDIRS -= concurrent diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro index e9b547be68..a6c638f530 100644 --- a/tests/auto/corelib/global/global.pro +++ b/tests/auto/corelib/global/global.pro @@ -5,4 +5,5 @@ SUBDIRS=\ qgetputenv \ qglobal \ qnumeric \ - qrand + qrand \ + qmessagehandler diff --git a/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp b/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp index 35a74f154d..ec021c5bb1 100644 --- a/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp +++ b/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index d80f401071..d466d7b8d8 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index 41fb311837..e074aeb3e9 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 23b9c6bbab..8fedaf427a 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/global/qmessagehandler/qmessagehandler.pro b/tests/auto/corelib/global/qmessagehandler/qmessagehandler.pro new file mode 100644 index 0000000000..8bdba4bfc4 --- /dev/null +++ b/tests/auto/corelib/global/qmessagehandler/qmessagehandler.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qmessagehandler +QT = core testlib +SOURCES = tst_qmessagehandler.cpp diff --git a/tests/auto/corelib/global/qmessagehandler/tst_qmessagehandler.cpp b/tests/auto/corelib/global/qmessagehandler/tst_qmessagehandler.cpp new file mode 100644 index 0000000000..39bd0986a5 --- /dev/null +++ b/tests/auto/corelib/global/qmessagehandler/tst_qmessagehandler.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qdebug.h> +#include <QtTest/QtTest> + +#include <qglobal.h> + +class tst_qmessagehandler : public QObject +{ + Q_OBJECT +private slots: + void cleanup(); + + void defaultHandler(); + void installMessageHandler(); + void installMsgHandler(); + void installBothHandler(); +}; + +static QtMsgType s_type; +const char *s_file; +int s_line; +const char *s_function; +static QString s_message; + +void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const char *msg) +{ + s_type = type; + s_file = context.file; + s_line = context.line; + s_function = context.function; + s_message = QString::fromLocal8Bit(msg); +} + +void customMsgHandler(QtMsgType type, const char *msg) +{ + s_type = type; + s_file = 0; + s_line = 0; + s_function = 0; + s_message = QString::fromLocal8Bit(msg); +} + +void tst_qmessagehandler::cleanup() +{ + qInstallMsgHandler(0); + qInstallMessageHandler(0); + s_type = QtFatalMsg; + s_file = 0; + s_line = 0; + s_function = 0; +} + +void tst_qmessagehandler::defaultHandler() +{ + // check that the default works + QTest::ignoreMessage(QtDebugMsg, "defaultHandler"); + qDebug("defaultHandler"); +} + +void tst_qmessagehandler::installMessageHandler() +{ + QMessageHandler oldHandler = qInstallMessageHandler(customMessageHandler); + + qDebug("installMessageHandler"); int line = __LINE__; + + QCOMPARE(s_type, QtDebugMsg); + QCOMPARE(s_message, QString::fromLocal8Bit("installMessageHandler")); + QCOMPARE(s_file, __FILE__); + QCOMPARE(s_function, Q_FUNC_INFO); + QCOMPARE(s_line, line); + + QMessageHandler myHandler = qInstallMessageHandler(oldHandler); + QCOMPARE((void*)myHandler, (void*)customMessageHandler); +} + +void tst_qmessagehandler::installMsgHandler() +{ + QtMsgHandler oldHandler = qInstallMsgHandler(customMsgHandler); + + qDebug("installMsgHandler"); + + QCOMPARE(s_type, QtDebugMsg); + QCOMPARE(s_message, QString::fromLocal8Bit("installMsgHandler")); + QCOMPARE(s_file, (const char*)0); + QCOMPARE(s_function, (const char*)0); + QCOMPARE(s_line, 0); + + QtMsgHandler myHandler = qInstallMsgHandler(oldHandler); + QCOMPARE((void*)myHandler, (void*)customMsgHandler); +} + +void tst_qmessagehandler::installBothHandler() +{ + qInstallMessageHandler(customMessageHandler); + qInstallMsgHandler(customMsgHandler); + + qDebug("installBothHandler"); int line = __LINE__; + + QCOMPARE(s_type, QtDebugMsg); + QCOMPARE(s_message, QString::fromLocal8Bit("installBothHandler")); + QCOMPARE(s_file, __FILE__); + QCOMPARE(s_function, Q_FUNC_INFO); + QCOMPARE(s_line, line); +} + +QTEST_MAIN(tst_qmessagehandler) +#include "tst_qmessagehandler.moc" diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index f73884fe02..064724e888 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/global/qrand/tst_qrand.cpp b/tests/auto/corelib/global/qrand/tst_qrand.cpp index 71f14e28e2..85618d94c2 100644 --- a/tests/auto/corelib/global/qrand/tst_qrand.cpp +++ b/tests/auto/corelib/global/qrand/tst_qrand.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index ae0b4968b8..095aa7a77d 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -22,6 +22,12 @@ SUBDIRS=\ qtemporaryfile \ qtextstream \ qurl \ + qwinoverlappedionotifier \ + +!win32|wince* { + SUBDIRS -=\ + qwinoverlappedionotifier +} !contains(QT_CONFIG, private_tests): SUBDIRS -= \ qfileinfo diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index ba2eced60a..e72960833f 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp index 1bffd63d1b..776ad4d0a7 100644 --- a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the FOO module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -47,10 +47,13 @@ #include <QtCore/QSharedPointer> #include <QtCore/QScopedPointer> #include <QtCore/QHash> +#include <QtCore/QDir> +#include <QtCore/QDirIterator> #include <QtTest/QTest> #include <QtCore/QDebug> +#include "../../../../shared/filesystem.h" class tst_QAbstractFileEngine : public QObject @@ -65,6 +68,8 @@ private slots: void fileIO_data(); void fileIO(); + void mounting_data(); + void mounting(); private: QStringList filesForRemoval; }; @@ -74,7 +79,7 @@ class ReferenceFileEngine { public: ReferenceFileEngine(const QString &fileName) - : fileName_(fileName) + : fileName_(QDir::cleanPath(fileName)) , position_(-1) , openForRead_(false) , openForWrite_(false) @@ -491,6 +496,60 @@ private: mutable QSharedPointer<File> openFile_; }; +class MountingFileEngine : public QFSFileEngine +{ +public: + class Iterator : public QAbstractFileEngineIterator + { + public: + Iterator(QDir::Filters filters, const QStringList &filterNames) + : QAbstractFileEngineIterator(filters, filterNames) + { + names.append("foo"); + names.append("bar"); + index = -1; + } + QString currentFileName() const + { + return names.at(index); + } + bool hasNext() const + { + return index < names.size() - 1; + } + QString next() + { + if (!hasNext()) + return QString(); + ++index; + return currentFilePath(); + } + QStringList names; + int index; + }; + MountingFileEngine(QString fileName) + : QFSFileEngine(fileName) + { + } + Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) + { + return new Iterator(filters, filterNames); + } + FileFlags fileFlags(FileFlags type) const + { + if (fileName(DefaultName).endsWith(".tar")) { + FileFlags ret = QFSFileEngine::fileFlags(type); + //make this file in file system appear to be a directory + ret &= ~FileType; + ret |= DirectoryType; + return ret; + } else { + //file inside the archive + return ExistsFlag | FileType; + } + } +}; + QMutex ReferenceFileEngine::fileSystemMutex; QHash<uint, QString> ReferenceFileEngine::fileSystemUsers, ReferenceFileEngine::fileSystemGroups; QHash<QString, QSharedPointer<ReferenceFileEngine::File> > ReferenceFileEngine::fileSystem; @@ -500,6 +559,8 @@ class FileEngineHandler { QAbstractFileEngine *create(const QString &fileName) const { + if (fileName.endsWith(".tar") || fileName.contains(".tar/")) + return new MountingFileEngine(fileName); if (fileName.startsWith("QFSFileEngine:")) return new QFSFileEngine(fileName.mid(14)); if (fileName.startsWith("reference-file-engine:")) @@ -803,6 +864,36 @@ void tst_QAbstractFileEngine::fileIO() // } +void tst_QAbstractFileEngine::mounting_data() +{ + QTest::addColumn<QString>("fileName"); + QTest::newRow("native") << "test.tar"; + QTest::newRow("Forced QFSFileEngine") << "QFSFileEngine:test.tar"; +} + +void tst_QAbstractFileEngine::mounting() +{ + FileSystem fs; + QVERIFY(fs.createFile("test.tar")); + FileEngineHandler handler; + + QFETCH(QString, fileName); + + QVERIFY(QFileInfo(fileName).isDir()); + QDir dir(fileName); + QCOMPARE(dir.entryList(), (QStringList() << "bar" << "foo")); + QDir dir2; + bool found = false; + foreach (QFileInfo info, dir2.entryInfoList()) { + if (info.fileName() == QLatin1String("test.tar")) { + QVERIFY(!found); + found = true; + QVERIFY(info.isDir()); + } + } + QVERIFY(found); +} + QTEST_APPLESS_MAIN(tst_QAbstractFileEngine) #include "tst_qabstractfileengine.moc" diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp index e2890d7891..bf62621bbc 100644 --- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index d17bab3bc1..eb227625a7 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -65,11 +65,6 @@ private slots: void stream_bool_data(); void stream_bool(); - void stream_QBool_data(); - void stream_QBool(); - - void stream_QBool_in_4_0(); - void stream_QBitArray_data(); void stream_QBitArray(); @@ -193,7 +188,6 @@ private slots: private: void writebool(QDataStream *s); - void writeQBool(QDataStream *s); void writeQBitArray(QDataStream *s); void writeQBrush(QDataStream *s); void writeQColor(QDataStream *s); @@ -221,7 +215,6 @@ private: void writeQEasingCurve(QDataStream *s); void readbool(QDataStream *s); - void readQBool(QDataStream *s); void readQBitArray(QDataStream *s); void readQBrush(QDataStream *s); void readQColor(QDataStream *s); @@ -262,7 +255,8 @@ static int NColorRoles[] = { QPalette::ToolTipText + 1, // Qt_4_4 QPalette::ToolTipText + 1, // Qt_4_5 QPalette::ToolTipText + 1, // Qt_4_6 - 0 // add the correct value for Qt_4_7 here later + QPalette::ToolTipText + 1, // Qt_5_0 + 0 // add the correct value for Qt_5_1 here later }; // Testing get/set functions @@ -292,6 +286,7 @@ void tst_QDataStream::getSetCheck() void tst_QDataStream::cleanupTestCase() { QFile::remove(QLatin1String("qdatastream.out")); + QFile::remove(QLatin1String("datastream.tmp")); } static int dataIndex(const QString &tag) @@ -797,57 +792,6 @@ void tst_QDataStream::readbool(QDataStream *s) // ************************************ -static QBool QBoolData(int index) -{ - switch (index) { - case 0: return QBool(true); - case 1: return QBool(false); - case 2: return QBool(bool(2)); - case 3: return QBool(bool(-1)); - case 4: return QBool(bool(127)); - } - - return QBool(false); -} - -void tst_QDataStream::stream_QBool_data() -{ - stream_data(5); -} - -void tst_QDataStream::stream_QBool() -{ - STREAM_IMPL(QBool); -} - -void tst_QDataStream::writeQBool(QDataStream *s) -{ - QBool d1 = QBoolData(dataIndex(QTest::currentDataTag())); - *s << d1; -} - -void tst_QDataStream::readQBool(QDataStream *s) -{ - QBool expected = QBoolData(dataIndex(QTest::currentDataTag())); - - bool d1 = true; - *s >> d1; - QVERIFY(d1 == expected); -} - -void tst_QDataStream::stream_QBool_in_4_0() -{ - QByteArray byteArray; - QDataStream out(&byteArray, QIODevice::WriteOnly); - - QString str("ABC"); - out << str.contains('A') << str.contains('Z'); - - QCOMPARE(byteArray.size(), 2); -} - -// ************************************ - static void QBitArrayData(QBitArray *b, int index) { QString filler = ""; diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 535807bfc3..12f7e28a1d 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -51,9 +51,10 @@ private slots: void assignment() const; void warningWithoutDebug() const; void criticalWithoutDebug() const; - void debugWithQBool() const; + void debugWithBool() const; void veryLongWarningMessage() const; void qDebugQStringRef() const; + void qDebugQLatin1String() const; void defaultMessagehandler() const; }; @@ -74,11 +75,17 @@ void tst_QDebug::assignment() const static QtMsgType s_msgType; static QByteArray s_msg; +static QByteArray s_file; +static int s_line; +static QByteArray s_function; -static void myMessageHandler(QtMsgType type, const char *msg) +static void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const char *msg) { s_msg = msg; s_msgType = type; + s_file = context.file; + s_line = context.line; + s_function = context.function; } // Helper class to ensure that the testlib message handler gets @@ -87,17 +94,17 @@ static void myMessageHandler(QtMsgType type, const char *msg) class MessageHandlerSetter { public: - MessageHandlerSetter(QtMsgHandler newMsgHandler) - : oldMsgHandler(qInstallMsgHandler(newMsgHandler)) + MessageHandlerSetter(QMessageHandler newMessageHandler) + : oldMessageHandler(qInstallMessageHandler(newMessageHandler)) { } ~MessageHandlerSetter() { - qInstallMsgHandler(oldMsgHandler); + qInstallMessageHandler(oldMessageHandler); } private: - QtMsgHandler oldMsgHandler; + QMessageHandler oldMessageHandler; }; /*! \internal @@ -107,8 +114,12 @@ void tst_QDebug::warningWithoutDebug() const { MessageHandlerSetter mhs(myMessageHandler); { qWarning() << "A qWarning() message"; } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; QCOMPARE(s_msgType, QtWarningMsg); QCOMPARE(QString::fromLatin1(s_msg.data()), QString::fromLatin1("A qWarning() message ")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); } /*! \internal @@ -118,16 +129,24 @@ void tst_QDebug::criticalWithoutDebug() const { MessageHandlerSetter mhs(myMessageHandler); { qCritical() << "A qCritical() message"; } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; QCOMPARE(s_msgType, QtCriticalMsg); QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("A qCritical() message ")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); } -void tst_QDebug::debugWithQBool() const +void tst_QDebug::debugWithBool() const { MessageHandlerSetter mhs(myMessageHandler); - { qDebug() << QBool(false) << QBool(true); } + { qDebug() << false << true; } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("false true ")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); } void tst_QDebug::veryLongWarningMessage() const @@ -140,8 +159,12 @@ void tst_QDebug::veryLongWarningMessage() const test.append(part); qWarning("Test output:\n%s\nend", qPrintable(test)); } + QString file = __FILE__; int line = __LINE__ - 2; QString function = Q_FUNC_INFO; QCOMPARE(s_msgType, QtWarningMsg); QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("Test output:\n")+test+QString::fromLatin1("\nend")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); } void tst_QDebug::qDebugQStringRef() const @@ -153,8 +176,12 @@ void tst_QDebug::qDebugQStringRef() const MessageHandlerSetter mhs(myMessageHandler); { qDebug() << inRef; } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"input\" ")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); } /* Use a null QStringRef. */ @@ -163,19 +190,35 @@ void tst_QDebug::qDebugQStringRef() const MessageHandlerSetter mhs(myMessageHandler); { qDebug() << inRef; } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"\" ")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); } } +void tst_QDebug::qDebugQLatin1String() const +{ + MessageHandlerSetter mhs(myMessageHandler); + { qDebug() << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3); } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"foo\" \"\" \"bar\" ")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); +} + void tst_QDebug::defaultMessagehandler() const { MessageHandlerSetter mhs(0); - QtMsgHandler defaultMessageHandler1 = qInstallMsgHandler(0); - QtMsgHandler defaultMessageHandler2 = qInstallMsgHandler(myMessageHandler); + QMessageHandler defaultMessageHandler1 = qInstallMessageHandler(0); + QMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler); bool same = (*defaultMessageHandler1 == *defaultMessageHandler2); QVERIFY(same); - QtMsgHandler messageHandler = qInstallMsgHandler(0); + QMessageHandler messageHandler = qInstallMessageHandler(0); same = (*messageHandler == *myMessageHandler); QVERIFY(same); } diff --git a/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp b/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp index 01cbc13d40..4d3d8e6f45 100644 --- a/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp +++ b/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp index 01cbc13d40..4d3d8e6f45 100644 --- a/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 1f4e05d0cd..f1c9015092 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -1848,8 +1848,6 @@ void tst_QDir::equalityOperator_data() //need a path in the root directory that is unlikely to be a symbolic link. #if defined (Q_OS_WIN) QString pathinroot("c:/windows/.."); -#elif defined (Q_OS_SYMBIAN) - QString pathinroot("c:/data/.."); #else QString pathinroot("/sbin/.."); #endif diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index 3b3b2b5a04..ad61db51d6 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qfile/stdinprocess/main.cpp b/tests/auto/corelib/io/qfile/stdinprocess/main.cpp index 14cb28af6b..6698440b70 100644 --- a/tests/auto/corelib/io/qfile/stdinprocess/main.cpp +++ b/tests/auto/corelib/io/qfile/stdinprocess/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro index 2f1e50010c..2611ff39bd 100644 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ b/tests/auto/corelib/io/qfile/test/test.pro @@ -9,13 +9,6 @@ TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \ ../Makefile ../forCopying.txt ../forRenaming.txt \ ../resources/file1.ext1 -win32 { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_qfile - } else { - TARGET = ../../release/tst_qfile - } - LIBS+=-lole32 -luuid -} +win32: LIBS+=-lole32 -luuid mac*:CONFIG+=insignificant_test diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 0549fe32f0..00e45354ba 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -343,9 +343,9 @@ void tst_QFile::cleanup() void tst_QFile::initTestCase() { - // chdir to testdata directory and use relative paths. - QString testdata_dir = QFileInfo(QFINDTESTDATA("testfile.txt")).absolutePath(); - QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); + QString workingDir = QFileInfo(QFINDTESTDATA("stdinprocess")).absolutePath(); + QVERIFY2(!workingDir.isEmpty(), qPrintable("Could not find working directory!")); + QVERIFY2(QDir::setCurrent(workingDir), qPrintable("Could not chdir to " + workingDir)); QFile::remove("noreadfile"); @@ -832,7 +832,7 @@ void tst_QFile::readAllStdin() QByteArray lotsOfData(1024, '@'); // 10 megs QProcess process; - process.start(QFINDTESTDATA("stdinprocess/stdinprocess")+" all"); + process.start("stdinprocess/stdinprocess all"); QVERIFY( process.waitForStarted() ); for (int i = 0; i < 5; ++i) { QTest::qWait(1000); @@ -867,7 +867,7 @@ void tst_QFile::readLineStdin() for (int i = 0; i < 2; ++i) { QProcess process; - process.start((QFINDTESTDATA("stdinprocess/stdinprocess")+QString(" line %1").arg(i)), QIODevice::Text | QIODevice::ReadWrite); + process.start((QString("stdinprocess/stdinprocess line %1").arg(i)), QIODevice::Text | QIODevice::ReadWrite); for (int i = 0; i < 5; ++i) { QTest::qWait(1000); process.write(lotsOfData); @@ -901,7 +901,7 @@ void tst_QFile::readLineStdin_lineByLine() #else for (int i = 0; i < 2; ++i) { QProcess process; - process.start(QFINDTESTDATA("stdinprocess/stdinprocess")+ QString(" line %1").arg(i), QIODevice::Text | QIODevice::ReadWrite); + process.start(QString("stdinprocess/stdinprocess line %1").arg(i), QIODevice::Text | QIODevice::ReadWrite); QVERIFY(process.waitForStarted()); for (int j = 0; j < 3; ++j) { diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 5764cee66d..7b80152b62 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -1028,6 +1028,19 @@ void tst_QFileInfo::fileTimes() //In Vista the last-access timestamp is not updated when the file is accessed/touched (by default). //To enable this the HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisableLastAccessUpdate //is set to 0, in the test machine. +#ifdef Q_OS_WIN + HKEY key; + if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\FileSystem", + 0, KEY_READ, &key)) { + DWORD disabledAccessTimes = 0; + DWORD size = sizeof(DWORD); + LONG error = RegQueryValueEx(key, L"NtfsDisableLastAccessUpdate" + , NULL, NULL, (LPBYTE)&disabledAccessTimes, &size); + if (ERROR_SUCCESS == error && disabledAccessTimes) + QEXPECT_FAIL("", "File access times are disabled in windows registry (this is the default setting)", Continue); + RegCloseKey(key); + } +#endif #ifdef Q_OS_WINCE QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); #endif @@ -1362,7 +1375,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QString junction = "junction_pwd"; FileSystem::createNtfsJunction(target, junction); QFileInfo targetInfo(target); - QTest::newRow("junction_pwd") << junction << true << targetInfo.absoluteFilePath() << targetInfo.canonicalFilePath(); + QTest::newRow("junction_pwd") << junction << false << QString() << QString(); QFileInfo fileInJunction(targetInfo.absoluteFilePath().append("/file")); QFile file(fileInJunction.absoluteFilePath()); @@ -1375,7 +1388,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() junction = "junction_root"; FileSystem::createNtfsJunction(target, junction); targetInfo.setFile(target); - QTest::newRow("junction_root") << junction << true << targetInfo.absoluteFilePath() << targetInfo.canonicalFilePath(); + QTest::newRow("junction_root") << junction << false << QString() << QString(); //Mountpoint typedef BOOLEAN (WINAPI *PtrGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD); @@ -1390,7 +1403,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() junction = "mountpoint"; rootVolume.replace("\\\\?\\","\\??\\"); FileSystem::createNtfsJunction(rootVolume, junction); - QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); + QTest::newRow("mountpoint") << junction << false << QString() << QString(); } } @@ -1403,8 +1416,10 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() QFileInfo fi(path); QCOMPARE(fi.isSymLink(), isSymLink); - QCOMPARE(fi.symLinkTarget(), linkTarget); - QCOMPARE(fi.canonicalFilePath(), canonicalFilePath); + if (isSymLink) { + QCOMPARE(fi.symLinkTarget(), linkTarget); + QCOMPARE(fi.canonicalFilePath(), canonicalFilePath); + } } void tst_QFileInfo::brokenShortcut() @@ -1632,6 +1647,12 @@ BOOL IsUserAdmin() } #endif +#if defined(Q_OS_WIN) +QT_BEGIN_NAMESPACE +extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; +QT_END_NAMESPACE +#endif + void tst_QFileInfo::owner() { QString userName; @@ -1672,7 +1693,6 @@ void tst_QFileInfo::owner() NetApiBufferFree(pBuf); } } - extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; qt_ntfs_permission_lookup = 1; #endif if (userName.isEmpty()) diff --git a/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp index cc75801638..fe2e30a95c 100644 --- a/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 05b2539182..5e5a99f937 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index b1c02a6c02..07a1fff993 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp index bca4d55037..0eea94f5d9 100644 --- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp +++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp index 5851ffe3da..5edb5489f7 100644 --- a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp +++ b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testDetached/main.cpp b/tests/auto/corelib/io/qprocess/testDetached/main.cpp index bcf237f488..c1231d3c71 100644 --- a/tests/auto/corelib/io/qprocess/testDetached/main.cpp +++ b/tests/auto/corelib/io/qprocess/testDetached/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp b/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp index 1475b3354d..ad8e69cad9 100644 --- a/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp +++ b/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp b/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp index c9e5d2e6a5..e4fba49090 100644 --- a/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp +++ b/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp b/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp index b7c0511d77..cb675b7369 100644 --- a/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp index 97d9208e19..cf33f22bc6 100644 --- a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp index bf3d190630..ad1ebfc5f2 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp index 0c915918e4..872ed4fad4 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp index 8f3bd70a3a..0578f4794f 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp index c5eb4df307..bfcc48832e 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp index 877b3c6175..a8a17b6951 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp index 146b61af0e..eab1ebac17 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessLoopback/main.cpp b/tests/auto/corelib/io/qprocess/testProcessLoopback/main.cpp index 78973f9f12..8b886ba5de 100644 --- a/tests/auto/corelib/io/qprocess/testProcessLoopback/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessLoopback/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp b/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp index 4fc8ea197c..b8b85730a8 100644 --- a/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp b/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp index 5284607e9f..fa2b60d542 100644 --- a/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp index 57fb68e841..d76e3054a3 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp index 6ce8892354..72af4df489 100644 --- a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp +++ b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp b/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp index fa368489d6..ef02de269f 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp +++ b/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp b/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp index 87ba12c008..e37fba6099 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp +++ b/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp b/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp index d42b8ed083..75862c682e 100644 --- a/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp +++ b/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index e16e00de91..c3c4607119 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -1000,9 +1000,21 @@ public: } } + void writeAfterStart(const char *buf, int count) + { + dataToWrite = QByteArray(buf, count); + } + + void start(const QString &program) + { + QProcess::start(program); + writePendingData(); + } + public slots: void terminateSlot() { + writePendingData(); // In cases 3 and 4 we haven't written the data yet. if (killing || (n == 4 && state() != Running)) { // Don't try to kill the process before it is running - that can // be hazardous, as the actual child process might not be running @@ -1025,8 +1037,18 @@ public slots: } private: + void writePendingData() + { + if (!dataToWrite.isEmpty()) { + write(dataToWrite); + dataToWrite.clear(); + } + } + +private: int n; bool killing; + QByteArray dataToWrite; }; //----------------------------------------------------------------------------- @@ -1049,11 +1071,10 @@ void tst_QProcess::softExitInSlots() for (int i = 0; i < 5; ++i) { SoftExitProcess proc(i); + proc.writeAfterStart("OLEBOLE", 8); // include the \0 proc.start(appName); - proc.write("OLEBOLE", 8); // include the \0 - QTestEventLoop::instance().enterLoop(10); + QTRY_VERIFY(proc.waitedForFinished); QCOMPARE(proc.state(), QProcess::NotRunning); - QVERIFY(proc.waitedForFinished); } } diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index 50579f0712..15eb7d3c48 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 539f49fa97..fa72083dcc 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 87f5b37e14..0d6443c5ac 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 1820d66496..1e288e2418 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -142,6 +142,7 @@ void tst_qstandardpaths::testLocateAll() setCustomLocations(); const QStringList allFiles = QStandardPaths::locateAll(QStandardPaths::ConfigLocation, "qstandardpaths.pro"); + QVERIFY2(allFiles.count() > 0, "qstandardpaths.pro not found in config locations!"); QCOMPARE(allFiles.first(), QString(m_thisDir + QString::fromLatin1("/qstandardpaths.pro"))); #endif } diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 86aa071410..46d2fa2bde 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -228,6 +228,9 @@ void tst_QTemporaryDir::autoRemove() void tst_QTemporaryDir::nonWritableCurrentDir() { #ifdef Q_OS_UNIX + if (::geteuid() == 0) + QSKIP("not valid running this test as root"); + struct ChdirOnReturn { ChdirOnReturn(const QString& d) : dir(d) {} diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 4c2e3f211b..cda29fdf0b 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -256,6 +256,9 @@ void tst_QTemporaryFile::autoRemove() void tst_QTemporaryFile::nonWritableCurrentDir() { #ifdef Q_OS_UNIX + if (::geteuid() == 0) + QSKIP("not valid running this test as root"); + struct ChdirOnReturn { ChdirOnReturn(const QString& d) : dir(d) {} diff --git a/tests/auto/corelib/io/qtextstream/readAllStdinProcess/main.cpp b/tests/auto/corelib/io/qtextstream/readAllStdinProcess/main.cpp index a33b6759b4..282ec22013 100644 --- a/tests/auto/corelib/io/qtextstream/readAllStdinProcess/main.cpp +++ b/tests/auto/corelib/io/qtextstream/readAllStdinProcess/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qtextstream/readLineStdinProcess/main.cpp b/tests/auto/corelib/io/qtextstream/readLineStdinProcess/main.cpp index e561fc886f..174a8368fe 100644 --- a/tests/auto/corelib/io/qtextstream/readLineStdinProcess/main.cpp +++ b/tests/auto/corelib/io/qtextstream/readLineStdinProcess/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qtextstream/stdinProcess/main.cpp b/tests/auto/corelib/io/qtextstream/stdinProcess/main.cpp index 7fcfd6d53b..dfdd431040 100644 --- a/tests/auto/corelib/io/qtextstream/stdinProcess/main.cpp +++ b/tests/auto/corelib/io/qtextstream/stdinProcess/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 6b6ac013bd..01aecc2a21 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -170,6 +170,7 @@ private slots: // text write operators void string_write_operator_ToDevice_data(); void string_write_operator_ToDevice(); + void latin1String_write_operator_ToDevice(); // other void skipWhiteSpace_data(); @@ -2384,6 +2385,20 @@ void tst_QTextStream::string_write_operator_ToDevice() } } +void tst_QTextStream::latin1String_write_operator_ToDevice() +{ + QBuffer buf; + buf.open(QBuffer::WriteOnly); + QTextStream stream(&buf); + stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); + stream.setAutoDetectUnicode(true); + + stream << QLatin1String("No explicit length"); + stream << QLatin1String("Explicit length - ignore this part", 15); + stream.flush(); + QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length"); +} + // ------------------------------------------------------------------------------ void tst_QTextStream::useCase1() { diff --git a/tests/auto/corelib/io/qurl/idna-test.c b/tests/auto/corelib/io/qurl/idna-test.c index 40538dfb65..3aabaad03f 100644 --- a/tests/auto/corelib/io/qurl/idna-test.c +++ b/tests/auto/corelib/io/qurl/idna-test.c @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index f0b6429089..611847852f 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -81,6 +81,8 @@ private slots: void effectiveTLDs(); void getSetCheck(); void constructing(); + void hashInPath(); + void unc(); void assignment(); void comparison(); void copying(); @@ -134,6 +136,7 @@ private slots: void toPercentEncoding(); void isRelative_data(); void isRelative(); + void setQueryItems(); void queryItems(); void hasQuery_data(); void hasQuery(); @@ -242,35 +245,6 @@ void tst_QUrl::constructing() QCOMPARE(url.port(), -1); QCOMPARE(url.toString(), QString()); - QList<QPair<QString, QString> > query; - query += qMakePair(QString("type"), QString("login")); - query += qMakePair(QString("name"), QString("åge nissemannsen")); - query += qMakePair(QString("ole&du"), QString("anne+jørgen=sant")); - query += qMakePair(QString("prosent"), QString("%")); - url.setQueryItems(query); - QVERIFY(!url.isEmpty()); - - QCOMPARE(url.encodedQuery().constData(), - QByteArray("type=login&name=%C3%A5ge%20nissemannsen&ole%26du=" - "anne+j%C3%B8rgen%3Dsant&prosent=%25").constData()); - - url.setQueryDelimiters('>', '/'); - url.setQueryItems(query); - - QCOMPARE(url.encodedQuery(), - QByteArray("type>login/name>%C3%A5ge%20nissemannsen/ole&du>" - "anne+j%C3%B8rgen=sant/prosent>%25")); - - url.setFragment(QString::fromLatin1("top")); - QCOMPARE(url.fragment(), QString::fromLatin1("top")); - - url.setScheme("http"); - url.setHost("qt.nokia.com"); - - QCOMPARE(url.toString(), - QString::fromLatin1("http://qt.nokia.com?type>login/name>åge nissemannsen" - "/ole&du>anne+jørgen=sant/prosent>%#top")); - QUrl justHost("qt.nokia.com"); QVERIFY(!justHost.isEmpty()); QVERIFY(justHost.host().isEmpty()); @@ -279,16 +253,22 @@ void tst_QUrl::constructing() QUrl hostWithSlashes("//qt.nokia.com"); QVERIFY(hostWithSlashes.path().isEmpty()); QCOMPARE(hostWithSlashes.host(), QString::fromLatin1("qt.nokia.com")); +} - +void tst_QUrl::hashInPath() +{ QUrl withHashInPath; withHashInPath.setPath(QString::fromLatin1("hi#mum.txt")); QCOMPARE(withHashInPath.path(), QString::fromLatin1("hi#mum.txt")); QCOMPARE(withHashInPath.toEncoded(), QByteArray("hi%23mum.txt")); + QCOMPARE(withHashInPath.toString(), QString("hi%23mum.txt")); + QUrl fromHashInPath = QUrl::fromEncoded(withHashInPath.toEncoded()); QVERIFY(withHashInPath == fromHashInPath); +} - +void tst_QUrl::unc() +{ QUrl buildUNC; buildUNC.setScheme(QString::fromLatin1("file")); buildUNC.setHost(QString::fromLatin1("somehost")); @@ -375,7 +355,7 @@ void tst_QUrl::setUrl() { QUrl url("hTTp://www.foo.bar:80"); QVERIFY(url.isValid()); - QCOMPARE(url.scheme(), QString::fromLatin1("hTTp")); + QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.path(), QString()); QVERIFY(url.encodedQuery().isEmpty()); QVERIFY(url.userInfo().isEmpty()); @@ -385,7 +365,7 @@ void tst_QUrl::setUrl() QCOMPARE(url.port(), 80); QUrl url2("//www1.foo.bar"); - QCOMPARE(url.resolved(url2).toString(), QString::fromLatin1("hTTp://www1.foo.bar")); + QCOMPARE(url.resolved(url2).toString(), QString::fromLatin1("http://www1.foo.bar")); } { @@ -544,13 +524,11 @@ void tst_QUrl::setUrl() } { - QUrl notPretty; - notPretty.setEncodedUrl("http://ferret.lmh.ox.ac.uk/%7Ekdecvs/"); + QUrl notPretty("http://ferret.lmh.ox.ac.uk/%7Ekdecvs/"); QVERIFY(notPretty.isValid()); QCOMPARE(notPretty.toString(), QString::fromLatin1("http://ferret.lmh.ox.ac.uk/~kdecvs/")); - QUrl notPretty2; - notPretty2.setEncodedUrl("file:/home/test/directory%20with%20spaces"); + QUrl notPretty2("file:/home/test/directory%20with%20spaces"); QVERIFY(notPretty2.isValid()); QCOMPARE(notPretty2.toString(), QString::fromLatin1("file:///home/test/directory with spaces")); @@ -564,7 +542,7 @@ void tst_QUrl::setUrl() QCOMPARE(url15581.toEncoded().constData(), QByteArray("http://alain.knaff.linux.lu/bug-reports/kde/spaces%20in%20url.html").constData()); QUrl url15582("http://alain.knaff.linux.lu/bug-reports/kde/percentage%in%url.html"); - QCOMPARE(url15582.toString(), QString::fromLatin1("http://alain.knaff.linux.lu/bug-reports/kde/percentage%in%url.html")); + QCOMPARE(url15582.toString(), QString::fromLatin1("http://alain.knaff.linux.lu/bug-reports/kde/percentage%25in%25url.html")); QCOMPARE(url15582.toEncoded(), QByteArray("http://alain.knaff.linux.lu/bug-reports/kde/percentage%25in%25url.html")); } @@ -577,8 +555,7 @@ void tst_QUrl::setUrl() charles.setPath("/home/charles/foo%20moo"); QCOMPARE(charles.path(), QString::fromLatin1("/home/charles/foo%20moo")); - QUrl charles2; - charles2.setEncodedUrl("file:/home/charles/foo%20moo"); + QUrl charles2("file:/home/charles/foo%20moo"); QCOMPARE(charles2.path(), QString::fromLatin1("/home/charles/foo moo")); } @@ -642,8 +619,7 @@ void tst_QUrl::setUrl() } { - QUrl url; - url.setEncodedUrl("data:text/javascript,d5%20%3D%20'five\\u0027s'%3B"); + QUrl url("data:text/javascript,d5%20%3D%20'five\\u0027s'%3B"); QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString("data")); QCOMPARE(url.host(), QString()); @@ -665,11 +641,11 @@ void tst_QUrl::i18n_data() QTest::addColumn<QString>("input"); QTest::addColumn<QByteArray>("punyOutput"); - QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") - << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); - QTest::newRow("räksmörgås") << QString::fromLatin1("http://www.räksmörgås.no/") + QTest::newRow("øl") << QString::fromUtf8("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") + << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); + QTest::newRow("räksmörgÃ¥s") << QString::fromUtf8("http://www.räksmörgÃ¥s.no/") << QByteArray("http://www.xn--rksmrgs-5wao1o.no/"); - QTest::newRow("bühler") << QString::fromLatin1("http://www.bühler.no/") + QTest::newRow("bühler") << QString::fromUtf8("http://www.bühler.no/") << QByteArray("http://www.xn--bhler-kva.no/"); QTest::newRow("non-latin1") << QString::fromUtf8("http://www.\316\261\316\270\316\256\316\275\316\261.info") @@ -1338,7 +1314,7 @@ void tst_QUrl::compat_decode_data() QTest::newRow("HTTPUrl") << QByteArray("http://qt.nokia.com") << QString("http://qt.nokia.com"); QTest::newRow("HTTPUrlEncoded") << QByteArray("http://qt%20nokia%20com") << QString("http://qt nokia com"); QTest::newRow("EmptyString") << QByteArray("") << QString(""); - QTest::newRow("Task27166") << QByteArray("Fran%C3%A7aise") << QString("Française"); + QTest::newRow("Task27166") << QByteArray("Fran%C3%A7aise") << QString::fromUtf8("Française"); } void tst_QUrl::compat_decode() @@ -1360,7 +1336,7 @@ void tst_QUrl::compat_encode_data() QTest::newRow("HTTPUrl") << QString("http://qt.nokia.com") << QByteArray("http%3A//qt.nokia.com"); QTest::newRow("HTTPUrlEncoded") << QString("http://qt nokia com") << QByteArray("http%3A//qt%20nokia%20com"); QTest::newRow("EmptyString") << QString("") << QByteArray(""); - QTest::newRow("Task27166") << QString::fromLatin1("Française") << QByteArray("Fran%C3%A7aise"); + QTest::newRow("Task27166") << QString::fromUtf8("Française") << QByteArray("Fran%C3%A7aise"); } void tst_QUrl::compat_encode() @@ -1393,7 +1369,7 @@ void tst_QUrl::percentEncoding_data() QTest::addColumn<QByteArray>("encoded"); QTest::newRow("test_01") << QString::fromLatin1("sdfsdf") << QByteArray("sdfsdf"); - QTest::newRow("test_02") << QString::fromLatin1("æss") << QByteArray("%C3%A6ss"); + QTest::newRow("test_02") << QString::fromUtf8("æss") << QByteArray("%C3%A6ss"); // not unreserved or reserved QTest::newRow("test_03") << QString::fromLatin1("{}") << QByteArray("%7B%7D"); } @@ -1407,6 +1383,7 @@ void tst_QUrl::percentEncoding() QVERIFY(QUrl::fromEncoded(QUrl(original).toEncoded()) == QUrl(original)); QCOMPARE(QUrl::fromEncoded(QUrl(original).toEncoded()).toString(), original); QVERIFY(QUrl::fromEncoded(encoded) == QUrl(original)); + QCOMPARE(QUrl(QUrl(original).toString()).toString(), original); } void tst_QUrl::toPercentEncoding_data() @@ -1460,15 +1437,15 @@ void tst_QUrl::swap() void tst_QUrl::symmetry() { - QUrl url(QString::fromLatin1("http://www.räksmörgås.se/pub?a=b&a=dø&a=f#vræl")); + QUrl url(QString::fromUtf8("http://www.räksmörgÃ¥s.se/pub?a=b&a=dø&a=f#vræl")); QCOMPARE(url.scheme(), QString::fromLatin1("http")); - QCOMPARE(url.host(), QString::fromLatin1("www.räksmörgås.se")); + QCOMPARE(url.host(), QString::fromUtf8("www.räksmörgÃ¥s.se")); QCOMPARE(url.path(), QString::fromLatin1("/pub")); // this will be encoded ... QCOMPARE(url.encodedQuery().constData(), QString::fromLatin1("a=b&a=d%C3%B8&a=f").toLatin1().constData()); // unencoded - QCOMPARE(url.allQueryItemValues("a").join("").toLatin1().constData(), "bdøf"); - QCOMPARE(url.fragment(), QString::fromLatin1("vræl")); + QCOMPARE(url.allQueryItemValues("a").join(""), QString::fromUtf8("bdøf")); + QCOMPARE(url.fragment(), QString::fromUtf8("vræl")); QUrl onlyHost("//qt.nokia.com"); QCOMPARE(onlyHost.toString(), QString::fromLatin1("//qt.nokia.com")); @@ -1480,14 +1457,16 @@ void tst_QUrl::symmetry() QByteArray b = urlPreviewList.toEncoded(); QCOMPARE(b.constData(), "http://desktop:33326/upnp/%7B32f525a6-6f31-426e-91ca-01c2e6c2c57e%7D"); QCOMPARE(QUrl::fromEncoded(b).toString(), urlString); - - }{ + QCOMPARE(QUrl(b).toString(), urlString); + } + { QString urlString = QString::fromLatin1("http://desktop:53423/deviceDescription?uuid={7977c17b-00bf-4af9-894e-fed28573c3a9}"); QUrl urlPreviewList(urlString); QCOMPARE(urlPreviewList.toString(), urlString); QByteArray b = urlPreviewList.toEncoded(); QCOMPARE(b.constData(), "http://desktop:53423/deviceDescription?uuid=%7B7977c17b-00bf-4af9-894e-fed28573c3a9%7D"); QCOMPARE(QUrl::fromEncoded(b).toString(), urlString); + QCOMPARE(QUrl(b).toString(), urlString); } } @@ -1567,9 +1546,9 @@ void tst_QUrl::punycode_data() QTest::addColumn<QString>("original"); QTest::addColumn<QByteArray>("encoded"); - QTest::newRow("øl") << QString::fromLatin1("øl") << QByteArray("xn--l-4ga"); - QTest::newRow("Bühler") << QString::fromLatin1("Bühler") << QByteArray("xn--Bhler-kva"); - QTest::newRow("räksmörgås") << QString::fromLatin1("räksmörgås") << QByteArray("xn--rksmrgs-5wao1o"); + QTest::newRow("øl") << QString::fromUtf8("øl") << QByteArray("xn--l-4ga"); + QTest::newRow("Bühler") << QString::fromUtf8("Bühler") << QByteArray("xn--Bhler-kva"); + QTest::newRow("räksmörgÃ¥s") << QString::fromUtf8("räksmörgÃ¥s") << QByteArray("xn--rksmrgs-5wao1o"); } void tst_QUrl::punycode() @@ -1608,6 +1587,43 @@ void tst_QUrl::isRelative() QCOMPARE(QUrl(url).isRelative(), trueFalse); } +void tst_QUrl::setQueryItems() +{ + QUrl url; + + QList<QPair<QString, QString> > query; + query += qMakePair(QString("type"), QString("login")); + query += qMakePair(QString("name"), QString::fromUtf8("Ã¥ge nissemannsen")); + query += qMakePair(QString("ole&du"), QString::fromUtf8("anne+jørgen=sant")); + query += qMakePair(QString("prosent"), QString("%")); + url.setQueryItems(query); + QVERIFY(!url.isEmpty()); + + QCOMPARE(url.encodedQuery().constData(), + QByteArray("type=login&name=%C3%A5ge%20nissemannsen&ole%26du=" + "anne+j%C3%B8rgen%3Dsant&prosent=%25").constData()); + + url.setQueryDelimiters('>', '/'); + url.setQueryItems(query); + + QCOMPARE(url.encodedQuery(), + QByteArray("type>login/name>%C3%A5ge%20nissemannsen/ole&du>" + "anne+j%C3%B8rgen=sant/prosent>%25")); + + url.setFragment(QString::fromLatin1("top")); + QCOMPARE(url.fragment(), QString::fromLatin1("top")); + + url.setScheme("http"); + url.setHost("qt.nokia.com"); + + QCOMPARE(url.toEncoded().constData(), + "http://qt.nokia.com?type>login/name>%C3%A5ge%20nissemannsen/ole&du>" + "anne+j%C3%B8rgen=sant/prosent>%25#top"); + QCOMPARE(url.toString(), + QString::fromUtf8("http://qt.nokia.com?type>login/name>Ã¥ge nissemannsen" + "/ole&du>anne+jørgen=sant/prosent>%25#top")); +} + void tst_QUrl::queryItems() { QUrl url; @@ -1844,8 +1860,7 @@ void tst_QUrl::tolerantParser() QCOMPARE(url.path(), QString("/path with spaces.html")); QCOMPARE(url.toEncoded(), QByteArray("http://www.example.com/path%20with%20spaces.html")); url.setUrl("http://www.example.com/path%20with spaces.html", QUrl::StrictMode); - QVERIFY(url.isValid()); - QCOMPARE(url.toEncoded(), QByteArray("http://www.example.com/path%2520with%20spaces.html")); + QVERIFY(!url.isValid()); } { QUrl url = QUrl::fromEncoded("http://www.example.com/path%20with spaces.html"); @@ -1940,7 +1955,7 @@ void tst_QUrl::correctEncodedMistakes_data() { QTest::addColumn<QByteArray>("encodedUrl"); QTest::addColumn<bool>("result"); - QTest::addColumn<QString>("toString"); + QTest::addColumn<QString>("toDecoded"); QTest::addColumn<QByteArray>("toEncoded"); QTest::newRow("%") << QByteArray("%") << true << QString("%") << QByteArray("%25"); @@ -1957,13 +1972,14 @@ void tst_QUrl::correctEncodedMistakes() { QFETCH(QByteArray, encodedUrl); QFETCH(bool, result); - QFETCH(QString, toString); + QFETCH(QString, toDecoded); QFETCH(QByteArray, toEncoded); QUrl url = QUrl::fromEncoded(encodedUrl); QCOMPARE(url.isValid(), result); if (url.isValid()) { - QCOMPARE(url.toString(), toString); + Q_UNUSED(toDecoded); // no full-decoding available at the moment + QCOMPARE(url.toString(), QString::fromLatin1(toEncoded)); QCOMPARE(url.toEncoded(), toEncoded); } } @@ -1972,7 +1988,7 @@ void tst_QUrl::correctDecodedMistakes_data() { QTest::addColumn<QString>("decodedUrl"); QTest::addColumn<bool>("result"); - QTest::addColumn<QString>("toString"); + QTest::addColumn<QString>("toDecoded"); QTest::addColumn<QByteArray>("toEncoded"); QTest::newRow("%") << QString("%") << true << QString("%") << QByteArray("%25"); @@ -1982,20 +1998,21 @@ void tst_QUrl::correctDecodedMistakes_data() QTest::newRow("13%!!") << QString("13%!!") << true << QString("13%!!") << QByteArray("13%25!!"); QTest::newRow("13%a") << QString("13%a") << true << QString("13%a") << QByteArray("13%25a"); QTest::newRow("13%az") << QString("13%az") << true << QString("13%az") << QByteArray("13%25az"); - QTest::newRow("13%25") << QString("13%25") << true << QString("13%25") << QByteArray("13%2525"); + QTest::newRow("13%25") << QString("13%25") << true << QString("13%25") << QByteArray("13%25"); } void tst_QUrl::correctDecodedMistakes() { QFETCH(QString, decodedUrl); QFETCH(bool, result); - QFETCH(QString, toString); + QFETCH(QString, toDecoded); QFETCH(QByteArray, toEncoded); QUrl url(decodedUrl); QCOMPARE(url.isValid(), result); if (url.isValid()) { - QCOMPARE(url.toString(), toString); + Q_UNUSED(toDecoded); // no full-decoding available at the moment + QCOMPARE(url.toString(), QString::fromLatin1(toEncoded)); QCOMPARE(url.toEncoded(), toEncoded); } } @@ -2695,7 +2712,7 @@ void tst_QUrl::tldRestrictions() { QFETCH(QString, tld); - // www.brød.tld + // www.brød.tld QByteArray ascii = "www.xn--brd-1na." + tld.toLatin1(); QString unicode = QLatin1String("www.br\370d.") + tld; QString encoded = QUrl::fromAce(ascii); diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/qwinoverlappedionotifier.pro b/tests/auto/corelib/io/qwinoverlappedionotifier/qwinoverlappedionotifier.pro new file mode 100644 index 0000000000..0b5bf9fd5c --- /dev/null +++ b/tests/auto/corelib/io/qwinoverlappedionotifier/qwinoverlappedionotifier.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qwinoverlappedionotifier +QT = core-private testlib +SOURCES = tst_qwinoverlappedionotifier.cpp diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp new file mode 100644 index 0000000000..6190b62bbf --- /dev/null +++ b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <private/qwinoverlappedionotifier_p.h> +#include <qbytearray.h> + +class tst_QWinOverlappedIoNotifier : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void readFile_data(); + void readFile(); + void waitForNotified_data(); + void waitForNotified(); + void brokenPipe(); + +private: + QFileInfo sourceFileInfo; + DWORD notifiedBytesRead; + DWORD notifiedErrorCode; +}; + +class NotifierSink : public QObject +{ + Q_OBJECT +public: + NotifierSink(QWinOverlappedIoNotifier *notifier) + : QObject(notifier), + notifications(0), + notifiedBytesRead(0), + notifiedErrorCode(ERROR_SUCCESS) + { + connect(notifier, &QWinOverlappedIoNotifier::notified, this, &NotifierSink::notified); + } + +protected slots: + void notified(DWORD bytesRead, DWORD errorCode) + { + notifications++; + notifiedBytesRead = bytesRead; + notifiedErrorCode = errorCode; + emit notificationReceived(); + } + +signals: + void notificationReceived(); + +public: + int notifications; + DWORD notifiedBytesRead; + DWORD notifiedErrorCode; +}; + +void tst_QWinOverlappedIoNotifier::initTestCase() +{ + sourceFileInfo.setFile(QFINDTESTDATA("tst_qwinoverlappedionotifier.cpp")); + QVERIFY2(sourceFileInfo.exists(), "File tst_qwinoverlappedionotifier.cpp not found."); +} + +void tst_QWinOverlappedIoNotifier::readFile_data() +{ + QTest::addColumn<QString>("fileName"); + QTest::addColumn<int>("readBufferSize"); + QTest::addColumn<DWORD>("expectedBytesRead"); + + QString sourceFileName = QDir::toNativeSeparators(sourceFileInfo.absoluteFilePath()); + int sourceFileSize = sourceFileInfo.size(); + + QTest::newRow("read file, less than available") + << sourceFileName << sourceFileSize / 2 << DWORD(sourceFileSize / 2); + QTest::newRow("read file, more than available") + << sourceFileName << sourceFileSize * 2 << DWORD(sourceFileSize); +} + +void tst_QWinOverlappedIoNotifier::readFile() +{ + QFETCH(QString, fileName); + QFETCH(int, readBufferSize); + QFETCH(DWORD, expectedBytesRead); + + QWinOverlappedIoNotifier notifier; + NotifierSink sink(¬ifier); + connect(&sink, &NotifierSink::notificationReceived, &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + + HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()), + GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + notifier.setHandle(hFile); + notifier.setEnabled(true); + + OVERLAPPED overlapped = {0}; + QByteArray buffer(readBufferSize, 0); + BOOL readSuccess = ReadFile(hFile, buffer.data(), buffer.size(), NULL, &overlapped); + QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING); + + QTestEventLoop::instance().enterLoop(3); + CloseHandle(hFile); + QCOMPARE(sink.notifications, 1); + QCOMPARE(sink.notifiedBytesRead, expectedBytesRead); + QCOMPARE(sink.notifiedErrorCode, DWORD(ERROR_SUCCESS)); +} + +void tst_QWinOverlappedIoNotifier::waitForNotified_data() +{ + readFile_data(); +} + +void tst_QWinOverlappedIoNotifier::waitForNotified() +{ + QFETCH(QString, fileName); + QFETCH(int, readBufferSize); + QFETCH(DWORD, expectedBytesRead); + + QWinOverlappedIoNotifier notifier; + NotifierSink sink(¬ifier); + HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()), + GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + QCOMPARE(notifier.waitForNotified(0), false); + notifier.setHandle(hFile); + notifier.setEnabled(true); + QCOMPARE(notifier.waitForNotified(100), false); + + OVERLAPPED overlapped = {0}; + QByteArray buffer(readBufferSize, 0); + BOOL readSuccess = ReadFile(hFile, buffer.data(), buffer.size(), NULL, &overlapped); + QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING); + + QCOMPARE(notifier.waitForNotified(3000), true); + CloseHandle(hFile); + QCOMPARE(sink.notifications, 1); + QCOMPARE(sink.notifiedBytesRead, expectedBytesRead); + QCOMPARE(sink.notifiedErrorCode, DWORD(ERROR_SUCCESS)); + QCOMPARE(notifier.waitForNotified(100), false); +} + +void tst_QWinOverlappedIoNotifier::brokenPipe() +{ + QWinOverlappedIoNotifier notifier; + NotifierSink sink(¬ifier); + connect(&sink, &NotifierSink::notificationReceived, &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + + wchar_t pipeName[] = L"\\\\.\\pipe\\tst_QWinOverlappedIoNotifier_brokenPipe"; + HANDLE hPipe = CreateNamedPipe(pipeName, + PIPE_ACCESS_DUPLEX, + PIPE_TYPE_BYTE | PIPE_NOWAIT | PIPE_REJECT_REMOTE_CLIENTS, + 1, 0, 0, 0, NULL); + QVERIFY(hPipe != INVALID_HANDLE_VALUE); + HANDLE hReadEnd = CreateFile(pipeName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + QVERIFY(hReadEnd != INVALID_HANDLE_VALUE); + notifier.setHandle(hReadEnd); + notifier.setEnabled(true); + + OVERLAPPED overlapped = {0}; + QByteArray buffer(1024, 0); + BOOL readSuccess = ReadFile(hReadEnd, buffer.data(), buffer.size(), NULL, &overlapped); + QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING); + + // close the write end of the pipe + CloseHandle(hPipe); + + QTestEventLoop::instance().enterLoop(3); + CloseHandle(hReadEnd); + QCOMPARE(sink.notifications, 1); + QCOMPARE(sink.notifiedBytesRead, DWORD(0)); + QCOMPARE(sink.notifiedErrorCode, DWORD(ERROR_BROKEN_PIPE)); +} + +QTEST_MAIN(tst_QWinOverlappedIoNotifier) + +#include "tst_qwinoverlappedionotifier.moc" diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro index acf74737a8..9e59251379 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qabstractitemmodel -QT += widgets testlib +QT += testlib mtdir = ../../../other/modeltest INCLUDEPATH += $$PWD/$${mtdir} diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index af1e492a8b..2ca5df477b 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -72,6 +72,7 @@ private slots: void match(); void dropMimeData_data(); void dropMimeData(); + void canDropMimeData(); void changePersistentIndex(); void movePersistentIndex(); @@ -79,6 +80,8 @@ private slots: void insertColumns(); void removeRows(); void removeColumns(); + void moveRows(); + void moveColumns(); void reset(); @@ -142,8 +145,15 @@ public: void setPersistent(const QModelIndex &from, const QModelIndex &to); bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ); bool removeColumns( int column, int count, const QModelIndex & parent = QModelIndex()); + bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, + const QModelIndex &destinationParent, int destinationChild); + bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, + const QModelIndex &destinationParent, int destinationChild); void reset(); + bool canDropMimeData(const QMimeData *data, Qt::DropAction action, + int row, int column, const QModelIndex &parent) const; + int cCount, rCount; mutable bool wrongIndex; QVector<QVector<QString> > table; @@ -246,11 +256,88 @@ bool QtTestModel::removeColumns(int column, int count, const QModelIndex & paren return true; } +bool QtTestModel::moveRows(const QModelIndex &sourceParent, int src, int cnt, + const QModelIndex &destinationParent, int dst) +{ + if (!QAbstractItemModel::beginMoveRows(sourceParent, src, src + cnt - 1, + destinationParent, dst)) + return false; + + QVector<QString> buf; + if (dst < src) { + for (int i = 0; i < cnt; ++i) { + buf.swap(table[src + i]); + table.remove(src + 1); + table.insert(dst, buf); + } + } else if (src < dst) { + for (int i = 0; i < cnt; ++i) { + buf.swap(table[src]); + table.remove(src); + table.insert(dst + i, buf); + } + } + + rCount = table.count(); + + QAbstractItemModel::endMoveRows(); + return true; +} + +bool QtTestModel::moveColumns(const QModelIndex &sourceParent, int src, int cnt, + const QModelIndex &destinationParent, int dst) +{ + if (!QAbstractItemModel::beginMoveColumns(sourceParent, src, src + cnt - 1, + destinationParent, dst)) + return false; + + for (int r = 0; r < rCount; ++r) { + QString buf; + if (dst < src) { + for (int i = 0; i < cnt; ++i) { + buf = table[r][src + i]; + table[r].remove(src + 1); + table[r].insert(dst, buf); + } + } else if (src < dst) { + for (int i = 0; i < cnt; ++i) { + buf = table[r][src]; + table[r].remove(src); + table[r].insert(dst + i, buf); + } + } + } + + cCount = table.at(0).count(); + + QAbstractItemModel::endMoveColumns(); + return true; +} + void QtTestModel::reset() { QAbstractItemModel::reset(); } +bool QtTestModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, + int row, int column, const QModelIndex &parent) const +{ + Q_UNUSED(data); + Q_UNUSED(action); + + // For testing purposes, we impose some arbitrary rules on what may be dropped. + if (!parent.isValid() && row < 0 && column < 0) { + // a drop in emtpy space in the view is allowed. + // For example, in a filesystem view, a file may be dropped into empty space + // if it represents a writable directory. + return true; + } + + // We then arbitrarily decide to only allow drops on odd rows. + // A filesystem view/model might be able to drop onto (writable) directories. + return row % 2 == 0; +} + /** * The source Model *must* be initialized before the _data function, since the _data function uses QModelIndexes to reference the items in the tables. * Therefore, we must initialize it globally. @@ -691,6 +778,15 @@ void tst_QAbstractItemModel::dropMimeData() } } +void tst_QAbstractItemModel::canDropMimeData() +{ + QtTestModel model(3, 3); + + QVERIFY(model.canDropMimeData(0, Qt::CopyAction, -1, -1, QModelIndex())); + QVERIFY(model.canDropMimeData(0, Qt::CopyAction, 0, 0, QModelIndex())); + QVERIFY(!model.canDropMimeData(0, Qt::CopyAction, 1, 0, QModelIndex())); +} + void tst_QAbstractItemModel::changePersistentIndex() { QtTestModel model(3, 3); @@ -781,6 +877,36 @@ void tst_QAbstractItemModel::insertColumns() QCOMPARE(columnsInsertedSpy.count(), 1); } +void tst_QAbstractItemModel::moveRows() +{ + QtTestModel model(10, 10); + + QSignalSpy rowsAboutToBeMovedSpy(&model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int , int, const QModelIndex &, int))); + QSignalSpy rowsMovedSpy(&model, SIGNAL(rowsMoved(const QModelIndex &, int , int, const QModelIndex &, int))); + + QVERIFY(rowsAboutToBeMovedSpy.isValid()); + QVERIFY(rowsMovedSpy.isValid()); + + QCOMPARE(model.moveRows(QModelIndex(), 6, 4, QModelIndex(), 1), true); + QCOMPARE(rowsAboutToBeMovedSpy.count(), 1); + QCOMPARE(rowsMovedSpy.count(), 1); +} + +void tst_QAbstractItemModel::moveColumns() +{ + QtTestModel model(10, 10); + + QSignalSpy columnsAboutToBeMovedSpy(&model, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int , int, const QModelIndex &, int))); + QSignalSpy columnsMovedSpy(&model, SIGNAL(columnsMoved(const QModelIndex &, int , int, const QModelIndex &, int))); + + QVERIFY(columnsAboutToBeMovedSpy.isValid()); + QVERIFY(columnsMovedSpy.isValid()); + + QCOMPARE(model.moveColumns(QModelIndex(), 6, 4, QModelIndex(), 1), true); + QCOMPARE(columnsAboutToBeMovedSpy.count(), 1); + QCOMPARE(columnsMovedSpy.count(), 1); +} + void tst_QAbstractItemModel::reset() { QtTestModel model(10, 10); @@ -1669,6 +1795,19 @@ private: }; +class ModelWithCustomRole : public QStringListModel +{ + Q_OBJECT +public: + ModelWithCustomRole(QObject *parent = 0) + : QStringListModel(parent) + { + QHash<int, QByteArray> roleNames_ = roleNames(); + roleNames_.insert(Qt::UserRole + 1, "custom"); + setRoleNames(roleNames_); + } +}; + ListenerObject::ListenerObject(QAbstractProxyModel *parent) : QObject(parent), m_model(parent) { @@ -1722,7 +1861,7 @@ void tst_QAbstractItemModel::testReset() nullProxy->setSourceModel(m_model); // Makes sure the model and proxy are in a consistent state. before and after reset. - new ListenerObject(nullProxy); + ListenerObject *listener = new ListenerObject(nullProxy); ModelResetCommandFixed *resetCommand = new ModelResetCommandFixed(m_model, this); @@ -1741,6 +1880,28 @@ void tst_QAbstractItemModel::testReset() QVERIFY(m_model->rowCount() == 9); QModelIndex destIndex = m_model->index(4, 0); QVERIFY(m_model->rowCount(destIndex) == 11); + + // Delete it because its slots test things which are not true after this point. + delete listener; + + QSignalSpy proxyBeforeResetSpy(nullProxy, SIGNAL(modelAboutToBeReset())); + QSignalSpy proxyAfterResetSpy(nullProxy, SIGNAL(modelReset())); + + // Before setting it, it does not have custom roles. + QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray()); + + nullProxy->setSourceModel(new ModelWithCustomRole(this)); + QVERIFY(proxyBeforeResetSpy.size() == 1); + QVERIFY(proxyAfterResetSpy.size() == 1); + + QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray("custom")); + + nullProxy->setSourceModel(m_model); + QVERIFY(proxyBeforeResetSpy.size() == 2); + QVERIFY(proxyAfterResetSpy.size() == 2); + + // After being reset the proxy must be queried again. + QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray()); } class CustomRoleModel : public QStringListModel diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp index 088ad0afdc..6d61f3f832 100644 --- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index fc11fbf763..567bb58752 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index 20985b69a6..99b9bb92f3 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 6d673ae00f..cbe7da11ad 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 552b3d6eab..94a81b981e 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 559a806ef3..b31b64d974 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h index 1de3018228..900b3152ae 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 6c7c87c940..6345678b2f 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro new file mode 100644 index 0000000000..5158b7337a --- /dev/null +++ b/tests/auto/corelib/json/json.pro @@ -0,0 +1,8 @@ +TARGET = tst_qtjson +QT = core testlib +CONFIG -= app_bundle +CONFIG += testcase + +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +SOURCES += tst_qtjson.cpp diff --git a/tests/auto/corelib/json/test.bjson b/tests/auto/corelib/json/test.bjson Binary files differnew file mode 100644 index 0000000000..aa412eec67 --- /dev/null +++ b/tests/auto/corelib/json/test.bjson diff --git a/tests/auto/corelib/json/test.json b/tests/auto/corelib/json/test.json new file mode 100644 index 0000000000..7c935fffc8 --- /dev/null +++ b/tests/auto/corelib/json/test.json @@ -0,0 +1,66 @@ +[ + "JSON Test Pattern pass1", + {"object with 1 member":["array with 1 element"]}, + {}, + [], + -42, + true, + false, + null, + { + "integer": 1234567890, + "real": -9876.543210, + "e": 0.123456789e-12, + "E": 1.234567890E+34, + "": 23456789012E66, + "zero": 0, + "one": 1, + "space": " ", + "quote": "\"", + "backslash": "\\", + "controls": "\b\f\n\r\t", + "slash": "/ & \/", + "alpha": "abcdefghijklmnopqrstuvwxyz", + "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "digit": "0123456789", + "0123456789": "digit", + "special": "`1~!@#$%^&*()_+-={\':[,]}|;.</>?", + "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", + "true": true, + "false": false, + "null": null, + "array":[ ], + "object":{ }, + "address": "50 St. James Street", + "url": "http://www.JSON.org/", + "comment": "// /* <!-- --", + "# -- --> */": " ", + " s p a c e d " :[1,2 , 3 + +, + +4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], + "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", + "quotes": "" \u0022 %22 0x22 034 "", + "\/\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?" : "A key can be any string" + }, + 0.5 ,98.6 +, +99.44 +, + +1066, +1e1, +0.1e1, +1e-1, +1e00, +2e+00, +2e-00, +"rosebud", +{"foo": "bar"}, +{"classification":{"relevancyScore":1000,"searchUrl":{"value":"http://www.bizrate.com/iphone-cases/index__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"}},"products":{"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$4,833.99","integral":483399}},"product":[{"type":"PRODUCT","title":"Silicone case for iPhone 3G/ 3GS","description":"Elite Horizontal Leather Pouch for Apple iPhone 3G/3Gs - Premium quality horizontal case for your Apple iPhone 3G/3Gs. This pouch is ideal for the style conscious on the go. This great looking case is made from high-quality leather with classic black...","manufacturer":"Apple","url":{"value":"http://www.bizrate.com/silicone-case-for-iphone-3g-3gs--pid1968262863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1968262863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1968262863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1968262863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1968262863","xsize":400,"ysize":400}]},"relevancy":310711221747712.000000,"priceSet":{"minPrice":{"value":"$1.56","integral":156},"maxPrice":{"value":"$29.99","integral":2999},"stores":14},"id":1968262863,"categoryId":8515},{"type":"PRODUCT","title":"Nonslip Checkered Silicone Skin Soft Case for iPhone 4 4G","description":"Specification:Product Name Silicone Skin Case Model for Apple iPhone 4 Color Black Material Soft Silicone Skin Weight 26g Package 1 x Case for Apple iPhone 4 Description:This is a non-OEM product.Accessory Only, Phone is not included.","manufacturer":"H&B","url":{"value":"http://www.bizrate.com/nonslip-checkered-silicone-skin-soft-case-for-iphone-4-4g--pid2534935499/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2534935499","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2534935499","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2534935499","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2534935499","xsize":400,"ysize":400}]},"relevancy":175580930637824.000000,"priceSet":{"minPrice":{"value":"$0.45","integral":45},"maxPrice":{"value":"$194.95","integral":19495},"stores":34},"id":2534935499,"categoryId":8515},{"type":"PRODUCT","title":"Plastic Case for iPhone 4 - Black","description":"Description:Detachable Windmill Type Matte Hard Plastic Case Cover for iPhone 4 (Black / Magenta)Customised your iPhone with this wonderful Plastic Case which is a accessory for your iPhone 4 which is made of high quality and durable plastic, protect","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/plastic-case-for-iphone-4-black--pid2305624670/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2305624670","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2305624670","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2305624670","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2305624670","xsize":400,"ysize":400}]},"relevancy":132488642953216.000000,"priceSet":{"minPrice":{"value":"$0.99","integral":99},"maxPrice":{"value":"$303.68","integral":30368},"stores":33},"id":2305624670,"categoryId":8515},{"type":"PRODUCT","title":"Protective Silicone Case for iPhone 4","description":"Made of high quality PVC material Protects your iPhone 4 from any scratch and dirt Easy to install and remove, no any tool needed Cut-out design allows user can access all keypad / button and slot without having to remove the case","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/protective-silicone-case-for-iphone-4--pid2120981405/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2120981405","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2120981405","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2120981405","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2120981405","xsize":400,"ysize":400}]},"relevancy":108614681362432.000000,"priceSet":{"minPrice":{"value":"$1.70","integral":170},"maxPrice":{"value":"$99.99","integral":9999},"stores":11},"id":2120981405,"categoryId":8515},{"type":"PRODUCT","title":"Iphone® 4 Aerosport Case","description":"Do more than just protect your iPhone 4 with this case bundle from rooCASE. This 3 in 1 bundle include a snap-on case, screen protector and a Nike+ sensor shoe pouch that can be use on most running shoes. Color: Purple Design: Love Provides protection...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/iphone-4-aerosport-case--pid2203798762/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2203798762","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2203798762","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2203798762","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2203798762","xsize":400,"ysize":400}]},"relevancy":96203484168192.000000,"priceSet":{"minPrice":{"value":"$2.49","integral":249},"maxPrice":{"value":"$79.95","integral":7995},"stores":16},"id":2203798762,"categoryId":8515},{"type":"PRODUCT","title":"Case Reflect For Iphone 3G","description":"NCAA iPhone 3G faceplate features the schools primary logo silk screened on the front of the case.","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/case-reflect-for-iphone-3g--pid1114627445/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1114627445","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1114627445","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1114627445","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1114627445","xsize":400,"ysize":400}]},"relevancy":84727583211520.000000,"priceSet":{"minPrice":{"value":"$0.69","integral":69},"maxPrice":{"value":"$75.52","integral":7552},"stores":59},"id":1114627445,"categoryId":8515},{"type":"PRODUCT","title":"Infuse Protector Case for iPhone 4 Black","description":"Protect and personalize your iPhone 4 with this front and back image design Protector Case. Form-fitting front and back hard plastic covers Protects your cell phone without adding a lot of bulk Smooth glossy finish Snaps on to the front edges, sides...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/infuse-protector-case-for-iphone-4-black--pid2557462717/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2557462717","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2557462717","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2557462717","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2557462717","xsize":400,"ysize":400}]},"relevancy":80831066406912.000000,"priceSet":{"minPrice":{"value":"$0.59","integral":59},"maxPrice":{"value":"$79.00","integral":7900},"stores":24},"id":2557462717,"categoryId":8515},{"type":"PRODUCT","title":"Dragonfly iPhone 4 Kream Case - Black","description":"DF-0030219 - White, Kream Case for iPhone 4 by Dragon-Fly","url":{"value":"http://www.bizrate.com/dragonfly-iphone-4-kream-case-black--pid2442061740/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2442061740","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2442061740","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2442061740","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2442061740","xsize":400,"ysize":400}]},"relevancy":70900229603328.000000,"priceSet":{"minPrice":{"value":"$1.05","integral":105},"maxPrice":{"value":"$94.49","integral":9449},"stores":30},"id":2442061740,"categoryId":8515},{"type":"PRODUCT","title":"Apple iPhone 3G/3GS Silicone Case (Black)","description":"Snap on Apple iPhone 3G 3GS Synthetic Leather Hardshell Case! Premium Qualtiy Synthetic Leather cover provides style, comfort, and protection to your iPhone 3G & 3GS. It also adds a sophisticated elegance and cool to your fashion. The case allows Quick...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/apple-iphone-3g3gs-silicone-case-black--pid2004746863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2004746863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2004746863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2004746863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2004746863","xsize":400,"ysize":400}]},"relevancy":65194915004416.000000,"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$414.99","integral":41499},"stores":39},"id":2004746863,"categoryId":8515},{"type":"PRODUCT","title":"Otterbox iPhone 4 Defender Case - Black","description":"Your iPhone 4 has become a big part of your life. With FaceTime video, retina display, multitasking, HD video recording and more - you've got a lot to lose. You won't find a tougher case than the OtterBox Defender Series for iPhone 4. This three-layer...","manufacturer":"Universal","url":{"value":"http://www.bizrate.com/otterbox-iphone-4-defender-case-black--pid2584611575/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2584611575","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2584611575","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2584611575","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2584611575","xsize":400,"ysize":400}]},"relevancy":61515478597632.000000,"priceSet":{"minPrice":{"value":"$3.28","integral":328},"maxPrice":{"value":"$110.65","integral":11065},"stores":25},"id":2584611575,"categoryId":8515}],"includedResults":10,"totalResults":2000}}, +{"classification":{"relevancyScore":1000,"searchUrl":{"value":"http://www.bizrate.com/iphone-cases/index__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"}},"products":{"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$4,833.99","integral":483399}},"product":[{"type":"PRODUCT","title":"Silicone case for iPhone 3G/ 3GS","description":"Elite Horizontal Leather Pouch for Apple iPhone 3G/3Gs - Premium quality horizontal case for your Apple iPhone 3G/3Gs. This pouch is ideal for the style conscious on the go. This great looking case is made from high-quality leather with classic black...","manufacturer":"Apple","url":{"value":"http://www.bizrate.com/silicone-case-for-iphone-3g-3gs--pid1968262863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1968262863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1968262863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1968262863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1968262863","xsize":400,"ysize":400}]},"relevancy":310711221747712.000000,"priceSet":{"minPrice":{"value":"$1.56","integral":156},"maxPrice":{"value":"$29.99","integral":2999},"stores":14},"id":1968262863,"categoryId":8515},{"type":"PRODUCT","title":"Nonslip Checkered Silicone Skin Soft Case for iPhone 4 4G","description":"Specification:Product Name Silicone Skin Case Model for Apple iPhone 4 Color Black Material Soft Silicone Skin Weight 26g Package 1 x Case for Apple iPhone 4 Description:This is a non-OEM product.Accessory Only, Phone is not included.","manufacturer":"H&B","url":{"value":"http://www.bizrate.com/nonslip-checkered-silicone-skin-soft-case-for-iphone-4-4g--pid2534935499/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2534935499","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2534935499","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2534935499","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2534935499","xsize":400,"ysize":400}]},"relevancy":175580930637824.000000,"priceSet":{"minPrice":{"value":"$0.45","integral":45},"maxPrice":{"value":"$194.95","integral":19495},"stores":34},"id":2534935499,"categoryId":8515},{"type":"PRODUCT","title":"Plastic Case for iPhone 4 - Black","description":"Description:Detachable Windmill Type Matte Hard Plastic Case Cover for iPhone 4 (Black / Magenta)Customised your iPhone with this wonderful Plastic Case which is a accessory for your iPhone 4 which is made of high quality and durable plastic, protect","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/plastic-case-for-iphone-4-black--pid2305624670/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2305624670","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2305624670","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2305624670","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2305624670","xsize":400,"ysize":400}]},"relevancy":132488642953216.000000,"priceSet":{"minPrice":{"value":"$0.99","integral":99},"maxPrice":{"value":"$303.68","integral":30368},"stores":33},"id":2305624670,"categoryId":8515},{"type":"PRODUCT","title":"Protective Silicone Case for iPhone 4","description":"Made of high quality PVC material Protects your iPhone 4 from any scratch and dirt Easy to install and remove, no any tool needed Cut-out design allows user can access all keypad / button and slot without having to remove the case","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/protective-silicone-case-for-iphone-4--pid2120981405/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2120981405","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2120981405","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2120981405","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2120981405","xsize":400,"ysize":400}]},"relevancy":108614681362432.000000,"priceSet":{"minPrice":{"value":"$1.70","integral":170},"maxPrice":{"value":"$99.99","integral":9999},"stores":11},"id":2120981405,"categoryId":8515},{"type":"PRODUCT","title":"Iphone® 4 Aerosport Case","description":"Do more than just protect your iPhone 4 with this case bundle from rooCASE. This 3 in 1 bundle include a snap-on case, screen protector and a Nike+ sensor shoe pouch that can be use on most running shoes. Color: Purple Design: Love Provides protection...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/iphone-4-aerosport-case--pid2203798762/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2203798762","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2203798762","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2203798762","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2203798762","xsize":400,"ysize":400}]},"relevancy":96203484168192.000000,"priceSet":{"minPrice":{"value":"$2.49","integral":249},"maxPrice":{"value":"$79.95","integral":7995},"stores":16},"id":2203798762,"categoryId":8515},{"type":"PRODUCT","title":"Case Reflect For Iphone 3G","description":"NCAA iPhone 3G faceplate features the schools primary logo silk screened on the front of the case.","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/case-reflect-for-iphone-3g--pid1114627445/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1114627445","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1114627445","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1114627445","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1114627445","xsize":400,"ysize":400}]},"relevancy":84727583211520.000000,"priceSet":{"minPrice":{"value":"$0.69","integral":69},"maxPrice":{"value":"$75.52","integral":7552},"stores":59},"id":1114627445,"categoryId":8515},{"type":"PRODUCT","title":"Infuse Protector Case for iPhone 4 Black","description":"Protect and personalize your iPhone 4 with this front and back image design Protector Case. Form-fitting front and back hard plastic covers Protects your cell phone without adding a lot of bulk Smooth glossy finish Snaps on to the front edges, sides...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/infuse-protector-case-for-iphone-4-black--pid2557462717/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2557462717","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2557462717","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2557462717","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2557462717","xsize":400,"ysize":400}]},"relevancy":80831066406912.000000,"priceSet":{"minPrice":{"value":"$0.59","integral":59},"maxPrice":{"value":"$79.00","integral":7900},"stores":24},"id":2557462717,"categoryId":8515},{"type":"PRODUCT","title":"Dragonfly iPhone 4 Kream Case - Black","description":"DF-0030219 - White, Kream Case for iPhone 4 by Dragon-Fly","url":{"value":"http://www.bizrate.com/dragonfly-iphone-4-kream-case-black--pid2442061740/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2442061740","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2442061740","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2442061740","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2442061740","xsize":400,"ysize":400}]},"relevancy":70900229603328.000000,"priceSet":{"minPrice":{"value":"$1.05","integral":105},"maxPrice":{"value":"$94.49","integral":9449},"stores":30},"id":2442061740,"categoryId":8515},{"type":"PRODUCT","title":"Apple iPhone 3G/3GS Silicone Case (Black)","description":"Snap on Apple iPhone 3G 3GS Synthetic Leather Hardshell Case! Premium Qualtiy Synthetic Leather cover provides style, comfort, and protection to your iPhone 3G & 3GS. It also adds a sophisticated elegance and cool to your fashion. The case allows Quick...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/apple-iphone-3g3gs-silicone-case-black--pid2004746863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2004746863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2004746863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2004746863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2004746863","xsize":400,"ysize":400}]},"relevancy":65194915004416.000000,"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$414.99","integral":41499},"stores":39},"id":2004746863,"categoryId":8515},{"type":"PRODUCT","title":"Otterbox iPhone 4 Defender Case - Black","description":"Your iPhone 4 has become a big part of your life. With FaceTime video, retina display, multitasking, HD video recording and more - you've got a lot to lose. You won't find a tougher case than the OtterBox Defender Series for iPhone 4. This three-layer...","manufacturer":"Universal","url":{"value":"http://www.bizrate.com/otterbox-iphone-4-defender-case-black--pid2584611575/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2584611575","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2584611575","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2584611575","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2584611575","xsize":400,"ysize":400}]},"relevancy":61515478597632.000000,"priceSet":{"minPrice":{"value":"$3.28","integral":328},"maxPrice":{"value":"$110.65","integral":11065},"stores":25},"id":2584611575,"categoryId":8515}],"includedResults":10,"totalResults":2000}}, +{"classification":{"relevancyScore":1000,"searchUrl":{"value":"http://www.bizrate.com/iphone-cases/index__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"}},"products":{"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$4,833.99","integral":483399}},"product":[{"type":"PRODUCT","title":"Silicone case for iPhone 3G/ 3GS","description":"Elite Horizontal Leather Pouch for Apple iPhone 3G/3Gs - Premium quality horizontal case for your Apple iPhone 3G/3Gs. This pouch is ideal for the style conscious on the go. This great looking case is made from high-quality leather with classic black...","manufacturer":"Apple","url":{"value":"http://www.bizrate.com/silicone-case-for-iphone-3g-3gs--pid1968262863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1968262863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1968262863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1968262863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1968262863","xsize":400,"ysize":400}]},"relevancy":310711221747712.000000,"priceSet":{"minPrice":{"value":"$1.56","integral":156},"maxPrice":{"value":"$29.99","integral":2999},"stores":14},"id":1968262863,"categoryId":8515},{"type":"PRODUCT","title":"Nonslip Checkered Silicone Skin Soft Case for iPhone 4 4G","description":"Specification:Product Name Silicone Skin Case Model for Apple iPhone 4 Color Black Material Soft Silicone Skin Weight 26g Package 1 x Case for Apple iPhone 4 Description:This is a non-OEM product.Accessory Only, Phone is not included.","manufacturer":"H&B","url":{"value":"http://www.bizrate.com/nonslip-checkered-silicone-skin-soft-case-for-iphone-4-4g--pid2534935499/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2534935499","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2534935499","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2534935499","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2534935499","xsize":400,"ysize":400}]},"relevancy":175580930637824.000000,"priceSet":{"minPrice":{"value":"$0.45","integral":45},"maxPrice":{"value":"$194.95","integral":19495},"stores":34},"id":2534935499,"categoryId":8515},{"type":"PRODUCT","title":"Plastic Case for iPhone 4 - Black","description":"Description:Detachable Windmill Type Matte Hard Plastic Case Cover for iPhone 4 (Black / Magenta)Customised your iPhone with this wonderful Plastic Case which is a accessory for your iPhone 4 which is made of high quality and durable plastic, protect","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/plastic-case-for-iphone-4-black--pid2305624670/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2305624670","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2305624670","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2305624670","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2305624670","xsize":400,"ysize":400}]},"relevancy":132488642953216.000000,"priceSet":{"minPrice":{"value":"$0.99","integral":99},"maxPrice":{"value":"$303.68","integral":30368},"stores":33},"id":2305624670,"categoryId":8515},{"type":"PRODUCT","title":"Protective Silicone Case for iPhone 4","description":"Made of high quality PVC material Protects your iPhone 4 from any scratch and dirt Easy to install and remove, no any tool needed Cut-out design allows user can access all keypad / button and slot without having to remove the case","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/protective-silicone-case-for-iphone-4--pid2120981405/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2120981405","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2120981405","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2120981405","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2120981405","xsize":400,"ysize":400}]},"relevancy":108614681362432.000000,"priceSet":{"minPrice":{"value":"$1.70","integral":170},"maxPrice":{"value":"$99.99","integral":9999},"stores":11},"id":2120981405,"categoryId":8515},{"type":"PRODUCT","title":"Iphone® 4 Aerosport Case","description":"Do more than just protect your iPhone 4 with this case bundle from rooCASE. This 3 in 1 bundle include a snap-on case, screen protector and a Nike+ sensor shoe pouch that can be use on most running shoes. Color: Purple Design: Love Provides protection...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/iphone-4-aerosport-case--pid2203798762/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2203798762","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2203798762","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2203798762","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2203798762","xsize":400,"ysize":400}]},"relevancy":96203484168192.000000,"priceSet":{"minPrice":{"value":"$2.49","integral":249},"maxPrice":{"value":"$79.95","integral":7995},"stores":16},"id":2203798762,"categoryId":8515},{"type":"PRODUCT","title":"Case Reflect For Iphone 3G","description":"NCAA iPhone 3G faceplate features the schools primary logo silk screened on the front of the case.","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/case-reflect-for-iphone-3g--pid1114627445/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1114627445","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1114627445","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1114627445","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1114627445","xsize":400,"ysize":400}]},"relevancy":84727583211520.000000,"priceSet":{"minPrice":{"value":"$0.69","integral":69},"maxPrice":{"value":"$75.52","integral":7552},"stores":59},"id":1114627445,"categoryId":8515},{"type":"PRODUCT","title":"Infuse Protector Case for iPhone 4 Black","description":"Protect and personalize your iPhone 4 with this front and back image design Protector Case. Form-fitting front and back hard plastic covers Protects your cell phone without adding a lot of bulk Smooth glossy finish Snaps on to the front edges, sides...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/infuse-protector-case-for-iphone-4-black--pid2557462717/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2557462717","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2557462717","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2557462717","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2557462717","xsize":400,"ysize":400}]},"relevancy":80831066406912.000000,"priceSet":{"minPrice":{"value":"$0.59","integral":59},"maxPrice":{"value":"$79.00","integral":7900},"stores":24},"id":2557462717,"categoryId":8515},{"type":"PRODUCT","title":"Dragonfly iPhone 4 Kream Case - Black","description":"DF-0030219 - White, Kream Case for iPhone 4 by Dragon-Fly","url":{"value":"http://www.bizrate.com/dragonfly-iphone-4-kream-case-black--pid2442061740/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2442061740","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2442061740","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2442061740","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2442061740","xsize":400,"ysize":400}]},"relevancy":70900229603328.000000,"priceSet":{"minPrice":{"value":"$1.05","integral":105},"maxPrice":{"value":"$94.49","integral":9449},"stores":30},"id":2442061740,"categoryId":8515},{"type":"PRODUCT","title":"Apple iPhone 3G/3GS Silicone Case (Black)","description":"Snap on Apple iPhone 3G 3GS Synthetic Leather Hardshell Case! Premium Qualtiy Synthetic Leather cover provides style, comfort, and protection to your iPhone 3G & 3GS. It also adds a sophisticated elegance and cool to your fashion. The case allows Quick...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/apple-iphone-3g3gs-silicone-case-black--pid2004746863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2004746863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2004746863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2004746863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2004746863","xsize":400,"ysize":400}]},"relevancy":65194915004416.000000,"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$414.99","integral":41499},"stores":39},"id":2004746863,"categoryId":8515},{"type":"PRODUCT","title":"Otterbox iPhone 4 Defender Case - Black","description":"Your iPhone 4 has become a big part of your life. With FaceTime video, retina display, multitasking, HD video recording and more - you've got a lot to lose. You won't find a tougher case than the OtterBox Defender Series for iPhone 4. This three-layer...","manufacturer":"Universal","url":{"value":"http://www.bizrate.com/otterbox-iphone-4-defender-case-black--pid2584611575/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2584611575","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2584611575","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2584611575","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2584611575","xsize":400,"ysize":400}]},"relevancy":61515478597632.000000,"priceSet":{"minPrice":{"value":"$3.28","integral":328},"maxPrice":{"value":"$110.65","integral":11065},"stores":25},"id":2584611575,"categoryId":8515}],"includedResults":10,"totalResults":2000}}, +{"classification":{"relevancyScore":1000,"searchUrl":{"value":"http://www.bizrate.com/iphone-cases/index__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"}},"products":{"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$4,833.99","integral":483399}},"product":[{"type":"PRODUCT","title":"Silicone case for iPhone 3G/ 3GS","description":"Elite Horizontal Leather Pouch for Apple iPhone 3G/3Gs - Premium quality horizontal case for your Apple iPhone 3G/3Gs. This pouch is ideal for the style conscious on the go. This great looking case is made from high-quality leather with classic black...","manufacturer":"Apple","url":{"value":"http://www.bizrate.com/silicone-case-for-iphone-3g-3gs--pid1968262863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1968262863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1968262863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1968262863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1968262863","xsize":400,"ysize":400}]},"relevancy":310711221747712.000000,"priceSet":{"minPrice":{"value":"$1.56","integral":156},"maxPrice":{"value":"$29.99","integral":2999},"stores":14},"id":1968262863,"categoryId":8515},{"type":"PRODUCT","title":"Nonslip Checkered Silicone Skin Soft Case for iPhone 4 4G","description":"Specification:Product Name Silicone Skin Case Model for Apple iPhone 4 Color Black Material Soft Silicone Skin Weight 26g Package 1 x Case for Apple iPhone 4 Description:This is a non-OEM product.Accessory Only, Phone is not included.","manufacturer":"H&B","url":{"value":"http://www.bizrate.com/nonslip-checkered-silicone-skin-soft-case-for-iphone-4-4g--pid2534935499/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2534935499","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2534935499","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2534935499","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2534935499","xsize":400,"ysize":400}]},"relevancy":175580930637824.000000,"priceSet":{"minPrice":{"value":"$0.45","integral":45},"maxPrice":{"value":"$194.95","integral":19495},"stores":34},"id":2534935499,"categoryId":8515},{"type":"PRODUCT","title":"Plastic Case for iPhone 4 - Black","description":"Description:Detachable Windmill Type Matte Hard Plastic Case Cover for iPhone 4 (Black / Magenta)Customised your iPhone with this wonderful Plastic Case which is a accessory for your iPhone 4 which is made of high quality and durable plastic, protect","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/plastic-case-for-iphone-4-black--pid2305624670/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2305624670","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2305624670","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2305624670","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2305624670","xsize":400,"ysize":400}]},"relevancy":132488642953216.000000,"priceSet":{"minPrice":{"value":"$0.99","integral":99},"maxPrice":{"value":"$303.68","integral":30368},"stores":33},"id":2305624670,"categoryId":8515},{"type":"PRODUCT","title":"Protective Silicone Case for iPhone 4","description":"Made of high quality PVC material Protects your iPhone 4 from any scratch and dirt Easy to install and remove, no any tool needed Cut-out design allows user can access all keypad / button and slot without having to remove the case","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/protective-silicone-case-for-iphone-4--pid2120981405/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2120981405","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2120981405","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2120981405","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2120981405","xsize":400,"ysize":400}]},"relevancy":108614681362432.000000,"priceSet":{"minPrice":{"value":"$1.70","integral":170},"maxPrice":{"value":"$99.99","integral":9999},"stores":11},"id":2120981405,"categoryId":8515},{"type":"PRODUCT","title":"Iphone® 4 Aerosport Case","description":"Do more than just protect your iPhone 4 with this case bundle from rooCASE. This 3 in 1 bundle include a snap-on case, screen protector and a Nike+ sensor shoe pouch that can be use on most running shoes. Color: Purple Design: Love Provides protection...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/iphone-4-aerosport-case--pid2203798762/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2203798762","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2203798762","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2203798762","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2203798762","xsize":400,"ysize":400}]},"relevancy":96203484168192.000000,"priceSet":{"minPrice":{"value":"$2.49","integral":249},"maxPrice":{"value":"$79.95","integral":7995},"stores":16},"id":2203798762,"categoryId":8515},{"type":"PRODUCT","title":"Case Reflect For Iphone 3G","description":"NCAA iPhone 3G faceplate features the schools primary logo silk screened on the front of the case.","manufacturer":"Griffin","url":{"value":"http://www.bizrate.com/case-reflect-for-iphone-3g--pid1114627445/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=1114627445","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=1114627445","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=1114627445","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=1114627445","xsize":400,"ysize":400}]},"relevancy":84727583211520.000000,"priceSet":{"minPrice":{"value":"$0.69","integral":69},"maxPrice":{"value":"$75.52","integral":7552},"stores":59},"id":1114627445,"categoryId":8515},{"type":"PRODUCT","title":"Infuse Protector Case for iPhone 4 Black","description":"Protect and personalize your iPhone 4 with this front and back image design Protector Case. Form-fitting front and back hard plastic covers Protects your cell phone without adding a lot of bulk Smooth glossy finish Snaps on to the front edges, sides...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/infuse-protector-case-for-iphone-4-black--pid2557462717/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2557462717","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2557462717","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2557462717","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2557462717","xsize":400,"ysize":400}]},"relevancy":80831066406912.000000,"priceSet":{"minPrice":{"value":"$0.59","integral":59},"maxPrice":{"value":"$79.00","integral":7900},"stores":24},"id":2557462717,"categoryId":8515},{"type":"PRODUCT","title":"Dragonfly iPhone 4 Kream Case - Black","description":"DF-0030219 - White, Kream Case for iPhone 4 by Dragon-Fly","url":{"value":"http://www.bizrate.com/dragonfly-iphone-4-kream-case-black--pid2442061740/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2442061740","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2442061740","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2442061740","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2442061740","xsize":400,"ysize":400}]},"relevancy":70900229603328.000000,"priceSet":{"minPrice":{"value":"$1.05","integral":105},"maxPrice":{"value":"$94.49","integral":9449},"stores":30},"id":2442061740,"categoryId":8515},{"type":"PRODUCT","title":"Apple iPhone 3G/3GS Silicone Case (Black)","description":"Snap on Apple iPhone 3G 3GS Synthetic Leather Hardshell Case! Premium Qualtiy Synthetic Leather cover provides style, comfort, and protection to your iPhone 3G & 3GS. It also adds a sophisticated elegance and cool to your fashion. The case allows Quick...","manufacturer":"Luxmo","url":{"value":"http://www.bizrate.com/apple-iphone-3g3gs-silicone-case-black--pid2004746863/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2004746863","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2004746863","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2004746863","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2004746863","xsize":400,"ysize":400}]},"relevancy":65194915004416.000000,"priceSet":{"minPrice":{"value":"$0.01","integral":1},"maxPrice":{"value":"$414.99","integral":41499},"stores":39},"id":2004746863,"categoryId":8515},{"type":"PRODUCT","title":"Otterbox iPhone 4 Defender Case - Black","description":"Your iPhone 4 has become a big part of your life. With FaceTime video, retina display, multitasking, HD video recording and more - you've got a lot to lose. You won't find a tougher case than the OtterBox Defender Series for iPhone 4. This three-layer...","manufacturer":"Universal","url":{"value":"http://www.bizrate.com/otterbox-iphone-4-defender-case-black--pid2584611575/compareprices__rf--af1__af_assettype_id--10__af_creative_id--6__af_id--50085__af_placement_id--1.html"},"images":{"image":[{"value":"http://image10.bizrate-images.com/resize?sq=60&uid=2584611575","xsize":60,"ysize":60},{"value":"http://image10.bizrate-images.com/resize?sq=100&uid=2584611575","xsize":100,"ysize":100},{"value":"http://image10.bizrate-images.com/resize?sq=160&uid=2584611575","xsize":160,"ysize":160},{"value":"http://image10.bizrate-images.com/resize?sq=400&uid=2584611575","xsize":400,"ysize":400}]},"relevancy":61515478597632.000000,"priceSet":{"minPrice":{"value":"$3.28","integral":328},"maxPrice":{"value":"$110.65","integral":11065},"stores":25},"id":2584611575,"categoryId":8515}],"includedResults":10,"totalResults":2000}} +] + diff --git a/tests/auto/corelib/json/test2.json b/tests/auto/corelib/json/test2.json new file mode 100644 index 0000000000..303f879b62 --- /dev/null +++ b/tests/auto/corelib/json/test2.json @@ -0,0 +1 @@ +{ "foo": ["ab"] } diff --git a/tests/auto/corelib/json/test3.json b/tests/auto/corelib/json/test3.json new file mode 100644 index 0000000000..48cb29a47f --- /dev/null +++ b/tests/auto/corelib/json/test3.json @@ -0,0 +1,15 @@ +{ + "firstName": "John", + "lastName" : "Smith", + "age" : 25, + "address" : { + "streetAddress": "21 2nd Street", + "city" : "New York", + "state" : "NY", + "postalCode" : "10021" + }, + "phoneNumber": [ + { "type" : "home", "number": "212 555-1234" }, + { "type" : "fax", "number": "646 555-4567" } + ] +} diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp new file mode 100644 index 0000000000..e35f645ef6 --- /dev/null +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -0,0 +1,1589 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest> +#include "qjsonarray.h" +#include "qjsonobject.h" +#include "qjsonvalue.h" +#include "qjsondocument.h" + +class TestQtJson: public QObject +{ + Q_OBJECT +public: + TestQtJson(QObject *parent = 0); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + void testValueSimple(); + void testNumbers(); + + void testObjectSimple(); + void testObjectSmallKeys(); + void testArraySimple(); + void testValueObject(); + void testValueArray(); + void testObjectNested(); + void testArrayNested(); + void testArrayNestedEmpty(); + void testObjectNestedEmpty(); + + void testValueRef(); + void testObjectIteration(); + void testArrayIteration(); + + void testObjectFind(); + + void testDocument(); + + void nullValues(); + void nullArrays(); + void nullObject(); + + void keySorting(); + + void undefinedValues(); + + void fromVariantMap(); + void toVariantMap(); + void toVariantList(); + + void toJson(); + void fromJson(); + void fromBinary(); + void toAndFromBinary_data(); + void toAndFromBinary(); + void parseNumbers(); + void parseStrings(); + void parseDuplicateKeys(); + void testParser(); + + void compactArray(); + void compactObject(); + + void validation(); + + void assignToDocument(); + + void testDuplicateKeys(); + void testCompaction(); + void testDebugStream(); + void testCompactionError(); +}; + +TestQtJson::TestQtJson(QObject *parent) : QObject(parent) +{ +} + +void TestQtJson::initTestCase() +{ +} + +void TestQtJson::cleanupTestCase() +{ +} + +void TestQtJson::init() +{ +} + +void TestQtJson::cleanup() +{ +} + +void TestQtJson::testValueSimple() +{ + QJsonValue value(true); + QCOMPARE(value.type(), QJsonValue::Bool); + QCOMPARE(value.toDouble(), 0.); + QCOMPARE(value.toString(), QString()); + QCOMPARE(value.toBool(), true); + QCOMPARE(value.toObject(), QJsonObject()); + QCOMPARE(value.toArray(), QJsonArray()); + + value = 999.; + QCOMPARE(value.type(), QJsonValue::Double); + QCOMPARE(value.toDouble(), 999.); + QCOMPARE(value.toString(), QString()); + QCOMPARE(value.toBool(), false); + QCOMPARE(value.toObject(), QJsonObject()); + QCOMPARE(value.toArray(), QJsonArray()); + + value = QLatin1String("test"); + QCOMPARE(value.toDouble(), 0.); + QCOMPARE(value.toString(), QLatin1String("test")); + QCOMPARE(value.toBool(), false); + QCOMPARE(value.toObject(), QJsonObject()); + QCOMPARE(value.toArray(), QJsonArray()); + + value = true; + QCOMPARE(value.toDouble(), 0.); + QCOMPARE(value.toString(), QString()); + QCOMPARE(value.toBool(), true); + QCOMPARE(value.toObject(), QJsonObject()); + QCOMPARE(value.toArray(), QJsonArray()); + + value = 999.; + QCOMPARE(value.toDouble(), 999.); + QCOMPARE(value.toString(), QString()); + QCOMPARE(value.toBool(), false); + QCOMPARE(value.toObject(), QJsonObject()); + QCOMPARE(value.toArray(), QJsonArray()); + +} + +void TestQtJson::testNumbers() +{ + { + int numbers[] = { + 0, + -1, + 1, + (1<<26), + (1<<27), + (1<<28), + -(1<<26), + -(1<<27), + -(1<<28), + (1<<26) - 1, + (1<<27) - 1, + (1<<28) - 1, + -((1<<26) - 1), + -((1<<27) - 1), + -((1<<28) - 1) + }; + int n = sizeof(numbers)/sizeof(int); + + QJsonArray array; + for (int i = 0; i < n; ++i) + array.append((double)numbers[i]); + for (int i = 0; i < array.size(); ++i) { + QCOMPARE(array.at(i).type(), QJsonValue::Double); + QCOMPARE(array.at(i).toDouble(), (double)numbers[i]); + } + } + + { + double numbers[] = { + 0, + -1, + 1, + (1<<26), + (1<<27), + (1<<28), + -(1<<26), + -(1<<27), + -(1<<28), + (1<<26) - 1, + (1<<27) - 1, + (1<<28) - 1, + -((1<<26) - 1), + -((1<<27) - 1), + -((1<<28) - 1), + 1.1, + 0.1, + -0.1, + -1.1, + 1e200, + -1e200 + }; + int n = sizeof(numbers)/sizeof(double); + + QJsonArray array; + for (int i = 0; i < n; ++i) + array.append(numbers[i]); + for (int i = 0; i < array.size(); ++i) { + QCOMPARE(array.at(i).type(), QJsonValue::Double); + QCOMPARE(array.at(i).toDouble(), numbers[i]); + } + } + +} + +void TestQtJson::testObjectSimple() +{ + QJsonObject object; + object.insert("number", 999.); + QCOMPARE(object.value("number").type(), QJsonValue::Double); + QCOMPARE(object.value("number").toDouble(), 999.); + object.insert("string", QString::fromLatin1("test")); + QCOMPARE(object.value("string").type(), QJsonValue::String); + QCOMPARE(object.value("string").toString(), QString("test")); + object.insert("boolean", true); + QCOMPARE(object.value("boolean").toBool(), true); + + QStringList keys = object.keys(); + QVERIFY2(keys.contains("number"), "key number not found"); + QVERIFY2(keys.contains("string"), "key string not found"); + QVERIFY2(keys.contains("boolean"), "key boolean not found"); + + // if we put a JsonValue into the JsonObject and retreive + // it, it should be identical. + QJsonValue value(QLatin1String("foo")); + object.insert("value", value); + QCOMPARE(object.value("value"), value); + + int size = object.size(); + object.remove("boolean"); + QCOMPARE(object.size(), size - 1); + QVERIFY2(!object.contains("boolean"), "key boolean should have been removed"); + + QJsonValue taken = object.take("value"); +// QCOMPARE(taken, value); + QVERIFY2(!object.contains("value"), "key value should have been removed"); + + QString before = object.value("string").toString(); + object.insert("string", QString::fromLatin1("foo")); + QVERIFY2(object.value("string").toString() != before, "value should have been updated"); +} + +void TestQtJson::testObjectSmallKeys() +{ + QJsonObject data1; + data1.insert(QStringLiteral("1"), 123); + QVERIFY(data1.contains(QStringLiteral("1"))); + QCOMPARE(data1.value(QStringLiteral("1")).toDouble(), (double)123); + data1.insert(QStringLiteral("12"), 133); + QCOMPARE(data1.value(QStringLiteral("12")).toDouble(), (double)133); + QVERIFY(data1.contains(QStringLiteral("12"))); + data1.insert(QStringLiteral("123"), 323); + QCOMPARE(data1.value(QStringLiteral("12")).toDouble(), (double)133); + QVERIFY(data1.contains(QStringLiteral("123"))); + QCOMPARE(data1.value(QStringLiteral("123")).type(), QJsonValue::Double); + QCOMPARE(data1.value(QStringLiteral("123")).toDouble(), (double)323); +} + +void TestQtJson::testArraySimple() +{ + QJsonArray array; + array.append(999.); + array.append(QString::fromLatin1("test")); + array.append(true); + + QJsonValue val = array.at(0); + QCOMPARE(array.at(0).toDouble(), 999.); + QCOMPARE(array.at(1).toString(), QString("test")); + QCOMPARE(array.at(2).toBool(), true); + QCOMPARE(array.size(), 3); + + // if we put a JsonValue into the JsonArray and retreive + // it, it should be identical. + QJsonValue value(QLatin1String("foo")); + array.append(value); + QCOMPARE(array.at(3), value); + + int size = array.size(); + array.removeAt(2); + --size; + QCOMPARE(array.size(), size); + + QJsonValue taken = array.takeAt(0); + --size; + QCOMPARE(taken.toDouble(), 999.); + QCOMPARE(array.size(), size); + + // check whether null values work + array.append(QJsonValue()); + ++size; + QCOMPARE(array.size(), size); + QCOMPARE(array.last().type(), QJsonValue::Null); + QCOMPARE(array.last(), QJsonValue()); + + QCOMPARE(array.first().type(), QJsonValue::String); + QCOMPARE(array.first(), QJsonValue(QLatin1String("test"))); + + array.prepend(false); + QCOMPARE(array.first().type(), QJsonValue::Bool); + QCOMPARE(array.first(), QJsonValue(false)); + + QCOMPARE(array.at(-1), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(array.at(array.size()), QJsonValue(QJsonValue::Undefined)); + + array.replace(0, -555.); + QCOMPARE(array.first().type(), QJsonValue::Double); + QCOMPARE(array.first(), QJsonValue(-555.)); + QCOMPARE(array.at(1).type(), QJsonValue::String); + QCOMPARE(array.at(1), QJsonValue(QLatin1String("test"))); +} + +void TestQtJson::testValueObject() +{ + QJsonObject object; + object.insert("number", 999.); + object.insert("string", QLatin1String("test")); + object.insert("boolean", true); + + QJsonValue value(object); + + // if we don't modify the original JsonObject, toObject() + // on the JsonValue should return the same object (non-detached). + QCOMPARE(value.toObject(), object); + + // if we modify the original object, it should detach + object.insert("test", QJsonValue(QLatin1String("test"))); + QVERIFY2(value.toObject() != object, "object should have detached"); +} + +void TestQtJson::testValueArray() +{ + QJsonArray array; + array.append(999.); + array.append(QLatin1String("test")); + array.append(true); + + QJsonValue value(array); + + // if we don't modify the original JsonArray, toArray() + // on the JsonValue should return the same object (non-detached). + QCOMPARE(value.toArray(), array); + + // if we modify the original array, it should detach + array.append(QLatin1String("test")); + QVERIFY2(value.toArray() != array, "array should have detached"); +} + +void TestQtJson::testObjectNested() +{ + QJsonObject inner, outer; + inner.insert("number", 999.); + outer.insert("nested", inner); + + // if we don't modify the original JsonObject, value() + // should return the same object (non-detached). + QJsonObject value = outer.value("nested").toObject(); + QCOMPARE(value, inner); + QCOMPARE(value.value("number").toDouble(), 999.); + + // if we modify the original object, it should detach and not + // affect the nested object + inner.insert("number", 555.); + value = outer.value("nested").toObject(); + QVERIFY2(inner.value("number").toDouble() != value.value("number").toDouble(), + "object should have detached"); + + // array in object + QJsonArray array; + array.append(123.); + array.append(456.); + outer.insert("array", array); + QCOMPARE(outer.value("array").toArray(), array); + QCOMPARE(outer.value("array").toArray().at(1).toDouble(), 456.); + + // two deep objects + QJsonObject twoDeep; + twoDeep.insert("boolean", true); + inner.insert("nested", twoDeep); + outer.insert("nested", inner); + QCOMPARE(outer.value("nested").toObject().value("nested").toObject(), twoDeep); + QCOMPARE(outer.value("nested").toObject().value("nested").toObject().value("boolean").toBool(), + true); +} + +void TestQtJson::testArrayNested() +{ + QJsonArray inner, outer; + inner.append(999.); + outer.append(inner); + + // if we don't modify the original JsonArray, value() + // should return the same array (non-detached). + QJsonArray value = outer.at(0).toArray(); + QCOMPARE(value, inner); + QCOMPARE(value.at(0).toDouble(), 999.); + + // if we modify the original array, it should detach and not + // affect the nested array + inner.append(555.); + value = outer.at(0).toArray(); + QVERIFY2(inner.size() != value.size(), "array should have detached"); + + // objects in arrays + QJsonObject object; + object.insert("boolean", true); + outer.append(object); + QCOMPARE(outer.last().toObject(), object); + QCOMPARE(outer.last().toObject().value("boolean").toBool(), true); + + // two deep arrays + QJsonArray twoDeep; + twoDeep.append(QJsonValue(QString::fromLatin1("nested"))); + inner.append(twoDeep); + outer.append(inner); + QCOMPARE(outer.last().toArray().last().toArray(), twoDeep); + QCOMPARE(outer.last().toArray().last().toArray().at(0).toString(), QString("nested")); +} + +void TestQtJson::testArrayNestedEmpty() +{ + QJsonObject object; + QJsonArray inner; + object.insert("inner", inner); + QJsonValue val = object.value("inner"); + QJsonArray value = object.value("inner").toArray(); + QCOMPARE(value.size(), 0); + QCOMPARE(value, inner); + QCOMPARE(value.size(), 0); + object.insert("count", 0.); + QCOMPARE(object.value("inner").toArray().size(), 0); + QVERIFY(object.value("inner").toArray().isEmpty()); + QJsonDocument(object).toBinaryData(); + QCOMPARE(object.value("inner").toArray().size(), 0); +} + +void TestQtJson::testObjectNestedEmpty() +{ + QJsonObject object; + QJsonObject inner; + QJsonObject inner2; + object.insert("inner", inner); + object.insert("inner2", inner2); + QJsonObject value = object.value("inner").toObject(); + QCOMPARE(value.size(), 0); + QCOMPARE(value, inner); + QCOMPARE(value.size(), 0); + object.insert("count", 0.); + QCOMPARE(object.value("inner").toObject().size(), 0); + QCOMPARE(object.value("inner").type(), QJsonValue::Object); + QJsonDocument(object).toBinaryData(); + QVERIFY(object.value("inner").toObject().isEmpty()); + QVERIFY(object.value("inner2").toObject().isEmpty()); + QJsonDocument doc = QJsonDocument::fromBinaryData(QJsonDocument(object).toBinaryData()); + QVERIFY(!doc.isNull()); + QJsonObject reconstituted(doc.object()); + QCOMPARE(reconstituted.value("inner").toObject().size(), 0); + QCOMPARE(reconstituted.value("inner").type(), QJsonValue::Object); + QCOMPARE(reconstituted.value("inner2").type(), QJsonValue::Object); +} + +void TestQtJson::testValueRef() +{ + QJsonArray array; + array.append(1.); + array.append(2.); + array.append(3.); + array[1] = false; + + QCOMPARE(array.size(), 3); + QCOMPARE(array.at(0).toDouble(), 1.); + QCOMPARE(array.at(2).toDouble(), 3.); + QCOMPARE(array.at(1).type(), QJsonValue::Bool); + QCOMPARE(array.at(1).toBool(), false); + + QJsonObject object; + object[QLatin1String("key")] = true; + QCOMPARE(object.size(), 1); + object.insert(QLatin1String("null"), QJsonValue()); + QCOMPARE(object.value(QLatin1String("null")), QJsonValue()); + object[QLatin1String("null")] = 100.; + QCOMPARE(object.value(QLatin1String("null")).type(), QJsonValue::Double); + QJsonValue val = object[QLatin1String("null")]; + QCOMPARE(val.toDouble(), 100.); + QCOMPARE(object.size(), 2); +} + +void TestQtJson::testObjectIteration() +{ + QJsonObject object; + for (int i = 0; i < 10; ++i) + object[QString::number(i)] = (double)i; + + QCOMPARE(object.size(), 10); + + for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it) { + QJsonValue value = it.value(); + QCOMPARE((double)it.key().toInt(), value.toDouble()); + } + + { + QJsonObject object2 = object; + QVERIFY(object == object2); + + QJsonValue val = *object2.begin(); + object2.erase(object2.begin()); + QCOMPARE(object.size(), 10); + QCOMPARE(object2.size(), 9); + + for (QJsonObject::const_iterator it = object2.constBegin(); it != object2.constEnd(); ++it) { + QJsonValue value = it.value(); + QVERIFY(it.value() != val); + QCOMPARE((double)it.key().toInt(), value.toDouble()); + } + } + + { + QJsonObject::Iterator it = object.begin(); + it += 5; + QCOMPARE(QJsonValue(it.value()).toDouble(), 5.); + it -= 3; + QCOMPARE(QJsonValue(it.value()).toDouble(), 2.); + QJsonObject::Iterator it2 = it + 5; + QCOMPARE(QJsonValue(it2.value()).toDouble(), 7.); + it2 = it - 1; + QCOMPARE(QJsonValue(it2.value()).toDouble(), 1.); + } + + { + QJsonObject::ConstIterator it = object.constBegin(); + it += 5; + QCOMPARE(QJsonValue(it.value()).toDouble(), 5.); + it -= 3; + QCOMPARE(QJsonValue(it.value()).toDouble(), 2.); + QJsonObject::ConstIterator it2 = it + 5; + QCOMPARE(QJsonValue(it2.value()).toDouble(), 7.); + it2 = it - 1; + QCOMPARE(QJsonValue(it2.value()).toDouble(), 1.); + } + + QJsonObject::Iterator it = object.begin(); + while (!object.isEmpty()) + it = object.erase(it); + QCOMPARE(object.size() , 0); + QVERIFY(it == object.end()); +} + +void TestQtJson::testArrayIteration() +{ + QJsonArray array; + for (int i = 0; i < 10; ++i) + array.append(i); + + QCOMPARE(array.size(), 10); + + int i = 0; + for (QJsonArray::iterator it = array.begin(); it != array.end(); ++it, ++i) { + QJsonValue value = (*it); + QCOMPARE((double)i, value.toDouble()); + } + + { + QJsonArray array2 = array; + QVERIFY(array == array2); + + QJsonValue val = *array2.begin(); + array2.erase(array2.begin()); + QCOMPARE(array.size(), 10); + QCOMPARE(array2.size(), 9); + + i = 1; + for (QJsonArray::const_iterator it = array2.constBegin(); it != array2.constEnd(); ++it, ++i) { + QJsonValue value = (*it); + QCOMPARE((double)i, value.toDouble()); + } + } + + { + QJsonArray::Iterator it = array.begin(); + it += 5; + QCOMPARE(QJsonValue((*it)).toDouble(), 5.); + it -= 3; + QCOMPARE(QJsonValue((*it)).toDouble(), 2.); + QJsonArray::Iterator it2 = it + 5; + QCOMPARE(QJsonValue(*it2).toDouble(), 7.); + it2 = it - 1; + QCOMPARE(QJsonValue(*it2).toDouble(), 1.); + } + + { + QJsonArray::ConstIterator it = array.constBegin(); + it += 5; + QCOMPARE(QJsonValue((*it)).toDouble(), 5.); + it -= 3; + QCOMPARE(QJsonValue((*it)).toDouble(), 2.); + QJsonArray::ConstIterator it2 = it + 5; + QCOMPARE(QJsonValue(*it2).toDouble(), 7.); + it2 = it - 1; + QCOMPARE(QJsonValue(*it2).toDouble(), 1.); + } + + QJsonArray::Iterator it = array.begin(); + while (!array.isEmpty()) + it = array.erase(it); + QCOMPARE(array.size() , 0); + QVERIFY(it == array.end()); +} + +void TestQtJson::testObjectFind() +{ + QJsonObject object; + for (int i = 0; i < 10; ++i) + object[QString::number(i)] = i; + + QCOMPARE(object.size(), 10); + + QJsonObject::iterator it = object.find(QLatin1String("1")); + QCOMPARE((*it).toDouble(), 1.); + it = object.find(QLatin1String("11")); + QVERIFY((*it).type() == QJsonValue::Undefined); + QVERIFY(it == object.end()); + + QJsonObject::const_iterator cit = object.constFind(QLatin1String("1")); + QCOMPARE((*cit).toDouble(), 1.); + cit = object.constFind(QLatin1String("11")); + QVERIFY((*it).type() == QJsonValue::Undefined); + QVERIFY(it == object.end()); +} + +void TestQtJson::testDocument() +{ + QJsonDocument doc; + QCOMPARE(doc.isEmpty(), true); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), false); + + QJsonObject object; + doc.setObject(object); + QCOMPARE(doc.isEmpty(), false); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), true); + + object.insert(QLatin1String("Key"), QLatin1String("Value")); + doc.setObject(object); + QCOMPARE(doc.isEmpty(), false); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), true); + QVERIFY(doc.object() == object); + QVERIFY(doc.array() == QJsonArray()); + + doc = QJsonDocument(); + QCOMPARE(doc.isEmpty(), true); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), false); + + QJsonArray array; + doc.setArray(array); + QCOMPARE(doc.isEmpty(), false); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + + array.append(QLatin1String("Value")); + doc.setArray(array); + QCOMPARE(doc.isEmpty(), false); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QVERIFY(doc.array() == array); + QVERIFY(doc.object() == QJsonObject()); + + QJsonObject outer; + outer.insert(QLatin1String("outerKey"), 22); + QJsonObject inner; + inner.insert(QLatin1String("innerKey"), 42); + outer.insert(QLatin1String("innter"), inner); + QJsonArray innerArray; + innerArray.append(23); + outer.insert(QLatin1String("innterArray"), innerArray); + + QJsonDocument doc2(outer.value(QLatin1String("innter")).toObject()); + QVERIFY(doc2.object().contains(QLatin1String("innerKey"))); + QCOMPARE(doc2.object().value(QLatin1String("innerKey")), QJsonValue(42)); + + QJsonDocument doc3; + doc3.setObject(outer.value(QLatin1String("innter")).toObject()); + QCOMPARE(doc3.isArray(), false); + QCOMPARE(doc3.isObject(), true); + QVERIFY(doc3.object().contains(QLatin1String("innerKey"))); + QCOMPARE(doc3.object().value(QLatin1String("innerKey")), QJsonValue(42)); + + QJsonDocument doc4(outer.value(QLatin1String("innterArray")).toArray()); + QCOMPARE(doc4.isArray(), true); + QCOMPARE(doc4.isObject(), false); + QCOMPARE(doc4.array().size(), 1); + QCOMPARE(doc4.array().at(0), QJsonValue(23)); + + QJsonDocument doc5; + doc5.setArray(outer.value(QLatin1String("innterArray")).toArray()); + QCOMPARE(doc5.isArray(), true); + QCOMPARE(doc5.isObject(), false); + QCOMPARE(doc5.array().size(), 1); + QCOMPARE(doc5.array().at(0), QJsonValue(23)); +} + +void TestQtJson::nullValues() +{ + QJsonArray array; + array.append(QJsonValue()); + + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), QJsonValue()); + + QJsonObject object; + object.insert(QString("key"), QJsonValue()); + QCOMPARE(object.contains("key"), true); + QCOMPARE(object.size(), 1); + QCOMPARE(object.value("key"), QJsonValue()); +} + +void TestQtJson::nullArrays() +{ + QJsonArray nullArray; + QJsonArray nonNull; + nonNull.append(QLatin1String("bar")); + + QCOMPARE(nullArray, QJsonArray()); + QVERIFY(nullArray != nonNull); + QVERIFY(nonNull != nullArray); + + QCOMPARE(nullArray.size(), 0); + QCOMPARE(nullArray.takeAt(0), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(nullArray.first(), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(nullArray.last(), QJsonValue(QJsonValue::Undefined)); + nullArray.removeAt(0); + nullArray.removeAt(-1); + + nullArray.append(QString("bar")); + nullArray.removeAt(0); + + QCOMPARE(nullArray.size(), 0); + QCOMPARE(nullArray.takeAt(0), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(nullArray.first(), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(nullArray.last(), QJsonValue(QJsonValue::Undefined)); + nullArray.removeAt(0); + nullArray.removeAt(-1); +} + +void TestQtJson::nullObject() +{ + QJsonObject nullObject; + QJsonObject nonNull; + nonNull.insert(QLatin1String("foo"), QLatin1String("bar")); + + QCOMPARE(nullObject, QJsonObject()); + QVERIFY(nullObject != nonNull); + QVERIFY(nonNull != nullObject); + + QCOMPARE(nullObject.size(), 0); + QCOMPARE(nullObject.keys(), QStringList()); + nullObject.remove("foo"); + QCOMPARE(nullObject, QJsonObject()); + QCOMPARE(nullObject.take("foo"), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(nullObject.contains("foo"), false); + + nullObject.insert("foo", QString("bar")); + nullObject.remove("foo"); + + QCOMPARE(nullObject.size(), 0); + QCOMPARE(nullObject.keys(), QStringList()); + nullObject.remove("foo"); + QCOMPARE(nullObject, QJsonObject()); + QCOMPARE(nullObject.take("foo"), QJsonValue(QJsonValue::Undefined)); + QCOMPARE(nullObject.contains("foo"), false); +} + +void TestQtJson::keySorting() +{ + const char *json = "{ \"B\": true, \"A\": false }"; + QJsonDocument doc = QJsonDocument::fromJson(json); + + QCOMPARE(doc.isObject(), true); + + QJsonObject o = doc.object(); + QCOMPARE(o.size(), 2); + QJsonObject::const_iterator it = o.constBegin(); + QCOMPARE(it.key(), QLatin1String("A")); + ++it; + QCOMPARE(it.key(), QLatin1String("B")); +} + +void TestQtJson::undefinedValues() +{ + QJsonObject object; + object.insert("Key", QJsonValue(QJsonValue::Undefined)); + QCOMPARE(object.size(), 0); + + object.insert("Key", QLatin1String("Value")); + QCOMPARE(object.size(), 1); + QCOMPARE(object.value("Key").type(), QJsonValue::String); + QCOMPARE(object.value("foo").type(), QJsonValue::Undefined); + object.insert("Key", QJsonValue(QJsonValue::Undefined)); + QCOMPARE(object.size(), 0); + QCOMPARE(object.value("Key").type(), QJsonValue::Undefined); + + QJsonArray array; + array.append(QJsonValue(QJsonValue::Undefined)); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0).type(), QJsonValue::Null); + + QCOMPARE(array.at(1).type(), QJsonValue::Undefined); + QCOMPARE(array.at(-1).type(), QJsonValue::Undefined); +} + + +void TestQtJson::fromVariantMap() +{ + QVariantMap map; + map.insert(QLatin1String("key1"), QLatin1String("value1")); + map.insert(QLatin1String("key2"), QLatin1String("value2")); + QJsonObject object = QJsonObject::fromVariantMap(map); + QCOMPARE(object.size(), 2); + QCOMPARE(object.value(QLatin1String("key1")), QJsonValue(QLatin1String("value1"))); + QCOMPARE(object.value(QLatin1String("key2")), QJsonValue(QLatin1String("value2"))); + + QVariantList list; + list.append(true); + list.append(QVariant()); + list.append(999.); + list.append(QLatin1String("foo")); + map.insert("list", list); + object = QJsonObject::fromVariantMap(map); + QCOMPARE(object.size(), 3); + QCOMPARE(object.value(QLatin1String("key1")), QJsonValue(QLatin1String("value1"))); + QCOMPARE(object.value(QLatin1String("key2")), QJsonValue(QLatin1String("value2"))); + QCOMPARE(object.value(QLatin1String("list")).type(), QJsonValue::Array); + QJsonArray array = object.value(QLatin1String("list")).toArray(); + QCOMPARE(array.size(), 4); + QCOMPARE(array.at(0).type(), QJsonValue::Bool); + QCOMPARE(array.at(0).toBool(), true); + QCOMPARE(array.at(1).type(), QJsonValue::Null); + QCOMPARE(array.at(2).type(), QJsonValue::Double); + QCOMPARE(array.at(2).toDouble(), 999.); + QCOMPARE(array.at(3).type(), QJsonValue::String); + QCOMPARE(array.at(3).toString(), QLatin1String("foo")); +} + +void TestQtJson::toVariantMap() +{ + QJsonObject object; + QVariantMap map = object.toVariantMap(); + QVERIFY(map.isEmpty()); + + object.insert("Key", QString("Value")); + object.insert("null", QJsonValue()); + QJsonArray array; + array.append(true); + array.append(999.); + array.append(QLatin1String("string")); + array.append(QJsonValue()); + object.insert("Array", array); + + map = object.toVariantMap(); + + QCOMPARE(map.size(), 3); + QCOMPARE(map.value("Key"), QVariant(QString("Value"))); + QCOMPARE(map.value("null"), QVariant()); + QCOMPARE(map.value("Array").type(), QVariant::List); + QVariantList list = map.value("Array").toList(); + QCOMPARE(list.size(), 4); + QCOMPARE(list.at(0), QVariant(true)); + QCOMPARE(list.at(1), QVariant(999.)); + QCOMPARE(list.at(2), QVariant(QLatin1String("string"))); + QCOMPARE(list.at(3), QVariant()); +} + +void TestQtJson::toVariantList() +{ + QJsonArray array; + QVariantList list = array.toVariantList(); + QVERIFY(list.isEmpty()); + + array.append(QString("Value")); + array.append(QJsonValue()); + QJsonArray inner; + inner.append(true); + inner.append(999.); + inner.append(QLatin1String("string")); + inner.append(QJsonValue()); + array.append(inner); + + list = array.toVariantList(); + + QCOMPARE(list.size(), 3); + QCOMPARE(list[0], QVariant(QString("Value"))); + QCOMPARE(list[1], QVariant()); + QCOMPARE(list[2].type(), QVariant::List); + QVariantList vlist = list[2].toList(); + QCOMPARE(vlist.size(), 4); + QCOMPARE(vlist.at(0), QVariant(true)); + QCOMPARE(vlist.at(1), QVariant(999.)); + QCOMPARE(vlist.at(2), QVariant(QLatin1String("string"))); + QCOMPARE(vlist.at(3), QVariant()); +} + +void TestQtJson::toJson() +{ + QJsonObject object; + object.insert("\\Key\n", QString("Value")); + object.insert("null", QJsonValue()); + QJsonArray array; + array.append(true); + array.append(999.); + array.append(QLatin1String("string")); + array.append(QJsonValue()); + array.append(QLatin1String("\\\a\n\r\b\tabcABC\"")); + object.insert("Array", array); + + QByteArray json = QJsonDocument(object).toJson(); + + QByteArray expected = + "{\n" + " \"Array\": [\n" + " true,\n" + " 999,\n" + " \"string\",\n" + " null,\n" + " \"\\\\\\u0007\\n\\r\\b\\tabcABC\\\"\"\n" + " ],\n" + " \"\\\\Key\\n\": \"Value\",\n" + " \"null\": null\n" + "}\n"; + QCOMPARE(json, expected); + + QJsonDocument doc; + doc.setObject(object); + json = doc.toJson(); + QCOMPARE(json, expected); + + doc.setArray(array); + json = doc.toJson(); + expected = + "[\n" + " true,\n" + " 999,\n" + " \"string\",\n" + " null,\n" + " \"\\\\\\u0007\\n\\r\\b\\tabcABC\\\"\"\n" + "]\n"; + QCOMPARE(json, expected); +} + +void TestQtJson::fromJson() +{ + { + QByteArray json = "[\n true\n]\n"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0).type(), QJsonValue::Bool); + QCOMPARE(array.at(0).toBool(), true); + QCOMPARE(doc.toJson(), json); + } + { + QByteArray json = "[]"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 0); + } + { + QByteArray json = "{}"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), true); + QJsonObject object = doc.object(); + QCOMPARE(object.size(), 0); + } + { + QByteArray json = "{\n \"Key\": true\n}\n"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), true); + QJsonObject object = doc.object(); + QCOMPARE(object.size(), 1); + QCOMPARE(object.value("Key"), QJsonValue(true)); + QCOMPARE(doc.toJson(), json); + } + { + QByteArray json = "[ null, true, false, \"Foo\", 1, [], {} ]"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 7); + QCOMPARE(array.at(0).type(), QJsonValue::Null); + QCOMPARE(array.at(1).type(), QJsonValue::Bool); + QCOMPARE(array.at(1).toBool(), true); + QCOMPARE(array.at(2).type(), QJsonValue::Bool); + QCOMPARE(array.at(2).toBool(), false); + QCOMPARE(array.at(3).type(), QJsonValue::String); + QCOMPARE(array.at(3).toString(), QLatin1String("Foo")); + QCOMPARE(array.at(4).type(), QJsonValue::Double); + QCOMPARE(array.at(4).toDouble(), 1.); + QCOMPARE(array.at(5).type(), QJsonValue::Array); + QCOMPARE(array.at(5).toArray().size(), 0); + QCOMPARE(array.at(6).type(), QJsonValue::Object); + QCOMPARE(array.at(6).toObject().size(), 0); + } + { + QByteArray json = "{ \"0\": null, \"1\": true, \"2\": false, \"3\": \"Foo\", \"4\": 1, \"5\": [], \"6\": {} }"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), true); + QJsonObject object = doc.object(); + QCOMPARE(object.size(), 7); + QCOMPARE(object.value("0").type(), QJsonValue::Null); + QCOMPARE(object.value("1").type(), QJsonValue::Bool); + QCOMPARE(object.value("1").toBool(), true); + QCOMPARE(object.value("2").type(), QJsonValue::Bool); + QCOMPARE(object.value("2").toBool(), false); + QCOMPARE(object.value("3").type(), QJsonValue::String); + QCOMPARE(object.value("3").toString(), QLatin1String("Foo")); + QCOMPARE(object.value("4").type(), QJsonValue::Double); + QCOMPARE(object.value("4").toDouble(), 1.); + QCOMPARE(object.value("5").type(), QJsonValue::Array); + QCOMPARE(object.value("5").toArray().size(), 0); + QCOMPARE(object.value("6").type(), QJsonValue::Object); + QCOMPARE(object.value("6").toObject().size(), 0); + } +} + +void TestQtJson::fromBinary() +{ + QFile file(QLatin1String(SRCDIR "test.json")); + file.open(QFile::ReadOnly); + QByteArray testJson = file.readAll(); + + QJsonDocument doc = QJsonDocument::fromJson(testJson); + QJsonDocument outdoc = QJsonDocument::fromBinaryData(doc.toBinaryData()); + QVERIFY(!outdoc.isNull()); + QVERIFY(doc == outdoc); + + QFile bfile(QLatin1String(SRCDIR "test.bjson")); + bfile.open(QFile::ReadOnly); + QByteArray binary = bfile.readAll(); + + QJsonDocument bdoc = QJsonDocument::fromBinaryData(binary); + QVERIFY(!bdoc.isNull()); + QVERIFY(doc.toVariant() == bdoc.toVariant()); + QVERIFY(doc == bdoc); +} + +void TestQtJson::toAndFromBinary_data() +{ + QTest::addColumn<QString>("filename"); + QTest::newRow("test.json") << QString::fromLatin1(SRCDIR "test.json"); + QTest::newRow("test2.json") << QString::fromLatin1(SRCDIR "test2.json"); +} + +void TestQtJson::toAndFromBinary() +{ + QFETCH(QString, filename); + QFile file(filename); + QVERIFY(file.open(QFile::ReadOnly)); + QByteArray data = file.readAll(); + + QJsonDocument doc = QJsonDocument::fromJson(data); + QVERIFY(!doc.isNull()); + QJsonDocument outdoc = QJsonDocument::fromBinaryData(doc.toBinaryData()); + QVERIFY(!outdoc.isNull()); + QVERIFY(doc == outdoc); +} + +void TestQtJson::parseNumbers() +{ + { + // test number parsing + struct Numbers { + const char *str; + int n; + }; + Numbers numbers [] = { + { "0", 0 }, + { "1", 1 }, + { "10", 10 }, + { "-1", -1 }, + { "100000", 100000 }, + { "-999", -999 } + }; + int size = sizeof(numbers)/sizeof(Numbers); + for (int i = 0; i < size; ++i) { + QByteArray json = "[ "; + json += numbers[i].str; + json += " ]"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 1); + QJsonValue val = array.at(0); + QCOMPARE(val.type(), QJsonValue::Double); + QCOMPARE(val.toDouble(), (double)numbers[i].n); + } + } + { + // test number parsing + struct Numbers { + const char *str; + double n; + }; + Numbers numbers [] = { + { "0", 0 }, + { "1", 1 }, + { "10", 10 }, + { "-1", -1 }, + { "100000", 100000 }, + { "-999", -999 }, + { "1.1", 1.1 }, + { "1e10", 1e10 }, + { "-1.1", -1.1 }, + { "-1e10", -1e10 }, + { "-1E10", -1e10 }, + { "1.1e10", 1.1e10 }, + { "1.1e308", 1.1e308 }, + { "-1.1e308", -1.1e308 }, + { "1.1e-308", 1.1e-308 }, + { "-1.1e-308", -1.1e-308 }, + { "1.1e+308", 1.1e+308 }, + { "-1.1e+308", -1.1e+308 }, + { "1.e+308", 1.e+308 }, + { "-1.e+308", -1.e+308 } + }; + int size = sizeof(numbers)/sizeof(Numbers); + for (int i = 0; i < size; ++i) { + QByteArray json = "[ "; + json += numbers[i].str; + json += " ]"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 1); + QJsonValue val = array.at(0); + QCOMPARE(val.type(), QJsonValue::Double); + QCOMPARE(val.toDouble(), numbers[i].n); + } + } +} + +void TestQtJson::parseStrings() +{ + const char *strings [] = + { + "Foo", + "abc\\\"abc", + "abc\\\\abc", + "abc\\babc", + "abc\\fabc", + "abc\\nabc", + "abc\\rabc", + "abc\\tabc", + "abc\\u0019abc", + "abcЂabc", + }; + int size = sizeof(strings)/sizeof(const char *); + + for (int i = 0; i < size; ++i) { + QByteArray json = "[\n \""; + json += strings[i]; + json += "\"\n]\n"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 1); + QJsonValue val = array.at(0); + QCOMPARE(val.type(), QJsonValue::String); + + QCOMPARE(doc.toJson(), json); + } + + struct Pairs { + const char *in; + const char *out; + }; + Pairs pairs [] = { + { "abc\\/abc", "abc/abc" }, + { "abc\\u0402abc", "abcЂabc" }, + { "abc\\u0065abc", "abceabc" } + }; + size = sizeof(pairs)/sizeof(Pairs); + + for (int i = 0; i < size; ++i) { + QByteArray json = "[\n \""; + json += pairs[i].in; + json += "\"\n]\n"; + QByteArray out = "[\n \""; + out += pairs[i].out; + out += "\"\n]\n"; + QJsonDocument doc = QJsonDocument::fromJson(json); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), true); + QCOMPARE(doc.isObject(), false); + QJsonArray array = doc.array(); + QCOMPARE(array.size(), 1); + QJsonValue val = array.at(0); + QCOMPARE(val.type(), QJsonValue::String); + + QCOMPARE(doc.toJson(), out); + } + +} + +void TestQtJson::parseDuplicateKeys() +{ + const char *json = "{ \"B\": true, \"A\": null, \"B\": false }"; + + QJsonDocument doc = QJsonDocument::fromJson(json); + QCOMPARE(doc.isObject(), true); + + QJsonObject o = doc.object(); + QCOMPARE(o.size(), 2); + QJsonObject::const_iterator it = o.constBegin(); + QCOMPARE(it.key(), QLatin1String("A")); + QCOMPARE(it.value(), QJsonValue()); + ++it; + QCOMPARE(it.key(), QLatin1String("B")); + QCOMPARE(it.value(), QJsonValue(false)); +} + +void TestQtJson::testParser() +{ + QFile file(QLatin1String(SRCDIR "test.json")); + file.open(QFile::ReadOnly); + QByteArray testJson = file.readAll(); + + QJsonDocument doc = QJsonDocument::fromJson(testJson); + QVERIFY(!doc.isEmpty()); +} + +void TestQtJson::compactArray() +{ + QJsonArray array; + array.append(QLatin1String("First Entry")); + array.append(QLatin1String("Second Entry")); + array.append(QLatin1String("Third Entry")); + QJsonDocument doc(array); + int s = doc.toBinaryData().size(); + array.removeAt(1); + doc.setArray(array); + QVERIFY(s > doc.toBinaryData().size()); + s = doc.toBinaryData().size(); + QCOMPARE(doc.toJson(), + QByteArray("[\n" + " \"First Entry\",\n" + " \"Third Entry\"\n" + "]\n")); + + array.removeAt(0); + doc.setArray(array); + QVERIFY(s > doc.toBinaryData().size()); + s = doc.toBinaryData().size(); + QCOMPARE(doc.toJson(), + QByteArray("[\n" + " \"Third Entry\"\n" + "]\n")); + + array.removeAt(0); + doc.setArray(array); + QVERIFY(s > doc.toBinaryData().size()); + s = doc.toBinaryData().size(); + QCOMPARE(doc.toJson(), + QByteArray("[\n" + "]\n")); + +} + +void TestQtJson::compactObject() +{ + QJsonObject object; + object.insert(QLatin1String("Key1"), QLatin1String("First Entry")); + object.insert(QLatin1String("Key2"), QLatin1String("Second Entry")); + object.insert(QLatin1String("Key3"), QLatin1String("Third Entry")); + QJsonDocument doc(object); + int s = doc.toBinaryData().size(); + object.remove(QLatin1String("Key2")); + doc.setObject(object); + QVERIFY(s > doc.toBinaryData().size()); + s = doc.toBinaryData().size(); + QCOMPARE(doc.toJson(), + QByteArray("{\n" + " \"Key1\": \"First Entry\",\n" + " \"Key3\": \"Third Entry\"\n" + "}\n")); + + object.remove(QLatin1String("Key1")); + doc.setObject(object); + QVERIFY(s > doc.toBinaryData().size()); + s = doc.toBinaryData().size(); + QCOMPARE(doc.toJson(), + QByteArray("{\n" + " \"Key3\": \"Third Entry\"\n" + "}\n")); + + object.remove(QLatin1String("Key3")); + doc.setObject(object); + QVERIFY(s > doc.toBinaryData().size()); + s = doc.toBinaryData().size(); + QCOMPARE(doc.toJson(), + QByteArray("{\n" + "}\n")); + +} + +void TestQtJson::validation() +{ + // this basically tests that we don't crash on corrupt data + QFile file(QLatin1String(SRCDIR "test.json")); + QVERIFY(file.open(QFile::ReadOnly)); + QByteArray testJson = file.readAll(); + QVERIFY(!testJson.isEmpty()); + + QJsonDocument doc = QJsonDocument::fromJson(testJson); + QVERIFY(!doc.isNull()); + + QByteArray binary = doc.toBinaryData(); + + // only test the first 1000 bytes. Testing the full file takes too long + for (int i = 0; i < 1000; ++i) { + QByteArray corrupted = binary; + corrupted[i] = 0xff; + QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); + if (doc.isNull()) + continue; + QByteArray json = doc.toJson(); + } + + + QFile file2(QLatin1String(SRCDIR "test3.json")); + file2.open(QFile::ReadOnly); + testJson = file2.readAll(); + QVERIFY(!testJson.isEmpty()); + + doc = QJsonDocument::fromJson(testJson); + QVERIFY(!doc.isNull()); + + binary = doc.toBinaryData(); + + for (int i = 0; i < binary.size(); ++i) { + QByteArray corrupted = binary; + corrupted[i] = 0xff; + QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); + if (doc.isNull()) + continue; + QByteArray json = doc.toJson(); + + corrupted = binary; + corrupted[i] = 0x00; + doc = QJsonDocument::fromBinaryData(corrupted); + if (doc.isNull()) + continue; + json = doc.toJson(); + } +} + +void TestQtJson::assignToDocument() +{ + { + const char *json = "{ \"inner\": { \"key\": true } }"; + QJsonDocument doc = QJsonDocument::fromJson(json); + + QJsonObject o = doc.object(); + QJsonValue inner = o.value("inner"); + + QJsonDocument innerDoc(inner.toObject()); + + QVERIFY(innerDoc != doc); + QVERIFY(innerDoc.object() == inner.toObject()); + } + { + const char *json = "[ [ true ] ]"; + QJsonDocument doc = QJsonDocument::fromJson(json); + + QJsonArray a = doc.array(); + QJsonValue inner = a.at(0); + + QJsonDocument innerDoc(inner.toArray()); + + QVERIFY(innerDoc != doc); + QVERIFY(innerDoc.array() == inner.toArray()); + } +} + + +void TestQtJson::testDuplicateKeys() +{ + QJsonObject obj; + obj.insert(QLatin1String("foo"), QLatin1String("bar")); + obj.insert(QLatin1String("foo"), QLatin1String("zap")); + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value(QLatin1String("foo")).toString(), QLatin1String("zap")); +} + +void TestQtJson::testCompaction() +{ + // modify object enough times to trigger compactionCounter + // and make sure the data is still valid + QJsonObject obj; + for (int i = 0; i < 33; ++i) { + obj.remove(QLatin1String("foo")); + obj.insert(QLatin1String("foo"), QLatin1String("bar")); + } + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value(QLatin1String("foo")).toString(), QLatin1String("bar")); + + QJsonDocument doc = QJsonDocument::fromBinaryData(QJsonDocument(obj).toBinaryData()); + QVERIFY(!doc.isNull()); + QVERIFY(!doc.isEmpty()); + QCOMPARE(doc.isArray(), false); + QCOMPARE(doc.isObject(), true); + QVERIFY(doc.object() == obj); +} + +void TestQtJson::testDebugStream() +{ + { + // QJsonObject + + QJsonObject object; + QTest::ignoreMessage(QtDebugMsg, "QJsonObject() "); + qDebug() << object; + + object.insert(QLatin1String("foo"), QLatin1String("bar")); + QTest::ignoreMessage(QtDebugMsg, "QJsonObject({\"foo\": \"bar\"}) "); + qDebug() << object; + } + + { + // QJsonArray + + QJsonArray array; + QTest::ignoreMessage(QtDebugMsg, "QJsonArray() "); + qDebug() << array; + + array.append(1); + array.append(QLatin1String("foo")); + QTest::ignoreMessage(QtDebugMsg, "QJsonArray([1,\"foo\"]) "); + qDebug() << array; + } + + { + // QJsonDocument + + QJsonDocument doc; + QTest::ignoreMessage(QtDebugMsg, "QJsonDocument() "); + qDebug() << doc; + + QJsonObject object; + object.insert(QLatin1String("foo"), QLatin1String("bar")); + doc.setObject(object); + QTest::ignoreMessage(QtDebugMsg, "QJsonDocument({\"foo\": \"bar\"}) "); + qDebug() << doc; + + QJsonArray array; + array.append(1); + array.append(QLatin1String("foo")); + QTest::ignoreMessage(QtDebugMsg, "QJsonDocument([1,\"foo\"]) "); + doc.setArray(array); + qDebug() << doc; + } + + { + // QJsonValue + + QJsonValue value; + + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(null) "); + qDebug() << value; + + value = QJsonValue(true); // bool + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(bool, true) "); + qDebug() << value; + + value = QJsonValue((double)4.2); // double + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(double, 4.2) "); + qDebug() << value; + + value = QJsonValue((int)42); // int + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(double, 42) "); + qDebug() << value; + + value = QJsonValue(QLatin1String("foo")); // string + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(string, \"foo\") "); + qDebug() << value; + + QJsonArray array; + array.append(1); + array.append(QLatin1String("foo")); + value = QJsonValue(array); // array + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(array, QJsonArray([1,\"foo\"]) ) "); + qDebug() << value; + + QJsonObject object; + object.insert(QLatin1String("foo"), QLatin1String("bar")); + value = QJsonValue(object); // object + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(object, QJsonObject({\"foo\": \"bar\"}) ) "); + qDebug() << value; + } +} + +void TestQtJson::testCompactionError() +{ + QJsonObject schemaObject; + schemaObject.insert("_Type", QLatin1String("_SchemaType")); + schemaObject.insert("name", QLatin1String("Address")); + schemaObject.insert("schema", QJsonObject()); + { + QJsonObject content(schemaObject); + QJsonDocument doc(content); + QVERIFY(!doc.isNull()); + QByteArray hash = QCryptographicHash::hash(doc.toBinaryData(), QCryptographicHash::Md5).toHex(); + schemaObject.insert("_Version", QString::fromLatin1(hash.constData(), hash.size())); + } + + QJsonObject schema; + schema.insert("streetNumber", schema.value("number").toObject()); + schemaObject.insert("schema", schema); + { + QJsonObject content(schemaObject); + content.remove("_Uuid"); + content.remove("_Version"); + QJsonDocument doc(content); + QVERIFY(!doc.isNull()); + QByteArray hash = QCryptographicHash::hash(doc.toBinaryData(), QCryptographicHash::Md5).toHex(); + schemaObject.insert("_Version", QString::fromLatin1(hash.constData(), hash.size())); + } +} + +QTEST_MAIN(TestQtJson) +#include "tst_qtjson.moc" diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index f9a38c2f14..14df20c986 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -1,4 +1,4 @@ CONFIG += testcase parallel_test TARGET = tst_qcoreapplication -QT = core testlib +QT = core testlib core-private SOURCES = tst_qcoreapplication.cpp diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 5c2ebc8948..97c9757107 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,14 +34,18 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ - #include <QtCore/QtCore> #include <QtTest/QtTest> +#include <private/qcoreapplication_p.h> +#include <private/qeventloop_p.h> +#include <private/qthread_p.h> + class tst_QCoreApplication: public QObject { Q_OBJECT @@ -63,6 +66,7 @@ private slots: void execAfterExit(); void eventLoopExecAfterExit(); void customEventDispatcher(); + void testQuitLock(); }; class EventSpy : public QObject @@ -127,7 +131,7 @@ void tst_QCoreApplication::argc() char *argv[] = { "tst_qcoreapplication" }; QCoreApplication app(argc, argv); QCOMPARE(argc, 1); - QCOMPARE(app.argc(), 1); + QCOMPARE(app.arguments().count(), 1); } { @@ -135,7 +139,7 @@ void tst_QCoreApplication::argc() char *argv[] = { "tst_qcoreapplication", "arg1", "arg2", "arg3" }; QCoreApplication app(argc, argv); QCOMPARE(argc, 4); - QCOMPARE(app.argc(), 4); + QCOMPARE(app.arguments().count(), 4); } { @@ -143,7 +147,7 @@ void tst_QCoreApplication::argc() char **argv = 0; QCoreApplication app(argc, argv); QCOMPARE(argc, 0); - QCOMPARE(app.argc(), 0); + QCOMPARE(app.arguments().count(), 0); } { @@ -151,7 +155,7 @@ void tst_QCoreApplication::argc() char *argv[] = { "tst_qcoreapplication", "-qmljsdebugger=port:3768,block" }; QCoreApplication app(argc, argv); QCOMPARE(argc, 1); - QCOMPARE(app.argc(), 1); + QCOMPARE(app.arguments().count(), 1); } } @@ -640,5 +644,113 @@ void tst_QCoreApplication::customEventDispatcher() QVERIFY(weak_ed.isNull()); } +class JobObject : public QObject +{ + Q_OBJECT +public: + + explicit JobObject(QEventLoop *loop, QObject *parent = 0) + : QObject(parent), locker(loop) + { + QTimer::singleShot(1000, this, SLOT(timeout())); + } + + explicit JobObject(QObject *parent = 0) + : QObject(parent) + { + QTimer::singleShot(1000, this, SLOT(timeout())); + } + +public slots: + void startSecondaryJob() + { + new JobObject(); + } + +private slots: + void timeout() + { + emit done(); + deleteLater(); + } + +signals: + void done(); + +private: + QEventLoopLocker locker; +}; + +class QuitTester : public QObject +{ + Q_OBJECT +public: + QuitTester(QObject *parent = 0) + : QObject(parent) + { + QTimer::singleShot(0, this, SLOT(doTest())); + } + +private slots: + void doTest() + { + QCoreApplicationPrivate *privateClass = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp)); + + { + QCOMPARE(privateClass->quitLockRef.load(), 0); + // Test with a lock active so that the refcount doesn't drop to zero during these tests, causing a quit. + // (until we exit the scope) + QEventLoopLocker locker; + + QCOMPARE(privateClass->quitLockRef.load(), 1); + + JobObject *job1 = new JobObject(this); + + QCOMPARE(privateClass->quitLockRef.load(), 2); + + delete job1; + + QCOMPARE(privateClass->quitLockRef.load(), 1); + + job1 = new JobObject(this); + + QCOMPARE(privateClass->quitLockRef.load(), 2); + + JobObject *job2 = new JobObject(this); + + QCOMPARE(privateClass->quitLockRef.load(), 3); + + delete job1; + + QCOMPARE(privateClass->quitLockRef.load(), 2); + + JobObject *job3 = new JobObject(job2); + + QCOMPARE(privateClass->quitLockRef.load(), 3); + + JobObject *job4 = new JobObject(job2); + + QCOMPARE(privateClass->quitLockRef.load(), 4); + + delete job2; + + QCOMPARE(privateClass->quitLockRef.load(), 1); + + } + QCOMPARE(privateClass->quitLockRef.load(), 0); + } +}; + +void tst_QCoreApplication::testQuitLock() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + QuitTester tester; + app.exec(); +} + + QTEST_APPLESS_MAIN(tst_QCoreApplication) #include "tst_qcoreapplication.moc" diff --git a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro index d21a7d64f6..adfc810788 100644 --- a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro +++ b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qeventloop -QT = core network testlib +QT = core network testlib core-private SOURCES = tst_qeventloop.cpp win32:!wince*:LIBS += -luser32 diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 49e3fec33e..e2144134d9 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -45,6 +45,7 @@ #include <qcoreapplication.h> #include <qcoreevent.h> #include <qeventloop.h> +#include <private/qeventloop_p.h> #include <qmutex.h> #include <qthread.h> #include <qtimer.h> @@ -194,6 +195,8 @@ private slots: // keep this test last: void nestedLoops(); + void testQuitLock(); + protected: void customEvent(QEvent *e); }; @@ -640,6 +643,85 @@ void tst_QEventLoop::deliverInDefinedOrder() } +class JobObject : public QObject +{ + Q_OBJECT +public: + + explicit JobObject(QEventLoop *loop, QObject *parent = 0) + : QObject(parent), loop(loop), locker(loop) + { + } + + explicit JobObject(QObject *parent = 0) + : QObject(parent) + { + } + +public slots: + void start(int timeout = 200) + { + QTimer::singleShot(timeout, this, SLOT(timeout())); + } + +private slots: + void timeout() + { + emit done(); + deleteLater(); + } + +signals: + void done(); + +private: + QEventLoop *loop; + QEventLoopLocker locker; +}; + +void tst_QEventLoop::testQuitLock() +{ + QEventLoop eventLoop; + + QTimer timer; + timer.setInterval(100); + QSignalSpy timerSpy(&timer, SIGNAL(timeout())); + timer.start(); + + QEventLoopPrivate* privateClass = static_cast<QEventLoopPrivate*>(QObjectPrivate::get(&eventLoop)); + + QCOMPARE(privateClass->quitLockRef.load(), 0); + + JobObject *job1 = new JobObject(&eventLoop, this); + job1->start(500); + + QCOMPARE(privateClass->quitLockRef.load(), 1); + + eventLoop.exec(); + + QCOMPARE(privateClass->quitLockRef.load(), 0); + + // The job takes long enough that the timer times out several times. + QVERIFY(timerSpy.count() > 3); + timerSpy.clear(); + + job1 = new JobObject(&eventLoop, this); + job1->start(200); + + JobObject *previousJob = job1; + for (int i = 0; i < 9; ++i) { + JobObject *subJob = new JobObject(&eventLoop, this); + connect(previousJob, SIGNAL(done()), subJob, SLOT(start())); + previousJob = subJob; + } + + eventLoop.exec(); + + qDebug() << timerSpy.count(); + // The timer times out more if it has more subjobs to do. + // We run 10 jobs in sequence here of about 200ms each. + QVERIFY(timerSpy.count() > 17); +} QTEST_MAIN(tst_QEventLoop) #include "tst_qeventloop.moc" diff --git a/tests/auto/corelib/kernel/qmath/tst_qmath.cpp b/tests/auto/corelib/kernel/qmath/tst_qmath.cpp index fab95564d2..bd5339a259 100644 --- a/tests/auto/corelib/kernel/qmath/tst_qmath.cpp +++ b/tests/auto/corelib/kernel/qmath/tst_qmath.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 0fe82f6277..68ff8e4bb6 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index fb7122aec4..def1b74ea4 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -47,7 +47,6 @@ class tst_QMetaObjectBuilder : public QObject { Q_OBJECT private slots: - void mocVersionCheck(); void create(); void className(); void superClass(); @@ -57,6 +56,7 @@ private slots: void signal(); void constructor(); void property(); + void variantProperty(); void notifySignal(); void enumerator(); void classInfo(); @@ -66,6 +66,14 @@ private slots: void serialize(); void removeNotifySignal(); + void usage_signal(); + void usage_property(); + void usage_slot(); + void usage_method(); + void usage_constructor(); + void usage_connect(); + void usage_templateConnect(); + private: static bool checkForSideEffects (const QMetaObjectBuilder& builder, @@ -129,18 +137,6 @@ signals: void propChanged(const QString&); }; -void tst_QMetaObjectBuilder::mocVersionCheck() -{ - // This test will fail when the moc version number is changed. - // It is intended as a reminder to also update QMetaObjectBuilder - // whenenver moc changes. Once QMetaObjectBuilder has been - // updated, this test can be changed to check for the next version. - int version = int(QObject::staticMetaObject.d.data[0]); - QVERIFY(version == 4 || version == 5 || version == 6); - version = int(staticMetaObject.d.data[0]); - QVERIFY(version == 4 || version == 5 || version == 6); -} - void tst_QMetaObjectBuilder::create() { QMetaObjectBuilder builder; @@ -727,6 +723,20 @@ void tst_QMetaObjectBuilder::property() QCOMPARE(builder.method(0).signature(), QByteArray("propChanged(QString)")); } +void tst_QMetaObjectBuilder::variantProperty() +{ + QMetaObjectBuilder builder; + builder.addProperty("variant", "const QVariant &"); + QMetaObject *meta = builder.toMetaObject(); + + QMetaProperty prop = meta->property(meta->propertyOffset()); + QCOMPARE(QMetaType::Type(prop.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(prop.userType()), QMetaType::QVariant); + QCOMPARE(QByteArray(prop.typeName()), QByteArray("QVariant")); + + qFree(meta); +} + void tst_QMetaObjectBuilder::notifySignal() { QMetaObjectBuilder builder; @@ -1259,6 +1269,353 @@ bool tst_QMetaObjectBuilder::sameMetaObject return true; } + +// This class is used to test that the meta-object generated by QMOB can be +// used by a real object. +// The class manually implements the functions normally generated by moc, and +// creates the corresponding meta-object using QMOB. The autotests check that +// this object can be used by QObject/QMetaObject functionality (property +// access, signals & slots, constructing instances, ...). + +class TestObject : public QObject +{ + // Manually expanded from Q_OBJECT macro +public: + Q_OBJECT_CHECK + virtual const QMetaObject *metaObject() const; + virtual void *qt_metacast(const char *); + virtual int qt_metacall(QMetaObject::Call, int, void **); +private: + Q_DECL_HIDDEN static const QMetaObjectExtraData staticMetaObjectExtraData; + Q_DECL_HIDDEN static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); + + //Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) +public: + TestObject(QObject *parent = 0); // Q_INVOKABLE + ~TestObject(); + + // Property accessors + int intProp() const; + void setIntProp(int v); + + void emitIntPropChanged(); + + int voidSlotIntArgument() const; + +// Q_INVOKABLE + QVariantList listInvokableQRealQString(qreal, const QString &); + +//public Q_SLOTS: + void voidSlotInt(int); + +//Q_SIGNALS: + void intPropChanged(int); + +private: + static QMetaObject *buildMetaObject(); + + QMetaObject *m_metaObject; + int m_intProp; + int m_voidSlotIntArg; +}; + +const QMetaObjectExtraData TestObject::staticMetaObjectExtraData = { + 0, qt_static_metacall +}; + +TestObject::TestObject(QObject *parent) + : QObject(parent), m_metaObject(buildMetaObject()), + m_intProp(-1), m_voidSlotIntArg(-1) +{ +} + +TestObject::~TestObject() +{ + qFree(m_metaObject); +} + +QMetaObject *TestObject::buildMetaObject() +{ + QMetaObjectBuilder builder; + // NOTE: If you change the meta-object, remember to adapt qt_metacall and + // friends below accordingly. + + builder.setClassName("TestObject"); + + builder.setStaticMetacallFunction(qt_static_metacall); + + QMetaMethodBuilder intPropChanged = builder.addSignal("intPropChanged(int)"); + intPropChanged.setParameterNames(QList<QByteArray>() << "newIntPropValue"); + + QMetaPropertyBuilder prop = builder.addProperty("intProp", "int"); + prop.setNotifySignal(intPropChanged); + + QMetaMethodBuilder voidSlotInt = builder.addSlot("voidSlotInt(int)"); + voidSlotInt.setParameterNames(QList<QByteArray>() << "slotIntArg"); + + QMetaMethodBuilder listInvokableQRealQString = builder.addMethod("listInvokableQRealQString(qreal,QString)"); + listInvokableQRealQString.setReturnType("QVariantList"); + listInvokableQRealQString.setParameterNames(QList<QByteArray>() << "qrealArg" << "qstringArg"); + + builder.addConstructor("TestObject(QObject*)"); + builder.addConstructor("TestObject()"); + + return builder.toMetaObject(); +} + +int TestObject::intProp() const +{ + return m_intProp; +} + +void TestObject::setIntProp(int value) +{ + if (m_intProp != value) { + m_intProp = value; + emit intPropChanged(value); + } +} + +void TestObject::emitIntPropChanged() +{ + emit intPropChanged(m_intProp); +} + +QVariantList TestObject::listInvokableQRealQString(qreal r, const QString &s) +{ + return QVariantList() << r << s; +} + +void TestObject::voidSlotInt(int value) +{ + m_voidSlotIntArg = value; +} + +int TestObject::voidSlotIntArgument() const +{ + return m_voidSlotIntArg; +} + +void TestObject::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + if (_c == QMetaObject::CreateInstance) { + switch (_id) { + case 0: { TestObject *_r = new TestObject((*reinterpret_cast< QObject*(*)>(_a[1]))); + if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break; + case 1: { TestObject *_r = new TestObject(); + if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break; + default: { + QMetaMethod ctor = _o->metaObject()->constructor(_id); + qFatal("You forgot to add a case for CreateInstance %s", ctor.signature()); + } + } + } else if (_c == QMetaObject::InvokeMetaMethod) { + Q_ASSERT(_o->metaObject()->cast(_o)); + TestObject *_t = static_cast<TestObject *>(_o); + switch (_id) { + case 0: _t->intPropChanged((*reinterpret_cast< int(*)>(_a[1]))); break; + case 1: _t->voidSlotInt((*reinterpret_cast< int(*)>(_a[1]))); break; + case 2: *reinterpret_cast<QVariantList(*)>(_a[0]) = _t->listInvokableQRealQString(*reinterpret_cast<qreal(*)>(_a[1]), *reinterpret_cast<QString(*)>(_a[2])); break; + default: { + QMetaMethod method = _o->metaObject()->method(_o->metaObject()->methodOffset() + _id); + qFatal("You forgot to add a case for InvokeMetaMethod %s", method.signature()); + } + } + } else if (_c == QMetaObject::IndexOfMethod) { + // This code is currently unreachable because it's only used by the + // template-based versions of connect() and disconnect(), which don't + // work with dynamically generated meta-objects (see test). + int *result = reinterpret_cast<int *>(_a[0]); + void **func = reinterpret_cast<void **>(_a[1]); + { + typedef void (TestObject::*_t)(int ); + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&TestObject::intPropChanged)) { + *result = 0; + } + } + { + typedef void (TestObject::*_t)(int ); + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&TestObject::voidSlotInt)) { + *result = 1; + } + } + { + typedef QVariantList (TestObject::*_t)(qreal, const QString &); + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&TestObject::listInvokableQRealQString)) { + *result = 2; + } + } + qFatal("You forgot to add one or more IndexOfMethod cases"); + } +} + +const QMetaObject *TestObject::metaObject() const +{ + return m_metaObject; +} + +void *TestObject::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, "TestObject")) + return static_cast<void*>(const_cast< TestObject*>(this)); + return QObject::qt_metacast(_clname); +} + +int TestObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + int ownMethodCount = m_metaObject->methodCount() - m_metaObject->methodOffset(); + int ownPropertyCount = m_metaObject->propertyCount() - m_metaObject->propertyOffset(); + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < ownMethodCount) + qt_static_metacall(this, _c, _id, _a); + _id -= ownMethodCount; + } +#ifndef QT_NO_PROPERTIES + else if (_c == QMetaObject::ReadProperty) { + void *_v = _a[0]; + switch (_id) { + case 0: *reinterpret_cast< int*>(_v) = intProp(); break; + default: if (_id < ownPropertyCount) { + QMetaProperty prop = m_metaObject->property(m_metaObject->propertyOffset() + _id); + qFatal("You forgot to add a case for ReadProperty %s", prop.name()); + } + } + _id -= ownPropertyCount; + } else if (_c == QMetaObject::WriteProperty) { + void *_v = _a[0]; + switch (_id) { + case 0: setIntProp(*reinterpret_cast< int*>(_v)); break; + default: if (_id < ownPropertyCount) { + QMetaProperty prop = m_metaObject->property(m_metaObject->propertyOffset() + _id); + qFatal("You forgot to add a case for WriteProperty %s", prop.name()); + } + } + _id -= ownPropertyCount; + } else if (_c == QMetaObject::ResetProperty) { + _id -= ownPropertyCount; + } else if (_c == QMetaObject::QueryPropertyDesignable) { + _id -= ownPropertyCount; + } else if (_c == QMetaObject::QueryPropertyScriptable) { + _id -= ownPropertyCount; + } else if (_c == QMetaObject::QueryPropertyStored) { + _id -= ownPropertyCount; + } else if (_c == QMetaObject::QueryPropertyEditable) { + _id -= ownPropertyCount; + } else if (_c == QMetaObject::QueryPropertyUser) { + _id -= ownPropertyCount; + } +#endif // QT_NO_PROPERTIES + return _id; +} + +// SIGNAL 0 +void TestObject::intPropChanged(int _t1) +{ + void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; + QMetaObject::activate(this, m_metaObject, 0, _a); +} + + +void tst_QMetaObjectBuilder::usage_signal() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + QSignalSpy propChangedSpy(testObject.data(), SIGNAL(intPropChanged(int))); + testObject->emitIntPropChanged(); + QCOMPARE(propChangedSpy.count(), 1); + QCOMPARE(propChangedSpy.at(0).count(), 1); + QCOMPARE(propChangedSpy.at(0).at(0).toInt(), testObject->intProp()); +} + +void tst_QMetaObjectBuilder::usage_property() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + QVariant prop = testObject->property("intProp"); + QCOMPARE(prop.type(), QVariant::Int); + QCOMPARE(prop.toInt(), testObject->intProp()); + + QSignalSpy propChangedSpy(testObject.data(), SIGNAL(intPropChanged(int))); + QVERIFY(testObject->intProp() != 123); + testObject->setProperty("intProp", 123); + QCOMPARE(propChangedSpy.count(), 1); + prop = testObject->property("intProp"); + QCOMPARE(prop.type(), QVariant::Int); + QCOMPARE(prop.toInt(), 123); +} + +void tst_QMetaObjectBuilder::usage_slot() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + int index = testObject->metaObject()->indexOfMethod("voidSlotInt(int)"); + QVERIFY(index != -1); + QMetaMethod voidSlotInt = testObject->metaObject()->method(index); + + QVERIFY(testObject->voidSlotIntArgument() == -1); + QVERIFY(voidSlotInt.invoke(testObject.data(), Q_ARG(int, 123))); + QCOMPARE(testObject->voidSlotIntArgument(), 123); +} + +void tst_QMetaObjectBuilder::usage_method() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + int index = testObject->metaObject()->indexOfMethod("listInvokableQRealQString(qreal,QString)"); + QVERIFY(index != -1); + QMetaMethod listInvokableQRealQString = testObject->metaObject()->method(index); + QVariantList list; + QVERIFY(listInvokableQRealQString.invoke(testObject.data(), Q_RETURN_ARG(QVariantList, list), + Q_ARG(qreal, 123.0), Q_ARG(QString, "ciao"))); + QCOMPARE(list.size(), 2); + QCOMPARE(list.at(0).type(), QVariant::Type(QMetaType::QReal)); + QCOMPARE(list.at(0).toDouble(), double(123)); + QCOMPARE(list.at(1).type(), QVariant::String); + QCOMPARE(list.at(1).toString(), QString::fromLatin1("ciao")); +} + +void tst_QMetaObjectBuilder::usage_constructor() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + QCOMPARE(testObject->metaObject()->constructorCount(), 2); + QScopedPointer<QObject> testInstance(testObject->metaObject()->newInstance()); + QVERIFY(testInstance != 0); + QScopedPointer<QObject> testInstance2(testObject->metaObject()->newInstance(Q_ARG(QObject*, testInstance.data()))); + QVERIFY(testInstance2 != 0); + QCOMPARE(testInstance2->parent(), testInstance.data()); +} + +void tst_QMetaObjectBuilder::usage_connect() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + QVERIFY(QObject::connect(testObject.data(), SIGNAL(intPropChanged(int)), + testObject.data(), SLOT(voidSlotInt(int)))); + + QVERIFY(testObject->voidSlotIntArgument() == -1); + testObject->setProperty("intProp", 123); + QCOMPARE(testObject->voidSlotIntArgument(), 123); + + QVERIFY(QObject::disconnect(testObject.data(), SIGNAL(intPropChanged(int)), + testObject.data(), SLOT(voidSlotInt(int)))); +} + +void tst_QMetaObjectBuilder::usage_templateConnect() +{ + QScopedPointer<TestObject> testObject(new TestObject); + + QTest::ignoreMessage(QtWarningMsg, "QObject::connect: signal not found in QObject"); + QMetaObject::Connection con = QObject::connect(testObject.data(), &TestObject::intPropChanged, + testObject.data(), &TestObject::voidSlotInt); + QEXPECT_FAIL("", "template-based connect() fails because meta-object is deduced at compile-time", Abort); + QVERIFY(con); +} + QTEST_MAIN(tst_QMetaObjectBuilder) #include "tst_qmetaobjectbuilder.moc" diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp index e225371a7f..3e1d4f1603 100644 --- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp +++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index d5aa369a92..be13b39e7e 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -89,6 +89,7 @@ private slots: void isRegistered(); void unregisterType(); void registerStreamBuiltin(); + void automaticTemplateRegistration(); }; struct Foo { int i; }; @@ -570,15 +571,12 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_COPY_FUNCTION) TypeTestFunctionGetter::get(type)(); } -template<typename T> struct SafeSizeOf { enum {Size = sizeof(T)}; }; -template<> struct SafeSizeOf<void> { enum {Size = 0}; }; - void tst_QMetaType::sizeOf_data() { QTest::addColumn<QMetaType::Type>("type"); QTest::addColumn<int>("size"); #define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ - QTest::newRow(#RealType) << QMetaType::MetaTypeName << int(SafeSizeOf<RealType>::Size); + QTest::newRow(#RealType) << QMetaType::MetaTypeName << int(QTypeInfo<RealType>::sizeOf); FOR_EACH_CORE_METATYPE(ADD_METATYPE_TEST_ROW) #undef ADD_METATYPE_TEST_ROW } @@ -596,21 +594,50 @@ Q_DECLARE_TYPEINFO(CustomMovable, Q_MOVABLE_TYPE); QT_END_NAMESPACE Q_DECLARE_METATYPE(CustomMovable); +class CustomObject : public QObject +{ + Q_OBJECT +public: + CustomObject(QObject *parent = 0) + : QObject(parent) + { + + } +}; +Q_DECLARE_METATYPE(CustomObject*); + +struct SecondBase {}; + +class CustomMultiInheritanceObject : public QObject, SecondBase +{ + Q_OBJECT +public: + CustomMultiInheritanceObject(QObject *parent = 0) + : QObject(parent) + { + + } +}; +Q_DECLARE_METATYPE(CustomMultiInheritanceObject*); + void tst_QMetaType::flags_data() { QTest::addColumn<int>("type"); QTest::addColumn<bool>("isMovable"); QTest::addColumn<bool>("isComplex"); + QTest::addColumn<bool>("isPointerToQObject"); #define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ - QTest::newRow(#RealType) << MetaTypeId << bool(!QTypeInfo<RealType>::isStatic) << bool(QTypeInfo<RealType>::isComplex); + QTest::newRow(#RealType) << MetaTypeId << bool(!QTypeInfo<RealType>::isStatic) << bool(QTypeInfo<RealType>::isComplex) << bool(QtPrivate::IsPointerToTypeDerivedFromQObject<RealType>::Value); QT_FOR_EACH_STATIC_CORE_CLASS(ADD_METATYPE_TEST_ROW) QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(ADD_METATYPE_TEST_ROW) QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) #undef ADD_METATYPE_TEST_ROW - QTest::newRow("TestSpace::Foo") << ::qMetaTypeId<TestSpace::Foo>() << false << true; - QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << false << true; - QTest::newRow("CustomMovable") << ::qMetaTypeId<CustomMovable>() << true << true; + QTest::newRow("TestSpace::Foo") << ::qMetaTypeId<TestSpace::Foo>() << false << true << false; + QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << false << true << false; + QTest::newRow("CustomMovable") << ::qMetaTypeId<CustomMovable>() << true << true << false; + QTest::newRow("CustomObject*") << ::qMetaTypeId<CustomObject*>() << true << false << true; + QTest::newRow("CustomMultiInheritanceObject*") << ::qMetaTypeId<CustomMultiInheritanceObject*>() << true << false << true; } void tst_QMetaType::flags() @@ -618,10 +645,12 @@ void tst_QMetaType::flags() QFETCH(int, type); QFETCH(bool, isMovable); QFETCH(bool, isComplex); + QFETCH(bool, isPointerToQObject); QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::NeedsConstruction), isComplex); QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::NeedsDestruction), isComplex); QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::MovableType), isMovable); + QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::PointerToQObject), isPointerToQObject); } void tst_QMetaType::construct_data() @@ -857,5 +886,63 @@ void tst_QMetaType::registerStreamBuiltin() qRegisterMetaTypeStreamOperators<QVariant>("QVariant"); } +Q_DECLARE_METATYPE(QSharedPointer<QObject>) + +void tst_QMetaType::automaticTemplateRegistration() +{ + { + QList<int> intList; + intList << 42; + QVERIFY(QVariant::fromValue(intList).value<QList<int> >().first() == 42); + QVector<QList<int> > vectorList; + vectorList << intList; + QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<int> > >().first().first() == 42); + } + + { + QList<QByteArray> bytearrayList; + bytearrayList << QByteArray("foo"); + QVERIFY(QVariant::fromValue(bytearrayList).value<QList<QByteArray> >().first() == QByteArray("foo")); + QVector<QList<QByteArray> > vectorList; + vectorList << bytearrayList; + QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<QByteArray> > >().first().first() == QByteArray("foo")); + } + + QCOMPARE(::qMetaTypeId<QVariantList>(), (int)QMetaType::QVariantList); + QCOMPARE(::qMetaTypeId<QList<QVariant> >(), (int)QMetaType::QVariantList); + + { + QList<QVariant> variantList; + variantList << 42; + QVERIFY(QVariant::fromValue(variantList).value<QList<QVariant> >().first() == 42); + QVector<QList<QVariant> > vectorList; + vectorList << variantList; + QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<QVariant> > >().first().first() == 42); + } + + { + QList<QSharedPointer<QObject> > sharedPointerList; + QObject *testObject = new QObject; + sharedPointerList << QSharedPointer<QObject>(testObject); + QVERIFY(QVariant::fromValue(sharedPointerList).value<QList<QSharedPointer<QObject> > >().first() == testObject); + QVector<QList<QSharedPointer<QObject> > > vectorList; + vectorList << sharedPointerList; + QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<QSharedPointer<QObject> > > >().first().first() == testObject); + } +} + +// Compile-time test, it should be possible to register function pointer types +class Undefined; + +typedef Undefined (*UndefinedFunction0)(); +typedef Undefined (*UndefinedFunction1)(Undefined); +typedef Undefined (*UndefinedFunction2)(Undefined, Undefined); +typedef Undefined (*UndefinedFunction3)(Undefined, Undefined, Undefined); + +Q_DECLARE_METATYPE(UndefinedFunction0); +Q_DECLARE_METATYPE(UndefinedFunction1); +Q_DECLARE_METATYPE(UndefinedFunction2); +Q_DECLARE_METATYPE(UndefinedFunction3); + QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc" diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp index f55701b3ec..09f17602b3 100644 --- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp +++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qobject/moc_oldnormalizeobject.cpp b/tests/auto/corelib/kernel/qobject/moc_oldnormalizeobject.cpp index b4069eba6c..2d180b88ea 100644 --- a/tests/auto/corelib/kernel/qobject/moc_oldnormalizeobject.cpp +++ b/tests/auto/corelib/kernel/qobject/moc_oldnormalizeobject.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qobject/oldnormalizeobject.h b/tests/auto/corelib/kernel/qobject/oldnormalizeobject.h index efd1df2f5a..f73027707a 100644 --- a/tests/auto/corelib/kernel/qobject/oldnormalizeobject.h +++ b/tests/auto/corelib/kernel/qobject/oldnormalizeobject.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the QtTest module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.cpp b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.cpp index 86e8869a33..a1fd6e7534 100644 --- a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.cpp +++ b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.h b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.h index bba612c998..661485885e 100644 --- a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.h +++ b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f3bba08544..7f95f68075 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -75,6 +75,7 @@ private slots: void findChildren(); void connectDisconnectNotify_data(); void connectDisconnectNotify(); + void connectNotifyPtr(); void emitInDefinedOrder(); void customTypes(); void streamCustomTypes(); @@ -134,6 +135,7 @@ private slots: void returnValue(); void returnValue2_data(); void returnValue2(); + void connectVirtualSlots(); }; class SenderObject : public QObject @@ -848,6 +850,19 @@ void tst_QObject::connectDisconnectNotify() delete r; } +void tst_QObject::connectNotifyPtr() +{ + NotifyObject *s = new NotifyObject; + NotifyObject *r = new NotifyObject; + + connect( (SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1 ); + QCOMPARE( s->org_signal, s->nw_signal ); + QCOMPARE( s->org_signal.toLatin1(), QMetaObject::normalizedSignature(SIGNAL(signal1()))); + + delete s; + delete r; +} + class SequenceObject : public ReceiverObject { Q_OBJECT @@ -1670,7 +1685,7 @@ void tst_QObject::property() const int idx = mo->indexOfProperty("variant"); QVERIFY(idx != -1); - QVERIFY(mo->property(idx).type() == QVariant::LastType); + QCOMPARE(QMetaType::Type(mo->property(idx).type()), QMetaType::QVariant); QCOMPARE(object.property("variant"), QVariant()); QVariant variant1(42); QVariant variant2("string"); @@ -3363,7 +3378,7 @@ void tst_QObject::deleteQObjectWhenDeletingEvent() }; QObject o; - QGuiApplication::postEvent(&o, new MyEvent); + QCoreApplication::postEvent(&o, new MyEvent); QCoreApplication::removePostedEvents(&o); // here you would get a deadlock } @@ -4128,11 +4143,17 @@ void tst_QObject::pointerConnect() r1->reset(); r2->reset(); ReceiverObject::sequence = 0; + QTimer timer; QVERIFY( connect( s, &SenderObject::signal1 , r1, &ReceiverObject::slot1 ) ); QVERIFY( connect( s, &SenderObject::signal1 , r2, &ReceiverObject::slot1 ) ); QVERIFY( connect( s, &SenderObject::signal1 , r1, &ReceiverObject::slot3 ) ); QVERIFY( connect( s, &SenderObject::signal3 , r1, &ReceiverObject::slot3 ) ); +#if defined(Q_CC_GNU) && defined(Q_OS_UNIX) + QEXPECT_FAIL("", "Test may fail due to failing comparison of pointers to member functions caused by problems with -reduce-relocations on this platform.", Continue); +#endif + QVERIFY2( connect( &timer, &QTimer::timeout, r1, &ReceiverObject::deleteLater ), + "Signal connection failed most likely due to failing comparison of pointers to member functions caused by problems with -reduce-relocations on this platform."); s->emitSignal1(); s->emitSignal2(); @@ -5150,6 +5171,52 @@ void tst_QObject::returnValue2() } } +class VirtualSlotsObjectBase : public QObject { + Q_OBJECT +public slots: + virtual void slot1() { + base_counter1++; + } +public: + VirtualSlotsObjectBase() : base_counter1(0) {} + int base_counter1; +signals: + void signal1(); +}; + +class VirtualSlotsObject : public VirtualSlotsObjectBase { + Q_OBJECT +public slots: + virtual void slot1() { + derived_counter1++; + } +public: + VirtualSlotsObject() : derived_counter1(0) {} + int derived_counter1; +}; + +void tst_QObject::connectVirtualSlots() +{ + VirtualSlotsObject obj; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, &VirtualSlotsObjectBase::slot1, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, &VirtualSlotsObjectBase::slot1, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + + QVERIFY(QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, &VirtualSlotsObjectBase::slot1)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, &VirtualSlotsObjectBase::slot1)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + + /* the C++ standard say the comparison between pointer to virtual member function is unspecified + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, &VirtualSlotsObjectBase::slot1, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, &VirtualSlotsObject::slot1, Qt::UniqueConnection)); + */ +} QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.pro b/tests/auto/corelib/kernel/qobject/tst_qobject.pro index e13852629c..d74f2bcb0f 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.pro +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.pro @@ -1,6 +1,6 @@ -CONFIG += testcase +CONFIG += testcase console TARGET = tst_qobject -QT = core-private network gui testlib +QT = core-private network testlib SOURCES = tst_qobject.cpp # this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp index df4c5f99cb..9eac2b78be 100644 --- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp +++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp b/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp index 4b9c37a5e0..b1fdf51c20 100644 --- a/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp +++ b/tests/auto/corelib/kernel/qsignalmapper/tst_qsignalmapper.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index 180e7d532b..e3bfe3bc6d 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 098d8a8825..e8dade9387 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp index a7ccc45642..033d10001f 100644 --- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/kernel/qvariant/qvariant.pro b/tests/auto/corelib/kernel/qvariant/qvariant.pro index 93877a1059..48229ee140 100644 --- a/tests/auto/corelib/kernel/qvariant/qvariant.pro +++ b/tests/auto/corelib/kernel/qvariant/qvariant.pro @@ -2,5 +2,6 @@ CONFIG += testcase TARGET = tst_qvariant QT += widgets network testlib SOURCES = tst_qvariant.cpp +RESOURCES += qvariant.qrc mac: CONFIG += insignificant_test # QTBUG-QTBUG-22747 diff --git a/tests/auto/corelib/kernel/qvariant/qvariant.qrc b/tests/auto/corelib/kernel/qvariant/qvariant.qrc new file mode 100644 index 0000000000..e6f7bdac80 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/qvariant.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>stream/qt4.9/</file> + <file>stream/qt5.0/</file> +</qresource> +</RCC> diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/bool.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/bool.bin Binary files differnew file mode 100644 index 0000000000..7929cb4129 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/bool.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/char.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/char.bin Binary files differnew file mode 100644 index 0000000000..3c15cb7850 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/char.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/double.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/double.bin Binary files differnew file mode 100644 index 0000000000..ac9ed179f2 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/double.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/float.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/float.bin Binary files differnew file mode 100644 index 0000000000..540c010dc9 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/float.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/int.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/int.bin Binary files differnew file mode 100644 index 0000000000..6b47a9aeb4 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/int.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/long.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/long.bin Binary files differnew file mode 100644 index 0000000000..66891d5ed8 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/long.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbitarray.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbitarray.bin Binary files differnew file mode 100644 index 0000000000..e534174651 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbitarray.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbitmap.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbitmap.bin Binary files differnew file mode 100644 index 0000000000..13f4dc374d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbitmap.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbrush.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbrush.bin Binary files differnew file mode 100644 index 0000000000..60ea8a2b08 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbrush.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbytearray.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbytearray.bin Binary files differnew file mode 100644 index 0000000000..19897811d0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qbytearray.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qchar.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qchar.bin Binary files differnew file mode 100644 index 0000000000..f4ef9df794 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qchar.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qcolor.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qcolor.bin Binary files differnew file mode 100644 index 0000000000..ba1c332e14 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qcolor.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qcursor.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qcursor.bin Binary files differnew file mode 100644 index 0000000000..545fa96a1f --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qcursor.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qdate.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qdate.bin Binary files differnew file mode 100644 index 0000000000..d3281b1336 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qdate.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qdatetime.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qdatetime.bin Binary files differnew file mode 100644 index 0000000000..664eb736a7 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qdatetime.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qeasingcurve.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qeasingcurve.bin Binary files differnew file mode 100644 index 0000000000..b9b9ea633b --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qeasingcurve.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qfont.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qfont.bin Binary files differnew file mode 100644 index 0000000000..76bc5d932f --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qfont.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qicon.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qicon.bin Binary files differnew file mode 100644 index 0000000000..2f8713244c --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qicon.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qimage.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qimage.bin Binary files differnew file mode 100644 index 0000000000..0ab1cbf6fa --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qimage.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qkeysequence.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qkeysequence.bin Binary files differnew file mode 100644 index 0000000000..03db168e93 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qkeysequence.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qline.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qline.bin Binary files differnew file mode 100644 index 0000000000..f1f5cde63c --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qline.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlinef.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlinef.bin Binary files differnew file mode 100644 index 0000000000..4b1c2f05fb --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlinef.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlocale.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlocale.bin Binary files differnew file mode 100644 index 0000000000..44d9d1c993 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlocale.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlonglong.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlonglong.bin Binary files differnew file mode 100644 index 0000000000..f1c297a91d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qlonglong.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qmatrix.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qmatrix.bin Binary files differnew file mode 100644 index 0000000000..fc88e2564a --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qmatrix.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qmatrix4x4.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qmatrix4x4.bin Binary files differnew file mode 100644 index 0000000000..3a8b664a69 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qmatrix4x4.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpalette.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpalette.bin Binary files differnew file mode 100644 index 0000000000..1ad94631bd --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpalette.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpen.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpen.bin Binary files differnew file mode 100644 index 0000000000..1eff5c83ad --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpen.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpixmap.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpixmap.bin Binary files differnew file mode 100644 index 0000000000..ce9cb8c434 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpixmap.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpoint.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpoint.bin Binary files differnew file mode 100644 index 0000000000..ca66b1ec4c --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpoint.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpointf.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpointf.bin Binary files differnew file mode 100644 index 0000000000..7aebb46299 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpointf.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpolygon.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpolygon.bin Binary files differnew file mode 100644 index 0000000000..fbdab8fffc --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qpolygon.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qquaternion.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qquaternion.bin Binary files differnew file mode 100644 index 0000000000..01ee6dcdbc --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qquaternion.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qrect.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qrect.bin Binary files differnew file mode 100644 index 0000000000..70730db7e1 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qrect.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qrectf.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qrectf.bin Binary files differnew file mode 100644 index 0000000000..2f8dac670b --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qrectf.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qregexp.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qregexp.bin Binary files differnew file mode 100644 index 0000000000..db8518e064 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qregexp.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qregion.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qregion.bin Binary files differnew file mode 100644 index 0000000000..27eec8c4d5 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qregion.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsize.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsize.bin Binary files differnew file mode 100644 index 0000000000..fec8c62c16 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsize.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsizef.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsizef.bin Binary files differnew file mode 100644 index 0000000000..210976a005 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsizef.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsizepolicy.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsizepolicy.bin Binary files differnew file mode 100644 index 0000000000..00f1b2906e --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qsizepolicy.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qstring.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qstring.bin Binary files differnew file mode 100644 index 0000000000..f44d7cbbc0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qstring.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qstringlist.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qstringlist.bin Binary files differnew file mode 100644 index 0000000000..34e6f73ab5 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qstringlist.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtextformat.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtextformat.bin Binary files differnew file mode 100644 index 0000000000..91382db9c4 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtextformat.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtextlength.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtextlength.bin Binary files differnew file mode 100644 index 0000000000..945dfc0ba9 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtextlength.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtime.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtime.bin Binary files differnew file mode 100644 index 0000000000..31f63fd1fb --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtime.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtransform.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtransform.bin Binary files differnew file mode 100644 index 0000000000..53c4db55f2 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qtransform.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qulonglong.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qulonglong.bin Binary files differnew file mode 100644 index 0000000000..e321e7d77d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qulonglong.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qurl.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qurl.bin Binary files differnew file mode 100644 index 0000000000..4e444b7cc0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qurl.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariant.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariant.bin Binary files differnew file mode 100644 index 0000000000..7d5c5303b8 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariant.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvarianthash.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvarianthash.bin Binary files differnew file mode 100644 index 0000000000..e2ffb002af --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvarianthash.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariantlist.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariantlist.bin Binary files differnew file mode 100644 index 0000000000..cf95d44875 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariantlist.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariantmap.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariantmap.bin Binary files differnew file mode 100644 index 0000000000..6b0b1fb27d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvariantmap.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector2d.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector2d.bin Binary files differnew file mode 100644 index 0000000000..a219ab66dd --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector2d.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector3d.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector3d.bin Binary files differnew file mode 100644 index 0000000000..4444fb6236 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector3d.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector4d.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector4d.bin Binary files differnew file mode 100644 index 0000000000..46bcc26f13 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/qvector4d.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/short.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/short.bin Binary files differnew file mode 100644 index 0000000000..124776f9d7 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/short.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/uchar.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/uchar.bin Binary files differnew file mode 100644 index 0000000000..1dea2c16c0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/uchar.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/uint.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/uint.bin Binary files differnew file mode 100644 index 0000000000..086e080224 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/uint.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/ulong.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/ulong.bin Binary files differnew file mode 100644 index 0000000000..92dfdaad6c --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/ulong.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/ushort.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/ushort.bin Binary files differnew file mode 100644 index 0000000000..d386a76f1a --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/ushort.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt4.9/void.bin b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/void.bin Binary files differnew file mode 100644 index 0000000000..7337dc7cfb --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt4.9/void.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/bool.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/bool.bin Binary files differnew file mode 100644 index 0000000000..7929cb4129 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/bool.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/char.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/char.bin Binary files differnew file mode 100644 index 0000000000..4422f29a62 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/char.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/double.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/double.bin Binary files differnew file mode 100644 index 0000000000..ac9ed179f2 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/double.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/float.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/float.bin Binary files differnew file mode 100644 index 0000000000..fc7cca7d07 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/float.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/int.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/int.bin Binary files differnew file mode 100644 index 0000000000..6b47a9aeb4 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/int.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/long.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/long.bin Binary files differnew file mode 100644 index 0000000000..5a1ed0d740 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/long.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbitarray.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbitarray.bin Binary files differnew file mode 100644 index 0000000000..e534174651 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbitarray.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbitmap.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbitmap.bin Binary files differnew file mode 100644 index 0000000000..511e260744 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbitmap.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbrush.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbrush.bin Binary files differnew file mode 100644 index 0000000000..60ea8a2b08 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbrush.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbytearray.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbytearray.bin Binary files differnew file mode 100644 index 0000000000..19897811d0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qbytearray.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qchar.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qchar.bin Binary files differnew file mode 100644 index 0000000000..f4ef9df794 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qchar.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qcolor.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qcolor.bin Binary files differnew file mode 100644 index 0000000000..ba1c332e14 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qcolor.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qcursor.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qcursor.bin Binary files differnew file mode 100644 index 0000000000..a7be10e143 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qcursor.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdate.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdate.bin Binary files differnew file mode 100644 index 0000000000..d3281b1336 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdate.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin Binary files differnew file mode 100644 index 0000000000..664eb736a7 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qeasingcurve.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qeasingcurve.bin Binary files differnew file mode 100644 index 0000000000..5cf664eb27 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qeasingcurve.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qfont.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qfont.bin Binary files differnew file mode 100644 index 0000000000..e8aa03af9b --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qfont.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qicon.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qicon.bin Binary files differnew file mode 100644 index 0000000000..bf3ca9ed4b --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qicon.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qimage.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qimage.bin Binary files differnew file mode 100644 index 0000000000..03665c1edc --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qimage.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qkeysequence.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qkeysequence.bin Binary files differnew file mode 100644 index 0000000000..7f7447a821 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qkeysequence.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qline.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qline.bin Binary files differnew file mode 100644 index 0000000000..f1f5cde63c --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qline.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlinef.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlinef.bin Binary files differnew file mode 100644 index 0000000000..4b1c2f05fb --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlinef.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlocale.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlocale.bin Binary files differnew file mode 100644 index 0000000000..44d9d1c993 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlocale.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlonglong.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlonglong.bin Binary files differnew file mode 100644 index 0000000000..f1c297a91d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qlonglong.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qmatrix.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qmatrix.bin Binary files differnew file mode 100644 index 0000000000..93434b42c9 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qmatrix.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qmatrix4x4.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qmatrix4x4.bin Binary files differnew file mode 100644 index 0000000000..8d3f9b81e8 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qmatrix4x4.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpalette.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpalette.bin Binary files differnew file mode 100644 index 0000000000..503c1a4664 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpalette.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpen.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpen.bin Binary files differnew file mode 100644 index 0000000000..edafc2d185 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpen.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpixmap.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpixmap.bin Binary files differnew file mode 100644 index 0000000000..ce9cb8c434 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpixmap.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpoint.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpoint.bin Binary files differnew file mode 100644 index 0000000000..ca66b1ec4c --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpoint.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpointf.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpointf.bin Binary files differnew file mode 100644 index 0000000000..7aebb46299 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpointf.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpolygon.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpolygon.bin Binary files differnew file mode 100644 index 0000000000..8d3275df41 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpolygon.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpolygonf.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpolygonf.bin Binary files differnew file mode 100644 index 0000000000..3e85997f2d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qpolygonf.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qquaternion.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qquaternion.bin Binary files differnew file mode 100644 index 0000000000..c498f8fd08 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qquaternion.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qrect.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qrect.bin Binary files differnew file mode 100644 index 0000000000..70730db7e1 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qrect.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qrectf.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qrectf.bin Binary files differnew file mode 100644 index 0000000000..2f8dac670b --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qrectf.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qregexp.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qregexp.bin Binary files differnew file mode 100644 index 0000000000..db8518e064 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qregexp.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qregion.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qregion.bin Binary files differnew file mode 100644 index 0000000000..ecf01a8b31 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qregion.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsize.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsize.bin Binary files differnew file mode 100644 index 0000000000..fec8c62c16 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsize.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsizef.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsizef.bin Binary files differnew file mode 100644 index 0000000000..210976a005 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsizef.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsizepolicy.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsizepolicy.bin Binary files differnew file mode 100644 index 0000000000..cfdf49b4c2 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qsizepolicy.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qstring.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qstring.bin Binary files differnew file mode 100644 index 0000000000..f44d7cbbc0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qstring.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qstringlist.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qstringlist.bin Binary files differnew file mode 100644 index 0000000000..34e6f73ab5 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qstringlist.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtextformat.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtextformat.bin Binary files differnew file mode 100644 index 0000000000..432068d921 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtextformat.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtextlength.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtextlength.bin Binary files differnew file mode 100644 index 0000000000..3b209f1be2 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtextlength.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtime.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtime.bin Binary files differnew file mode 100644 index 0000000000..31f63fd1fb --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtime.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtransform.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtransform.bin Binary files differnew file mode 100644 index 0000000000..52cddb5e93 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qtransform.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qulonglong.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qulonglong.bin Binary files differnew file mode 100644 index 0000000000..e321e7d77d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qulonglong.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qurl.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qurl.bin Binary files differnew file mode 100644 index 0000000000..4e444b7cc0 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qurl.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/quuid.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/quuid.bin Binary files differnew file mode 100644 index 0000000000..a8d57c6acd --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/quuid.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariant.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariant.bin Binary files differnew file mode 100644 index 0000000000..1c8bc45769 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariant.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvarianthash.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvarianthash.bin Binary files differnew file mode 100644 index 0000000000..e2ffb002af --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvarianthash.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariantlist.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariantlist.bin Binary files differnew file mode 100644 index 0000000000..cf95d44875 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariantlist.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariantmap.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariantmap.bin Binary files differnew file mode 100644 index 0000000000..6b0b1fb27d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvariantmap.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector2d.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector2d.bin Binary files differnew file mode 100644 index 0000000000..2bc3aeb18d --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector2d.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector3d.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector3d.bin Binary files differnew file mode 100644 index 0000000000..b035f7f074 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector3d.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector4d.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector4d.bin Binary files differnew file mode 100644 index 0000000000..a804c5e655 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qvector4d.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/short.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/short.bin Binary files differnew file mode 100644 index 0000000000..e7ae61f176 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/short.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/uchar.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/uchar.bin Binary files differnew file mode 100644 index 0000000000..426f97426f --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/uchar.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/uint.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/uint.bin Binary files differnew file mode 100644 index 0000000000..086e080224 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/uint.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/ulong.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/ulong.bin Binary files differnew file mode 100644 index 0000000000..399a9ea220 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/ulong.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/ushort.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/ushort.bin Binary files differnew file mode 100644 index 0000000000..25cb14e173 --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/ushort.bin diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/void.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/void.bin Binary files differnew file mode 100644 index 0000000000..7337dc7cfb --- /dev/null +++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/void.bin diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index c2d4f0a240..2bf554dd78 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -262,6 +262,19 @@ private slots: void forwardDeclare(); void debugStream_data(); void debugStream(); + + void loadQt4Stream_data(); + void loadQt4Stream(); + void saveQt4Stream_data(); + void saveQt4Stream(); + void loadQt5Stream_data(); + void loadQt5Stream(); + void saveQt5Stream_data(); + void saveQt5Stream(); +private: + void dataStream_data(QDataStream::Version version); + void loadQVariantFromDataStream(QDataStream::Version version); + void saveQVariantFromDataStream(QDataStream::Version version); }; Q_DECLARE_METATYPE(QDate) @@ -1906,7 +1919,7 @@ void tst_QVariant::typeName_data() QTest::newRow("39") << int(QVariant::RectF) << QByteArray("QRectF"); QTest::newRow("40") << int(QVariant::PointF) << QByteArray("QPointF"); QTest::newRow("41") << int(QVariant::RegExp) << QByteArray("QRegExp"); - QTest::newRow("42") << int(QVariant::UserType) << QByteArray("UserType"); + QTest::newRow("42") << int(QVariant::UserType) << QByteArray(); QTest::newRow("43") << int(QVariant::Matrix) << QByteArray("QMatrix"); QTest::newRow("44") << int(QVariant::Transform) << QByteArray("QTransform"); QTest::newRow("45") << int(QVariant::Hash) << QByteArray("QVariantHash"); @@ -1948,7 +1961,14 @@ void tst_QVariant::typeToName() QVERIFY( QVariant::nameToType( 0 ) == QVariant::Invalid ); QVERIFY( QVariant::nameToType( "" ) == QVariant::Invalid ); QVERIFY( QVariant::nameToType( "foo" ) == QVariant::Invalid ); - QCOMPARE(QVariant::nameToType("QIconSet"), QVariant::Icon); + + QCOMPARE(QVariant::nameToType("UserType"), QVariant::Invalid); + + // We don't support these old (Qt3) types anymore. + QCOMPARE(QVariant::nameToType("QIconSet"), QVariant::Invalid); + QCOMPARE(QVariant::nameToType("Q3CString"), QVariant::Invalid); + QCOMPARE(QVariant::nameToType("Q_LLONG"), QVariant::Invalid); + QCOMPARE(QVariant::nameToType("Q_ULLONG"), QVariant::Invalid); } void tst_QVariant::streamInvalidVariant() @@ -2003,13 +2023,6 @@ Q_DECLARE_METATYPE(MyType*) void tst_QVariant::userType() { { - QVariant userVariant(QVariant::UserType); - - QVERIFY(userVariant.isValid()); - QVERIFY(userVariant.isNull()); - } - - { MyType data(1, "eins"); MyType data2(2, "zwei"); @@ -3248,6 +3261,34 @@ void tst_QVariant::moreCustomTypes() PLAY_WITH_VARIANT(d, false, QString(), 0, false); } QCOMPARE(MyMovable::count, 0); + + { + QList<QList<int> > data; + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + data << (QList<int>() << 42); + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + } + + { + QList<QVector<int> > data; + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + data << (QVector<int>() << 42); + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + } + + { + QList<QSet<int> > data; + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + data << (QSet<int>() << 42); + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + } + + { + QList<QLinkedList<int> > data; + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + data << (QLinkedList<int>() << 42); + PLAY_WITH_VARIANT(data, false, QString(), 0, false); + } } void tst_QVariant::movabilityTest() @@ -3324,6 +3365,11 @@ void tst_QVariant::colorInteger() } class Forward; +QT_BEGIN_NAMESPACE namespace QtPrivate { +template <> struct IsPointerToTypeDerivedFromQObject<Forward*> { + enum { Value = false }; +}; +} QT_END_NAMESPACE Q_DECLARE_METATYPE(Forward*); void tst_QVariant::forwardDeclare() @@ -3333,6 +3379,123 @@ void tst_QVariant::forwardDeclare() QCOMPARE(qvariant_cast<Forward*>(v), f); } +void tst_QVariant::loadQt5Stream_data() +{ + dataStream_data(QDataStream::Qt_5_0); +} + +void tst_QVariant::loadQt5Stream() +{ + loadQVariantFromDataStream(QDataStream::Qt_5_0); +} + +void tst_QVariant::saveQt5Stream_data() +{ + dataStream_data(QDataStream::Qt_5_0); +} + +void tst_QVariant::saveQt5Stream() +{ + saveQVariantFromDataStream(QDataStream::Qt_5_0); +} + +void tst_QVariant::loadQt4Stream_data() +{ + dataStream_data(QDataStream::Qt_4_9); +} + +void tst_QVariant::loadQt4Stream() +{ + loadQVariantFromDataStream(QDataStream::Qt_4_9); +} + +void tst_QVariant::saveQt4Stream_data() +{ + dataStream_data(QDataStream::Qt_4_9); +} + +void tst_QVariant::saveQt4Stream() +{ + saveQVariantFromDataStream(QDataStream::Qt_4_9); +} + +void tst_QVariant::dataStream_data(QDataStream::Version version) +{ + QTest::addColumn<QString>("fileName"); + + QString path; + switch (version) { + case QDataStream::Qt_4_9: + path = QString::fromLatin1("qt4.9"); + break; + case QDataStream::Qt_5_0: + path = QString::fromLatin1("qt5.0"); + break; + default: + Q_UNIMPLEMENTED(); + } + + path = path.prepend(":/stream/").append("/"); + QDir dir(path); + uint i = 0; + foreach (const QFileInfo &fileInfo, dir.entryInfoList(QStringList() << "*.bin")) { + QTest::newRow((path + fileInfo.fileName()).toLatin1()) << fileInfo.filePath(); + i += 1; + } + QVERIFY(i > 10); +} + +void tst_QVariant::loadQVariantFromDataStream(QDataStream::Version version) +{ + QFETCH(QString, fileName); + + QFile file(fileName); + QVERIFY(file.open(QIODevice::ReadOnly)); + + QDataStream stream(&file); + stream.setVersion(version); + + QString typeName; + QVariant loadedVariant; + stream >> typeName >> loadedVariant; + + const int id = QMetaType::type(typeName.toLatin1()); + QVariant constructedVariant(static_cast<QVariant::Type>(id)); + QCOMPARE(constructedVariant.userType(), id); + QCOMPARE(QMetaType::typeName(loadedVariant.userType()), typeName.toLatin1().constData()); + QCOMPARE(loadedVariant.userType(), constructedVariant.userType()); +} + +void tst_QVariant::saveQVariantFromDataStream(QDataStream::Version version) +{ + QFETCH(QString, fileName); + + QFile file(fileName); + QVERIFY(file.open(QIODevice::ReadOnly)); + QDataStream dataFileStream(&file); + + QString typeName; + dataFileStream >> typeName; + QByteArray data = file.readAll(); + const int id = QMetaType::type(typeName.toLatin1()); + + QBuffer buffer; + buffer.open(QIODevice::ReadWrite); + QDataStream stream(&buffer); + stream.setVersion(version); + + QVariant constructedVariant(static_cast<QVariant::Type>(id)); + QCOMPARE(constructedVariant.userType(), id); + stream << constructedVariant; + + // We are testing QVariant there is no point in testing full array. + QCOMPARE(buffer.data().left(5), data.left(5)); + + buffer.seek(0); + QVariant recunstructedVariant; + stream >> recunstructedVariant; + QCOMPARE(recunstructedVariant.userType(), constructedVariant.userType()); +} class MessageHandler { public: @@ -3392,6 +3555,5 @@ void tst_QVariant::debugStream() QVERIFY(msgHandler.testPassed()); } - QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index cd87bed601..0d3c4e0f88 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qlibrary/lib/mylib.c b/tests/auto/corelib/plugin/qlibrary/lib/mylib.c index 04a59f210c..8e32bb47af 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/mylib.c +++ b/tests/auto/corelib/plugin/qlibrary/lib/mylib.c @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c b/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c index 525f3e3aab..e68832cabc 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c +++ b/tests/auto/corelib/plugin/qlibrary/lib2/mylib.c @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index 75f854667e..cff98de54f 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -103,8 +103,8 @@ static QString sys_qualifiedLibraryName(const QString &fileName) { - QString currDir = QDir::currentPath(); - return currDir + "/" + PREFIX + fileName + SUFFIX; + QString appDir = QCoreApplication::applicationDirPath(); + return appDir + "/" + PREFIX + fileName + SUFFIX; } QT_FORWARD_DECLARE_CLASS(QLibrary) @@ -170,8 +170,8 @@ void tst_QLibrary::version() QFETCH( int, resultversion ); #if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) - QString currDir = QDir::currentPath(); - QLibrary library( currDir + QLatin1Char('/') + lib, loadversion ); + QString appDir = QCoreApplication::applicationDirPath(); + QLibrary library( appDir + QLatin1Char('/') + lib, loadversion ); QVERIFY2(library.load(), qPrintable(library.errorString())); VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion"); @@ -190,24 +190,24 @@ void tst_QLibrary::load_data() QTest::addColumn<QString>("lib"); QTest::addColumn<bool>("result"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); - QTest::newRow( "ok00" ) << currDir + "/mylib" << true; - QTest::newRow( "notexist" ) << currDir + "/nolib" << false; - QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << false; + QTest::newRow( "ok00" ) << appDir + "/mylib" << true; + QTest::newRow( "notexist" ) << appDir + "/nolib" << false; + QTest::newRow( "badlibrary" ) << appDir + "/qlibrary.pro" << false; #ifdef Q_OS_MAC - QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<true; + QTest::newRow("ok (libmylib ver. 1)") << appDir + "/libmylib" <<true; #endif # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.qt.test.mylib.dll" << true; + QTest::newRow( "ok01 (with suffix)" ) << appDir + "/mylib.dll" << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/mylib.dl2" << true; + QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << true; # elif defined Q_OS_UNIX - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.qt.test.mylib.so" << true; + QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << true; + QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << true; # endif // Q_OS_UNIX } @@ -231,14 +231,14 @@ void tst_QLibrary::unload_data() QTest::addColumn<QString>("lib"); QTest::addColumn<bool>("result"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); - QTest::newRow( "mylib" ) << currDir + "/mylib" << true; + QTest::newRow( "mylib" ) << appDir + "/mylib" << true; #ifdef Q_OS_MAC if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3) QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue); #endif - QTest::newRow( "ok01" ) << currDir + "/nolib" << false; + QTest::newRow( "ok01" ) << appDir + "/nolib" << false; } void tst_QLibrary::unload() @@ -272,11 +272,11 @@ void tst_QLibrary::resolve_data() QTest::addColumn<QString>("symbol"); QTest::addColumn<bool>("goodPointer"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); - QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << true; - QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << false; - QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << false; + QTest::newRow( "ok00" ) << appDir + "/mylib" << QString("mylibversion") << true; + QTest::newRow( "bad00" ) << appDir + "/mylib" << QString("nosym") << false; + QTest::newRow( "bad01" ) << appDir + "/nolib" << QString("nosym") << false; } void tst_QLibrary::resolve() @@ -353,16 +353,16 @@ void tst_QLibrary::errorString_data() QTest::addColumn<bool>("success"); QTest::addColumn<QString>("errorString"); - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); #ifdef Q_OS_WINCE - QTest::newRow("bad resolve") << (int)Resolve << currDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*"); + QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*"); #else - QTest::newRow("bad resolve") << (int)Resolve << currDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*"); + QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*"); #endif - QTest::newRow("good resolve") << (int)Resolve << currDir + "/mylib" << true << QString("Unknown error"); + QTest::newRow("good resolve") << (int)Resolve << appDir + "/mylib" << true << QString("Unknown error"); #ifdef Q_OS_WIN QTest::newRow("bad load() with .dll suffix") << (int)Load << QString("nosuchlib.dll") << false << QString("Cannot load library nosuchlib.dll: The specified module could not be found."); @@ -431,17 +431,17 @@ void tst_QLibrary::loadHints_data() } #endif - QString currDir = QDir::currentPath(); + QString appDir = QCoreApplication::applicationDirPath(); lh |= QLibrary::ResolveAllSymbolsHint; # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.qt.test.mylib.dll" << int(lh) << true; + QTest::newRow( "ok01 (with suffix)" ) << appDir + "/mylib.dll" << int(lh) << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/mylib.dl2" << int(lh) << true; + QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true; # elif defined Q_OS_UNIX - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.qt.test.mylib.so" << int(lh) << true; + QTest::newRow( "ok01 (with suffix)" ) << appDir + "/libmylib" SUFFIX << int(lh) << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/libmylib.so2" << int(lh) << true; + QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.so" << int(lh) << true; # endif // Q_OS_UNIX } @@ -504,7 +504,7 @@ void tst_QLibrary::fileName() void tst_QLibrary::multipleInstancesForOneLibrary() { - QString lib = QDir::currentPath() + "/mylib"; + QString lib = QCoreApplication::applicationDirPath() + "/mylib"; { QLibrary lib1(lib); diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp index 3dc5ec377c..057db69174 100644 --- a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp index 99f3c8f452..9542695112 100644 --- a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index 63c1100c5c..e6a83cf3d7 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp index 353b5e0158..4b2057087a 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h index e4a9b376b2..6658a5be8d 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c b/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c index c87ec5b66d..043e857fc0 100644 --- a/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c +++ b/tests/auto/corelib/plugin/qpluginloader/lib/mylib.c @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h index 92b7a1b4dc..a568dd118d 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp index 660dbd2b90..b064901a4d 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h index e1ded8f07b..b769aa6eed 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index bf046524d7..b79479ace8 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp index 072d722cff..3012c532db 100644 --- a/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp +++ b/tests/auto/corelib/plugin/quuid/testProcessUniqueness/main.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 789659cd04..ea88e4832e 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp index 7ca7fc5120..841a111070 100644 --- a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp +++ b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 2183016c32..6a06a3fb5b 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index f7969eb55e..a6d38ca078 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp index ac83601414..a8f7e037d0 100644 --- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 6669a5c4b4..72670ab33f 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp index e92dddca95..33ea2bedb4 100644 --- a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp +++ b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp b/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp index 4ba28f60ef..58819dad4b 100644 --- a/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp +++ b/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index 418ae02add..2fcce773bc 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp index 2901e8f6c9..1d54c8e036 100644 --- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp +++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 1afd913fe9..25e1a0587c 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp index c37823436a..6d63a4b6ea 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.h b/tests/auto/corelib/thread/qthreadonce/qthreadonce.h index 3c5a42e814..6fc937efa9 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.h +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -48,7 +48,6 @@ QT_BEGIN_HEADER -QT_MODULE(Core) #ifndef QT_NO_THREAD diff --git a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp index 81f57215cc..8d4ee73d7f 100644 --- a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/concurrent/qthreadpool/.gitignore b/tests/auto/corelib/thread/qthreadpool/.gitignore index 16105821a2..16105821a2 100644 --- a/tests/auto/corelib/concurrent/qthreadpool/.gitignore +++ b/tests/auto/corelib/thread/qthreadpool/.gitignore diff --git a/tests/auto/corelib/concurrent/qthreadpool/qthreadpool.pro b/tests/auto/corelib/thread/qthreadpool/qthreadpool.pro index 4d81218f24..4d81218f24 100644 --- a/tests/auto/corelib/concurrent/qthreadpool/qthreadpool.pro +++ b/tests/auto/corelib/thread/qthreadpool/qthreadpool.pro diff --git a/tests/auto/corelib/concurrent/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index e08ed2b3fc..1dd0410f41 100644 --- a/tests/auto/corelib/concurrent/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp index 4c5fcf916a..388c233d84 100644 --- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index c74b85154f..fff361ea2a 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp index 6bb562e146..578f867032 100644 --- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp b/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp index f975351e32..7481b9d9f1 100644 --- a/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp +++ b/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/thread/thread.pro b/tests/auto/corelib/thread/thread.pro index a137748b75..12a284c7c7 100644 --- a/tests/auto/corelib/thread/thread.pro +++ b/tests/auto/corelib/thread/thread.pro @@ -9,6 +9,7 @@ SUBDIRS=\ qsemaphore \ qthread \ qthreadonce \ + qthreadpool \ qthreadstorage \ qwaitcondition \ qwritelocker diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 5735c4043b..1d7cb1e903 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -105,29 +105,24 @@ QVector<DataType> generateData(QString dataSetType, const int length) { QVector<DataType> container; if (dataSetType == "Random") { - for(int i=0; i < length; ++i) + for (int i = 0; i < length; ++i) container.append(rand()); - } - else if (dataSetType == "Ascending") { - for (int i=0; i < length; ++i) + } else if (dataSetType == "Ascending") { + for (int i = 0; i < length; ++i) container.append(i); - } - else if (dataSetType == "Descending") { - for (int i=0; i < length; ++i) + } else if (dataSetType == "Descending") { + for (int i = 0; i < length; ++i) container.append(length - i); - } - else if (dataSetType == "Equal") { - for (int i=0; i < length; ++i) + } else if (dataSetType == "Equal") { + for (int i = 0; i < length; ++i) container.append(43); - } - else if (dataSetType == "Duplicates") { - for (int i=0; i < length; ++i) + } else if (dataSetType == "Duplicates") { + for (int i = 0; i < length; ++i) container.append(i % 10); - } - else if (dataSetType == "Almost Sorted") { - for (int i=0; i < length; ++i) + } else if (dataSetType == "Almost Sorted") { + for (int i = 0; i < length; ++i) container.append(i); - for(int i = 0; i<= length / 10; ++i) { + for (int i = 0; i <= length / 10; ++i) { const int iswap = i * 9; DataType tmp = container.at(iswap); container[iswap] = container.at(iswap + 1); diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp index 9ee006827f..588506534a 100644 --- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp +++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 5b660ecd3f..585d6afa44 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -130,7 +130,8 @@ private slots: void byteRefDetaching() const; void reserve(); - + void movablity_data(); + void movablity(); void literals(); }; @@ -1497,6 +1498,85 @@ void tst_QByteArray::reserve() nil2.reserve(0); } +void tst_QByteArray::movablity_data() +{ + QTest::addColumn<QByteArray>("array"); + + QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00", 4); + QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff", 4); + QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff", 4); + QTest::newRow("empty") << QByteArray(""); + QTest::newRow("null") << QByteArray(); + QTest::newRow("sss") << QByteArray(3, 's'); +} + +void tst_QByteArray::movablity() +{ + QFETCH(QByteArray, array); + + QVERIFY(!QTypeInfo<QByteArray>::isStatic); + + const int size = array.size(); + const bool isEmpty = array.isEmpty(); + const bool isNull = array.isNull(); + const int capacity = array.capacity(); + + QByteArray memSpace; + + // we need only memory space not the instance + memSpace.~QByteArray(); + // move array -> memSpace + memcpy(&memSpace, &array, sizeof(QByteArray)); + // reconstruct empty QByteArray + new (&array) QByteArray; + + QCOMPARE(memSpace.size(), size); + QCOMPARE(memSpace.isEmpty(), isEmpty); + QCOMPARE(memSpace.isNull(), isNull); + QCOMPARE(memSpace.capacity(), capacity); + + // try to not crash + memSpace.toLower(); + memSpace.toUpper(); + memSpace.prepend('a'); + memSpace.append("b", 1); + memSpace.squeeze(); + memSpace.reserve(array.size() + 16); + + QByteArray copy(memSpace); + + // reinitialize base values + const int newSize = size + 2; + const bool newIsEmpty = false; + const bool newIsNull = false; + const int newCapacity = 16; + + // move back memSpace -> array + array.~QByteArray(); + memcpy(&array, &memSpace, sizeof(QByteArray)); + // reconstruct empty QByteArray + new (&memSpace) QByteArray; + + QCOMPARE(array.size(), newSize); + QCOMPARE(array.isEmpty(), newIsEmpty); + QCOMPARE(array.isNull(), newIsNull); + QCOMPARE(array.capacity(), newCapacity); + QVERIFY(array.startsWith("a")); + QVERIFY(array.endsWith("b")); + + QCOMPARE(copy.size(), newSize); + QCOMPARE(copy.isEmpty(), newIsEmpty); + QCOMPARE(copy.isNull(), newIsNull); + QCOMPARE(copy.capacity(), newCapacity); + QVERIFY(copy.startsWith("a")); + QVERIFY(copy.endsWith("b")); + + // try to not crash + array.squeeze(); + array.reserve(array.size() + 3); + QVERIFY(true); +} + void tst_QByteArray::literals() { #if defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU) diff --git a/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp index 8bc827ef7f..d0ba1fadc9 100644 --- a/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp +++ b/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qcache/tst_qcache.cpp b/tests/auto/corelib/tools/qcache/tst_qcache.cpp index 88b56612af..8129f1510c 100644 --- a/tests/auto/corelib/tools/qcache/tst_qcache.cpp +++ b/tests/auto/corelib/tools/qcache/tst_qcache.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index c5fdeeb54a..1732f628ea 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index ad464dc40a..37fe346684 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index 14b41e178d..3a257c2f11 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index 7bb6de8c9f..4921a7e734 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -48,20 +48,32 @@ class tst_QDate : public QObject Q_OBJECT private slots: void toString(); + void isNull_data(); + void isNull(); void isValid_data(); void isValid(); void julianDay_data(); void julianDay(); + void dayOfWeek_data(); + void dayOfWeek(); + void dayOfYear_data(); + void dayOfYear(); + void daysInMonth_data(); + void daysInMonth(); + void daysInYear(); + void getDate(); void weekNumber_invalid_data(); void weekNumber_invalid(); void weekNumber_data(); void weekNumber(); + void julianDaysLimits(); void addDays_data(); void addDays(); void addMonths_data(); void addMonths(); void addYears_data(); void addYears(); + void daysTo(); void operator_eq_eq(); void operator_not_eq(); void operator_lt(); @@ -92,66 +104,92 @@ private slots: Q_DECLARE_METATYPE(QDate) +void tst_QDate::isNull_data() +{ + QTest::addColumn<qint64>("jd"); + QTest::addColumn<bool>("null"); + + qint64 minJd = std::numeric_limits<qint64>::min() / 2; + qint64 maxJd = std::numeric_limits<qint64>::max() / 2; + + QTest::newRow("qint64 min") << std::numeric_limits<qint64>::min() << true; + QTest::newRow("minJd - 1") << minJd - 1 << true; + QTest::newRow("minJd") << minJd << false; + QTest::newRow("minJd + 1") << minJd + 1 << false; + QTest::newRow("maxJd - 1") << maxJd - 1 << false; + QTest::newRow("maxJd") << maxJd << false; + QTest::newRow("maxJd + 1") << maxJd + 1 << true; + QTest::newRow("qint64 max") << std::numeric_limits<qint64>::max() << true; +} + +void tst_QDate::isNull() +{ + QFETCH(qint64, jd); + + QDate d = QDate::fromJulianDay(jd); + QTEST(d.isNull(), "null"); +} + void tst_QDate::isValid_data() { + qint64 nullJd = std::numeric_limits<qint64>::min(); + QTest::addColumn<int>("year"); QTest::addColumn<int>("month"); QTest::addColumn<int>("day"); - QTest::addColumn<uint>("jd"); + QTest::addColumn<qint64>("jd"); QTest::addColumn<bool>("valid"); - QTest::newRow("0-0-0") << 0 << 0 << 0 << 0U << false; - QTest::newRow("month 0") << 2000 << 0 << 1 << 0U << false; - QTest::newRow("day 0") << 2000 << 1 << 0 << 0U << false; + QTest::newRow("0-0-0") << 0 << 0 << 0 << nullJd << false; + QTest::newRow("month 0") << 2000 << 0 << 1 << nullJd << false; + QTest::newRow("day 0") << 2000 << 1 << 0 << nullJd << false; - QTest::newRow("month 13") << 2000 << 13 << 1 << 0U << false; + QTest::newRow("month 13") << 2000 << 13 << 1 << nullJd << false; // test leap years - QTest::newRow("non-leap") << 2006 << 2 << 29 << 0U << false; - QTest::newRow("normal leap") << 2004 << 2 << 29 << 2453065U << true; - QTest::newRow("century leap") << 1900 << 2 << 29 << 0U << false; - QTest::newRow("century leap") << 2100 << 2 << 29 << 0U << false; - QTest::newRow("400-years leap") << 2000 << 2 << 29 << 2451604U << true; - QTest::newRow("400-years leap 2") << 2400 << 2 << 29 << 2597701U << true; - QTest::newRow("400-years leap 3") << 1600 << 2 << 29 << 2305507U << true; - QTest::newRow("year 0") << 0 << 2 << 27 << 0U << false; + QTest::newRow("non-leap") << 2006 << 2 << 29 << nullJd << false; + QTest::newRow("normal leap") << 2004 << 2 << 29 << qint64(2453065) << true; + QTest::newRow("century leap") << 1900 << 2 << 29 << nullJd << false; + QTest::newRow("century leap") << 2100 << 2 << 29 << nullJd << false; + QTest::newRow("400-years leap") << 2000 << 2 << 29 << qint64(2451604) << true; + QTest::newRow("400-years leap 2") << 2400 << 2 << 29 << qint64(2597701) << true; + QTest::newRow("400-years leap 3") << 1600 << 2 << 29 << qint64(2305507) << true; + QTest::newRow("year 0") << 0 << 2 << 27 << nullJd << false; // test the number of days in months: - QTest::newRow("jan") << 2000 << 1 << 31 << 2451575U << true; - QTest::newRow("feb") << 2000 << 2 << 29 << 2451604U << true; // same data as 400-years leap - QTest::newRow("mar") << 2000 << 3 << 31 << 2451635U << true; - QTest::newRow("apr") << 2000 << 4 << 30 << 2451665U << true; - QTest::newRow("may") << 2000 << 5 << 31 << 2451696U << true; - QTest::newRow("jun") << 2000 << 6 << 30 << 2451726U << true; - QTest::newRow("jul") << 2000 << 7 << 31 << 2451757U << true; - QTest::newRow("aug") << 2000 << 8 << 31 << 2451788U << true; - QTest::newRow("sep") << 2000 << 9 << 30 << 2451818U << true; - QTest::newRow("oct") << 2000 << 10 << 31 << 2451849U << true; - QTest::newRow("nov") << 2000 << 11 << 30 << 2451879U << true; - QTest::newRow("dec") << 2000 << 12 << 31 << 2451910U << true; + QTest::newRow("jan") << 2000 << 1 << 31 << qint64(2451575) << true; + QTest::newRow("feb") << 2000 << 2 << 29 << qint64(2451604) << true; // same data as 400-years leap + QTest::newRow("mar") << 2000 << 3 << 31 << qint64(2451635) << true; + QTest::newRow("apr") << 2000 << 4 << 30 << qint64(2451665) << true; + QTest::newRow("may") << 2000 << 5 << 31 << qint64(2451696) << true; + QTest::newRow("jun") << 2000 << 6 << 30 << qint64(2451726) << true; + QTest::newRow("jul") << 2000 << 7 << 31 << qint64(2451757) << true; + QTest::newRow("aug") << 2000 << 8 << 31 << qint64(2451788) << true; + QTest::newRow("sep") << 2000 << 9 << 30 << qint64(2451818) << true; + QTest::newRow("oct") << 2000 << 10 << 31 << qint64(2451849) << true; + QTest::newRow("nov") << 2000 << 11 << 30 << qint64(2451879) << true; + QTest::newRow("dec") << 2000 << 12 << 31 << qint64(2451910) << true; // and invalid dates: - QTest::newRow("ijan") << 2000 << 1 << 32 << 0U << false; - QTest::newRow("ifeb") << 2000 << 2 << 30 << 0U << false; - QTest::newRow("imar") << 2000 << 3 << 32 << 0U << false; - QTest::newRow("iapr") << 2000 << 4 << 31 << 0U << false; - QTest::newRow("imay") << 2000 << 5 << 32 << 0U << false; - QTest::newRow("ijun") << 2000 << 6 << 31 << 0U << false; - QTest::newRow("ijul") << 2000 << 7 << 32 << 0U << false; - QTest::newRow("iaug") << 2000 << 8 << 32 << 0U << false; - QTest::newRow("isep") << 2000 << 9 << 31 << 0U << false; - QTest::newRow("ioct") << 2000 << 10 << 32 << 0U << false; - QTest::newRow("inov") << 2000 << 11 << 31 << 0U << false; - QTest::newRow("idec") << 2000 << 12 << 32 << 0U << false; + QTest::newRow("ijan") << 2000 << 1 << 32 << nullJd << false; + QTest::newRow("ifeb") << 2000 << 2 << 30 << nullJd << false; + QTest::newRow("imar") << 2000 << 3 << 32 << nullJd << false; + QTest::newRow("iapr") << 2000 << 4 << 31 << nullJd << false; + QTest::newRow("imay") << 2000 << 5 << 32 << nullJd << false; + QTest::newRow("ijun") << 2000 << 6 << 31 << nullJd << false; + QTest::newRow("ijul") << 2000 << 7 << 32 << nullJd << false; + QTest::newRow("iaug") << 2000 << 8 << 32 << nullJd << false; + QTest::newRow("isep") << 2000 << 9 << 31 << nullJd << false; + QTest::newRow("ioct") << 2000 << 10 << 32 << nullJd << false; + QTest::newRow("inov") << 2000 << 11 << 31 << nullJd << false; + QTest::newRow("idec") << 2000 << 12 << 32 << nullJd << false; // the beginning of the Julian Day calendar: - QTest::newRow("jd negative1") << -4714 << 1 << 1 << 0U << false; - QTest::newRow("jd negative2") << -4713 << 1 << 1 << 0U << false; - QTest::newRow("jd negative3") << -4713 << 1 << 2 << 1U << true; - QTest::newRow("jd negative4") << -4713 << 1 << 3 << 2U << true; - QTest::newRow("jd 0") << -4713 << 1 << 1 << 0U << false; - QTest::newRow("jd 1") << -4713 << 1 << 2 << 1U << true; - QTest::newRow("imminent overflow") << 11754508 << 12 << 13 << 4294967295U << true; + QTest::newRow("jd earliest formula") << -4800 << 1 << 1 << qint64( -31738) << true; + QTest::newRow("jd -1") << -4714 << 11 << 23 << qint64( -1) << true; + QTest::newRow("jd 0") << -4714 << 11 << 24 << qint64( 0) << true; + QTest::newRow("jd 1") << -4714 << 11 << 25 << qint64( 1) << true; + QTest::newRow("jd latest formula") << 1400000 << 12 << 31 << qint64(513060925) << true; } void tst_QDate::isValid() @@ -159,12 +197,25 @@ void tst_QDate::isValid() QFETCH(int, year); QFETCH(int, month); QFETCH(int, day); + QFETCH(qint64, jd); + QFETCH(bool, valid); - QTEST(QDate::isValid(year, month, day), "valid"); + QCOMPARE(QDate::isValid(year, month, day), valid); QDate d; d.setDate(year, month, day); - QTEST(d.isValid(), "valid"); + QCOMPARE(d.isValid(), valid); + QCOMPARE(d.toJulianDay(), jd); + + if (valid) { + QCOMPARE(d.year(), year); + QCOMPARE(d.month(), month); + QCOMPARE(d.day(), day); + } else { + QCOMPARE(d.year(), 0); + QCOMPARE(d.month(), 0); + QCOMPARE(d.day(), 0); + } } void tst_QDate::julianDay_data() @@ -177,15 +228,15 @@ void tst_QDate::julianDay() QFETCH(int, year); QFETCH(int, month); QFETCH(int, day); - QFETCH(uint, jd); + QFETCH(qint64, jd); { QDate d; d.setDate(year, month, day); - QCOMPARE(uint(d.toJulianDay()), jd); + QCOMPARE(d.toJulianDay(), jd); } - if (jd) { + if (jd != std::numeric_limits<qint64>::min()) { QDate d = QDate::fromJulianDay(jd); QCOMPARE(d.year(), year); QCOMPARE(d.month(), month); @@ -193,6 +244,137 @@ void tst_QDate::julianDay() } } +void tst_QDate::dayOfWeek_data() +{ + QTest::addColumn<int>("year"); + QTest::addColumn<int>("month"); + QTest::addColumn<int>("day"); + QTest::addColumn<int>("dayOfWeek"); + + QTest::newRow("data0") << 0 << 0 << 0 << 0; + QTest::newRow("data1") << 2000 << 1 << 3 << 1; + QTest::newRow("data2") << 2000 << 1 << 4 << 2; + QTest::newRow("data3") << 2000 << 1 << 5 << 3; + QTest::newRow("data4") << 2000 << 1 << 6 << 4; + QTest::newRow("data5") << 2000 << 1 << 7 << 5; + QTest::newRow("data6") << 2000 << 1 << 8 << 6; + QTest::newRow("data7") << 2000 << 1 << 9 << 7; + QTest::newRow("data8") << -4800 << 1 << 1 << 1; + QTest::newRow("data9") << -4800 << 1 << 2 << 2; + QTest::newRow("data10") << -4800 << 1 << 3 << 3; + QTest::newRow("data12") << -4800 << 1 << 4 << 4; + QTest::newRow("data12") << -4800 << 1 << 5 << 5; + QTest::newRow("data13") << -4800 << 1 << 6 << 6; + QTest::newRow("data14") << -4800 << 1 << 7 << 7; + QTest::newRow("data15") << -4800 << 1 << 8 << 1; +} + +void tst_QDate::dayOfWeek() +{ + QFETCH(int, year); + QFETCH(int, month); + QFETCH(int, day); + QFETCH(int, dayOfWeek); + + QDate dt(year, month, day); + QCOMPARE(dt.dayOfWeek(), dayOfWeek); +} + +void tst_QDate::dayOfYear_data() +{ + QTest::addColumn<int>("year"); + QTest::addColumn<int>("month"); + QTest::addColumn<int>("day"); + QTest::addColumn<int>("dayOfYear"); + + QTest::newRow("data0") << 0 << 0 << 0 << 0; + QTest::newRow("data1") << 2000 << 1 << 1 << 1; + QTest::newRow("data2") << 2000 << 1 << 2 << 2; + QTest::newRow("data3") << 2000 << 1 << 3 << 3; + QTest::newRow("data4") << 2000 << 12 << 31 << 366; + QTest::newRow("data5") << 2001 << 12 << 31 << 365; + QTest::newRow("data6") << 1815 << 1 << 1 << 1; + QTest::newRow("data7") << 1815 << 12 << 31 << 365; + QTest::newRow("data8") << 1500 << 1 << 1 << 1; + QTest::newRow("data9") << 1500 << 12 << 31 << 365; + QTest::newRow("data10") << -1500 << 1 << 1 << 1; + QTest::newRow("data11") << -1500 << 12 << 31 << 365; + QTest::newRow("data12") << -4800 << 1 << 1 << 1; + QTest::newRow("data13") << -4800 << 12 << 31 << 365; +} + +void tst_QDate::dayOfYear() +{ + QFETCH(int, year); + QFETCH(int, month); + QFETCH(int, day); + QFETCH(int, dayOfYear); + + QDate dt(year, month, day); + QCOMPARE(dt.dayOfYear(), dayOfYear); +} + +void tst_QDate::daysInMonth_data() +{ + QTest::addColumn<int>("year"); + QTest::addColumn<int>("month"); + QTest::addColumn<int>("day"); + QTest::addColumn<int>("daysInMonth"); + + QTest::newRow("data0") << 0 << 0 << 0 << 0; + QTest::newRow("data1") << 2000 << 1 << 1 << 31; + QTest::newRow("data2") << 2000 << 2 << 1 << 29; + QTest::newRow("data3") << 2000 << 3 << 1 << 31; + QTest::newRow("data4") << 2000 << 4 << 1 << 30; + QTest::newRow("data5") << 2000 << 5 << 1 << 31; + QTest::newRow("data6") << 2000 << 6 << 1 << 30; + QTest::newRow("data7") << 2000 << 7 << 1 << 31; + QTest::newRow("data8") << 2000 << 8 << 1 << 31; + QTest::newRow("data9") << 2000 << 9 << 1 << 30; + QTest::newRow("data10") << 2000 << 10 << 1 << 31; + QTest::newRow("data11") << 2000 << 11 << 1 << 30; + QTest::newRow("data12") << 2000 << 12 << 1 << 31; + QTest::newRow("data13") << 2001 << 2 << 1 << 28; +} + +void tst_QDate::daysInMonth() +{ + QFETCH(int, year); + QFETCH(int, month); + QFETCH(int, day); + QFETCH(int, daysInMonth); + + QDate dt(year, month, day); + QCOMPARE(dt.daysInMonth(), daysInMonth); +} + +void tst_QDate::daysInYear() +{ + QDate dt(2000, 1, 1); + QCOMPARE(dt.daysInYear(), 366); + dt.setDate(2001, 1, 1); + QCOMPARE(dt.daysInYear(), 365); + dt.setDate(4, 1, 1); + QCOMPARE(dt.daysInYear(), 366); + dt.setDate(5, 1, 1); + QCOMPARE(dt.daysInYear(), 365); +} + +void tst_QDate::getDate() +{ + int y, m, d; + QDate dt(2000, 1, 1); + dt.getDate(&y, &m, &d); + QCOMPARE(y, 2000); + QCOMPARE(m, 1); + QCOMPARE(d, 1); + dt.setDate(0, 0, 0); + dt.getDate(&y, &m, &d); + QCOMPARE(y, 0); + QCOMPARE(m, 0); + QCOMPARE(d, 0); +} + void tst_QDate::weekNumber_data() { QTest::addColumn<int>("expectedWeekNum"); @@ -244,6 +426,68 @@ void tst_QDate::weekNumber_invalid() QCOMPARE( dt.weekNumber( &yearNumber ), 0 ); } +void tst_QDate::julianDaysLimits() +{ + qint64 min = std::numeric_limits<qint64>::min(); + qint64 max = std::numeric_limits<qint64>::max(); + qint64 minJd = std::numeric_limits<qint64>::min() / 2; + qint64 maxJd = std::numeric_limits<qint64>::max() / 2; + + QDate maxDate = QDate::fromJulianDay(maxJd); + QDate minDate = QDate::fromJulianDay(minJd); + QDate zeroDate = QDate::fromJulianDay(0); + + QDate dt = QDate::fromJulianDay(min); + QCOMPARE(dt.isValid(), false); + dt = QDate::fromJulianDay(minJd - 1); + QCOMPARE(dt.isValid(), false); + dt = QDate::fromJulianDay(minJd); + QCOMPARE(dt.isValid(), true); + dt = QDate::fromJulianDay(minJd + 1); + QCOMPARE(dt.isValid(), true); + dt = QDate::fromJulianDay(maxJd - 1); + QCOMPARE(dt.isValid(), true); + dt = QDate::fromJulianDay(maxJd); + QCOMPARE(dt.isValid(), true); + dt = QDate::fromJulianDay(maxJd + 1); + QCOMPARE(dt.isValid(), false); + dt = QDate::fromJulianDay(max); + QCOMPARE(dt.isValid(), false); + + dt = maxDate.addDays(1); + QCOMPARE(dt.isValid(), false); + dt = maxDate.addDays(0); + QCOMPARE(dt.isValid(), true); + dt = maxDate.addDays(-1); + QCOMPARE(dt.isValid(), true); + dt = maxDate.addDays(max); + QCOMPARE(dt.isValid(), false); + dt = maxDate.addDays(min); + QCOMPARE(dt.isValid(), false); + + dt = minDate.addDays(-1); + QCOMPARE(dt.isValid(), false); + dt = minDate.addDays(0); + QCOMPARE(dt.isValid(), true); + dt = minDate.addDays(1); + QCOMPARE(dt.isValid(), true); + dt = minDate.addDays(min); + QCOMPARE(dt.isValid(), false); + dt = minDate.addDays(max); + QCOMPARE(dt.isValid(), true); + + dt = zeroDate.addDays(-1); + QCOMPARE(dt.isValid(), true); + dt = zeroDate.addDays(0); + QCOMPARE(dt.isValid(), true); + dt = zeroDate.addDays(1); + QCOMPARE(dt.isValid(), true); + dt = zeroDate.addDays(min); + QCOMPARE(dt.isValid(), false); + dt = zeroDate.addDays(max); + QCOMPARE(dt.isValid(), false); +} + void tst_QDate::addDays() { QFETCH( int, year ); @@ -286,9 +530,8 @@ void tst_QDate::addDays_data() QTest::newRow( "data10" ) << 2000 << 2 << 28 << -1 << 2000 << 2 << 27; QTest::newRow( "data11" ) << 2001 << 2 << 28 << -30 << 2001 << 1 << 29; - QDate invalid; - QTest::newRow( "data12" ) << -4713 << 1 << 2 << -2 - << invalid.year() << invalid.month() << invalid.day(); + QTest::newRow( "data12" ) << -4713 << 1 << 2 << -2 << -4714 << 12 << 31; + QTest::newRow( "data13" ) << -4713 << 1 << 2 << 2 << -4713 << 1 << 4; } void tst_QDate::addMonths() @@ -341,14 +584,6 @@ void tst_QDate::addMonths_data() QTest::newRow( "data15" ) << 1 << 1 << 1 << -12 << -1 << 1 << 1; QTest::newRow( "data16" ) << -1 << 12 << 1 << 1 << 1 << 1 << 1; QTest::newRow( "data17" ) << -1 << 1 << 1 << 12 << 1 << 1 << 1; - - // Gregorian/Julian switchover - QTest::newRow( "data18" ) << 1582 << 9 << 4 << 1 << 1582 << 10 << 4; - QTest::newRow( "data19" ) << 1582 << 9 << 10 << 1 << 1582 << 10 << 15; - QTest::newRow( "data20" ) << 1582 << 9 << 20 << 1 << 1582 << 10 << 20; - QTest::newRow( "data21" ) << 1582 << 11 << 4 << -1 << 1582 << 10 << 4; - QTest::newRow( "data22" ) << 1582 << 11 << 10 << -1 << 1582 << 10 << 4; - QTest::newRow( "data23" ) << 1582 << 11 << 20 << -1 << 1582 << 10 << 20; } void tst_QDate::addYears() @@ -402,6 +637,35 @@ void tst_QDate::addYears_data() QTest::newRow( "data19" ) << -2000 << 1 << 1 << 2001 << 2 << 1 << 1; } +void tst_QDate::daysTo() +{ + qint64 minJd = std::numeric_limits<qint64>::min() / 2; + qint64 maxJd = std::numeric_limits<qint64>::max() / 2; + + QDate dt1(2000, 1, 1); + QDate dt2(2000, 1, 5); + QCOMPARE(dt1.daysTo(dt2), (qint64) 4); + QCOMPARE(dt2.daysTo(dt1), (qint64) -4); + + dt1.setDate(0, 0, 0); + QCOMPARE(dt1.daysTo(dt2), (qint64) 0); + dt1.setDate(2000, 1, 1); + dt2.setDate(0, 0, 0); + QCOMPARE(dt1.daysTo(dt2), (qint64) 0); + + + QDate maxDate = QDate::fromJulianDay(maxJd); + QDate minDate = QDate::fromJulianDay(minJd); + QDate zeroDate = QDate::fromJulianDay(0); + + QCOMPARE(maxDate.daysTo(minDate), minJd - maxJd); + QCOMPARE(minDate.daysTo(maxDate), maxJd - minJd); + QCOMPARE(maxDate.daysTo(zeroDate), -maxJd); + QCOMPARE(zeroDate.daysTo(maxDate), maxJd); + QCOMPARE(minDate.daysTo(zeroDate), -minJd); + QCOMPARE(zeroDate.daysTo(minDate), minJd); +} + void tst_QDate::operator_eq_eq() { QDate d1(2000,1,2); @@ -636,6 +900,8 @@ void tst_QDate::toString_format() void tst_QDate::isLeapYear() { + QVERIFY(QDate::isLeapYear(-4801)); + QVERIFY(!QDate::isLeapYear(-4800)); QVERIFY(QDate::isLeapYear(-4445)); QVERIFY(!QDate::isLeapYear(-4444)); QVERIFY(!QDate::isLeapYear(-6)); @@ -651,10 +917,10 @@ void tst_QDate::isLeapYear() QVERIFY(QDate::isLeapYear(4)); QVERIFY(!QDate::isLeapYear(7)); QVERIFY(QDate::isLeapYear(8)); - QVERIFY(QDate::isLeapYear(100)); + QVERIFY(!QDate::isLeapYear(100)); QVERIFY(QDate::isLeapYear(400)); - QVERIFY(QDate::isLeapYear(700)); - QVERIFY(QDate::isLeapYear(1500)); + QVERIFY(!QDate::isLeapYear(700)); + QVERIFY(!QDate::isLeapYear(1500)); QVERIFY(QDate::isLeapYear(1600)); QVERIFY(!QDate::isLeapYear(1700)); QVERIFY(!QDate::isLeapYear(1800)); @@ -703,6 +969,7 @@ void tst_QDate::yearsZeroToNinetyNine() QVERIFY(QDate::isValid(1, 2, 3)); QVERIFY(QDate::isValid(-1, 2, 3)); +#if QT_DEPRECATED_SINCE(5,0) { QDate dt; dt.setYMD(1, 2, 3); @@ -710,6 +977,7 @@ void tst_QDate::yearsZeroToNinetyNine() QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); } +#endif { QDate dt; @@ -777,6 +1045,8 @@ void tst_QDate::roundtripGermanLocale() const void tst_QDate::shortDayName() const { + QCOMPARE(QDate::shortDayName(0), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::shortDayName(1), QLatin1String("Mon")); QCOMPARE(QDate::shortDayName(7), QLatin1String("Sun")); @@ -790,6 +1060,8 @@ void tst_QDate::shortDayName() const void tst_QDate::standaloneShortDayName() const { + QCOMPARE(QDate::shortDayName(0, QDate::StandaloneFormat), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::shortDayName(1, QDate::StandaloneFormat), QLatin1String("Mon")); QCOMPARE(QDate::shortDayName(7, QDate::StandaloneFormat), QLatin1String("Sun")); @@ -803,6 +1075,8 @@ void tst_QDate::standaloneShortDayName() const void tst_QDate::longDayName() const { + QCOMPARE(QDate::longDayName(0), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::longDayName(1), QLatin1String("Monday")); QCOMPARE(QDate::longDayName(7), QLatin1String("Sunday")); @@ -816,6 +1090,8 @@ void tst_QDate::longDayName() const void tst_QDate::standaloneLongDayName() const { + QCOMPARE(QDate::longDayName(0, QDate::StandaloneFormat), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::longDayName(1, QDate::StandaloneFormat), QLatin1String("Monday")); QCOMPARE(QDate::longDayName(7, QDate::StandaloneFormat), QLatin1String("Sunday")); @@ -829,6 +1105,8 @@ void tst_QDate::standaloneLongDayName() const void tst_QDate::shortMonthName() const { + QCOMPARE(QDate::shortMonthName(0), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::shortMonthName(1), QLatin1String("Jan")); QCOMPARE(QDate::shortMonthName(8), QLatin1String("Aug")); @@ -842,6 +1120,8 @@ void tst_QDate::shortMonthName() const void tst_QDate::standaloneShortMonthName() const { + QCOMPARE(QDate::shortMonthName(0, QDate::StandaloneFormat), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::shortMonthName(1, QDate::StandaloneFormat), QLatin1String("Jan")); QCOMPARE(QDate::shortMonthName(8, QDate::StandaloneFormat), QLatin1String("Aug")); @@ -855,6 +1135,8 @@ void tst_QDate::standaloneShortMonthName() const void tst_QDate::longMonthName() const { + QCOMPARE(QDate::longMonthName(0), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::longMonthName(1), QLatin1String("January")); QCOMPARE(QDate::longMonthName(8), QLatin1String("August")); @@ -868,6 +1150,8 @@ void tst_QDate::longMonthName() const void tst_QDate::standaloneLongMonthName() const { + QCOMPARE(QDate::longMonthName(0, QDate::StandaloneFormat), QString()); + if (QLocale::system().language() == QLocale::C) { QCOMPARE(QDate::longMonthName(1, QDate::StandaloneFormat), QLatin1String("January")); QCOMPARE(QDate::longMonthName(8, QDate::StandaloneFormat), QLatin1String("August")); @@ -885,28 +1169,44 @@ void tst_QDate::roundtrip() const // year(), month(), day(), julianDayFromDate(), and getDateFromJulianDay() // to ensure they are internally consistent (but doesn't guarantee correct) - // Test Julian round trip in both BC and AD + // Test Julian round trip around JD 0 and current low end of valid range QDate testDate; - QDate loopDate = QDate::fromJulianDay(1684899); // 1 Jan 100 BC - while ( loopDate.toJulianDay() <= 1757948 ) { // 31 Dec 100 AD - testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() ); - QCOMPARE( loopDate.toJulianDay(), testDate.toJulianDay() ); + QDate loopDate = QDate::fromJulianDay(-31738); // 1 Jan 4800 BC + while (loopDate.toJulianDay() <= 5150) { // 31 Dec 4700 BC + testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); + QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); loopDate = loopDate.addDays(1); } - // Test Julian and Gregorian round trip during changeover period - loopDate = QDate::fromJulianDay(2298153); // 1 Jan 1580 AD - while ( loopDate.toJulianDay() <= 2300334 ) { // 31 Dec 1585 AD - testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() ); - QCOMPARE( loopDate.toJulianDay(), testDate.toJulianDay() ); + // Test Julian round trip in both BC and AD + loopDate = QDate::fromJulianDay(1684901); // 1 Jan 100 BC + while (loopDate.toJulianDay() <= 1757949) { // 31 Dec 100 AD + testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); + QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); loopDate = loopDate.addDays(1); } // Test Gregorian round trip during current useful period loopDate = QDate::fromJulianDay(2378497); // 1 Jan 1900 AD - while ( loopDate.toJulianDay() <= 2488433 ) { // 31 Dec 2100 AD - testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() ); - QCOMPARE( loopDate.toJulianDay(), testDate.toJulianDay() ); + while (loopDate.toJulianDay() <= 2488433) { // 31 Dec 2100 AD + testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); + QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); + loopDate = loopDate.addDays(1); + } + + // Test Gregorian round trip at top end of widget/format range + loopDate = QDate::fromJulianDay(5336961); // 1 Jan 9900 AD + while (loopDate.toJulianDay() <= 5373484) { // 31 Dec 9999 AD + testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); + QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); + loopDate = loopDate.addDays(1); + } + + // Test Gregorian round trip at top end of conversion range + loopDate = QDate::fromJulianDay(513024036); // 1 Jan 1399900 AD + while (loopDate.toJulianDay() <= 513060925) { // 31 Dec 1400000 AD + testDate.setDate(loopDate.year(), loopDate.month(), loopDate.day()); + QCOMPARE(loopDate.toJulianDay(), testDate.toJulianDay()); loopDate = loopDate.addDays(1); } } diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 4ef508e92b..af8deefa4c 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -726,14 +726,6 @@ void tst_QDateTime::addSecs_data() QTest::newRow("toPositive") << QDateTime(QDate(-1, 12, 31), QTime(23, 59, 59), Qt::UTC) << 1 << QDateTime(QDate(1, 1, 1), QTime(0, 0, 0), Qt::UTC); - - // Gregorian/Julian switchover - QTest::newRow("toGregorian") << QDateTime(QDate(1582, 10, 4), QTime(23, 59, 59)) - << 1 - << QDateTime(QDate(1582, 10, 15), QTime(0, 0, 0)); - QTest::newRow("toJulian") << QDateTime(QDate(1582, 10, 15), QTime(0, 0, 0)) - << -1 - << QDateTime(QDate(1582, 10, 4), QTime(23, 59, 59)); } void tst_QDateTime::addSecs() @@ -883,22 +875,22 @@ void tst_QDateTime::daysTo() QDateTime dt2(QDate(1760, 2, 2), QTime()); QDateTime dt3(QDate(1760, 3, 2), QTime()); - QCOMPARE(dt1.daysTo(dt2), 31); + QCOMPARE(dt1.daysTo(dt2), (qint64) 31); QCOMPARE(dt1.addDays(31), dt2); - QCOMPARE(dt2.daysTo(dt3), 29); + QCOMPARE(dt2.daysTo(dt3), (qint64) 29); QCOMPARE(dt2.addDays(29), dt3); - QCOMPARE(dt1.daysTo(dt3), 60); + QCOMPARE(dt1.daysTo(dt3), (qint64) 60); QCOMPARE(dt1.addDays(60), dt3); - QCOMPARE(dt2.daysTo(dt1), -31); + QCOMPARE(dt2.daysTo(dt1), (qint64) -31); QCOMPARE(dt2.addDays(-31), dt1); - QCOMPARE(dt3.daysTo(dt2), -29); + QCOMPARE(dt3.daysTo(dt2), (qint64) -29); QCOMPARE(dt3.addDays(-29), dt2); - QCOMPARE(dt3.daysTo(dt1), -60); + QCOMPARE(dt3.daysTo(dt1), (qint64) -60); QCOMPARE(dt3.addDays(-60), dt1); } diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index a4a96c6df7..0a006ab5b4 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp b/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp index 0e2f61ab98..7f28e8dc0c 100644 --- a/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp +++ b/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp b/tests/auto/corelib/tools/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp index a031bf811d..e0e74efdd0 100644 --- a/tests/auto/corelib/tools/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp +++ b/tests/auto/corelib/tools/qexplicitlyshareddatapointer/tst_qexplicitlyshareddatapointer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qfreelist/tst_qfreelist.cpp b/tests/auto/corelib/tools/qfreelist/tst_qfreelist.cpp index a713fd4ca7..86696ab0c9 100644 --- a/tests/auto/corelib/tools/qfreelist/tst_qfreelist.cpp +++ b/tests/auto/corelib/tools/qfreelist/tst_qfreelist.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 6c941179d6..3b5d15dbfc 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index 0c4df63884..28ed8d3e22 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index c1b71de2b7..fbb821c730 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.cpp b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.cpp index 2b6280fd2b..508833b5d0 100644 --- a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.cpp +++ b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index a670cac03c..5544c0fd71 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -123,9 +123,6 @@ private slots: void monthName(); void standaloneMonthName(); - // QSystemLocale tests - void queryDateTime(); - void ampm(); void currency(); void quoteString(); @@ -1778,43 +1775,6 @@ a(QLatin1String("0.0000000000000000000000000000000000000000000000000000000000000 QVERIFY(!ok); } -class SystemLocale : public QSystemLocale -{ -public: - virtual QVariant query(QueryType type, QVariant in) const - { - switch (type) { - case DateTimeFormatLong: return QLatin1String("dddd ddd dd d MMMM MMM MM M yyyy hh:mm:ss.zzz"); - case DateTimeFormatShort: return QLatin1String("d M yy h:m"); - case DateTimeToStringLong: - case DateTimeToStringShort: - return in.toDateTime().toString(type == DateTimeToStringShort - ? QLatin1String("dMyyhm") - : QLatin1String("ddMMyyyyhhmmsszzz")); - default: - break; - } - return QSystemLocale::query(type, in); - } -}; - - - -void tst_QLocale::queryDateTime() -{ - SystemLocale loc; - QCOMPARE(QLocale::system().dateTimeFormat(QLocale::LongFormat), - loc.query(QSystemLocale::DateTimeFormatLong, QVariant()).toString()); - QCOMPARE(QLocale::system().dateTimeFormat(QLocale::ShortFormat), - loc.query(QSystemLocale::DateTimeFormatShort, QVariant()).toString()); - QCOMPARE(QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::ShortFormat), - QString("1127412")); - QCOMPARE(QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::NarrowFormat), - QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::ShortFormat)); - QCOMPARE(QLocale::system().toString(QDateTime(QDate(1974, 12, 1), QTime(1, 2, 3, 4)), QLocale::LongFormat), - QString("01121974010203004")); -} - void tst_QLocale::ampm() { QLocale c(QLocale::C); diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index c48bcfb4b3..79b0a931cb 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp index bdaf98cbf2..de3c0269e1 100644 --- a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp +++ b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp index acdfd20488..aaeb6bd9f5 100644 --- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp +++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qqueue/tst_qqueue.cpp b/tests/auto/corelib/tools/qqueue/tst_qqueue.cpp index 5282d2964b..eb800e57bc 100644 --- a/tests/auto/corelib/tools/qqueue/tst_qqueue.cpp +++ b/tests/auto/corelib/tools/qqueue/tst_qqueue.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index c2a9d05af6..f9d0f0f291 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 836c02dfca..0148e933e4 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -829,6 +829,8 @@ void tst_QRegExp::testEscapingWildcard_data(){ QTest::newRow("? Escaped") << "\\?O;" << "?O;" << true; QTest::newRow("[] not escaped") << "[lL]" << "l" << true; + QTest::newRow("[] escaped") << "\\[\\]" << "[]" << true; + QTest::newRow("case [[]") << "[[abc]" << "[" << true; QTest::newRow("case []abc] match ]") << "[]abc]" << "]" << true; QTest::newRow("case []abc] match a") << "[]abc]" << "a" << true; @@ -844,7 +846,7 @@ void tst_QRegExp::testEscapingWildcard_data(){ QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true; QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true; - QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true; + QTest::newRow("a '\\' at the end") << "\\\\Qt;\\" << "\\\\Qt;\\" << true; } void tst_QRegExp::testEscapingWildcard(){ @@ -1309,7 +1311,7 @@ void tst_QRegExp::posAndCapConsistency() QFETCH( QString, cap2 ); QRegExp re(reStr); - QCOMPARE(re.numCaptures(), 2); + QCOMPARE(re.captureCount(), 2); QCOMPARE(re.capturedTexts().size(), 3); QCOMPARE(re.indexIn(text), matchIndex); diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp index 67de98b867..d94d35afaf 100644 --- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp +++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp index 22f6cb7d32..45ccaa671d 100644 --- a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp index c0e036e232..b070b105da 100644 --- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp +++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 4c0ecce5ec..d7d8c99071 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp index c7ffe8cb7b..fb946d9ca1 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -52,6 +52,7 @@ #include <QtCore/QDirIterator> #include <QtCore/QDateTime> #include <QtCore/QDebug> +#include <QtCore/QLibraryInfo> #ifndef DEFAULT_MAKESPEC # error DEFAULT_MAKESPEC not defined @@ -464,7 +465,11 @@ namespace QTest { "SOURCES += project.cpp\n" "QT -= core gui\n" "INCLUDEPATH += . "); - projectFile.write(QFile::encodeName(QDir::currentPath())); + + QString workingDir = QDir::currentPath(); + if (extraProgramSources.count() > 0) + workingDir = QFileInfo(extraProgramSources.first()).absolutePath(); + projectFile.write(QFile::encodeName(workingDir)); #ifndef QT_NO_DEBUG projectFile.write("\nCONFIG += debug\n"); @@ -565,7 +570,17 @@ namespace QTest { << makespec() << QLatin1String("project.pro"); qmake.setWorkingDirectory(temporaryDirPath); - qmake.start(QLatin1String("qmake"), args); + + QString cmd = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake"; +#ifdef Q_OS_WIN + cmd.append(".exe"); +#endif + if (!QFile::exists(cmd)) { + cmd = "qmake"; + qWarning("qmake from build not found, fallback to PATH's qmake"); + } + + qmake.start(cmd, args); std_out += "### --- stdout from qmake --- ###\n"; std_err += "### --- stderr from qmake --- ###\n"; diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.h b/tests/auto/corelib/tools/qsharedpointer/externaltests.h index 6903433b70..96edbd8a2b 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.h +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/forwarddeclaration.cpp b/tests/auto/corelib/tools/qsharedpointer/forwarddeclaration.cpp index b5d59de037..6fb01c6aa2 100644 --- a/tests/auto/corelib/tools/qsharedpointer/forwarddeclaration.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/forwarddeclaration.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.cpp b/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.cpp index 17812216c0..b10b7e53ba 100644 --- a/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h b/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h index cebbe94ef1..23f6dbf24c 100644 --- a/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h +++ b/tests/auto/corelib/tools/qsharedpointer/forwarddeclared.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 35b63deb4c..2bae52a622 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/wrapper.cpp b/tests/auto/corelib/tools/qsharedpointer/wrapper.cpp index 889493ddb4..9123853696 100644 --- a/tests/auto/corelib/tools/qsharedpointer/wrapper.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/wrapper.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsharedpointer/wrapper.h b/tests/auto/corelib/tools/qsharedpointer/wrapper.h index 66202a5a31..98b9a804c4 100644 --- a/tests/auto/corelib/tools/qsharedpointer/wrapper.h +++ b/tests/auto/corelib/tools/qsharedpointer/wrapper.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp index bc40e2aa64..be8a374a49 100644 --- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp +++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp index c74f4c3754..a098abe5b0 100644 --- a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp +++ b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstl/tst_qstl.cpp b/tests/auto/corelib/tools/qstl/tst_qstl.cpp index f9e3549a4d..6fff2b7d6b 100644 --- a/tests/auto/corelib/tools/qstl/tst_qstl.cpp +++ b/tests/auto/corelib/tools/qstl/tst_qstl.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstring/double_data.h b/tests/auto/corelib/tools/qstring/double_data.h index 8ffb981675..dc392723d3 100644 --- a/tests/auto/corelib/tools/qstring/double_data.h +++ b/tests/auto/corelib/tools/qstring/double_data.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 622d494a06..37d80afd34 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -220,6 +220,11 @@ private slots: void reserve(); void toHtmlEscaped_data(); void toHtmlEscaped(); + + void operatorGreaterWithQLatin1String(); + void compareQLatin1Strings(); + void fromQLatin1StringWithLength(); + void assignQLatin1String(); }; typedef QList<int> IntList; @@ -1417,6 +1422,10 @@ void tst_QString::mid() QCOMPARE(a.mid(3,3),(QString)"DEF"); QCOMPARE(a.mid(0,0),(QString)""); + QVERIFY(!a.mid(15,0).isNull()); + QVERIFY(a.mid(15,0).isEmpty()); + QVERIFY(!a.mid(15,1).isNull()); + QVERIFY(a.mid(15,1).isEmpty()); QVERIFY(a.mid(9999).isNull()); QVERIFY(a.mid(9999,1).isNull()); @@ -1439,6 +1448,10 @@ void tst_QString::midRef() QCOMPARE(a.midRef(3,3).toString(),(QString)"DEF"); QCOMPARE(a.midRef(0,0).toString(),(QString)""); + QVERIFY(!a.midRef(15,0).toString().isNull()); + QVERIFY(a.midRef(15,0).toString().isEmpty()); + QVERIFY(!a.midRef(15,1).toString().isNull()); + QVERIFY(a.midRef(15,1).toString().isEmpty()); QVERIFY(a.midRef(9999).toString().isEmpty()); QVERIFY(a.midRef(9999,1).toString().isEmpty()); @@ -3976,107 +3989,83 @@ void tst_QString::operator_smaller() void tst_QString::integer_conversion_data() { - QTest::addColumn<QString>("locale_name"); QTest::addColumn<QString>("num_str"); QTest::addColumn<int>("base"); QTest::addColumn<bool>("good"); QTest::addColumn<qlonglong>("num"); - QTest::newRow("C empty 0") << QString("C") << QString("") << 0 << false << (qlonglong)0; - QTest::newRow("C empty 8") << QString("C") << QString("") << 8 << false << (qlonglong)0; - QTest::newRow("C empty 10") << QString("C") << QString("") << 10 << false << (qlonglong)0; - QTest::newRow("C empty 16") << QString("C") << QString("") << 16 << false << (qlonglong)0; - - QTest::newRow("C null 0") << QString("C") << QString() << 0 << false << (qlonglong)0; - QTest::newRow("C null 8") << QString("C") << QString() << 8 << false << (qlonglong)0; - QTest::newRow("C null 10") << QString("C") << QString() << 10 << false << (qlonglong)0; - QTest::newRow("C null 16") << QString("C") << QString() << 16 << false << (qlonglong)0; - - QTest::newRow("C -0xf 0") << QString("C") << QString(" -0xf") << 0 << true << (qlonglong)-15; - QTest::newRow("C -0xf 0") << QString("C") << QString("-0xf ") << 0 << true << (qlonglong)-15; - QTest::newRow("C \t0xf\t 0") << QString("C") << QString("\t0xf\t") << 0 << true << (qlonglong)15; - QTest::newRow("C -010 0") << QString("C") << QString(" -010") << 0 << true << (qlonglong)-8; - QTest::newRow("C 010 0") << QString("C") << QString("010 ") << 0 << true << (qlonglong)8; - QTest::newRow("C \t-010\t 0") << QString("C") << QString("\t-010\t") << 0 << true << (qlonglong)-8; - QTest::newRow("C 123 10") << QString("C") << QString(" 123") << 10 << true << (qlonglong)123; - QTest::newRow("C 123 10") << QString("C") << QString("123 ") << 10 << true << (qlonglong)123; - QTest::newRow("C \t123\t 10") << QString("C") << QString("\t123\t") << 10 << true << (qlonglong)123; - QTest::newRow("C -0xf 16") << QString("C") << QString(" -0xf") << 16 << true << (qlonglong)-15; - QTest::newRow("C -0xf 16") << QString("C") << QString("-0xf ") << 16 << true << (qlonglong)-15; - QTest::newRow("C \t0xf\t 16") << QString("C") << QString("\t0xf\t") << 16 << true << (qlonglong)15; - - QTest::newRow("C -0 0") << QString("C") << QString("-0") << 0 << true << (qlonglong)0; - QTest::newRow("C -0 8") << QString("C") << QString("-0") << 8 << true << (qlonglong)0; - QTest::newRow("C -0 10") << QString("C") << QString("-0") << 10 << true << (qlonglong)0; - QTest::newRow("C -0 16") << QString("C") << QString("-0") << 16 << true << (qlonglong)0; - - QTest::newRow("C 1.234 10") << QString("C") << QString("1.234") << 10 << false << (qlonglong)0; - QTest::newRow("C 1,234 10") << QString("C") << QString("1,234") << 10 << false << (qlonglong)0; - QTest::newRow("de_DE 1.234 10") << QString("de_DE") << QString("1.234") << 10 << false << (qlonglong)0; - QTest::newRow("de_DE 1,234 10") << QString("de_DE") << QString("1,234") << 10 << false << (qlonglong)0; - - QTest::newRow("C 0x 0") << QString("C") << QString("0x") << 0 << false << (qlonglong)0; - QTest::newRow("C 0x 16") << QString("C") << QString("0x") << 16 << false << (qlonglong)0; - - QTest::newRow("C 10 0") << QString("C") << QString("10") << 0 << true << (qlonglong)10; - QTest::newRow("C 010 0") << QString("C") << QString("010") << 0 << true << (qlonglong)8; - QTest::newRow("C 0x10 0") << QString("C") << QString("0x10") << 0 << true << (qlonglong)16; - QTest::newRow("C 10 8") << QString("C") << QString("10") << 8 << true << (qlonglong)8; - QTest::newRow("C 010 8") << QString("C") << QString("010") << 8 << true << (qlonglong)8; - QTest::newRow("C 0x10 8") << QString("C") << QString("0x10") << 8 << false << (qlonglong)0; - QTest::newRow("C 10 10") << QString("C") << QString("10") << 10 << true << (qlonglong)10; - QTest::newRow("C 010 10") << QString("C") << QString("010") << 10 << true << (qlonglong)10; - QTest::newRow("C 0x10 10") << QString("C") << QString("0x10") << 10 << false << (qlonglong)0; - QTest::newRow("C 10 16") << QString("C") << QString("10") << 16 << true << (qlonglong)16; - QTest::newRow("C 010 16") << QString("C") << QString("010") << 16 << true << (qlonglong)16; - QTest::newRow("C 0x10 16") << QString("C") << QString("0x10") << 16 << true << (qlonglong)16; - - QTest::newRow("de_DE 10 0") << QString("de_DE") << QString("10") << 0 << true << (qlonglong)10; - QTest::newRow("de_DE 010 0") << QString("de_DE") << QString("010") << 0 << true << (qlonglong)8; - QTest::newRow("de_DE 0x10 0") << QString("de_DE") << QString("0x10") << 0 << true << (qlonglong)16; - QTest::newRow("de_DE 10 8") << QString("de_DE") << QString("10") << 8 << true << (qlonglong)8; - QTest::newRow("de_DE 010 8") << QString("de_DE") << QString("010") << 8 << true << (qlonglong)8; - QTest::newRow("de_DE 0x10 8") << QString("de_DE") << QString("0x10") << 8 << false << (qlonglong)0; - QTest::newRow("de_DE 10 10") << QString("de_DE") << QString("10") << 10 << true << (qlonglong)10; - QTest::newRow("de_DE 010 10") << QString("de_DE") << QString("010") << 10 << true << (qlonglong)10; - QTest::newRow("de_DE 0x10 10") << QString("de_DE") << QString("0x10") << 10 << false << (qlonglong)0; - QTest::newRow("de_DE 10 16") << QString("de_DE") << QString("10") << 16 << true << (qlonglong)16; - QTest::newRow("de_DE 010 16") << QString("de_DE") << QString("010") << 16 << true << (qlonglong)16; - QTest::newRow("de_DE 0x10 16") << QString("de_DE") << QString("0x10") << 16 << true << (qlonglong)16; - - QTest::newRow("C -10 0") << QString("C") << QString("-10") << 0 << true << (qlonglong)-10; - QTest::newRow("C -010 0") << QString("C") << QString("-010") << 0 << true << (qlonglong)-8; - QTest::newRow("C -0x10 0") << QString("C") << QString("-0x10") << 0 << true << (qlonglong)-16; - QTest::newRow("C -10 8") << QString("C") << QString("-10") << 8 << true << (qlonglong)-8; - QTest::newRow("C -010 8") << QString("C") << QString("-010") << 8 << true << (qlonglong)-8; - QTest::newRow("C -0x10 8") << QString("C") << QString("-0x10") << 8 << false << (qlonglong)0; - QTest::newRow("C -10 10") << QString("C") << QString("-10") << 10 << true << (qlonglong)-10; - QTest::newRow("C -010 10") << QString("C") << QString("-010") << 10 << true << (qlonglong)-10; - QTest::newRow("C -0x10 10") << QString("C") << QString("-0x10") << 10 << false << (qlonglong)0; - QTest::newRow("C -10 16") << QString("C") << QString("-10") << 16 << true << (qlonglong)-16; - QTest::newRow("C -010 16") << QString("C") << QString("-010") << 16 << true << (qlonglong)-16; - QTest::newRow("C -0x10 16") << QString("C") << QString("-0x10") << 16 << true << (qlonglong)-16; + QTest::newRow("C empty 0") << QString("") << 0 << false << (qlonglong)0; + QTest::newRow("C empty 8") << QString("") << 8 << false << (qlonglong)0; + QTest::newRow("C empty 10") << QString("") << 10 << false << (qlonglong)0; + QTest::newRow("C empty 16") << QString("") << 16 << false << (qlonglong)0; + + QTest::newRow("C null 0") << QString() << 0 << false << (qlonglong)0; + QTest::newRow("C null 8") << QString() << 8 << false << (qlonglong)0; + QTest::newRow("C null 10") << QString() << 10 << false << (qlonglong)0; + QTest::newRow("C null 16") << QString() << 16 << false << (qlonglong)0; + + QTest::newRow("C -0xf 0") << QString(" -0xf") << 0 << true << (qlonglong)-15; + QTest::newRow("C -0xf 0") << QString("-0xf ") << 0 << true << (qlonglong)-15; + QTest::newRow("C \t0xf\t 0") << QString("\t0xf\t") << 0 << true << (qlonglong)15; + QTest::newRow("C -010 0") << QString(" -010") << 0 << true << (qlonglong)-8; + QTest::newRow("C 010 0") << QString("010 ") << 0 << true << (qlonglong)8; + QTest::newRow("C \t-010\t 0") << QString("\t-010\t") << 0 << true << (qlonglong)-8; + QTest::newRow("C 123 10") << QString(" 123") << 10 << true << (qlonglong)123; + QTest::newRow("C 123 10") << QString("123 ") << 10 << true << (qlonglong)123; + QTest::newRow("C \t123\t 10") << QString("\t123\t") << 10 << true << (qlonglong)123; + QTest::newRow("C -0xf 16") << QString(" -0xf") << 16 << true << (qlonglong)-15; + QTest::newRow("C -0xf 16") << QString("-0xf ") << 16 << true << (qlonglong)-15; + QTest::newRow("C \t0xf\t 16") << QString("\t0xf\t") << 16 << true << (qlonglong)15; + + QTest::newRow("C -0 0") << QString("-0") << 0 << true << (qlonglong)0; + QTest::newRow("C -0 8") << QString("-0") << 8 << true << (qlonglong)0; + QTest::newRow("C -0 10") << QString("-0") << 10 << true << (qlonglong)0; + QTest::newRow("C -0 16") << QString("-0") << 16 << true << (qlonglong)0; + + QTest::newRow("C 1.234 10") << QString("1.234") << 10 << false << (qlonglong)0; + QTest::newRow("C 1,234 10") << QString("1,234") << 10 << false << (qlonglong)0; + + QTest::newRow("C 0x 0") << QString("0x") << 0 << false << (qlonglong)0; + QTest::newRow("C 0x 16") << QString("0x") << 16 << false << (qlonglong)0; + + QTest::newRow("C 10 0") << QString("10") << 0 << true << (qlonglong)10; + QTest::newRow("C 010 0") << QString("010") << 0 << true << (qlonglong)8; + QTest::newRow("C 0x10 0") << QString("0x10") << 0 << true << (qlonglong)16; + QTest::newRow("C 10 8") << QString("10") << 8 << true << (qlonglong)8; + QTest::newRow("C 010 8") << QString("010") << 8 << true << (qlonglong)8; + QTest::newRow("C 0x10 8") << QString("0x10") << 8 << false << (qlonglong)0; + QTest::newRow("C 10 10") << QString("10") << 10 << true << (qlonglong)10; + QTest::newRow("C 010 10") << QString("010") << 10 << true << (qlonglong)10; + QTest::newRow("C 0x10 10") << QString("0x10") << 10 << false << (qlonglong)0; + QTest::newRow("C 10 16") << QString("10") << 16 << true << (qlonglong)16; + QTest::newRow("C 010 16") << QString("010") << 16 << true << (qlonglong)16; + QTest::newRow("C 0x10 16") << QString("0x10") << 16 << true << (qlonglong)16; + + QTest::newRow("C -10 0") << QString("-10") << 0 << true << (qlonglong)-10; + QTest::newRow("C -010 0") << QString("-010") << 0 << true << (qlonglong)-8; + QTest::newRow("C -0x10 0") << QString("-0x10") << 0 << true << (qlonglong)-16; + QTest::newRow("C -10 8") << QString("-10") << 8 << true << (qlonglong)-8; + QTest::newRow("C -010 8") << QString("-010") << 8 << true << (qlonglong)-8; + QTest::newRow("C -0x10 8") << QString("-0x10") << 8 << false << (qlonglong)0; + QTest::newRow("C -10 10") << QString("-10") << 10 << true << (qlonglong)-10; + QTest::newRow("C -010 10") << QString("-010") << 10 << true << (qlonglong)-10; + QTest::newRow("C -0x10 10") << QString("-0x10") << 10 << false << (qlonglong)0; + QTest::newRow("C -10 16") << QString("-10") << 16 << true << (qlonglong)-16; + QTest::newRow("C -010 16") << QString("-010") << 16 << true << (qlonglong)-16; + QTest::newRow("C -0x10 16") << QString("-0x10") << 16 << true << (qlonglong)-16; // Let's try some Arabic const quint16 arabic_str[] = { 0x0661, 0x0662, 0x0663, 0x0664, 0x0000 }; // "1234" - QTest::newRow("ar_SA 1234 0") << QString("ar_SA") << QString::fromUtf16(arabic_str) << 0 << true << (qlonglong)1234; - QTest::newRow("ar_SA 1234 8") << QString("ar_SA") << QString::fromUtf16(arabic_str) << 8 << true << (qlonglong)668; - QTest::newRow("ar_SA 1234 10") << QString("ar_SA") << QString::fromUtf16(arabic_str) << 10 << true << (qlonglong)1234; - QTest::newRow("ar_SA 1234 16") << QString("ar_SA") << QString::fromUtf16(arabic_str) << 16 << true << (qlonglong)4660; + QTest::newRow("ar_SA 1234 0") << QString::fromUtf16(arabic_str) << 0 << false << (qlonglong)0; } void tst_QString::integer_conversion() { - QFETCH(QString, locale_name); QFETCH(QString, num_str); QFETCH(int, base); QFETCH(bool, good); QFETCH(qlonglong, num); - - QLocale::setDefault(locale_name); - QCOMPARE(QLocale().name(), locale_name); - bool ok; qlonglong d = num_str.toLongLong(&ok, base); QCOMPARE(ok, good); @@ -4084,100 +4073,65 @@ void tst_QString::integer_conversion() if (ok) { QCOMPARE(d, num); } - - QLocale::setDefault(QLocale::C); } void tst_QString::double_conversion_data() { - QTest::addColumn<QString>("locale_name"); QTest::addColumn<QString>("num_str"); QTest::addColumn<bool>("good"); QTest::addColumn<double>("num"); // The good... - QTest::newRow("C 1") << QString("C") << QString("1") << true << 1.0; - QTest::newRow("C 1.0") << QString("C") << QString("1.0") << true << 1.0; - QTest::newRow("C 1.234") << QString("C") << QString("1.234") << true << 1.234; - QTest::newRow("C 1.234e-10") << QString("C") << QString("1.234e-10") << true << 1.234e-10; - QTest::newRow("C 1.234E10") << QString("C") << QString("1.234E10") << true << 1.234e10; - QTest::newRow("C 1e10") << QString("C") << QString("1e10") << true << 1.0e10; + QTest::newRow("C 1") << QString("1") << true << 1.0; + QTest::newRow("C 1.0") << QString("1.0") << true << 1.0; + QTest::newRow("C 1.234") << QString("1.234") << true << 1.234; + QTest::newRow("C 1.234e-10") << QString("1.234e-10") << true << 1.234e-10; + QTest::newRow("C 1.234E10") << QString("1.234E10") << true << 1.234e10; + QTest::newRow("C 1e10") << QString("1e10") << true << 1.0e10; // The bad... - QTest::newRow("C empty") << QString("C") << QString("") << false << 0.0; - QTest::newRow("C null") << QString("C") << QString() << false << 0.0; - QTest::newRow("C .") << QString("C") << QString(".") << false << 0.0; - QTest::newRow("C 1e") << QString("C") << QString("1e") << false << 0.0; - QTest::newRow("C 1,") << QString("C") << QString("1,") << false << 0.0; - QTest::newRow("C 1,0") << QString("C") << QString("1,0") << false << 0.0; - QTest::newRow("C 1,000") << QString("C") << QString("1,000") << false << 0.0; - QTest::newRow("C 1e1.0") << QString("C") << QString("1e1.0") << false << 0.0; - QTest::newRow("C 1e+") << QString("C") << QString("1e+") << false << 0.0; - QTest::newRow("C 1e-") << QString("C") << QString("1e-") << false << 0.0; + QTest::newRow("C empty") << QString("") << false << 0.0; + QTest::newRow("C null") << QString() << false << 0.0; + QTest::newRow("C .") << QString(".") << false << 0.0; + QTest::newRow("C 1e") << QString("1e") << false << 0.0; + QTest::newRow("C 1,") << QString("1,") << false << 0.0; + QTest::newRow("C 1,0") << QString("1,0") << false << 0.0; + QTest::newRow("C 1,000") << QString("1,000") << false << 0.0; + QTest::newRow("C 1e1.0") << QString("1e1.0") << false << 0.0; + QTest::newRow("C 1e+") << QString("1e+") << false << 0.0; + QTest::newRow("C 1e-") << QString("1e-") << false << 0.0; + QTest::newRow("de_DE 1,0") << QString("1,0") << false << 0.0; + QTest::newRow("de_DE 1,234") << QString("1,234") << false << 0.0; + QTest::newRow("de_DE 1,234e-10") << QString("1,234e-10") << false << 0.0; + QTest::newRow("de_DE 1,234E10") << QString("1,234E10") << false << 0.0; // And the ugly... - QTest::newRow("C .1") << QString("C") << QString(".1") << true << 0.1; - QTest::newRow("C -.1") << QString("C") << QString("-.1") << true << -0.1; - QTest::newRow("C 1.") << QString("C") << QString("1.") << true << 1.0; - QTest::newRow("C 1.E10") << QString("C") << QString("1.E10") << true << 1.0e10; - QTest::newRow("C 1e+10") << QString("C") << QString("1e+10") << true << 1.0e+10; - - QTest::newRow("de_DE 1") << QString("de_DE") << QString("1") << true << 1.0; - QTest::newRow("de_DE 1.0") << QString("de_DE") << QString("1.0") << true << 1.0; - QTest::newRow("de_DE 1.234") << QString("de_DE") << QString("1.234") << true << 1.234; - QTest::newRow("de_DE 1.234e-10") << QString("de_DE") << QString("1.234e-10") << true << 1.234e-10; - QTest::newRow("de_DE 1.234E10") << QString("de_DE") << QString("1.234E10") << true << 1.234e10; - QTest::newRow("de_DE 1e10") << QString("de_DE") << QString("1e10") << true << 1.0e10; - QTest::newRow("de_DE .1") << QString("de_DE") << QString(".1") << true << 0.1; - QTest::newRow("de_DE -.1") << QString("de_DE") << QString("-.1") << true << -0.1; - QTest::newRow("de_DE 1.") << QString("de_DE") << QString("1.") << true << 1.0; - QTest::newRow("de_DE 1.E10") << QString("de_DE") << QString("1.E10") << true << 1.0e10; - QTest::newRow("de_DE 1e+10") << QString("de_DE") << QString("1e+10") << true << 1.0e+10; - - QTest::newRow("de_DE 1,0") << QString("de_DE") << QString("1,0") << true << 1.0; - QTest::newRow("de_DE 1,234") << QString("de_DE") << QString("1,234") << true << 1.234; - QTest::newRow("de_DE 1,234e-10") << QString("de_DE") << QString("1,234e-10") << true << 1.234e-10; - QTest::newRow("de_DE 1,234E10") << QString("de_DE") << QString("1,234E10") << true << 1.234e10; - QTest::newRow("de_DE ,1") << QString("de_DE") << QString(",1") << true << 0.1; - QTest::newRow("de_DE -,1") << QString("de_DE") << QString("-,1") << true << -0.1; - QTest::newRow("de_DE 1,") << QString("de_DE") << QString("1,") << true << 1.0; - QTest::newRow("de_DE 1,E10") << QString("de_DE") << QString("1,E10") << true << 1.0e10; - - QTest::newRow("de_DE empty") << QString("de_DE") << QString("") << false << 0.0; - QTest::newRow("de_DE null") << QString("de_DE") << QString() << false << 0.0; - QTest::newRow("de_DE .") << QString("de_DE") << QString(".") << false << 0.0; - QTest::newRow("de_DE 1e") << QString("de_DE") << QString("1e") << false << 0.0; - QTest::newRow("de_DE 1e1.0") << QString("de_DE") << QString("1e1.0") << false << 0.0; - QTest::newRow("de_DE 1e+") << QString("de_DE") << QString("1e+") << false << 0.0; - QTest::newRow("de_DE 1e-") << QString("de_DE") << QString("1e-") << false << 0.0; - - QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0; - QTest::newRow("C 1 ") << QString("C") << QString("1 ") << true << 1.0; - QTest::newRow("de_DE 1") << QString("de_DE") << QString(" 1") << true << 1.0; - QTest::newRow("de_DE 1 ") << QString("de_DE") << QString("1 ") << true << 1.0; + QTest::newRow("C .1") << QString(".1") << true << 0.1; + QTest::newRow("C -.1") << QString("-.1") << true << -0.1; + QTest::newRow("C 1.") << QString("1.") << true << 1.0; + QTest::newRow("C 1.E10") << QString("1.E10") << true << 1.0e10; + QTest::newRow("C 1e+10") << QString("1e+10") << true << 1.0e+10; + QTest::newRow("C 1") << QString(" 1") << true << 1.0; + QTest::newRow("C 1 ") << QString("1 ") << true << 1.0; // Let's try some Arabic const quint16 arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662, 0x0663, 0x0664, 0x0065, 0x0662, 0x0000 }; // "0.1234e2" - QTest::newRow("ar_SA") << QString("ar_SA") << QString::fromUtf16(arabic_str) << true << 0.1234e2; + QTest::newRow("ar_SA") << QString::fromUtf16(arabic_str) << false << 0.0; } void tst_QString::double_conversion() { #define MY_DOUBLE_EPSILON (2.22045e-16) - QFETCH(QString, locale_name); QFETCH(QString, num_str); QFETCH(bool, good); QFETCH(double, num); - QLocale::setDefault(locale_name); - QCOMPARE(QLocale().name(), locale_name); - bool ok; double d = num_str.toDouble(&ok); QCOMPARE(ok, good); @@ -4188,8 +4142,6 @@ void tst_QString::double_conversion() diff = -diff; QVERIFY(diff <= MY_DOUBLE_EPSILON); } - - QLocale::setDefault(QLocale::C); } #ifndef Q_MOC_RUN @@ -4788,6 +4740,13 @@ void tst_QString::compare() QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir); QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()))), csr); QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir); + QByteArray l1 = s2.toLatin1(); + l1 += "x"; + QLatin1String l1str(l1.constData(), l1.size() - 1); + QCOMPARE(sign(QString::compare(s1, l1str)), csr); + QCOMPARE(sign(QString::compare(s1, l1str, Qt::CaseInsensitive)), cir); + QCOMPARE(sign(QStringRef::compare(r1, l1str)), csr); + QCOMPARE(sign(QStringRef::compare(r1, l1str, Qt::CaseInsensitive)), cir); } if (isLatin(s1)) { @@ -5167,6 +5126,128 @@ void tst_QString::toHtmlEscaped() QCOMPARE(original.toHtmlEscaped(), expected); } +void tst_QString::operatorGreaterWithQLatin1String() +{ + QLatin1String latin1foo("fooZZ", 3); + QString stringfoo = QString::fromLatin1("foo"); + QVERIFY(stringfoo >= latin1foo); + QVERIFY(!(stringfoo > latin1foo)); + QVERIFY(stringfoo <= latin1foo); + QVERIFY(!(stringfoo < latin1foo)); +} + +void tst_QString::compareQLatin1Strings() +{ + QLatin1String abc("abc"); + QLatin1String abcd("abcd"); + QLatin1String cba("cba"); + QLatin1String de("de"); + + QVERIFY(abc == abc); + QVERIFY(!(abc == cba)); + QVERIFY(!(cba == abc)); + QVERIFY(!(abc == abcd)); + QVERIFY(!(abcd == abc)); + + QVERIFY(abc != cba); + QVERIFY(!(abc != abc)); + QVERIFY(cba != abc); + QVERIFY(abc != abcd); + QVERIFY(abcd != abc); + + QVERIFY(abc < abcd); + QVERIFY(abc < cba); + QVERIFY(abc < de); + QVERIFY(abcd < cba); + QVERIFY(!(abc < abc)); + QVERIFY(!(abcd < abc)); + QVERIFY(!(de < cba)); + + QVERIFY(abcd > abc); + QVERIFY(cba > abc); + QVERIFY(de > abc); + QVERIFY(!(abc > abc)); + QVERIFY(!(abc > abcd)); + QVERIFY(!(abcd > cba)); + + QVERIFY(abc <= abc); + QVERIFY(abc <= abcd); + QVERIFY(abc <= cba); + QVERIFY(abc <= de); + QVERIFY(!(abcd <= abc)); + QVERIFY(!(cba <= abc)); + QVERIFY(!(cba <= abcd)); + QVERIFY(!(de <= abc)); + + QVERIFY(abc >= abc); + QVERIFY(abcd >= abc); + QVERIFY(!(abc >= abcd)); + QVERIFY(cba >= abc); + QVERIFY(!(abc >= cba)); + QVERIFY(de >= abc); + QVERIFY(!(abc >= de)); + + QLatin1String subfoo("fooZZ", 3); + QLatin1String foo("foo"); + QVERIFY(subfoo == foo); + QVERIFY(foo == subfoo); + QVERIFY(!(subfoo != foo)); + QVERIFY(!(foo != subfoo)); + QVERIFY(!(foo < subfoo)); + QVERIFY(!(subfoo < foo)); + QVERIFY(foo >= subfoo); + QVERIFY(subfoo >= foo); + QVERIFY(!(foo > subfoo)); + QVERIFY(!(subfoo > foo)); + QVERIFY(foo <= subfoo); + QVERIFY(subfoo <= foo); + + QLatin1String subabc("abcZZ", 3); + QLatin1String subab("abcZZ", 2); + QVERIFY(subabc != subab); + QVERIFY(subab != subabc); + QVERIFY(!(subabc == subab)); + QVERIFY(!(subab == subabc)); + QVERIFY(subab < subabc); + QVERIFY(!(subabc < subab)); + QVERIFY(subabc > subab); + QVERIFY(!(subab > subabc)); + QVERIFY(subab <= subabc); + QVERIFY(!(subabc <= subab)); + QVERIFY(subabc >= subab); + QVERIFY(!(subab >= subabc)); +} + +void tst_QString::fromQLatin1StringWithLength() +{ + QLatin1String latin1foo("foobar", 3); + QString foo(latin1foo); + QCOMPARE(foo.size(), latin1foo.size()); + QCOMPARE(foo, QString::fromLatin1("foo")); +} + +void tst_QString::assignQLatin1String() +{ + QString empty = QLatin1String(""); + QVERIFY(empty.isEmpty()); + QVERIFY(!empty.isNull()); + + QString null = QLatin1String(0); + QVERIFY(null.isEmpty()); + QVERIFY(null.isNull()); + + QLatin1String latin1foo("foo"); + QString foo = latin1foo; + QCOMPARE(foo.size(), latin1foo.size()); + QCOMPARE(foo, QString::fromLatin1("foo")); + + QLatin1String latin1subfoo("foobar", 3); + foo = latin1subfoo; + QCOMPARE(foo.size(), latin1subfoo.size()); + QCOMPARE(foo, QString::fromLatin1("foo")); + +} + QTEST_APPLESS_MAIN(tst_QString) #include "tst_qstring.moc" diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 283e707c1b..95e24b22fb 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp index fd92aafadd..4201fc3f5c 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp index 6bdb607431..0e8e081c46 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp index 915c0d23ad..09d7f38125 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp index c9837a0489..91bb07039a 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite module of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 54ca9dd3a7..e3eb1a21ac 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp index 10906902ff..ebbad86c81 100644 --- a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp +++ b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index c0dc253167..77d2101320 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 100ddfcb12..89dd01ac3a 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp index bc03e74b41..d8f72dffdb 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -242,6 +242,7 @@ void tst_QTime::hour_data() QTest::newRow( "data2" ) << 1 << 2 << 3 << 4; QTest::newRow( "data3" ) << 2 << 12 << 13 << 65; QTest::newRow( "data4" ) << 23 << 59 << 59 << 999; + QTest::newRow( "data5" ) << -1 << -1 << -1 << -1; } void tst_QTime::hour() @@ -271,6 +272,7 @@ void tst_QTime::setHMS_data() QTest::newRow( "data4" ) << 23 << 0 << 0; QTest::newRow( "data5" ) << 23 << 59 << 0; QTest::newRow( "data6" ) << 23 << 59 << 59; + QTest::newRow( "data7" ) << -1 << -1 << -1; } void tst_QTime::setHMS() @@ -296,6 +298,9 @@ void tst_QTime::secsTo_data() QTest::newRow( "data1" ) << QTime(0,0,0) << QTime(0,1,0) << 60; QTest::newRow( "data2" ) << QTime(0,0,0) << QTime(0,10,0) << 600; QTest::newRow( "data3" ) << QTime(0,0,0) << QTime(23,59,59) << 86399; + QTest::newRow( "data4" ) << QTime(-1, -1, -1) << QTime(0, 0, 0) << 0; + QTest::newRow( "data5" ) << QTime(0, 0, 0) << QTime(-1, -1, -1) << 0; + QTest::newRow( "data6" ) << QTime(-1, -1, -1) << QTime(-1, -1, -1) << 0; } void tst_QTime::secsTo() @@ -317,6 +322,9 @@ void tst_QTime::msecsTo_data() QTest::newRow( "data1" ) << QTime(0,0,0,0) << QTime(0,0,1,0) << 1000; QTest::newRow( "data2" ) << QTime(0,0,0,0) << QTime(0,0,10,0) << 10000; QTest::newRow( "data3" ) << QTime(0,0,0,0) << QTime(23,59,59,0) << 86399000; + QTest::newRow( "data4" ) << QTime(-1, -1, -1, -1) << QTime(0, 0, 0, 0) << 0; + QTest::newRow( "data5" ) << QTime(0, 0, 0, 0) << QTime(-1, -1, -1, -1) << 0; + QTest::newRow( "data6" ) << QTime(-1, -1, -1, -1) << QTime(-1, -1, -1, -1) << 0; } void tst_QTime::msecsTo() diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index db08bc5724..f05497d7a2 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index cc2bbe2f1f..8361150d1c 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index bed2e25d31..67ca547736 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/xml/qxmlstream/qc14n.h b/tests/auto/corelib/xml/qxmlstream/qc14n.h index ed7bd3b323..a45a61eaa7 100644 --- a/tests/auto/corelib/xml/qxmlstream/qc14n.h +++ b/tests/auto/corelib/xml/qxmlstream/qc14n.h @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/corelib/xml/qxmlstream/setupSuite.sh b/tests/auto/corelib/xml/qxmlstream/setupSuite.sh index ca85fa2884..f52a6b4ead 100755 --- a/tests/auto/corelib/xml/qxmlstream/setupSuite.sh +++ b/tests/auto/corelib/xml/qxmlstream/setupSuite.sh @@ -2,8 +2,7 @@ ############################################################################# ## ## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -## All rights reserved. -## Contact: Nokia Corporation (qt-info@nokia.com) +## Contact: http://www.qt-project.org/ ## ## This file is the build configuration utility of the Qt Toolkit. ## @@ -36,6 +35,7 @@ ## ## ## +## ## $QT_END_LICENSE$ ## ############################################################################# diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index 8d3ddfa096..0ce0da06aa 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -1,8 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -532,6 +532,7 @@ public: private slots: void initTestCase(); + void cleanupTestCase(); void reportFailures() const; void reportFailures_data(); void checkBaseline() const; @@ -589,6 +590,11 @@ void tst_QXmlStream::initTestCase() QVERIFY(reader.parse(&source, false)); } +void tst_QXmlStream::cleanupTestCase() +{ + QFile::remove(QLatin1String("test.xml")); +} + void tst_QXmlStream::reportFailures() const { QFETCH(bool, isError); |