summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Vogel <lukedirtwalker@gmail.com>2018-03-13 17:57:18 +0100
committerLukas Vogel <lukedirtwalker@gmail.com>2018-03-14 15:58:51 +0100
commit0dd26429fd63c1119741344e8b94801986a0997a (patch)
treea74ea37c1a1074d5ab5f40397aa2bd55f4bbe5f9 /tests
parent0e427be160ebaf0cc6556fddd0092b1bd70ceff6 (diff)
Add a test for PasswordDialog
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/ui/tst_ui.cpp61
-rw-r--r--tests/auto/ui/ui.pro22
3 files changed, 84 insertions, 1 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 66e5fab2..523445e1 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += util
+SUBDIRS += util ui
diff --git a/tests/auto/ui/tst_ui.cpp b/tests/auto/ui/tst_ui.cpp
new file mode 100644
index 00000000..39a6bb69
--- /dev/null
+++ b/tests/auto/ui/tst_ui.cpp
@@ -0,0 +1,61 @@
+#include "../../../src/passworddialog.h"
+#include <QCoreApplication>
+#include <QtTest>
+
+/**
+ * @brief The tst_ui class is our first unit test
+ */
+class tst_ui : public QObject {
+ Q_OBJECT
+
+private Q_SLOTS:
+ void contentRemainsSame();
+};
+
+/**
+ * @brief tst_ui::contentRemainsSame test that content set with PasswordDialog::setPassword
+ * is repeated when calling PasswordDialog::getPassword.
+ */
+void tst_ui::contentRemainsSame() {
+ QScopedPointer<PasswordDialog> d(new PasswordDialog(passwordConfiguration{}, NULL));
+ d->setTemplate("", false);
+ QString input = "pw\n";
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+
+ d.reset(new PasswordDialog(passwordConfiguration{}, NULL));
+ input = "pw\nname: value\n";
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+
+ d.reset(new PasswordDialog(passwordConfiguration{}, NULL));
+ d->setTemplate("name", false);
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+
+ d.reset(new PasswordDialog(passwordConfiguration{}, NULL));
+ d->setTemplate("name", true);
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+
+ d.reset(new PasswordDialog(passwordConfiguration{}, NULL));
+ d->setTemplate("", false);
+ d->templateAll(true);
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+
+ d.reset(new PasswordDialog(passwordConfiguration{}, NULL));
+ d->setTemplate("", true);
+ d->templateAll(true);
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+
+ d.reset(new PasswordDialog(passwordConfiguration{}, NULL));
+ d->setTemplate("name", true);
+ d->templateAll(true);
+ d->setPass(input);
+ QCOMPARE(d->getPassword(), input);
+}
+
+QTEST_MAIN(tst_ui)
+#include "tst_ui.moc"
diff --git a/tests/auto/ui/ui.pro b/tests/auto/ui/ui.pro
new file mode 100644
index 00000000..ca89f2b0
--- /dev/null
+++ b/tests/auto/ui/ui.pro
@@ -0,0 +1,22 @@
+!include(../auto.pri) { error("Couldn't find the auto.pri file!") }
+
+message($$QMAKE_LINK_OBJECT_MAX)
+
+SOURCES += tst_ui.cpp
+
+LIBS = -L"$$OUT_PWD/../../../src/$(OBJECTS_DIR)" -lqtpass $$LIBS
+
+HEADERS += passworddialog.h
+
+OBJ_PATH += ../../../src/$(OBJECTS_DIR)
+
+VPATH += ../../../src
+INCLUDEPATH += ../../../src
+
+win32 {
+ RC_FILE = ../../../windows.rc
+# temporary workaround for QTBUG-6453
+ QMAKE_LINK_OBJECT_MAX=24
+# setting this may also work, but I can't find appropriate value right now
+# QMAKE_LINK_OBJECT_SCRIPT =
+}