aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-25 23:35:34 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-25 23:35:34 +0100
commitcc1c3d0e2be6dfea6befebdc5f25e519e3fe79b2 (patch)
treef160486b34c9157f42e12b23f2e0a3dd9aa2ef1b /tests
parent7fa08472d32055a3d6e8b775b843f38ef65e9ce6 (diff)
parent4fae8ff1e73eeb48734b28a9c846fbdff1c2ffe1 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.75.7
Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp src/quick/util/qquickprofiler_p.h Change-Id: I11a89c2a166115d6697adfba09928805643e709e
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp8
-rw-r--r--tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml27
-rw-r--r--tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp13
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp34
-rw-r--r--tests/benchmarks/qml/creation/tst_creation.cpp8
5 files changed, 88 insertions, 2 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 63fefbe9f1..e8cff9affe 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -192,6 +192,8 @@ private slots:
void withNoContext();
void holeInPropertyData();
+ void malformedExpression();
+
signals:
void testSignal();
};
@@ -3876,6 +3878,12 @@ void tst_QJSEngine::holeInPropertyData()
QVERIFY(ok.toBool());
}
+void tst_QJSEngine::malformedExpression()
+{
+ QJSEngine engine;
+ engine.evaluate("5%55555&&5555555\n7-0");
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"
diff --git a/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml
new file mode 100644
index 0000000000..6bf750dcda
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.0
+
+QtObject {
+ property ListModel model: ListModel {
+ ListElement { modified: false }
+ ListElement { modified: false }
+ ListElement { modified: false }
+ ListElement { modified: false }
+ ListElement { modified: false }
+ }
+
+ property bool isModified: {
+ for (var i = 0; i < model.count; ++i) {
+ if (model.get(i).modified)
+ return true;
+ }
+ return false;
+ }
+
+ property bool success: false
+ Component.onCompleted: {
+ // trigger read and setup of property captures
+ success = isModified
+ model.setProperty(0, "modified", true)
+ success = isModified
+ }
+}
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
index cd497cbd79..555ca5713e 100644
--- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
+++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
@@ -122,6 +122,7 @@ private slots:
void datetime_data();
void about_to_be_signals();
void modify_through_delegate();
+ void bindingsOnGetResult();
};
bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object)
@@ -1469,6 +1470,18 @@ void tst_qqmllistmodel::modify_through_delegate()
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18);
}
+void tst_qqmllistmodel::bindingsOnGetResult()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("bindingsOnGetResult.qml"));
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+
+ QVERIFY(obj->property("success").toBool());
+}
+
QTEST_MAIN(tst_qqmllistmodel)
#include "tst_qqmllistmodel.moc"
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 300f5b90e5..0d9a561378 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -89,6 +89,7 @@ private slots:
void customValueTypeInQml();
void gadgetInheritance();
void toStringConversion();
+ void enumProperties();
private:
QQmlEngine engine;
@@ -1649,6 +1650,39 @@ void tst_qqmlvaluetypes::toStringConversion()
QCOMPARE(stringConversion.toString(), StringLessGadget_to_QString(g));
}
+struct GadgetWithEnum
+{
+ Q_GADGET
+public:
+
+ enum MyEnum { FirstValue, SecondValue };
+
+ Q_ENUM(MyEnum)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty)
+
+ MyEnum enumProperty() const { return SecondValue; }
+};
+
+void tst_qqmlvaluetypes::enumProperties()
+{
+ QJSEngine engine;
+
+ // When creating the property cache for the gadget when MyEnum is _not_ a registered
+ // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently
+ // property-read meta-calls will return an int (as expected in this test). However if we
+ // explicitly register the gadget, then QMetaProperty::type() will return the user-type
+ // and QQmlValueTypeWrapper should still handle that and return an integer/number for the
+ // enum property when it is read.
+ qRegisterMetaType<GadgetWithEnum::MyEnum>();
+
+ GadgetWithEnum g;
+ QJSValue value = engine.toScriptValue(g);
+
+ QJSValue enumValue = value.property("enumProperty");
+ QVERIFY(enumValue.isNumber());
+ QCOMPARE(enumValue.toInt(), int(g.enumProperty()));
+}
+
QTEST_MAIN(tst_qqmlvaluetypes)
diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp
index e5ad04b92f..c835e4799c 100644
--- a/tests/benchmarks/qml/creation/tst_creation.cpp
+++ b/tests/benchmarks/qml/creation/tst_creation.cpp
@@ -215,12 +215,15 @@ inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent)
void tst_creation::itemtree_notree_cpp()
{
+ std::vector<QQuickItem *> kids;
+ kids.resize(30);
QBENCHMARK {
QQuickItem *item = new QQuickItem;
for (int i = 0; i < 30; ++i) {
QQuickItem *child = new QQuickItem;
- Q_UNUSED(child);
+ kids[i] = child;
}
+ qDeleteAll(kids);
delete item;
}
}
@@ -252,12 +255,13 @@ void tst_creation::itemtree_cpp()
void tst_creation::itemtree_data_cpp()
{
+ QQmlEngine engine;
QBENCHMARK {
QQuickItem *item = new QQuickItem;
for (int i = 0; i < 30; ++i) {
QQuickItem *child = new QQuickItem;
QQmlGraphics_setParent_noEvent(child,item);
- QQmlListReference ref(item, "data");
+ QQmlListReference ref(item, "data", &engine);
ref.append(child);
}
delete item;