mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add tests & minor edits
This commit is contained in:
parent
ca30d1832d
commit
397d804cdd
@ -1137,7 +1137,7 @@ QMenu* EditEntryWidget::createPresetsMenu()
|
|||||||
return expirePresetsMenu;
|
return expirePresetsMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEntryWidget::setupColorButton(bool foreground, QColor color)
|
void EditEntryWidget::setupColorButton(bool foreground, const QColor& color)
|
||||||
{
|
{
|
||||||
QWidget* button = m_advancedUi->fgColorButton;
|
QWidget* button = m_advancedUi->fgColorButton;
|
||||||
QCheckBox* checkBox = m_advancedUi->fgColorCheckBox;
|
QCheckBox* checkBox = m_advancedUi->fgColorCheckBox;
|
||||||
@ -1165,7 +1165,7 @@ void EditEntryWidget::pickColor()
|
|||||||
oldColor = QColor(m_advancedUi->bgColorButton->property("color").toString());
|
oldColor = QColor(m_advancedUi->bgColorButton->property("color").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColorDialog colorDialog;
|
QColorDialog colorDialog(this);
|
||||||
QColor newColor = colorDialog.getColor(oldColor);
|
QColor newColor = colorDialog.getColor(oldColor);
|
||||||
if (newColor.isValid()) {
|
if (newColor.isValid()) {
|
||||||
setupColorButton(isForeground, newColor);
|
setupColorButton(isForeground, newColor);
|
||||||
|
@ -121,7 +121,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
void setupProperties();
|
void setupProperties();
|
||||||
void setupHistory();
|
void setupHistory();
|
||||||
void setupColorButton(bool foreground, QColor color);
|
void setupColorButton(bool foreground, const QColor& color);
|
||||||
|
|
||||||
bool passwordsEqual();
|
bool passwordsEqual();
|
||||||
void setForms(const Entry* entry, bool restore = false);
|
void setForms(const Entry* entry, bool restore = false);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
@ -279,6 +280,7 @@ void TestGui::testTabs()
|
|||||||
void TestGui::testEditEntry()
|
void TestGui::testEditEntry()
|
||||||
{
|
{
|
||||||
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
||||||
|
int editCount = 0;
|
||||||
|
|
||||||
// Select the first entry in the database
|
// Select the first entry in the database
|
||||||
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
|
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
|
||||||
@ -305,7 +307,24 @@ void TestGui::testEditEntry()
|
|||||||
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
||||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
|
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
|
||||||
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
||||||
QCOMPARE(entry->historyItems().size(), 1);
|
QCOMPARE(entry->historyItems().size(), ++editCount);
|
||||||
|
|
||||||
|
// Test entry colors (simulate choosing a color)
|
||||||
|
editEntryWidget->setCurrentPage(1);
|
||||||
|
auto fgColor = QColor(Qt::red);
|
||||||
|
auto bgColor = QColor(Qt::blue);
|
||||||
|
// Set foreground color
|
||||||
|
auto colorButton = editEntryWidget->findChild<QPushButton*>("fgColorButton");
|
||||||
|
auto colorCheckBox = editEntryWidget->findChild<QCheckBox*>("fgColorCheckBox");
|
||||||
|
colorButton->setProperty("color", fgColor);
|
||||||
|
colorCheckBox->setChecked(true);
|
||||||
|
// Set background color
|
||||||
|
colorButton = editEntryWidget->findChild<QPushButton*>("bgColorButton");
|
||||||
|
colorCheckBox = editEntryWidget->findChild<QCheckBox*>("bgColorCheckBox");
|
||||||
|
colorButton->setProperty("color", bgColor);
|
||||||
|
colorCheckBox->setChecked(true);
|
||||||
|
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
||||||
|
QCOMPARE(entry->historyItems().size(), ++editCount);
|
||||||
|
|
||||||
// Test protected attributes
|
// Test protected attributes
|
||||||
editEntryWidget->setCurrentPage(1);
|
editEntryWidget->setCurrentPage(1);
|
||||||
@ -337,7 +356,11 @@ void TestGui::testEditEntry()
|
|||||||
// Confirm edit was made
|
// Confirm edit was made
|
||||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
|
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
|
||||||
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
||||||
QCOMPARE(entry->historyItems().size(), 2);
|
QCOMPARE(entry->foregroundColor(), fgColor);
|
||||||
|
QCOMPARE(entryItem.data(Qt::ForegroundRole), QVariant(fgColor));
|
||||||
|
QCOMPARE(entry->backgroundColor(), bgColor);
|
||||||
|
QCOMPARE(entryItem.data(Qt::BackgroundRole), QVariant(bgColor));
|
||||||
|
QCOMPARE(entry->historyItems().size(), ++editCount);
|
||||||
|
|
||||||
// Confirm modified indicator is showing
|
// Confirm modified indicator is showing
|
||||||
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("%1*").arg(m_dbFileName));
|
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("%1*").arg(m_dbFileName));
|
||||||
|
Loading…
Reference in New Issue
Block a user