diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-18 08:37:31 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-18 08:37:31 +0100 |
commit | beb65dcd79f8c354dab7bb4a8d08157bd9d69329 (patch) | |
tree | 4632a0ff0df8462f8913f347042cf8378de03268 /tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp | |
parent | 3fc1002489d5861d4f7cc2e1e8800881d6593c9d (diff) | |
parent | e3288f246b44ba2b6d90b90eb99ab61f496d8d57 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/gui/painting/painting.pri
src/plugins/platforms/xcb/qxcbconnection.cpp
tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro
tests/auto/corelib/tools/qlocale/test/test.pro
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
tools/configure/environment.cpp
Change-Id: I9c40f458b89b2c206de2d2c24e90b5f679c93495
Diffstat (limited to 'tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index d88a70c1e5..76341db701 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -95,18 +95,18 @@ private slots: void creatingQObject(); void mixTrackingPointerCode(); void reentrancyWhileDestructing(); + void map(); + void hash(); + void qvariantCast(); + void sharedFromThis(); void threadStressTest_data(); void threadStressTest(); - void map(); - void hash(); void validConstructs(); void invalidConstructs_data(); void invalidConstructs(); - - void qvariantCast(); - void sharedFromThis(); - + // let invalidConstructs be the last test, because it's the slowest; + // add new tests above this block public slots: void cleanup() { safetyCheck(); } @@ -232,6 +232,14 @@ void tst_QSharedPointer::basics() QCOMPARE(sizeof(weakref), 2*sizeof(void*)); } + { + QSharedPointer<const Data> ptr; + QWeakPointer<const Data> weakref; + + QCOMPARE(sizeof(ptr), 2*sizeof(void*)); + QCOMPARE(sizeof(weakref), 2*sizeof(void*)); + } + QFETCH(bool, isNull); Data *aData = 0; if (!isNull) @@ -2232,6 +2240,16 @@ void tst_QSharedPointer::sharedFromThis() QVERIFY(const_scp.isNull()); QCOMPARE(Data::generationCounter, generations + 1); QCOMPARE(Data::destructorCounter, destructions); + + QWeakPointer<SomeClass> wcp = sc.sharedFromThis(); + QVERIFY(wcp.isNull()); + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions); + + QWeakPointer<const SomeClass> const_wcp = sc.sharedFromThis(); + QVERIFY(const_wcp.isNull()); + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions); } QCOMPARE(Data::generationCounter, generations + 1); @@ -2243,6 +2261,11 @@ void tst_QSharedPointer::sharedFromThis() QVERIFY(const_scp.isNull()); QCOMPARE(Data::generationCounter, generations + 2); QCOMPARE(Data::destructorCounter, destructions + 1); + + QWeakPointer<const SomeClass> const_wcp = sc.sharedFromThis(); + QVERIFY(const_wcp.isNull()); + QCOMPARE(Data::generationCounter, generations + 2); + QCOMPARE(Data::destructorCounter, destructions + 1); } QCOMPARE(Data::generationCounter, generations + 2); @@ -2434,6 +2457,21 @@ void tst_QSharedPointer::sharedFromThis() QCOMPARE(Data::generationCounter, generations + 5); QCOMPARE(Data::destructorCounter, destructions + 5); + + { + QSharedPointer<const SomeClass> scp2(new SomeClass()); + QVERIFY(!scp2.isNull()); + QCOMPARE(Data::generationCounter, generations + 6); + QCOMPARE(Data::destructorCounter, destructions + 5); + + QWeakPointer<const SomeClass> wcp2(scp2.constCast<SomeClass>()); + QVERIFY(!wcp2.isNull()); + QCOMPARE(Data::generationCounter, generations + 6); + QCOMPARE(Data::destructorCounter, destructions + 5); + } + + QCOMPARE(Data::generationCounter, generations + 6); + QCOMPARE(Data::destructorCounter, destructions + 6); } namespace ReentrancyWhileDestructing { |