summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2013-04-24 11:18:32 +0200
committerTim Jenssen <tim.jenssen@digia.com>2013-04-24 11:50:44 +0200
commitc8a2fcc08a98b1d2f81efb51c0c47087c96e696a (patch)
tree2e5c9f561dbacf5d2024c06b7e8696adc81ef734 /tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
parentedf9b08824214efc5dfffae290d3ea75373990cb (diff)
reduce the time which it takes to run the messageboxhandler test
Change-Id: I116fbc546cbc54ed5f5cb37a86a75393a7719cff Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp')
-rw-r--r--tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
index 4b12507d3..f705154b5 100644
--- a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
+++ b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
@@ -6,6 +6,9 @@
#include <QScriptEngine>
#include <QDebug>
+#include <stdlib.h> /* srand, rand */
+#include <time.h> /* time */
+
using namespace QInstaller;
namespace QTest {
@@ -64,7 +67,7 @@ private slots:
void testDefaultAction()
{
- int standardButtons = QMessageBox::FirstButton;
+ int standardButtons = QMessageBox::NoButton;
QList<QMessageBox::Button> orderedButtons = MessageBoxHandler::orderedButtons();
MessageBoxHandler *messageBoxHandler = MessageBoxHandler::instance();
@@ -74,9 +77,16 @@ private slots:
QString testMessage(QLatin1String("This is a test error message."));
const char *ignoreMessage("\"created critical message box TestError: 'A test error', This is a test error message.\" ");
+ /* initialize random seed: */
+ srand(time(0));
do {
standardButtons += QMessageBox::FirstButton;
+ /* generate secret number between 1 and 10: */
+ int iSecret = rand() % 10 + 1;
+ // use only every 5th run to reduce the time which it takes to run this test
+ if (iSecret > 2)
+ continue;
QTest::ignoreMessage(QtDebugMsg, ignoreMessage);
const QMessageBox::StandardButton returnButton = static_cast<QMessageBox::StandardButton>(
messageBoxHandler->critical(testidentifier, testTitle, testMessage,
@@ -94,7 +104,6 @@ private slots:
QCOMPARE(returnButton, wantedButton);
} while (standardButtons < m_maxStandardButtons);
-
}
private: