mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-23 23:10:44 -04:00
Fix assert hit when viewing entry history
* Fixes #11371 * Adds test for showing entry history * Improved page switching capabilities for entry edit widget
This commit is contained in:
parent
c6800bf705
commit
2836364e1a
6 changed files with 110 additions and 23 deletions
|
@ -471,8 +471,28 @@ void TestGui::testEditEntry()
|
|||
QCOMPARE(entry->historyItems().size(), ++editCount);
|
||||
QVERIFY(!applyButton->isEnabled());
|
||||
|
||||
// Test viewing entry history
|
||||
auto historyView = editEntryWidget->findChild<QTreeView*>("historyView");
|
||||
auto showButton = editEntryWidget->findChild<QPushButton*>("showButton");
|
||||
QVERIFY(historyView);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::History);
|
||||
QApplication::processEvents();
|
||||
QVERIFY(historyView->isVisible());
|
||||
QVERIFY(!showButton->isEnabled());
|
||||
// Select the second row in the history view
|
||||
historyView->setCurrentIndex(historyView->model()->index(1, 0));
|
||||
QVERIFY(showButton->isEnabled());
|
||||
QTest::mouseClick(showButton, Qt::LeftButton);
|
||||
// Verify that the entry history widget is shown
|
||||
auto entryHistoryWidget = m_dbWidget->findChild<QWidget*>("editEntryHistoryWidget");
|
||||
QVERIFY(entryHistoryWidget);
|
||||
QVERIFY(entryHistoryWidget->isVisible());
|
||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::EditEntryMode);
|
||||
QTest::keyClick(entryHistoryWidget, Qt::Key_Escape);
|
||||
QVERIFY(historyView->isVisible());
|
||||
|
||||
// Test the "known bad" checkbox
|
||||
editEntryWidget->setCurrentPage(1);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Advanced);
|
||||
auto excludeReportsCheckBox = editEntryWidget->findChild<QCheckBox*>("excludeReportsCheckBox");
|
||||
QVERIFY(excludeReportsCheckBox);
|
||||
QCOMPARE(excludeReportsCheckBox->isChecked(), false);
|
||||
|
@ -495,7 +515,7 @@ void TestGui::testEditEntry()
|
|||
QCOMPARE(tags->tags().last(), QString("tag 2_is!awesome"));
|
||||
|
||||
// Test entry colors (simulate choosing a color)
|
||||
editEntryWidget->setCurrentPage(1);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Advanced);
|
||||
auto fgColor = QString("#FF0000");
|
||||
auto bgColor = QString("#0000FF");
|
||||
// Set foreground color
|
||||
|
@ -512,7 +532,7 @@ void TestGui::testEditEntry()
|
|||
QCOMPARE(entry->historyItems().size(), ++editCount);
|
||||
|
||||
// Test protected attributes
|
||||
editEntryWidget->setCurrentPage(1);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Advanced);
|
||||
auto* attrTextEdit = editEntryWidget->findChild<QPlainTextEdit*>("attributesEdit");
|
||||
QTest::mouseClick(editEntryWidget->findChild<QAbstractButton*>("addAttributeButton"), Qt::LeftButton);
|
||||
QString attrText = "TEST TEXT";
|
||||
|
@ -522,7 +542,7 @@ void TestGui::testEditEntry()
|
|||
QVERIFY(attrTextEdit->toPlainText().contains("PROTECTED"));
|
||||
QTest::mouseClick(editEntryWidget->findChild<QAbstractButton*>("revealAttributeButton"), Qt::LeftButton);
|
||||
QCOMPARE(attrTextEdit->toPlainText(), attrText);
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
|
||||
// Save the edit (press OK)
|
||||
QTest::mouseClick(okButton, Qt::LeftButton);
|
||||
|
@ -901,7 +921,7 @@ void TestGui::testTotp()
|
|||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::EditEntryMode);
|
||||
|
||||
auto* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
|
||||
editEntryWidget->setCurrentPage(1);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Advanced);
|
||||
auto* attrTextEdit = editEntryWidget->findChild<QPlainTextEdit*>("attributesEdit");
|
||||
QTest::mouseClick(editEntryWidget->findChild<QAbstractButton*>("revealAttributeButton"), Qt::LeftButton);
|
||||
QCOMPARE(attrTextEdit->toPlainText(), expectedFinalSeed);
|
||||
|
@ -1623,7 +1643,7 @@ void TestGui::testDatabaseSettings()
|
|||
QTest::keyClicks(titleEdit, "Test autosaveDelay 1");
|
||||
|
||||
// 2.b) Save changes
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
auto* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
|
||||
|
@ -1637,7 +1657,7 @@ void TestGui::testDatabaseSettings()
|
|||
QTest::keyClicks(titleEdit, "Test autosaveDelay 2");
|
||||
|
||||
// 2.e) Save changes
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
|
||||
|
@ -1657,7 +1677,7 @@ void TestGui::testDatabaseSettings()
|
|||
QTest::keyClicks(titleEdit, "Test autosaveDelay 3");
|
||||
|
||||
// 4.b) Save changes
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
|
||||
|
@ -1676,7 +1696,7 @@ void TestGui::testDatabaseSettings()
|
|||
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::EditEntryMode);
|
||||
QTest::keyClicks(titleEdit, "Test autosaveDelay 4");
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
Tools::wait(150); // due to modify timer
|
||||
|
@ -1922,7 +1942,7 @@ void TestGui::testAutoType()
|
|||
QTest::keyClicks(usernameComboBox, "AutocompletionUsername");
|
||||
|
||||
// 1.b) Uncheck Auto-Type checkbox
|
||||
editEntryWidget->setCurrentPage(3);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::AutoType);
|
||||
auto* enableAutoTypeButton = editEntryWidget->findChild<QCheckBox*>("enableButton");
|
||||
QVERIFY(enableAutoTypeButton);
|
||||
QVERIFY(enableAutoTypeButton->isVisible());
|
||||
|
@ -1932,7 +1952,7 @@ void TestGui::testAutoType()
|
|||
QVERIFY(!enableAutoTypeButton->isChecked());
|
||||
|
||||
// 1.c) Save changes
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
auto* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
|
||||
|
@ -1946,13 +1966,13 @@ void TestGui::testAutoType()
|
|||
QTest::keyClicks(usernameComboBox, "AutocompletionUsername");
|
||||
|
||||
// 2.b) Confirm AutoType is enabled and default
|
||||
editEntryWidget->setCurrentPage(3);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::AutoType);
|
||||
QVERIFY(enableAutoTypeButton->isChecked());
|
||||
auto* inheritSequenceButton = editEntryWidget->findChild<QRadioButton*>("inheritSequenceButton");
|
||||
QVERIFY(inheritSequenceButton->isChecked());
|
||||
|
||||
// 2.c) Save changes
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
|
||||
// 3. Create an entry with custom Auto-Type sequence
|
||||
|
@ -1965,7 +1985,7 @@ void TestGui::testAutoType()
|
|||
QTest::keyClicks(usernameComboBox, "AutocompletionUsername");
|
||||
|
||||
// 3.b) Confirm AutoType is enabled and set custom sequence
|
||||
editEntryWidget->setCurrentPage(3);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::AutoType);
|
||||
QVERIFY(enableAutoTypeButton->isChecked());
|
||||
auto* customSequenceButton = editEntryWidget->findChild<QRadioButton*>("customSequenceButton");
|
||||
QTest::mouseClick(customSequenceButton, Qt::LeftButton);
|
||||
|
@ -1978,7 +1998,7 @@ void TestGui::testAutoType()
|
|||
QTest::keyClicks(sequenceEdit, "{USERNAME}{TAB}{TAB}{PASSWORD}{ENTER}");
|
||||
|
||||
// 3.c) Save changes
|
||||
editEntryWidget->setCurrentPage(0);
|
||||
editEntryWidget->switchToPage(EditEntryWidget::Page::Main);
|
||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
QApplication::processEvents();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue