summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2015-12-22 17:34:55 -0500
committerRJ Ryan <rryan@mixxx.org>2015-12-22 17:34:55 -0500
commit745a2d643b1c1fee4d08ffbeceb4b14febd4f65b (patch)
treeef2a5b2eb7ddca3ed5d2c17d11e418bd55e0f4a2 /src
parent608d346a60cef90a288ed4c9d6e8e18827a2147c (diff)
Disable ErrorDialogHandler when running tests.
Diffstat (limited to 'src')
-rw-r--r--src/errordialoghandler.cpp15
-rw-r--r--src/errordialoghandler.h2
-rw-r--r--src/test/main.cpp4
3 files changed, 20 insertions, 1 deletions
diff --git a/src/errordialoghandler.cpp b/src/errordialoghandler.cpp
index 640e238c5d..c0888fbfab 100644
--- a/src/errordialoghandler.cpp
+++ b/src/errordialoghandler.cpp
@@ -67,6 +67,12 @@ void ErrorDialogProperties::addButton(QMessageBox::StandardButton button) {
// ---------- ErrorDialogHandler begins here ----------
ErrorDialogHandler* ErrorDialogHandler::s_pInstance = NULL;
+bool ErrorDialogHandler::s_bEnabled = true;
+
+// static
+void ErrorDialogHandler::setEnabled(bool enabled) {
+ s_bEnabled = enabled;
+}
ErrorDialogHandler::ErrorDialogHandler()
: m_signalMapper(this) {
@@ -88,6 +94,9 @@ ErrorDialogProperties* ErrorDialogHandler::newDialogProperties() {
bool ErrorDialogHandler::requestErrorDialog(DialogType type, QString message,
bool shouldQuit) {
+ if (!s_bEnabled) {
+ return false;
+ }
ErrorDialogProperties* props = newDialogProperties();
props->setType(type);
props->setText(message);
@@ -109,9 +118,15 @@ bool ErrorDialogHandler::requestErrorDialog(DialogType type, QString message,
}
bool ErrorDialogHandler::requestErrorDialog(ErrorDialogProperties* props) {
+ if (!s_bEnabled) {
+ delete props;
+ return false;
+ }
+
// Make sure the minimum items are set
QString text = props->getText();
DEBUG_ASSERT_AND_HANDLE(!text.isEmpty()) {
+ delete props;
return false;
}
diff --git a/src/errordialoghandler.h b/src/errordialoghandler.h
index 1e2ee96588..6e2cd34adf 100644
--- a/src/errordialoghandler.h
+++ b/src/errordialoghandler.h
@@ -140,6 +140,7 @@ class ErrorDialogHandler : public QObject {
s_pInstance = new ErrorDialogHandler();
return s_pInstance;
}
+ static void setEnabled(bool enabled);
virtual ~ErrorDialogHandler();
// Call this to get a new instance of ErrorDialogProperties to populate with
@@ -172,6 +173,7 @@ class ErrorDialogHandler : public QObject {
ErrorDialogHandler();
static ErrorDialogHandler *s_pInstance;
+ static bool s_bEnabled;
bool m_errorCondition;
QList<QString> m_dialogKeys;
diff --git a/src/test/main.cpp b/src/test/main.cpp
index 105050d97b..0645ab6dcc 100644
--- a/src/test/main.cpp
+++ b/src/test/main.cpp
@@ -1,9 +1,11 @@
#include <gtest/gtest.h>
#include "util/console.h"
-
+#include "errordialoghandler.h"
int main(int argc, char **argv) {
Console console();
+ // We never want to popup error dialogs when running tests.
+ ErrorDialogHandler::setEnabled(false);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}