diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2015-12-01 15:53:06 +0100 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@kdab.com> | 2015-12-02 16:20:04 +0000 |
commit | c25253d5ddc2cd1eb79b3f3206484903a1f77959 (patch) | |
tree | cd14a9efdf39e763d38b4592cbea08943d94a00c /tests | |
parent | 271f58aabed6b2ab5f934de53153db9c3d7f5e9f (diff) |
Move definition of tests in the class
It will make this test suite just easier to update.
Change-Id: I1d6df0f4bb7b0e36f1471c9ca29a2246d0795ffa
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/core/qaspectengine/tst_qaspectengine.cpp | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp index 69b7a916e..e3d8fb9d9 100644 --- a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp +++ b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp @@ -49,57 +49,53 @@ public: ~tst_QAspectEngine() {} private Q_SLOTS: - void constructionDestruction(); - void setRootEntity(); - void shouldNotCrashOnShutdownWhenComponentIsCreatedWithParentBeforeItsEntity(); - // TODO: Add more QAspectEngine tests -}; - -void tst_QAspectEngine::constructionDestruction() -{ - QAspectEngine *engine = new QAspectEngine; - QVERIFY(engine->rootEntity() == Q_NULLPTR); - delete engine; -} - -void tst_QAspectEngine::setRootEntity() -{ - QAspectEngine *engine = new QAspectEngine; - - QEntity *e = new QEntity; - e->setObjectName("root"); - engine->setRootEntity(e); - QSharedPointer<QEntity> root = engine->rootEntity(); - QVERIFY(root == e); - QVERIFY(root->objectName() == "root"); - root = QSharedPointer<QEntity>(); - QVERIFY(engine->rootEntity()->objectName() == "root"); - - delete engine; -} - -void tst_QAspectEngine::shouldNotCrashOnShutdownWhenComponentIsCreatedWithParentBeforeItsEntity() -{ - // GIVEN - QEntity *root = new QEntity; - // A component parented to an entity... - QComponent *component = new Qt3DCore::QTransform(root); - // ... created *before* the entity it will be added to. - QEntity *entity = new QEntity(root); - entity->addComponent(component); - - // An initialized engine (so that the arbiter has been fed) - QAspectEngine engine; - engine.initialize(); - - // WHEN - engine.setRootEntity(root); - - // THEN - // Nothing particular happen on exit, especially no crash -} + void constructionDestruction() + { + QAspectEngine *engine = new QAspectEngine; + QVERIFY(engine->rootEntity() == Q_NULLPTR); + delete engine; + } + + void setRootEntity() + { + QAspectEngine *engine = new QAspectEngine; + + QEntity *e = new QEntity; + e->setObjectName("root"); + engine->setRootEntity(e); + + QSharedPointer<QEntity> root = engine->rootEntity(); + QVERIFY(root == e); + QVERIFY(root->objectName() == "root"); + root = QSharedPointer<QEntity>(); + QVERIFY(engine->rootEntity()->objectName() == "root"); + + delete engine; + } + + void shouldNotCrashOnShutdownWhenComponentIsCreatedWithParentBeforeItsEntity() + { + // GIVEN + QEntity *root = new QEntity; + // A component parented to an entity... + QComponent *component = new Qt3DCore::QTransform(root); + // ... created *before* the entity it will be added to. + QEntity *entity = new QEntity(root); + entity->addComponent(component); + + // An initialized engine (so that the arbiter has been fed) + QAspectEngine engine; + engine.initialize(); + + // WHEN + engine.setRootEntity(root); + + // THEN + // Nothing particular happen on exit, especially no crash + } +}; QTEST_MAIN(tst_QAspectEngine) |