diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ecd064d..d851053 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,6 +12,6 @@ find_package(Qt5Widgets REQUIRED) find_package(Qt5Test REQUIRED) find_package(Qt5Quick REQUIRED) -add_executable(${PROJECT_NAME} Resources.qrc test_dynamicqobject.cpp main.qml) +add_executable(${PROJECT_NAME} Resources.qrc test_dotherside.cpp main.qml) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} DOtherSideStatic Qt5::Quick Qt5::Widgets Qt5::Test Qt5::Core) diff --git a/test/test_dynamicqobject.cpp b/test/test_dotherside.cpp similarity index 85% rename from test/test_dynamicqobject.cpp rename to test/test_dotherside.cpp index 895c260..73c4aa1 100644 --- a/test/test_dynamicqobject.cpp +++ b/test/test_dotherside.cpp @@ -14,7 +14,6 @@ #include "DOtherSide/DynamicQObject.h" #include "DOtherSide/DynamicQObjectFactory.h" - template bool ExecuteTest(int argc, char* argv[]) { Test test; @@ -34,6 +33,7 @@ bool ExecuteGuiTest(int argc, char* argv[]) { class TestQGuiApplication : public QObject { Q_OBJECT + private slots: void testExecution() { bool quit = false; @@ -51,6 +51,7 @@ private slots: class TestQApplication : public QObject { Q_OBJECT + private slots: void testExecution() { bool quit = false; @@ -68,11 +69,16 @@ private slots: class TestQQmlApplicationEngine : public QObject { Q_OBJECT + private slots: void initTestCase() { m_engine = nullptr; } + void cleanupTestCase() { + QVERIFY(m_engine == nullptr); + } + void init() { QVERIFY(m_engine == nullptr); dos_qqmlapplicationengine_create(&m_engine); @@ -117,8 +123,37 @@ private: /* * Test QQmlContext */ -class TestQQmlContext { +class TestQQmlContext : public QObject +{ + Q_OBJECT +private slots: + void initTestCase() { + m_engine = nullptr; + m_context = nullptr; + } + + void cleanupTestCase() { + QVERIFY(m_engine == nullptr); + QVERIFY(m_context == nullptr); + } + + void init() { + dos_qqmlapplicationengine_create(&m_engine); + dos_qqmlapplicationengine_context(m_engine, &m_context); + QVERIFY(m_engine != nullptr); + QVERIFY(m_context != nullptr); + } + + void cleanup() { + m_context = nullptr; + dos_qqmlapplicationengine_delete(m_engine); + m_engine = nullptr; + } + +private: + void* m_engine; + void* m_context; }; /* @@ -166,4 +201,4 @@ int main(int argc, char* argv[]) return success ? 0 : 1; } -#include "test_dynamicqobject.moc" +#include "test_dotherside.moc"