Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Geyer <debfx@fobos.de>2011-12-26 22:18:21 +0400
committerFelix Geyer <debfx@fobos.de>2011-12-26 22:18:21 +0400
commit4da6da882899cceb610240c25573a152d08776b7 (patch)
tree216dec306ca1bf87850cbc0c85ca690c628f12a2
parent509328343f490192b93b7bfe51df7e1da82478a8 (diff)
Add a GUI unit test.
-rw-r--r--CMakeLists.txt1
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/gui/CMakeLists.txt16
-rw-r--r--tests/gui/TestGui.cpp59
-rw-r--r--tests/gui/TestGui.h32
5 files changed, 113 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3da3de0c..8b3472c8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,7 @@ cmake_minimum_required(VERSION 2.6.0)
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
option(WITH_TESTS "Enable building of unit tests" ON)
+option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
set( KEEPASSX_VERSION "0.9.0" )
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 044f997a1..cf131c435 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -122,3 +122,8 @@ add_unit_test(NAME testsymmetriccipher SOURCES TestSymmetricCipher.cpp MOCS Test
add_unit_test(NAME testhashedblockstream SOURCES TestHashedBlockStream.cpp MOCS TestHashedBlockStream.h LIBS ${TEST_LIBRARIES})
add_unit_test(NAME testkeepass2randomstream SOURCES TestKeePass2RandomStream.cpp MOCS TestKeePass2RandomStream.h LIBS ${TEST_LIBRARIES})
+
+
+if(WITH_GUI_TESTS)
+ add_subdirectory(gui)
+endif(WITH_GUI_TESTS)
diff --git a/tests/gui/CMakeLists.txt b/tests/gui/CMakeLists.txt
new file mode 100644
index 000000000..93beccd46
--- /dev/null
+++ b/tests/gui/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 or (at your option)
+# version 3 of the License.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+add_unit_test(NAME testgui SOURCES TestGui.cpp MOCS TestGui.h LIBS ${TEST_LIBRARIES})
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
new file mode 100644
index 000000000..711bbd56d
--- /dev/null
+++ b/tests/gui/TestGui.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 or (at your option)
+ * version 3 of the License.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "TestGui.h"
+
+#include <QtTest/QTest>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QLineEdit>
+#include <QtGui/QPushButton>
+
+#include "config-keepassx-tests.h"
+#include "crypto/Crypto.h"
+#include "gui/FileDialog.h"
+#include "gui/MainWindow.h"
+
+void TestGui::initTestCase()
+{
+ Crypto::init();
+}
+
+void TestGui::testOpenDatabase()
+{
+ MainWindow mainWindow;
+ mainWindow.show();
+ QAction* actionDatabaseOpen = mainWindow.findChild<QAction*>("actionDatabaseOpen");
+ fileDialog()->setNextFileName(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx"));
+ actionDatabaseOpen->trigger();
+
+ QTest::qWait(500);
+
+ QLineEdit* editPassword = QApplication::activeWindow()->findChild<QLineEdit*>("editPassword");
+ QVERIFY(editPassword);
+ QTest::keyClicks(editPassword, "a");
+
+ QDialogButtonBox* buttonBox = QApplication::activeWindow()->findChild<QDialogButtonBox*>("buttonBox");
+ QTest::mouseClick(buttonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
+
+ QTabWidget* tabWidget = mainWindow.findChild<QTabWidget*>("tabWidget");
+ QCOMPARE(tabWidget->count(), 1);
+ QCOMPARE(tabWidget->tabText(tabWidget->currentIndex()), QString("NewDatabase.kdbx"));
+}
+
+QTEST_MAIN(TestGui);
diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h
new file mode 100644
index 000000000..7ba8fa37c
--- /dev/null
+++ b/tests/gui/TestGui.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 or (at your option)
+ * version 3 of the License.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KEEPASSX_TESTGUI_H
+#define KEEPASSX_TESTGUI_H
+
+#include <QtCore/QObject>
+
+class TestGui : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void initTestCase();
+ void testOpenDatabase();
+};
+
+#endif // KEEPASSX_TESTGUI_H