From f767a098d66dbd5076b988b519e20e0e9afcb2c7 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Tue, 17 Jul 2012 10:35:17 +0200 Subject: [PATCH] Add GUI test for changing the database transform rounds. Refs #34 --- src/gui/DatabaseWidget.cpp | 1 + tests/gui/TestGui.cpp | 20 ++++++++++++++++++++ tests/gui/TestGui.h | 1 + 3 files changed, 22 insertions(+) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 33ecb2263..acf5137ca 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -115,6 +115,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) headlineLabelFont.setPointSize(headlineLabelFont.pointSize() + 2); m_changeMasterKeyWidget->headlineLabel()->setFont(headlineLabelFont); m_databaseSettingsWidget = new DatabaseSettingsWidget(); + m_databaseSettingsWidget->setObjectName("databaseSettingsWidget"); m_databaseOpenWidget = new DatabaseOpenWidget(); m_databaseOpenWidget->setObjectName("databaseOpenWidget"); m_keepass1OpenWidget = new KeePass1OpenWidget(); diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index fcc28298b..a6b2cbf26 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -252,6 +253,25 @@ void TestGui::testSave() QVERIFY(checkDatabase()); } +void TestGui::testDatabaseSettings() +{ + QAction* actionChangeDatabaseSettings = m_mainWindow->findChild("actionChangeDatabaseSettings"); + actionChangeDatabaseSettings->trigger(); + QWidget* dbSettingsWidget = m_dbWidget->findChild("databaseSettingsWidget"); + QSpinBox* transformRoundsSpinBox = dbSettingsWidget->findChild("transformRoundsSpinBox"); + transformRoundsSpinBox->setValue(100); + QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter); + QTest::qWait(200); // wait for modified timer + QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*")); + QCOMPARE(m_db->transformRounds(), Q_UINT64_C(100)); + + QAction* actionDatabaseSave = m_mainWindow->findChild("actionDatabaseSave"); + actionDatabaseSave->trigger(); + QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save")); + + QVERIFY(checkDatabase()); +} + void TestGui::testKeePass1Import() { QAction* actionImportKeePass1 = m_mainWindow->findChild("actionImportKeePass1"); diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h index 224d4546a..2a4e58f4e 100644 --- a/tests/gui/TestGui.h +++ b/tests/gui/TestGui.h @@ -39,6 +39,7 @@ private Q_SLOTS: void testSearch(); void testSaveAs(); void testSave(); + void testDatabaseSettings(); void testKeePass1Import(); void cleanupTestCase();