diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/qml/creation/tst_creation.cpp | 20 | ||||
-rw-r--r-- | tests/benchmarks/qml/holistic/testtypes.h | 5 | ||||
-rw-r--r-- | tests/benchmarks/qml/painting/paintbenchmark.cpp | 3 |
3 files changed, 12 insertions, 16 deletions
diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 30d7ef902e..ed2e52f869 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -204,19 +204,13 @@ void tst_creation::qobject_qmltype() } } -struct QQmlGraphics_Derived : public QObject -{ - void setParent_noEvent(QObject *parent) { - bool sce = d_ptr->sendChildEvents; - d_ptr->sendChildEvents = false; - setParent(parent); - d_ptr->sendChildEvents = sce; - } -}; - inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) { - static_cast<QQmlGraphics_Derived *>(object)->setParent_noEvent(parent); + QObjectPrivate *d_ptr = QObjectPrivate::get(object); + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + object->setParent(parent); + d_ptr->sendChildEvents = sce; } void tst_creation::itemtree_notree_cpp() @@ -385,7 +379,7 @@ void tst_creation::bindings_qml() return; } - QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QQuickItem *obj = qobject_cast<QQuickItem *>(component.create()); QVERIFY(obj != nullptr); int height = 0; @@ -407,7 +401,7 @@ void tst_creation::bindings_parent_qml() return; } - QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QQuickItem *obj = qobject_cast<QQuickItem *>(component.create()); QVERIFY(obj != nullptr); int height = 0; diff --git a/tests/benchmarks/qml/holistic/testtypes.h b/tests/benchmarks/qml/holistic/testtypes.h index a752a8585b..6ff64c645d 100644 --- a/tests/benchmarks/qml/holistic/testtypes.h +++ b/tests/benchmarks/qml/holistic/testtypes.h @@ -34,6 +34,7 @@ #include <QtCore/qpoint.h> #include <QtCore/qsize.h> #include <QtQml/qqmllist.h> +#include <QtCore/qrandom.h> #include <QtCore/qrect.h> #include <QtGui/qmatrix.h> #include <QtGui/qcolor.h> @@ -223,7 +224,7 @@ public: { QPixmap pv(150, 150); pv.fill(Qt::green); - int choice = qrand() % 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; @@ -253,7 +254,7 @@ public: QVariant retn; QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300); pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256)); - int choice = qrand() % 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 0a9dee4664..d195675ab8 100644 --- a/tests/benchmarks/qml/painting/paintbenchmark.cpp +++ b/tests/benchmarks/qml/painting/paintbenchmark.cpp @@ -36,6 +36,7 @@ #include <QVBoxLayout> #include <QTime> #include <QDebug> +#include <QRandomGenerator> #include <QStaticText> int iterations = 20; @@ -321,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[rand() % len]); + strings[i] += QChar(chars[QRandomGenerator::global()->bounded(len)]); } } } |