summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-04-13 21:13:52 -0700
committerLars Knoll <lars.knoll@qt.io>2017-11-08 09:14:03 +0000
commit19b0ce5daa31e2ffebfcf2701143742302f1deb4 (patch)
tree730cccd80947c60ee4872e16f71d4d48d906c354 /tests/auto/widgets/widgets
parent59c5f7bd9da63621887260fc45e6669282d71ecd (diff)
Change almost all other uses of qrand() to QRandomGenerator
The vast majority is actually switched to QRandomGenerator::bounded(), which gives a mostly uniform distribution over the [0, bound) range. There are very few floating point cases left, as many of those that did use floating point did not need to, after all. (I did leave some that were too ugly for me to understand) This commit also found a couple of calls to rand() instead of qrand(). This commit does not include changes to SSL code that continues to use qrand() (job for someone else): src/network/ssl/qsslkey_qt.cpp src/network/ssl/qsslsocket_mac.cpp tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp16
1 files changed, 1 insertions, 15 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 71969ec695..3d9620e75a 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -43,10 +43,6 @@
#include <private/qapplication_p.h>
#include "qclipboard.h"
-#ifdef Q_OS_MAC
-#include <cstdlib> // For the random function.
-#endif
-
#include <qlineedit.h>
#include <private/qlineedit_p.h>
#include <private/qwidgetlinecontrol_p.h>
@@ -1949,17 +1945,7 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly()
static void figureOutProperKey(Qt::Key &key, Qt::KeyboardModifiers &pressState)
{
#ifdef Q_OS_MAC
- static bool tst_lineedit_randomized = false;
- // Mac has 3 different ways of accomplishing this (same for moving to the back)
- // So I guess we should just randomly do this for now. Which may get people mad, but if
- // we fail at one point, it's just a matter of setting roll to the correct value
- // instead of random.
-
- if (!tst_lineedit_randomized) {
- tst_lineedit_randomized = true;
- ::srandom(ulong(time(0)));
- }
- long roll = ::random() % 3;
+ long roll = QRandomGenerator::global()->bounded(3);
switch (roll) {
case 0:
key = key == Qt::Key_Home ? Qt::Key_Up : Qt::Key_Down;