Add TestGui::testEditEntry().

This tests that the database isn't marked as modified when we don't change
anything but still press the Ok button.
This commit is contained in:
Felix Geyer 2012-04-14 20:31:35 +02:00
parent 38585663e1
commit 3baaf6be97
3 changed files with 32 additions and 0 deletions

View File

@ -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();

View File

@ -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<QDialogButtonBox*>("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<DatabaseTabWidget*>("tabWidget");
DatabaseWidget* dbWidget = tabWidget->currentDatabaseWidget();
EntryView* entryView = dbWidget->findChild<EntryView*>("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<QAction*>("actionEntryEdit");
QVERIFY(actionEntryEdit->isEnabled());
actionEntryEdit->trigger();
QTest::qWait(20);
EditEntryWidget* editEntryWidget = dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("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;

View File

@ -30,6 +30,7 @@ private Q_SLOTS:
void initTestCase();
void testOpenDatabase();
void testTabs();
void testEditEntry();
void cleanupTestCase();
private: