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:
Felix Geyer
2013-10-08 22:09:20 +02:00
parent 551637f0c2
commit d5b70b1bef
11 changed files with 176 additions and 41 deletions

View File

@@ -24,7 +24,6 @@
#include <QDesktopServices>
#include <QStackedLayout>
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include "core/Database.h"
@@ -35,6 +34,7 @@
#include "gui/EditWidgetIcons.h"
#include "gui/EditWidgetProperties.h"
#include "gui/FileDialog.h"
#include "gui/MessageBox.h"
#include "gui/entry/AutoTypeAssociationsModel.h"
#include "gui/entry/EntryAttachmentsModel.h"
#include "gui/entry/EntryAttributesModel.h"
@@ -381,7 +381,7 @@ void EditEntryWidget::saveEntry()
}
if (!passwordsEqual()) {
QMessageBox::warning(this, tr("Error"), tr("Different passwords supplied."));
MessageBox::warning(this, tr("Error"), tr("Different passwords supplied."));
return;
}
@@ -614,14 +614,14 @@ void EditEntryWidget::insertAttachment()
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::warning(this, tr("Error"),
MessageBox::warning(this, tr("Error"),
tr("Unable to open file:\n").append(file.errorString()));
return;
}
QByteArray data;
if (!Tools::readAllFromDevice(&file, data)) {
QMessageBox::warning(this, tr("Error"),
MessageBox::warning(this, tr("Error"),
tr("Unable to open file:\n").append(file.errorString()));
return;
}
@@ -646,12 +646,12 @@ void EditEntryWidget::saveCurrentAttachment()
QFile file(savePath);
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::warning(this, tr("Error"),
MessageBox::warning(this, tr("Error"),
tr("Unable to save the attachment:\n").append(file.errorString()));
return;
}
if (file.write(attachmentData) != attachmentData.size()) {
QMessageBox::warning(this, tr("Error"),
MessageBox::warning(this, tr("Error"),
tr("Unable to save the attachment:\n").append(file.errorString()));
return;
}