diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index f3980b952..fb97abcd2 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -39,7 +39,9 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) QSplitter* splitter = new QSplitter(m_mainWidget); m_groupView = new GroupView(db, splitter); + m_groupView->setObjectName("groupView"); m_entryView = new EntryView(splitter); + m_entryView->setObjectName("entryView"); QSizePolicy policy; @@ -58,7 +60,9 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) m_mainWidget->setLayout(layout); m_editEntryWidget = new EditEntryWidget(); + m_editEntryWidget->setObjectName("editEntryWidget"); m_editGroupWidget = new EditGroupWidget(); + m_editGroupWidget->setObjectName("editGroupWidget"); m_changeMasterKeyWidget = new ChangeMasterKeyWidget(); m_changeMasterKeyWidget->headlineLabel()->setText(tr("Change master key")); QFont headlineLabelFont = m_changeMasterKeyWidget->headlineLabel()->font(); diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index f4de88fce..d0ac3faf1 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -27,6 +27,10 @@ #include "config-keepassx-tests.h" #include "tests.h" #include "crypto/Crypto.h" +#include "gui/DatabaseTabWidget.h" +#include "gui/DatabaseWidget.h" +#include "gui/EditEntryWidget.h" +#include "gui/EntryView.h" #include "gui/FileDialog.h" #include "gui/MainWindow.h" @@ -52,6 +56,7 @@ void TestGui::testOpenDatabase() QDialogButtonBox* buttonBox = keyDialog->findChild("buttonBox"); QTest::mouseClick(buttonBox->button(QDialogButtonBox::Ok), Qt::LeftButton); + QTest::qWait(20); } void TestGui::testTabs() @@ -61,6 +66,28 @@ void TestGui::testTabs() QCOMPARE(tabWidget->tabText(tabWidget->currentIndex()), QString("NewDatabase.kdbx")); } +void TestGui::testEditEntry() +{ + DatabaseTabWidget* tabWidget = m_mainWindow->findChild("tabWidget"); + DatabaseWidget* dbWidget = tabWidget->currentDatabaseWidget(); + EntryView* entryView = dbWidget->findChild("entryView"); + QModelIndex item = entryView->model()->index(0, 0); + QRect itemRect = entryView->visualRect(item); + QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center()); + QTest::qWait(20); + QAction* actionEntryEdit = m_mainWindow->findChild("actionEntryEdit"); + QVERIFY(actionEntryEdit->isEnabled()); + actionEntryEdit->trigger(); + QTest::qWait(20); + EditEntryWidget* editEntryWidget = dbWidget->findChild("editEntryWidget"); + QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild("buttonBox"); + QVERIFY(editEntryWidgetButtonBox); + QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton); + QTest::qWait(20); + // make sure the database isn't marked as modified + QCOMPARE(tabWidget->tabText(tabWidget->currentIndex()), QString("NewDatabase.kdbx")); +} + void TestGui::cleanupTestCase() { delete m_mainWindow; diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h index 91b305058..70facdc57 100644 --- a/tests/gui/TestGui.h +++ b/tests/gui/TestGui.h @@ -30,6 +30,7 @@ private Q_SLOTS: void initTestCase(); void testOpenDatabase(); void testTabs(); + void testEditEntry(); void cleanupTestCase(); private: