mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-31 18:26:20 -05:00
Merge pull request #1141 from keepassxreboot/hotfix/apply-button-save
Fix apply button not saving new entries
This commit is contained in:
commit
7ef61b47e3
@ -278,6 +278,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q
|
|||||||
m_database = database;
|
m_database = database;
|
||||||
m_create = create;
|
m_create = create;
|
||||||
m_history = history;
|
m_history = history;
|
||||||
|
m_saved = false;
|
||||||
|
|
||||||
if (history) {
|
if (history) {
|
||||||
setHeadline(QString("%1 > %2").arg(parentName, tr("Entry history")));
|
setHeadline(QString("%1 > %2").arg(parentName, tr("Entry history")));
|
||||||
@ -438,6 +439,7 @@ void EditEntryWidget::saveEntry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateEntryData(m_entry);
|
updateEntryData(m_entry);
|
||||||
|
m_saved = true;
|
||||||
|
|
||||||
if (!m_create) {
|
if (!m_create) {
|
||||||
m_entry->endUpdate();
|
m_entry->endUpdate();
|
||||||
@ -510,7 +512,7 @@ void EditEntryWidget::cancel()
|
|||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
emit editFinished(false);
|
emit editFinished(m_saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEntryWidget::clear()
|
void EditEntryWidget::clear()
|
||||||
|
@ -121,6 +121,7 @@ private:
|
|||||||
|
|
||||||
bool m_create;
|
bool m_create;
|
||||||
bool m_history;
|
bool m_history;
|
||||||
|
bool m_saved;
|
||||||
const QScopedPointer<Ui::EditEntryWidgetMain> m_mainUi;
|
const QScopedPointer<Ui::EditEntryWidgetMain> m_mainUi;
|
||||||
const QScopedPointer<Ui::EditEntryWidgetAdvanced> m_advancedUi;
|
const QScopedPointer<Ui::EditEntryWidgetAdvanced> m_advancedUi;
|
||||||
const QScopedPointer<Ui::EditEntryWidgetAutoType> m_autoTypeUi;
|
const QScopedPointer<Ui::EditEntryWidgetAutoType> m_autoTypeUi;
|
||||||
|
@ -332,15 +332,27 @@ void TestGui::testAddEntry()
|
|||||||
QTest::keyClicks(passwordRepeatEdit, "something 2");
|
QTest::keyClicks(passwordRepeatEdit, "something 2");
|
||||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
|
||||||
// Add entry "something 3"
|
// Add entry "something 3" using the apply button then click ok
|
||||||
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||||
QTest::keyClicks(titleEdit, "something 3");
|
QTest::keyClicks(titleEdit, "something 3");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
||||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
|
||||||
|
// Add entry "something 4" using the apply button then click cancel
|
||||||
|
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||||
|
QTest::keyClicks(titleEdit, "something 4");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Cancel), Qt::LeftButton);
|
||||||
|
|
||||||
|
// Add entry "something 5" but click cancel button (does NOT add entry)
|
||||||
|
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||||
|
QTest::keyClicks(titleEdit, "something 5");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Cancel), Qt::LeftButton);
|
||||||
|
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
||||||
// Confirm that 4 entries now exist
|
// Confirm that 5 entries now exist
|
||||||
QTRY_COMPARE(entryView->model()->rowCount(), 4);
|
QTRY_COMPARE(entryView->model()->rowCount(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGui::testPasswordEntryEntropy()
|
void TestGui::testPasswordEntryEntropy()
|
||||||
@ -513,7 +525,7 @@ void TestGui::testTotp()
|
|||||||
void TestGui::testSearch()
|
void TestGui::testSearch()
|
||||||
{
|
{
|
||||||
// Add canned entries for consistent testing
|
// Add canned entries for consistent testing
|
||||||
testAddEntry();
|
Q_UNUSED(addCannedEntries());
|
||||||
|
|
||||||
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
||||||
|
|
||||||
@ -629,7 +641,7 @@ void TestGui::testSearch()
|
|||||||
void TestGui::testDeleteEntry()
|
void TestGui::testDeleteEntry()
|
||||||
{
|
{
|
||||||
// Add canned entries for consistent testing
|
// Add canned entries for consistent testing
|
||||||
testAddEntry();
|
Q_UNUSED(addCannedEntries());
|
||||||
|
|
||||||
GroupView* groupView = m_dbWidget->findChild<GroupView*>("groupView");
|
GroupView* groupView = m_dbWidget->findChild<GroupView*>("groupView");
|
||||||
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
|
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
|
||||||
@ -905,6 +917,42 @@ void TestGui::cleanupTestCase()
|
|||||||
delete m_mainWindow;
|
delete m_mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TestGui::addCannedEntries()
|
||||||
|
{
|
||||||
|
int entries_added = 0;
|
||||||
|
|
||||||
|
// Find buttons
|
||||||
|
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
||||||
|
QWidget* entryNewWidget = toolBar->widgetForAction(m_mainWindow->findChild<QAction*>("actionEntryNew"));
|
||||||
|
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
|
||||||
|
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
|
||||||
|
QLineEdit* passwordEdit = editEntryWidget->findChild<QLineEdit*>("passwordEdit");
|
||||||
|
QLineEdit* passwordRepeatEdit = editEntryWidget->findChild<QLineEdit*>("passwordRepeatEdit");
|
||||||
|
|
||||||
|
// Add entry "test" and confirm added
|
||||||
|
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||||
|
QTest::keyClicks(titleEdit, "test");
|
||||||
|
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
++entries_added;
|
||||||
|
|
||||||
|
// Add entry "something 2"
|
||||||
|
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||||
|
QTest::keyClicks(titleEdit, "something 2");
|
||||||
|
QTest::keyClicks(passwordEdit, "something 2");
|
||||||
|
QTest::keyClicks(passwordRepeatEdit, "something 2");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
++entries_added;
|
||||||
|
|
||||||
|
// Add entry "something 3"
|
||||||
|
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||||
|
QTest::keyClicks(titleEdit, "something 3");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
++entries_added;
|
||||||
|
|
||||||
|
return entries_added;
|
||||||
|
}
|
||||||
|
|
||||||
void TestGui::checkDatabase(QString dbFileName)
|
void TestGui::checkDatabase(QString dbFileName)
|
||||||
{
|
{
|
||||||
if (dbFileName.isEmpty())
|
if (dbFileName.isEmpty())
|
||||||
|
@ -61,6 +61,7 @@ private slots:
|
|||||||
void testDatabaseLocking();
|
void testDatabaseLocking();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int addCannedEntries();
|
||||||
void checkDatabase(QString dbFileName = "");
|
void checkDatabase(QString dbFileName = "");
|
||||||
void triggerAction(const QString& name);
|
void triggerAction(const QString& name);
|
||||||
void dragAndDropGroup(const QModelIndex& sourceIndex, const QModelIndex& targetIndex, int row,
|
void dragAndDropGroup(const QModelIndex& sourceIndex, const QModelIndex& targetIndex, int row,
|
||||||
|
Loading…
Reference in New Issue
Block a user