From e4fd2d8491e576f72b16b315f47ff151cb0f17eb Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 19 Dec 2017 13:33:50 +0100 Subject: Moved tests to the relevant component --- components/CMakeLists.txt | 1 + components/kube/tests/CMakeLists.txt | 1 + components/kube/tests/tst_applicationstart.qml | 42 ++++++++++++++++ components/kube/tests/tst_logview.qml | 65 +++++++++++++++++++++++++ tests/CMakeLists.txt | 13 +---- tests/kubetestrunner.cpp | 8 +--- tests/tst_applicationstart.qml | 41 ---------------- tests/tst_logview.qml | 66 -------------------------- 8 files changed, 111 insertions(+), 126 deletions(-) create mode 100644 components/kube/tests/CMakeLists.txt create mode 100644 components/kube/tests/tst_applicationstart.qml create mode 100644 components/kube/tests/tst_logview.qml delete mode 100644 tests/tst_applicationstart.qml delete mode 100644 tests/tst_logview.qml diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index ed28b5f4..9ae2824d 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -8,5 +8,6 @@ macro(install_qml_component name) endmacro(install_qml_component) install_qml_component(kube) +add_subdirectory(kube/tests) install_qml_component(accounts) install_qml_component(mailviewer) diff --git a/components/kube/tests/CMakeLists.txt b/components/kube/tests/CMakeLists.txt new file mode 100644 index 00000000..0c786cfe --- /dev/null +++ b/components/kube/tests/CMakeLists.txt @@ -0,0 +1 @@ +add_test(NAME kubecomponenttests COMMAND kubetestrunner WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/components/kube/tests/tst_applicationstart.qml b/components/kube/tests/tst_applicationstart.qml new file mode 100644 index 00000000..fdfc2634 --- /dev/null +++ b/components/kube/tests/tst_applicationstart.qml @@ -0,0 +1,42 @@ +/* + * Copyright 2017 Christian Mollekopf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.1 +import QtTest 1.0 +import "../qml" + + +TestCase { + id: testCase + width: 400 + height: 400 + name: "ApplicationStart" + + Kube { + id: kube + } + + function test_startToWizard() { + var accountWizard = findChild(kube, "accountWizard"); + verify(accountWizard) + verify(accountWizard.visible) + } +} diff --git a/components/kube/tests/tst_logview.qml b/components/kube/tests/tst_logview.qml new file mode 100644 index 00000000..d3326db1 --- /dev/null +++ b/components/kube/tests/tst_logview.qml @@ -0,0 +1,65 @@ +/* + * Copyright 2017 Christian Mollekopf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.1 +import QtTest 1.0 +import org.kube.framework 1.0 as Kube +import "../qml" + +TestCase { + id: logviewTestcase + width: 400 + height: 400 + name: "LogView" + + LogView { + id: logView + } + + function test_logview() { + var listModel = findChild(logView, "logModel"); + verify(listModel) + compare(listModel.count, 0) + //ignore progress + Kube.Fabric.postMessage(Kube.Messages.progressNotification, {}) + compare(listModel.count, 0) + + Kube.Fabric.postMessage(Kube.Messages.notification, {type: Kube.Notifications.info, message: "foobar", resource: "resource"}) + compare(listModel.count, 1) + compare(logView.pendingError, false) + + Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, message: "foobar", resource: "resource"}) + compare(listModel.count, 2) + compare(logView.pendingError, true) + compare(listModel.get(0).type, Kube.Notifications.error) + compare(listModel.get(0).errors.count, 1) + compare(listModel.get(0).errors.get(0).message, "foobar") + compare(listModel.get(0).errors.get(0).resource, "resource") + + Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge1", resource: "resource1"}) + compare(listModel.count, 3) + Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge2", resource: "resource2"}) + compare(listModel.count, 3) + compare(listModel.get(0).errors.count, 2) + compare(listModel.get(0).errors.get(0).message, "merge2") + compare(listModel.get(0).errors.get(0).resource, "resource2") + } +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0515c052..70e21481 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,17 +1,6 @@ -project(tests) +find_package(Qt5 REQUIRED NO_MODULE COMPONENTS QuickTest) -find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Widgets WebEngine QuickTest) - -# build testrunner add_executable(kubetestrunner kubetestrunner.cpp) target_link_libraries(kubetestrunner - Qt5::Gui - Qt5::Quick - Qt5::Widgets - Qt5::WebEngine Qt5::QuickTest ) - -# tests -add_test(NAME qmltests COMMAND kubetestrunner WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - diff --git a/tests/kubetestrunner.cpp b/tests/kubetestrunner.cpp index 4a8d447a..c114c5fd 100644 --- a/tests/kubetestrunner.cpp +++ b/tests/kubetestrunner.cpp @@ -1,8 +1,2 @@ #include - -int main(int argc, char **argv) -{ - QTEST_ADD_GPU_BLACKLIST_SUPPORT - QTEST_SET_MAIN_SOURCE_PATH - return quick_test_main(argc, argv, "kubetest", 0); -} +QUICK_TEST_MAIN("kube") diff --git a/tests/tst_applicationstart.qml b/tests/tst_applicationstart.qml deleted file mode 100644 index 16107ec0..00000000 --- a/tests/tst_applicationstart.qml +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2017 Christian Mollekopf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.7 -import QtQuick.Controls 2.0 -import QtQuick.Window 2.1 -import QtTest 1.0 -import org.kube.components.kube 1.0 as Kube - - -TestCase { - id: testCase - width: 400 - height: 400 - name: "ApplicationStart" - - Kube.Kube { - id: kube - } - - function test_startToWizard() { - var accountWizard = findChild(kube, "accountWizard"); - verify(accountWizard.visible) - } -} diff --git a/tests/tst_logview.qml b/tests/tst_logview.qml deleted file mode 100644 index 86668d72..00000000 --- a/tests/tst_logview.qml +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2017 Christian Mollekopf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.7 -import QtQuick.Controls 2.0 -import QtQuick.Window 2.1 -import QtTest 1.0 -import org.kube.framework 1.0 as Kube -import "../components/kube/contents/ui/" as Components - - -TestCase { - id: logviewTestcase - width: 400 - height: 400 - name: "LogView" - - Components.LogView { - id: logView - } - - function test_logview() { - var listModel = findChild(logView, "logModel"); - verify(listModel) - compare(listModel.count, 0) - //ignore progress - Kube.Fabric.postMessage(Kube.Messages.progressNotification, {}) - compare(listModel.count, 0) - - Kube.Fabric.postMessage(Kube.Messages.notification, {type: Kube.Notifications.info, message: "foobar", resource: "resource"}) - compare(listModel.count, 1) - compare(logView.pendingError, false) - - Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, message: "foobar", resource: "resource"}) - compare(listModel.count, 2) - compare(logView.pendingError, true) - compare(listModel.get(0).type, Kube.Notifications.error) - compare(listModel.get(0).errors.count, 1) - compare(listModel.get(0).errors.get(0).message, "foobar") - compare(listModel.get(0).errors.get(0).resource, "resource") - - Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge1", resource: "resource1"}) - compare(listModel.count, 3) - Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge2", resource: "resource2"}) - compare(listModel.count, 3) - compare(listModel.get(0).errors.count, 2) - compare(listModel.get(0).errors.get(0).message, "merge2") - compare(listModel.get(0).errors.get(0).resource, "resource2") - } -} -- cgit v1.2.3