diff options
author | Mirko Damiani <mirko@develer.com> | 2010-02-08 15:09:24 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2010-05-31 07:21:11 (GMT) |
commit | 9b4ff3deb28b3d642dc4480207f2f23841cf26e9 (patch) | |
tree | 103e8f6b0639e85e0f9a0af7ca0d943e64c518fd /tests | |
parent | 90abe364b7e9b0aa201a3e0ed0b043643519e21b (diff) | |
download | Qt-9b4ff3deb28b3d642dc4480207f2f23841cf26e9.zip Qt-9b4ff3deb28b3d642dc4480207f2f23841cf26e9.tar.gz Qt-9b4ff3deb28b3d642dc4480207f2f23841cf26e9.tar.bz2 |
Added native key support to QSharedMemory API.
Methods setNativeKey() and nativeKey() were added to
QSharedMemory API. Shared memory's native key is returned
by nativeKey() and it is set with either setKey() or
setNativeKey(). setKey() leads to a native key that is
platform independent while setNativeKey() directly sets
the native key without any mangling.
When using setNativeKey(), key() returns a null string
and shared memory's system semaphore is not set. This
means that is up to the user to define a such protection
mechanism (i.e. lock() can't be used on native keys).
QSharedMemory tests were updated.
Merge-request: 1497
Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
Reviewed-by: Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index 1f65ae7..dc071ab 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -225,11 +225,17 @@ void tst_QSharedMemory::key_data() { QTest::addColumn<QString>("constructorKey"); QTest::addColumn<QString>("setKey"); - - QTest::newRow("null, null") << QString() << QString(); - QTest::newRow("null, one") << QString() << QString("one"); - QTest::newRow("one, two") << QString("one") << QString("two"); - QTest::newRow("invalid") << QString("o/e") << QString("t/o"); + QTest::addColumn<QString>("setNativeKey"); + + QTest::newRow("null, null, null") << QString() << QString() << QString(); + QTest::newRow("one, null, null") << QString("one") << QString() << QString(); + QTest::newRow("null, one, null") << QString() << QString("one") << QString(); + QTest::newRow("null, null, one") << QString() << QString() << QString("one"); + QTest::newRow("one, two, null") << QString("one") << QString("two") << QString(); + QTest::newRow("one, null, two") << QString("one") << QString() << QString("two"); + QTest::newRow("null, one, two") << QString() << QString("one") << QString("two"); + QTest::newRow("one, two, three") << QString("one") << QString("two") << QString("three"); + QTest::newRow("invalid") << QString("o/e") << QString("t/o") << QString("|x"); } /*! @@ -239,11 +245,17 @@ void tst_QSharedMemory::key() { QFETCH(QString, constructorKey); QFETCH(QString, setKey); + QFETCH(QString, setNativeKey); QSharedMemory sm(constructorKey); QCOMPARE(sm.key(), constructorKey); + QCOMPARE(sm.nativeKey().isEmpty(), constructorKey.isEmpty()); sm.setKey(setKey); QCOMPARE(sm.key(), setKey); + QCOMPARE(sm.nativeKey().isEmpty(), setKey.isEmpty()); + sm.setNativeKey(setNativeKey); + QVERIFY(sm.key().isNull()); + QCOMPARE(sm.nativeKey(), setNativeKey); QCOMPARE(sm.isAttached(), false); QCOMPARE(sm.error(), QSharedMemory::NoError); @@ -262,7 +274,7 @@ void tst_QSharedMemory::create_data() QTest::addColumn<QSharedMemory::SharedMemoryError>("error"); QTest::newRow("null key") << QString() << 1024 - << false << QSharedMemory::LockError; + << false << QSharedMemory::KeyError; QTest::newRow("-1 size") << QString("negsize") << -1 << false << QSharedMemory::InvalidSize; QTest::newRow("nor size") << QString("norsize") << 1024 @@ -302,7 +314,7 @@ void tst_QSharedMemory::attach_data() QTest::addColumn<bool>("exists"); QTest::addColumn<QSharedMemory::SharedMemoryError>("error"); - QTest::newRow("null key") << QString() << false << QSharedMemory::LockError; + QTest::newRow("null key") << QString() << false << QSharedMemory::KeyError; QTest::newRow("doesn't exists") << QString("doesntexists") << false << QSharedMemory::NotFound; QTest::newRow("already exists") << QString(EXISTING_SHARE) << true << QSharedMemory::NoError; } |