changeset 559:dd8a295d5b4d

Add framework for mainwindow testing
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 22 May 2014 10:20:45 +0000
parents bde15f68942b
children 3af16cbc961d
files ui/mainwindow.h ui/tests/CMakeLists.txt ui/tests/mainwindowtest.cpp ui/tests/mainwindowtest.h
diffstat 4 files changed, 77 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ui/mainwindow.h	Thu May 22 10:19:54 2014 +0000
+++ b/ui/mainwindow.h	Thu May 22 10:20:45 2014 +0000
@@ -78,12 +78,6 @@
     void installerSuccess();
     void installCerts();
 
-    /* @brief Execute the file fileName to install the softwareupdate.
-     *
-     * Once the installer process is started this function terminates
-     * the application. */
-    void installNewSW(const QString& fileName, const QDateTime& modDate);
-
     void saveAutoUpdate(int state);
     void saveAutoStart(int state);
 
@@ -126,8 +120,19 @@
      */
     void loadUnselectedCertificates();
 
+protected slots:
+    /** @brief cleanup and close the main window
+     *
+     * Perform a clean exit (saving state etc.) and close
+     * the application */
     void closeApp();
 
+    /* @brief Execute the file fileName to install the softwareupdate.
+     *
+     * Once the installer process is started this function terminates
+     * the application. */
+    void installNewSW(const QString& fileName, const QDateTime& modDate);
+
 private:
     /** @brief check the integrity of available files.
      *
--- a/ui/tests/CMakeLists.txt	Thu May 22 10:19:54 2014 +0000
+++ b/ui/tests/CMakeLists.txt	Thu May 22 10:20:45 2014 +0000
@@ -56,6 +56,7 @@
 add_custom_test(commontest.cpp "")
 
 add_custom_test(createcertlisttest.cpp "${CMAKE_SOURCE_DIR}/ui/createcertlistdialog.cpp")
+add_custom_test(mainwindowtest.cpp "${TRUSTBRIDGE_SOURCES}")
 
 if (WIN32)
    add_custom_test(windowsstoretest.cpp "${CMAKE_SOURCE_DIR}/cinst/windowsstore.c")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/tests/mainwindowtest.cpp	Thu May 22 10:20:45 2014 +0000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+
+#include "mainwindowtest.h"
+
+#ifdef Q_OS_WIN
+ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+#else
+ Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
+#endif
+
+MainWindowTest::MainWindowTest() : MainWindow(true) {
+}
+
+void MainWindowTest::closeApp() {
+    emit closeCalled();
+}
+
+void MainWindowTest::testInvalidUpdate() {
+    // TODO
+}
+
+void MainWindowTest::testValidUpdate() {
+    // TODO
+}
+
+QTEST_MAIN(MainWindowTest);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/tests/mainwindowtest.h	Thu May 22 10:20:45 2014 +0000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+#ifndef MAINWINDOWTEST_H
+#define MAINWINDOWTEST_H
+
+#include <QObject>
+#include <QtTest>
+#include "mainwindow.h"
+
+class MainWindowTest: public MainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindowTest();
+
+protected slots:
+    void closeApp();
+
+private Q_SLOTS:
+    void testInvalidUpdate();
+    void testValidUpdate();
+
+Q_SIGNALS:
+    void closeCalled();
+};
+
+#endif // MAINWINDOWTEST_H

http://wald.intevation.org/projects/trustbridge/