summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Ihrig <holger.ihrig@nokia.com>2011-08-24 10:51:34 +0200
committerHolger Ihrig <holger.ihrig@nokia.com>2011-08-30 13:17:07 +0200
commit0547598a28c3c1dd5c5f4c3ec9888b0de499199b (patch)
tree036c2f68f61cdef119cc74088ac8d4d60d608162 /tests
parentd610fbc13e589b36ce8f1e1af7166d215f0ccc90 (diff)
Moving relevant tests to corelib/concurrent
Adding tests for QFutureSynchronizer and QtConcurrentResultStore Added minor things in QFutureSynchronizer and QtConcurrentResultStore and removed tests for destruction Task-number: QTBUG-21066 Change-Id: I9f088b89463340f339c914bcb37fb2f9d3b62057 Reviewed-on: http://codereview.qt.nokia.com/3477 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib.pro15
-rw-r--r--tests/auto/corelib/concurrent/concurrent.pro19
-rw-r--r--tests/auto/corelib/concurrent/qfuture/.gitignore (renamed from tests/auto/qfuture/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qfuture/qfuture.pro (renamed from tests/auto/qfuture/qfuture.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qfuture/tst_qfuture.cpp (renamed from tests/auto/qfuture/tst_qfuture.cpp)0
-rw-r--r--tests/auto/corelib/concurrent/qfuture/versioncheck.h (renamed from tests/auto/qfuture/versioncheck.h)0
-rw-r--r--tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro5
-rw-r--r--tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp158
-rw-r--r--tests/auto/corelib/concurrent/qfuturewatcher/.gitignore (renamed from tests/auto/qfuturewatcher/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qfuturewatcher/qfuturewatcher.pro (renamed from tests/auto/qfuturewatcher/qfuturewatcher.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp (renamed from tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp)2
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentfilter/.gitignore (renamed from tests/auto/qtconcurrentfilter/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro (renamed from tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp (renamed from tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentiteratekernel/.gitignore (renamed from tests/auto/qtconcurrentiteratekernel/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro (renamed from tests/auto/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp (renamed from tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentmap/.gitignore (renamed from tests/auto/qtconcurrentmap/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentmap/functions.h (renamed from tests/auto/qtconcurrentmap/functions.h)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentmap/qtconcurrentmap.pro (renamed from tests/auto/qtconcurrentmap/qtconcurrentmap.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp (renamed from tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro5
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp491
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentrun/.gitignore (renamed from tests/auto/qtconcurrentrun/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentrun/qtconcurrentrun.pro (renamed from tests/auto/qtconcurrentrun/qtconcurrentrun.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp (renamed from tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentthreadengine/.gitignore (renamed from tests/auto/qtconcurrentthreadengine/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentthreadengine/qtconcurrentthreadengine.pro (renamed from tests/auto/qtconcurrentthreadengine/qtconcurrentthreadengine.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp (renamed from tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp)0
-rw-r--r--tests/auto/corelib/concurrent/qthreadpool/.gitignore (renamed from tests/auto/qthreadpool/.gitignore)0
-rw-r--r--tests/auto/corelib/concurrent/qthreadpool/qthreadpool.pro (renamed from tests/auto/qthreadpool/qthreadpool.pro)0
-rw-r--r--tests/auto/corelib/concurrent/qthreadpool/tst_qthreadpool.cpp (renamed from tests/auto/qthreadpool/tst_qthreadpool.cpp)0
-rw-r--r--tests/auto/corelib/corelib.pro3
33 files changed, 681 insertions, 17 deletions
diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro
index f9434d58bd..927d439b13 100644
--- a/tests/auto/corelib.pro
+++ b/tests/auto/corelib.pro
@@ -27,8 +27,6 @@ SUBDIRS=\
qfilesystemwatcher \
qflags \
qfreelist \
- qfuture \
- qfuturewatcher \
qgetputenv \
qglobal \
qhash \
@@ -73,16 +71,10 @@ SUBDIRS=\
qstringlist \
qstringmatcher \
qstringref \
- qtconcurrentfilter \
- qtconcurrentiteratekernel \
- qtconcurrentmap \
- qtconcurrentrun \
- qtconcurrentthreadengine \
qtemporaryfile \
qtextboundaryfinder \
qthread \
qthreadonce \
- qthreadpool \
qthreadstorage \
qtime \
qtimeline \
@@ -101,13 +93,6 @@ SUBDIRS=\
qfilesystementry \
qabstractfileengine
-symbian:SUBDIRS -= \
- qtconcurrentfilter \
- qtconcurrentiteratekernel \
- qtconcurrentmap \
- qtconcurrentrun \
- qtconcurrentthreadengine \
-
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
qfileinfo \
diff --git a/tests/auto/corelib/concurrent/concurrent.pro b/tests/auto/corelib/concurrent/concurrent.pro
new file mode 100644
index 0000000000..6d7850b18f
--- /dev/null
+++ b/tests/auto/corelib/concurrent/concurrent.pro
@@ -0,0 +1,19 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qfuture \
+ qfuturesynchronizer \
+ qfuturewatcher \
+ qtconcurrentfilter \
+ qtconcurrentiteratekernel \
+ qtconcurrentmap \
+ qtconcurrentresultstore \
+ qtconcurrentrun \
+ qtconcurrentthreadengine \
+ qthreadpool
+
+symbian:SUBDIRS -= \
+ qtconcurrentfilter \
+ qtconcurrentiteratekernel \
+ qtconcurrentmap \
+ qtconcurrentrun \
+ qtconcurrentthreadengine \
diff --git a/tests/auto/qfuture/.gitignore b/tests/auto/corelib/concurrent/qfuture/.gitignore
index 77c055c874..77c055c874 100644
--- a/tests/auto/qfuture/.gitignore
+++ b/tests/auto/corelib/concurrent/qfuture/.gitignore
diff --git a/tests/auto/qfuture/qfuture.pro b/tests/auto/corelib/concurrent/qfuture/qfuture.pro
index 0e74f47678..0e74f47678 100644
--- a/tests/auto/qfuture/qfuture.pro
+++ b/tests/auto/corelib/concurrent/qfuture/qfuture.pro
diff --git a/tests/auto/qfuture/tst_qfuture.cpp b/tests/auto/corelib/concurrent/qfuture/tst_qfuture.cpp
index 2178489bd9..2178489bd9 100644
--- a/tests/auto/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/concurrent/qfuture/tst_qfuture.cpp
diff --git a/tests/auto/qfuture/versioncheck.h b/tests/auto/corelib/concurrent/qfuture/versioncheck.h
index 9e4d0c6eeb..9e4d0c6eeb 100644
--- a/tests/auto/qfuture/versioncheck.h
+++ b/tests/auto/corelib/concurrent/qfuture/versioncheck.h
diff --git a/tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro b/tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro
new file mode 100644
index 0000000000..11012cce24
--- /dev/null
+++ b/tests/auto/corelib/concurrent/qfuturesynchronizer/qfuturesynchronizer.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core
+SOURCES += tst_qfuturesynchronizer.cpp \
+
+CONFIG += parallel_test
diff --git a/tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp b/tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
new file mode 100644
index 0000000000..5aced3f8c1
--- /dev/null
+++ b/tests/auto/corelib/concurrent/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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/qfuturewatcher/.gitignore b/tests/auto/corelib/concurrent/qfuturewatcher/.gitignore
index 1d778431c5..1d778431c5 100644
--- a/tests/auto/qfuturewatcher/.gitignore
+++ b/tests/auto/corelib/concurrent/qfuturewatcher/.gitignore
diff --git a/tests/auto/qfuturewatcher/qfuturewatcher.pro b/tests/auto/corelib/concurrent/qfuturewatcher/qfuturewatcher.pro
index 9de37d014f..9de37d014f 100644
--- a/tests/auto/qfuturewatcher/qfuturewatcher.pro
+++ b/tests/auto/corelib/concurrent/qfuturewatcher/qfuturewatcher.pro
diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp
index f45bd9f989..d8fa2230f3 100644
--- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/corelib/concurrent/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -47,7 +47,7 @@
#include <qfuturewatcher.h>
#include <qtconcurrentrun.h>
#include <qtconcurrentmap.h>
-#include "../../shared/util.h"
+#include "../../../../shared/util.h"
#ifndef QT_NO_CONCURRENT_TEST
#include <private/qfutureinterface_p.h>
diff --git a/tests/auto/qtconcurrentfilter/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentfilter/.gitignore
index f93d27e009..f93d27e009 100644
--- a/tests/auto/qtconcurrentfilter/.gitignore
+++ b/tests/auto/corelib/concurrent/qtconcurrentfilter/.gitignore
diff --git a/tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro b/tests/auto/corelib/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro
index 62d4908e69..62d4908e69 100644
--- a/tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro
+++ b/tests/auto/corelib/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro
diff --git a/tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/corelib/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
index 33611d7331..33611d7331 100644
--- a/tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
+++ b/tests/auto/corelib/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
diff --git a/tests/auto/qtconcurrentiteratekernel/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/.gitignore
index ac5dec4db6..ac5dec4db6 100644
--- a/tests/auto/qtconcurrentiteratekernel/.gitignore
+++ b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/.gitignore
diff --git a/tests/auto/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro
index a61d275241..a61d275241 100644
--- a/tests/auto/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro
+++ b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/qtconcurrentiteratekernel.pro
diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
index 521c517d90..521c517d90 100644
--- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+++ b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
diff --git a/tests/auto/qtconcurrentmap/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentmap/.gitignore
index f1c563e979..f1c563e979 100644
--- a/tests/auto/qtconcurrentmap/.gitignore
+++ b/tests/auto/corelib/concurrent/qtconcurrentmap/.gitignore
diff --git a/tests/auto/qtconcurrentmap/functions.h b/tests/auto/corelib/concurrent/qtconcurrentmap/functions.h
index a3dcd3c300..a3dcd3c300 100644
--- a/tests/auto/qtconcurrentmap/functions.h
+++ b/tests/auto/corelib/concurrent/qtconcurrentmap/functions.h
diff --git a/tests/auto/qtconcurrentmap/qtconcurrentmap.pro b/tests/auto/corelib/concurrent/qtconcurrentmap/qtconcurrentmap.pro
index 6fc358514e..6fc358514e 100644
--- a/tests/auto/qtconcurrentmap/qtconcurrentmap.pro
+++ b/tests/auto/corelib/concurrent/qtconcurrentmap/qtconcurrentmap.pro
diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/corelib/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
index 74a254cbf4..74a254cbf4 100644
--- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/corelib/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
diff --git a/tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro b/tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro
new file mode 100644
index 0000000000..8bc20c3f13
--- /dev/null
+++ b/tests/auto/corelib/concurrent/qtconcurrentresultstore/qtconcurrentresultstore.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+DEFINES += QT_STRICT_ITERATORS
+SOURCES += tst_qtconcurrentresultstore.cpp
+QT = core core-private
+CONFIG += parallel_test
diff --git a/tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp b/tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp
new file mode 100644
index 0000000000..1728be68fe
--- /dev/null
+++ b/tests/auto/corelib/concurrent/qtconcurrentresultstore/tst_qtconcurrentresultstore.cpp
@@ -0,0 +1,491 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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;
+ ResultIteratorBase it = store.begin();
+ 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/qtconcurrentrun/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentrun/.gitignore
index d7a8334ec4..d7a8334ec4 100644
--- a/tests/auto/qtconcurrentrun/.gitignore
+++ b/tests/auto/corelib/concurrent/qtconcurrentrun/.gitignore
diff --git a/tests/auto/qtconcurrentrun/qtconcurrentrun.pro b/tests/auto/corelib/concurrent/qtconcurrentrun/qtconcurrentrun.pro
index 24576048e9..24576048e9 100644
--- a/tests/auto/qtconcurrentrun/qtconcurrentrun.pro
+++ b/tests/auto/corelib/concurrent/qtconcurrentrun/qtconcurrentrun.pro
diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/corelib/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index cacb09aae1..cacb09aae1 100644
--- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/corelib/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
diff --git a/tests/auto/qtconcurrentthreadengine/.gitignore b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/.gitignore
index a2e2896246..a2e2896246 100644
--- a/tests/auto/qtconcurrentthreadengine/.gitignore
+++ b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/.gitignore
diff --git a/tests/auto/qtconcurrentthreadengine/qtconcurrentthreadengine.pro b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/qtconcurrentthreadengine.pro
index bbfcf5ebe3..bbfcf5ebe3 100644
--- a/tests/auto/qtconcurrentthreadengine/qtconcurrentthreadengine.pro
+++ b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/qtconcurrentthreadengine.pro
diff --git a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
index 772c749711..772c749711 100644
--- a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+++ b/tests/auto/corelib/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
diff --git a/tests/auto/qthreadpool/.gitignore b/tests/auto/corelib/concurrent/qthreadpool/.gitignore
index 16105821a2..16105821a2 100644
--- a/tests/auto/qthreadpool/.gitignore
+++ b/tests/auto/corelib/concurrent/qthreadpool/.gitignore
diff --git a/tests/auto/qthreadpool/qthreadpool.pro b/tests/auto/corelib/concurrent/qthreadpool/qthreadpool.pro
index dbaeb208dd..dbaeb208dd 100644
--- a/tests/auto/qthreadpool/qthreadpool.pro
+++ b/tests/auto/corelib/concurrent/qthreadpool/qthreadpool.pro
diff --git a/tests/auto/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/concurrent/qthreadpool/tst_qthreadpool.cpp
index 49c517a569..49c517a569 100644
--- a/tests/auto/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/concurrent/qthreadpool/tst_qthreadpool.cpp
diff --git a/tests/auto/corelib/corelib.pro b/tests/auto/corelib/corelib.pro
index 4c84fbbbcb..122c834c63 100644
--- a/tests/auto/corelib/corelib.pro
+++ b/tests/auto/corelib/corelib.pro
@@ -1,4 +1,5 @@
TEMPLATE=subdirs
SUBDIRS=\
animation \
- codecs
+ codecs \
+ concurrent