diff options
author | mread <qt-info@nokia.com> | 2010-10-22 13:01:00 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2010-10-22 14:07:59 (GMT) |
commit | 6c08eefabfde2d09a94684307aae8fe2163fa1d2 (patch) | |
tree | e4af4b0cb64b5c63891ed8b02193491327d3be6e /tests/auto/qtipc | |
parent | b8238ec7e41d483a9166eb7aebbf911f36976cdc (diff) | |
download | Qt-6c08eefabfde2d09a94684307aae8fe2163fa1d2.zip Qt-6c08eefabfde2d09a94684307aae8fe2163fa1d2.tar.gz Qt-6c08eefabfde2d09a94684307aae8fe2163fa1d2.tar.bz2 |
Symbian shared memory could not be distinguished by numeric key
Fixes a problem where QSharedMemory objects on Symbian could not be
distinguished by numeric keys, or keys that differed in any non-alpha
way.
This is fixed by using the same native key generation system as on other
platforms, where a SHA1 hash of the original key is appended to a
version of the key with all non-alpha characters stripped.
Task-number: QT-3712
Reviewed-by: Shane Kearns
Diffstat (limited to 'tests/auto/qtipc')
-rw-r--r-- | tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index dc071ab..18a0cb0 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -107,6 +107,10 @@ private slots: void useTooMuchMemory(); void attachTooMuch(); + // unique keys + void uniqueKey_data(); + void uniqueKey(); + protected: int remove(const QString &key); @@ -795,6 +799,35 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() QCOMPARE(failedProcesses, (unsigned int)(0)); } +void tst_QSharedMemory::uniqueKey_data() +{ + QTest::addColumn<QString>("key1"); + QTest::addColumn<QString>("key2"); + + QTest::newRow("null == null") << QString() << QString(); + QTest::newRow("key == key") << QString("key") << QString("key"); + QTest::newRow("key1 == key1") << QString("key1") << QString("key1"); + QTest::newRow("key != key1") << QString("key") << QString("key1"); + QTest::newRow("ke1y != key1") << QString("ke1y") << QString("key1"); + QTest::newRow("key1 != key2") << QString("key1") << QString("key2"); +} + +void tst_QSharedMemory::uniqueKey() +{ + QFETCH(QString, key1); + QFETCH(QString, key2); + + QSharedMemory sm1(key1); + QSharedMemory sm2(key2); + + bool setEqual = (key1 == key2); + bool keyEqual = (sm1.key() == sm2.key()); + bool nativeEqual = (sm1.nativeKey() == sm2.nativeKey()); + + QCOMPARE(keyEqual, setEqual); + QCOMPARE(nativeEqual, setEqual); +} + QTEST_MAIN(tst_QSharedMemory) #include "tst_qsharedmemory.moc" |