mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-07 00:56:45 -04:00
Add a QMessageBox wrapper class to help gui tests.
QMessageBox displays modal dialogs which blocks the gui tests. To work around this we add a MessageBox wrapper class where the tests can set the answer for the next dialog. The answer is then returned without actually showing the dialog.
This commit is contained in:
parent
551637f0c2
commit
d5b70b1bef
11 changed files with 176 additions and 41 deletions
|
@ -18,7 +18,6 @@
|
|||
#include "DatabaseTabWidget.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
|
@ -30,6 +29,7 @@
|
|||
#include "gui/DatabaseWidget.h"
|
||||
#include "gui/DragTabBar.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/GroupView.h"
|
||||
|
||||
|
@ -106,7 +106,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
|
|||
QFileInfo fileInfo(fileName);
|
||||
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
||||
if (canonicalFilePath.isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Warning"), tr("File not found!"));
|
||||
MessageBox::warning(this, tr("Warning"), tr("File not found!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
|||
}
|
||||
if (dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode && db->hasKey()) {
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(
|
||||
MessageBox::question(
|
||||
this, tr("Close?"),
|
||||
tr("\"%1\" is in edit mode.\nClose anyway?").arg(dbName),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
|
@ -205,7 +205,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
|||
}
|
||||
else {
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(
|
||||
MessageBox::question(
|
||||
this, tr("Save changes?"),
|
||||
tr("\"%1\" was modified.\nSave changes?").arg(dbName),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
|
||||
|
@ -270,8 +270,8 @@ void DatabaseTabWidget::saveDatabase(Database* db)
|
|||
updateTabName(db);
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -309,8 +309,8 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
|||
updateLastDatabases(dbStruct.filePath);
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue