diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-06-25 13:57:04 +1000 |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-06-25 13:57:04 +1000 |
commit | 2838ce6e034cfdb2b217f3503b1f84855b03b9bf (patch) | |
tree | 0272402a419f5879d9d1576e50d8189dbbc81033 /tests/auto | |
parent | 82d4dfa37afc48b4a097d807e207defe7d906086 (diff) |
Add some unit tests for QtConcurrent::run().
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qcl/tst_qcl.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qcl/tst_qcl.cpp b/tests/auto/qcl/tst_qcl.cpp index 2e8a319..7aa3fda 100644 --- a/tests/auto/qcl/tst_qcl.cpp +++ b/tests/auto/qcl/tst_qcl.cpp @@ -69,6 +69,7 @@ private slots: void qimageFormat_data(); void qimageFormat(); void eventList(); + void concurrent(); private: QCLContext context; @@ -843,6 +844,37 @@ void tst_QCL::eventList() QVERIFY(!list.contains(QCLEvent())); } +#ifndef QT_NO_CONCURRENT + +// Regular QtConcurrent function that checks that normal usage of +// QtConcurrent is not inhibited by the definitions in qclkernel.h. +static void runStoreFloat(QCLKernel &kernel, const QCLBuffer &buffer, float v) +{ + kernel(buffer, v).waitForFinished(); +} + +#endif + +void tst_QCL::concurrent() +{ +#ifndef QT_NO_CONCURRENT + QCLBuffer buffer = context.createBufferDevice + (sizeof(float) * 16, QCLMemoryObject::WriteOnly); + float buf[16]; + + QCLKernel storeFloat = program.createKernel("storeFloat"); + QFuture<void> future = QtConcurrent::run(storeFloat, buffer, 5.0f); + future.waitForFinished(); + buffer.read(buf, sizeof(float)); + QCOMPARE(buf[0], 5.0f); + + future = QtConcurrent::run(runStoreFloat, storeFloat, buffer, 7.0f); + future.waitForFinished(); + buffer.read(buf, sizeof(float)); + QCOMPARE(buf[0], 7.0f); +#endif +} + QTEST_MAIN(tst_QCL) #include "tst_qcl.moc" |