Skip to content

Commit b55f221

Browse files
committedJun 11, 2019
Add deleteLater test
1 parent 0c3540c commit b55f221

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎tests/src/core/testqobjectuniqueptr.cpp‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class TestQObjectUniquePtr : public QObject
2929
void testOperatorBool();
3030
void testSwap();
3131
void testOperatorArrow();
32+
void testDeleteLater();
3233
};
3334

3435
void TestQObjectUniquePtr::testMemLeak()
@@ -103,5 +104,26 @@ void TestQObjectUniquePtr::testOperatorArrow()
103104
QCOMPARE( obj->objectName(), QStringLiteral( "Teddy" ) );
104105
}
105106

107+
void TestQObjectUniquePtr::testDeleteLater()
108+
{
109+
int argc;
110+
QCoreApplication ca( argc, nullptr );
111+
QObject *o = new QObject();
112+
QObject *o2 = new QObject();
113+
114+
QObjectUniquePtr<QObject> obj( o );
115+
QObjectUniquePtr<QObject> obj2( o2 );
116+
117+
obj2->deleteLater();
118+
obj->deleteLater();
119+
120+
obj2.reset();
121+
122+
connect( o, &QObject::destroyed, &ca, &QCoreApplication::quit );
123+
ca.exec();
124+
QVERIFY( obj.isNull() );
125+
QVERIFY( obj2.isNull() );
126+
}
127+
106128
QGSTEST_MAIN( TestQObjectUniquePtr )
107129
#include "testqobjectuniqueptr.moc"

0 commit comments

Comments
 (0)
Please sign in to comment.