mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-24 05:31:11 -05:00
Add gui test for search.
This commit is contained in:
parent
ea6f2477ef
commit
b08d2d45b7
@ -150,6 +150,66 @@ void TestGui::testAddEntry()
|
|||||||
QCOMPARE(entry->historyItems().size(), 1);
|
QCOMPARE(entry->historyItems().size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestGui::testSearch()
|
||||||
|
{
|
||||||
|
DatabaseTabWidget* tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
|
||||||
|
DatabaseWidget* dbWidget = tabWidget->currentDatabaseWidget();
|
||||||
|
|
||||||
|
EntryView* entryView = dbWidget->findChild<EntryView*>("entryView");
|
||||||
|
QLineEdit* searchEdit = dbWidget->findChild<QLineEdit*>("searchEdit");
|
||||||
|
QPushButton* clearSearch = dbWidget->findChild<QPushButton*>("clearSearchButton");
|
||||||
|
|
||||||
|
QTest::keyClicks(searchEdit, "ZZZ");
|
||||||
|
QTest::keyClick(searchEdit, Qt::Key_Return);
|
||||||
|
QTest::qWait(20);
|
||||||
|
|
||||||
|
QCOMPARE(entryView->model()->rowCount(), 0);
|
||||||
|
|
||||||
|
QTest::mouseClick(clearSearch, Qt::LeftButton);
|
||||||
|
QTest::keyClicks(searchEdit, "some");
|
||||||
|
QTest::keyClick(searchEdit, Qt::Key_Return);
|
||||||
|
QTest::qWait(20);
|
||||||
|
|
||||||
|
QCOMPARE(entryView->model()->rowCount(), 2);
|
||||||
|
|
||||||
|
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
||||||
|
|
||||||
|
QModelIndex item = entryView->model()->index(0, 1);
|
||||||
|
QRect itemRect = entryView->visualRect(item);
|
||||||
|
QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
|
||||||
|
QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
|
||||||
|
QVERIFY(entryEditAction->isEnabled());
|
||||||
|
QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
|
||||||
|
QVERIFY(entryEditWidget->isVisible());
|
||||||
|
QVERIFY(entryEditWidget->isEnabled());
|
||||||
|
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
|
||||||
|
QTest::qWait(20);
|
||||||
|
|
||||||
|
QCOMPARE(dbWidget->currentMode(), DatabaseWidget::EditMode);
|
||||||
|
|
||||||
|
EditEntryWidget* editEntryWidget = dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
|
||||||
|
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
QTest::qWait(20);
|
||||||
|
|
||||||
|
QCOMPARE(dbWidget->currentMode(), DatabaseWidget::ViewMode);
|
||||||
|
|
||||||
|
QModelIndex item2 = entryView->model()->index(1, 0);
|
||||||
|
QRect itemRect2 = entryView->visualRect(item2);
|
||||||
|
QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect2.center());
|
||||||
|
QAction* entryDeleteAction = m_mainWindow->findChild<QAction*>("actionEntryDelete");
|
||||||
|
|
||||||
|
QWidget* entryDeleteWidget = toolBar->widgetForAction(entryDeleteAction);
|
||||||
|
QVERIFY(entryDeleteWidget->isVisible());
|
||||||
|
QVERIFY(entryDeleteWidget->isEnabled());
|
||||||
|
|
||||||
|
QTest::mouseClick(entryDeleteWidget, Qt::LeftButton);
|
||||||
|
QTest::qWait(20);
|
||||||
|
|
||||||
|
QCOMPARE(entryView->model()->rowCount(), 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TestGui::cleanupTestCase()
|
void TestGui::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete m_mainWindow;
|
delete m_mainWindow;
|
||||||
|
@ -32,6 +32,7 @@ private Q_SLOTS:
|
|||||||
void testTabs();
|
void testTabs();
|
||||||
void testEditEntry();
|
void testEditEntry();
|
||||||
void testAddEntry();
|
void testAddEntry();
|
||||||
|
void testSearch();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user