aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-02-27 08:43:10 +0100
committerLiang Qi <liang.qi@qt.io>2018-02-27 08:43:10 +0100
commitbb7a5d0cb6e62fa411e8b66759bf6b798c3f68d9 (patch)
tree06c325dc386afd26281ba0ebdbf4fd3f56f892b0 /tests/auto/qml/qjsengine
parent41edb3bd9f373a865d5698ac8c18bf341071eae9 (diff)
parente41d067227eb6225b05df88ab724708588fa5304 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/parser/qqmljslexer.cpp src/qml/qml/v8/qv8engine.cpp src/qml/util/qqmladaptormodel_p.h src/quick/items/qquickanimatedsprite.cpp tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
Diffstat (limited to 'tests/auto/qml/qjsengine')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp56
1 files changed, 25 insertions, 31 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 73e10e5dc4..9dc088486b 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -618,10 +618,10 @@ void tst_QJSEngine::newQObject()
QObject temp;
{
- QJSValue qobject = eng.newQObject(0);
+ QJSValue qobject = eng.newQObject(nullptr);
QCOMPARE(qobject.isNull(), true);
QCOMPARE(qobject.isObject(), false);
- QCOMPARE(qobject.toQObject(), (QObject *)0);
+ QCOMPARE(qobject.toQObject(), (QObject *)nullptr);
}
{
QJSValue qobject = eng.newQObject(&temp);
@@ -642,7 +642,7 @@ void tst_QJSEngine::newQObject_ownership()
QJSEngine eng;
{
QPointer<QObject> ptr = new QObject();
- QVERIFY(ptr != 0);
+ QVERIFY(ptr != nullptr);
{
QJSValue v = eng.newQObject(ptr);
}
@@ -653,7 +653,7 @@ void tst_QJSEngine::newQObject_ownership()
}
{
QPointer<QObject> ptr = new QObject(this);
- QVERIFY(ptr != 0);
+ QVERIFY(ptr != nullptr);
{
QJSValue v = eng.newQObject(ptr);
}
@@ -668,11 +668,11 @@ void tst_QJSEngine::newQObject_ownership()
QJSValue v = eng.newQObject(child);
QCOMPARE(v.toQObject(), child);
delete parent;
- QCOMPARE(v.toQObject(), (QObject *)0);
+ QCOMPARE(v.toQObject(), (QObject *)nullptr);
}
{
QPointer<QObject> ptr = new QObject();
- QVERIFY(ptr != 0);
+ QVERIFY(ptr != nullptr);
{
QJSValue v = eng.newQObject(ptr);
}
@@ -685,18 +685,18 @@ void tst_QJSEngine::newQObject_ownership()
{
QObject *parent = new QObject();
QPointer<QObject> child = new QObject(parent);
- QVERIFY(child != 0);
+ QVERIFY(child != nullptr);
{
QJSValue v = eng.newQObject(child);
}
eng.collectGarbage();
// has parent, so it should be like QtOwnership
- QVERIFY(child != 0);
+ QVERIFY(child != nullptr);
delete parent;
}
{
QPointer<QObject> ptr = new QObject();
- QVERIFY(ptr != 0);
+ QVERIFY(ptr != nullptr);
{
QQmlEngine::setObjectOwnership(ptr.data(), QQmlEngine::CppOwnership);
QJSValue v = eng.newQObject(ptr);
@@ -738,23 +738,18 @@ public:
};
Q_ENUMS(Enum1 Enum2)
- Q_INVOKABLE TestQMetaObject()
- : m_called(1) {
- }
+ Q_INVOKABLE TestQMetaObject() {}
Q_INVOKABLE TestQMetaObject(int)
- : m_called(2) {
- }
+ : m_called(2) {}
Q_INVOKABLE TestQMetaObject(QString)
- : m_called(3) {
- }
+ : m_called(3) {}
Q_INVOKABLE TestQMetaObject(QString, int)
- : m_called(4) {
- }
+ : m_called(4) {}
int called() const {
return m_called;
}
private:
- int m_called;
+ int m_called = 1;
};
void tst_QJSEngine::newQObjectPropertyCache()
@@ -1303,8 +1298,8 @@ void tst_QJSEngine::errorMessage_QT679()
struct Foo {
public:
- int x, y;
- Foo() : x(-1), y(-1) { }
+ int x = -1, y = -1;
+ Foo() {}
};
Q_DECLARE_METATYPE(Foo)
@@ -1380,7 +1375,7 @@ void tst_QJSEngine::valueConversion_basic()
QCOMPARE(eng.fromScriptValue<QChar>(eng.toScriptValue(c)), c);
}
- QVERIFY(eng.toScriptValue(static_cast<void *>(0)).isNull());
+ QVERIFY(eng.toScriptValue(static_cast<void *>(nullptr)).isNull());
}
void tst_QJSEngine::valueConversion_QVariant()
@@ -1466,7 +1461,7 @@ void tst_QJSEngine::valueConversion_QVariant()
QCOMPARE(qjsvalue_cast<QVariant>(QJSValue(123)), QVariant(123));
- QVERIFY(eng.toScriptValue(QVariant(QMetaType::VoidStar, 0)).isNull());
+ QVERIFY(eng.toScriptValue(QVariant(QMetaType::VoidStar, nullptr)).isNull());
QVERIFY(eng.toScriptValue(QVariant::fromValue(nullptr)).isNull());
{
@@ -1577,7 +1572,7 @@ class Klazz : public QWidget,
Q_INTERFACES(QGraphicsItem)
Q_OBJECT
public:
- Klazz(QWidget *parent = 0) : QWidget(parent) { }
+ Klazz(QWidget *parent = nullptr) : QWidget(parent) { }
virtual QRectF boundingRect() const { return QRectF(); }
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) { }
};
@@ -1606,7 +1601,7 @@ void tst_QJSEngine::collectGarbage()
a = eng.newObject();
a = eng.newObject();
QPointer<QObject> ptr = new QObject();
- QVERIFY(ptr != 0);
+ QVERIFY(ptr != nullptr);
(void)eng.newQObject(ptr);
eng.collectGarbage();
if (ptr)
@@ -3159,10 +3154,9 @@ class ThreadedTestEngine : public QThread {
Q_OBJECT;
public:
- int result;
+ int result = 0;
- ThreadedTestEngine()
- : result(0) {}
+ ThreadedTestEngine() {}
void run() {
QJSEngine firstEngine;
@@ -3375,7 +3369,7 @@ void tst_QJSEngine::dynamicProperties()
QQmlEngine qmlEngine;
QQmlComponent component(&qmlEngine);
component.setData("import QtQml 2.0; QtObject { property QtObject subObject: QtObject {} }", QUrl());
- QObject *root = component.create(0);
+ QObject *root = component.create(nullptr);
QVERIFY(root);
QVERIFY(qmlContext(root));
@@ -4061,9 +4055,9 @@ class TestObject : public QObject
{
Q_OBJECT
public:
- TestObject() : called(false) {}
+ TestObject() {}
- bool called;
+ bool called = false;
Q_INVOKABLE void callMe(QQmlV4Function *) {
called = true;