[PATCH 3 of 3] Add framework for mainwindow testing

Wald Commits scm-commit at wald.intevation.org
Thu May 22 12:20:51 CEST 2014


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1400754045 0
# Node ID dd8a295d5b4d33a282ec5f8cdcb71cbb56ae54ab
# Parent  bde15f68942bc60c16561ec0c8672017db4a242e
Add framework for mainwindow testing

diff -r bde15f68942b -r dd8a295d5b4d ui/mainwindow.h
--- 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.
      *
diff -r bde15f68942b -r dd8a295d5b4d ui/tests/CMakeLists.txt
--- 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")
diff -r bde15f68942b -r dd8a295d5b4d ui/tests/mainwindowtest.cpp
--- /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);
diff -r bde15f68942b -r dd8a295d5b4d ui/tests/mainwindowtest.h
--- /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


More information about the Trustbridge-commits mailing list