aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-09-21 12:23:48 -0700
committerLars Knoll <lars.knoll@qt.io>2017-11-03 09:12:14 +0000
commitee00fa01dc41deaaedfa0d1d5cc6cd750bfe75f4 (patch)
treee764c6bab1bd0883fcbfe20c7703f997fb22d510 /tests
parent62e23e1ae6542b5ab837a2481d9257c81e484013 (diff)
Update to new QRandomGenerator API
Change-Id: I69f37f9304f24709a823fffd14e676c097712329 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp16
-rw-r--r--tests/auto/quick/qquicklistview/randomsortmodel.cpp4
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp4
-rw-r--r--tests/benchmarks/qml/holistic/testtypes.h4
-rw-r--r--tests/benchmarks/qml/painting/paintbenchmark.cpp2
5 files changed, 15 insertions, 15 deletions
diff --git a/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp b/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp
index 65ac1ef320..f12c3432c2 100644
--- a/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp
+++ b/tests/auto/qml/qqmlchangeset/tst_qqmlchangeset.cpp
@@ -1487,27 +1487,27 @@ void tst_qqmlchangeset::random()
for (int j = 0; j < combinations; ++j) {
QQmlChangeSet set;
for (int k = 0; k < depth; ++k) {
- switch (-QRandomGenerator::bounded(3)) {
+ switch (-QRandomGenerator::global()->bounded(3)) {
case InsertOp: {
- int index = QRandomGenerator::bounded(modelCount + 1);
- int count = QRandomGenerator::bounded(5) + 1;
+ int index = QRandomGenerator::global()->bounded(modelCount + 1);
+ int count = QRandomGenerator::global()->bounded(5) + 1;
set.insert(index, count);
input.append(Insert(index, count));
modelCount += count;
break;
}
case RemoveOp: {
- const int index = QRandomGenerator::bounded(modelCount + 1);
- const int count = QRandomGenerator::bounded(modelCount - index + 1);
+ const int index = QRandomGenerator::global()->bounded(modelCount + 1);
+ const int count = QRandomGenerator::global()->bounded(modelCount - index + 1);
set.remove(index, count);
input.append(Remove(index, count));
modelCount -= count;
break;
}
case MoveOp: {
- const int from = QRandomGenerator::bounded(modelCount + 1);
- const int count = QRandomGenerator::bounded(modelCount - from + 1);
- const int to = QRandomGenerator::bounded(modelCount - count + 1);
+ const int from = QRandomGenerator::global()->bounded(modelCount + 1);
+ const int count = QRandomGenerator::global()->bounded(modelCount - from + 1);
+ const int to = QRandomGenerator::global()->bounded(modelCount - count + 1);
const int moveId = moveCount++;
set.move(from, to, count, moveId);
input.append(Move(from, to, count, moveId));
diff --git a/tests/auto/quick/qquicklistview/randomsortmodel.cpp b/tests/auto/quick/qquicklistview/randomsortmodel.cpp
index 7c4bd5111c..7375fe0dbe 100644
--- a/tests/auto/quick/qquicklistview/randomsortmodel.cpp
+++ b/tests/auto/quick/qquicklistview/randomsortmodel.cpp
@@ -74,14 +74,14 @@ QVariant RandomSortModel::data(const QModelIndex& index, int role) const
void RandomSortModel::randomize()
{
- const int row = QRandomGenerator::bounded(mData.count());
+ const int row = QRandomGenerator::global()->bounded(mData.count());
int random;
bool exists = false;
// Make sure we won't end up with two items with the same weight, as that
// would make unit-testing much harder
do {
exists = false;
- random = QRandomGenerator::bounded(mData.count() * 10);
+ random = QRandomGenerator::global()->bounded(mData.count() * 10);
QList<QPair<QString, int> >::ConstIterator iter, end;
for (iter = mData.constBegin(), end = mData.constEnd(); iter != end; ++iter) {
if ((*iter).second == random) {
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index a33c5eae96..d5bf0110c4 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -374,7 +374,7 @@ void QQuickViewTestUtil::StressTestModel::updateModel()
{
if (m_rowCount > 10) {
for (int i = 0; i < 10; ++i) {
- int rnum = QRandomGenerator::bounded(m_rowCount);
+ int rnum = QRandomGenerator::global()->bounded(m_rowCount);
beginRemoveRows(QModelIndex(), rnum, rnum);
m_rowCount--;
endRemoveRows();
@@ -382,7 +382,7 @@ void QQuickViewTestUtil::StressTestModel::updateModel()
}
if (m_rowCount < 20) {
for (int i = 0; i < 10; ++i) {
- int rnum = QRandomGenerator::bounded(m_rowCount);
+ int rnum = QRandomGenerator::global()->bounded(m_rowCount);
beginInsertRows(QModelIndex(), rnum, rnum);
m_rowCount++;
endInsertRows();
diff --git a/tests/benchmarks/qml/holistic/testtypes.h b/tests/benchmarks/qml/holistic/testtypes.h
index 29ebe97f39..6ff64c645d 100644
--- a/tests/benchmarks/qml/holistic/testtypes.h
+++ b/tests/benchmarks/qml/holistic/testtypes.h
@@ -224,7 +224,7 @@ public:
{
QPixmap pv(150, 150);
pv.fill(Qt::green);
- int choice = QRandomGenerator::bounded(4);
+ int choice = QRandomGenerator::global()->bounded(4);
switch (choice) {
case 0: setArbitraryVariant(QVariant(QString(QLatin1String("string variant value")))); break;
case 1: setArbitraryVariant(QVariant(QColor(110, 120, 130))); break;
@@ -254,7 +254,7 @@ public:
QVariant retn;
QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300);
pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256));
- int choice = QRandomGenerator::bounded(4);
+ int choice = QRandomGenerator::global()->bounded(4);
switch (choice) {
case 0: retn = QVariant(QString(QLatin1String("string variant value"))); break;
case 1: retn = QVariant(QColor(randomFactorThree % 256, randomFactorTwo % 256, randomFactorOne % 256)); break;
diff --git a/tests/benchmarks/qml/painting/paintbenchmark.cpp b/tests/benchmarks/qml/painting/paintbenchmark.cpp
index 98d8d7c16a..d195675ab8 100644
--- a/tests/benchmarks/qml/painting/paintbenchmark.cpp
+++ b/tests/benchmarks/qml/painting/paintbenchmark.cpp
@@ -322,7 +322,7 @@ public:
int len = strlen(chars);
for (int i = 0; i < lines; ++i) {
for (int j = 0; j < 60; j++) {
- strings[i] += QChar(chars[QRandomGenerator::bounded(len)]);
+ strings[i] += QChar(chars[QRandomGenerator::global()->bounded(len)]);
}
}
}