From c8a2fcc08a98b1d2f81efb51c0c47087c96e696a Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Wed, 24 Apr 2013 11:18:32 +0200 Subject: reduce the time which it takes to run the messageboxhandler test Change-Id: I116fbc546cbc54ed5f5cb37a86a75393a7719cff Reviewed-by: Karsten Heimrich --- .../installer/messageboxhandler/tst_messageboxhandler.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') 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 #include +#include /* srand, rand */ +#include /* time */ + using namespace QInstaller; namespace QTest { @@ -64,7 +67,7 @@ private slots: void testDefaultAction() { - int standardButtons = QMessageBox::FirstButton; + int standardButtons = QMessageBox::NoButton; QList 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( messageBoxHandler->critical(testidentifier, testTitle, testMessage, @@ -94,7 +104,6 @@ private slots: QCOMPARE(returnButton, wantedButton); } while (standardButtons < m_maxStandardButtons); - } private: -- cgit v1.2.3