aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-11 11:08:11 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-02-11 12:00:31 +0100
commit7c9497a6d47a02d961baef3993ba4cf4267ec607 (patch)
tree335fae3e9e3a84d33310efca23f1d6993265805b /tests
parent67ba88947f57ab2d1859bbeb96c6dcba020561b1 (diff)
parent6c840c70d61c3ae277b60a024a086215c743e5b3 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/jsruntime/qv4arrayobject.cpp src/qml/jsruntime/qv4context.cpp Change-Id: Ied5b23bec4dc14abe51127c507aed668f855c1e1
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp24
-rw-r--r--tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml13
-rw-r--r--tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml9
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp15
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp1
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp1
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp6
-rw-r--r--tests/auto/quick/qquicklistview/data/headerCrash.qml20
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp39
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp1
11 files changed, 120 insertions, 15 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 529b97ed89..bb5f83bed1 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -47,6 +47,7 @@
#include <qgraphicsitem.h>
#include <qstandarditemmodel.h>
#include <QtCore/qnumeric.h>
+#include <qqmlengine.h>
#include <stdlib.h>
#include <private/qv4alloca_p.h>
@@ -82,6 +83,7 @@ private slots:
void newQObject();
void newQObject_ownership();
void newQObject_deletedEngine();
+ void exceptionInSlot();
void globalObjectProperties();
void globalObjectEquals();
void globalObjectProperties_enumerate();
@@ -145,6 +147,9 @@ private slots:
void arrayPop_QTBUG_35979();
void regexpLastMatch();
+
+signals:
+ void testSignal();
};
tst_QJSEngine::tst_QJSEngine()
@@ -507,6 +512,25 @@ void tst_QJSEngine::newQObject_deletedEngine()
QTRY_VERIFY(spy.count());
}
+void tst_QJSEngine::exceptionInSlot()
+{
+ QJSEngine engine;
+ QJSValue wrappedThis = engine.newQObject(this);
+ QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
+ engine.globalObject().setProperty("testCase", wrappedThis);
+ engine.evaluate(
+ "var called = false\n"
+ "function throwingSlot() {\n"
+ " called = true\n"
+ " throw 42;\n"
+ "}\n"
+ "testCase.testSignal.connect(throwingSlot)\n"
+ );
+ QCOMPARE(engine.globalObject().property("called").toBool(), false);
+ emit testSignal();
+ QCOMPARE(engine.globalObject().property("called").toBool(), true);
+}
+
void tst_QJSEngine::globalObjectProperties()
{
// See ECMA-262 Section 15.1, "The Global Object".
diff --git a/tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml b/tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml
new file mode 100644
index 0000000000..81cb56f0e5
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Item
+{
+ property int someInt: 4
+ property var variantArray: [1, 2]
+ property int arrayLength: 0
+
+ onSomeIntChanged:
+ {
+ arrayLength = variantArray.length
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml b/tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml
new file mode 100644
index 0000000000..2f55ff0709
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.1
+
+LazyBindingComponent
+{
+ someInt: 5
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
index 8d08cc5559..8847055a70 100644
--- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
@@ -141,6 +141,15 @@ Item {
expected = 7;
if (poppedVal != expected) success = false;
+ // push
+ msco.stringListProperty = [ "one", "two" ]
+ msco.stringListProperty.push("three")
+ expected = [ "one", "two", "three" ]
+ if (msco.stringListProperty.toString() != expected.toString()) success = false;
+ msco.stringListProperty.push("four", "five")
+ expected = [ "one", "two", "three", "four", "five" ]
+ if (msco.stringListProperty.toString() != expected.toString()) success = false;
+
// concat
msco.stringListProperty = [ "one", "two" ]
stringList = [ "hello", "world" ]
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 6163628ab5..a39564bd19 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -317,6 +317,7 @@ private slots:
void qtbug_34792();
void noCaptureWhenWritingProperty();
void singletonWithEnum();
+ void lazyBindingEvaluation();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -663,7 +664,7 @@ void tst_qqmlecmascript::methods()
void tst_qqmlecmascript::bindingLoop()
{
QQmlComponent component(&engine, testFileUrl("bindingLoop.qml"));
- QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
+ QString warning = component.url().toString() + ":9:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QObject *object = component.create();
QVERIFY(object != 0);
@@ -7533,6 +7534,18 @@ void tst_qqmlecmascript::singletonWithEnum()
QCOMPARE(prop.toInt(), int(SingletonWithEnum::TestValue));
}
+void tst_qqmlecmascript::lazyBindingEvaluation()
+{
+ QQmlComponent component(&engine, testFileUrl("lazyBindingEvaluation.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ if (obj.isNull())
+ qDebug() << component.errors().first().toString();
+ QVERIFY(!obj.isNull());
+ QVariant prop = obj->property("arrayLength");
+ QVERIFY(prop.type() == QVariant::Int);
+ QCOMPARE(prop.toInt(), 2);
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index e44d5aa8d5..95ca8b5c94 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -67,6 +67,7 @@ void tst_QQMLTypeLoader::testLoadComplete()
QTRY_VERIFY(rootObject != 0);
QTRY_COMPARE(rootObject->property("created").toInt(), 2);
QTRY_COMPARE(rootObject->property("loaded").toInt(), 2);
+ delete window;
}
QTEST_MAIN(tst_QQMLTypeLoader)
diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp
index 7c84cdb5cf..662e78ef6c 100644
--- a/tests/auto/quick/nodes/tst_nodestest.cpp
+++ b/tests/auto/quick/nodes/tst_nodestest.cpp
@@ -98,7 +98,6 @@ void NodesTest::initTestCase()
void NodesTest::cleanupTestCase()
{
renderContext->invalidate();
- delete renderContext;
context->doneCurrent();
delete context;
delete surface;
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index 06dc348f61..54eb3509bd 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -379,11 +379,11 @@ void tst_QQuickAccessible::hitTest()
void tst_QQuickAccessible::checkableTest()
{
- QQuickView *window = new QQuickView();
+ QScopedPointer<QQuickView> window(new QQuickView());
window->setSource(testFileUrl("checkbuttons.qml"));
window->show();
window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickItem *contentItem = window->contentItem();
QVERIFY(contentItem);
@@ -394,7 +394,7 @@ void tst_QQuickAccessible::checkableTest()
QAccessible::State activatedChange;
activatedChange.active = true;
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window);
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window.data());
QVERIFY(iface);
QAccessibleInterface *root = iface->child(0);
diff --git a/tests/auto/quick/qquicklistview/data/headerCrash.qml b/tests/auto/quick/qquicklistview/data/headerCrash.qml
new file mode 100644
index 0000000000..124fa894f2
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/headerCrash.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+ListView {
+ id: myList
+
+ width: 400; height: 400
+ model: 10
+
+ header: Item {
+ height: parent ? 20 : 10
+ width: 400
+ }
+
+ delegate: Rectangle {
+ width: parent.width; height: 20
+ color: index % 2 ? "green" : "red"
+ }
+
+ Component.onCompleted: myList.verticalLayoutDirection = ListView.BottomToTop
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index f741fec159..7d0b76ad63 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -219,6 +219,8 @@ private slots:
void highlightItemGeometryChanges();
+ void QTBUG_36481();
+
private:
template <class T> void items(const QUrl &source);
template <class T> void changed(const QUrl &source);
@@ -3918,7 +3920,8 @@ void tst_QQuickListView::extents()
QFETCH(QPointF, minPos);
QFETCH(QPointF, maxPos);
QFETCH(QPointF, origin_empty);
- QFETCH(QPointF, origin_nonEmpty);
+ QFETCH(QPointF, origin_short);
+ QFETCH(QPointF, origin_long);
QQuickView *window = getView();
@@ -3955,12 +3958,20 @@ void tst_QQuickListView::extents()
QCOMPARE(listview->originX(), origin_empty.x());
QCOMPARE(listview->originY(), origin_empty.y());
- for (int i=0; i<30; i++)
+
+ for (int i=0; i<3; i++)
+ model.addItem("Item" + QString::number(i), "");
+ listview->forceLayout();
+ QTRY_COMPARE(listview->count(), model.count());
+ QCOMPARE(listview->originX(), origin_short.x());
+ QCOMPARE(listview->originY(), origin_short.y());
+
+ for (int i=3; i<30; i++)
model.addItem("Item" + QString::number(i), "");
listview->forceLayout();
QTRY_COMPARE(listview->count(), model.count());
- QCOMPARE(listview->originX(), origin_nonEmpty.x());
- QCOMPARE(listview->originY(), origin_nonEmpty.y());
+ QCOMPARE(listview->originX(), origin_long.x());
+ QCOMPARE(listview->originY(), origin_long.y());
releaseView(window);
}
@@ -3975,7 +3986,8 @@ void tst_QQuickListView::extents_data()
QTest::addColumn<QPointF>("minPos");
QTest::addColumn<QPointF>("maxPos");
QTest::addColumn<QPointF>("origin_empty");
- QTest::addColumn<QPointF>("origin_nonEmpty");
+ QTest::addColumn<QPointF>("origin_short");
+ QTest::addColumn<QPointF>("origin_long");
// header is 240x20 (or 20x320 in Horizontal orientation)
// footer is 240x30 (or 30x320 in Horizontal orientation)
@@ -3984,25 +3996,25 @@ void tst_QQuickListView::extents_data()
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
<< QPointF(0, -20) << QPointF(0, 0)
<< QPointF(0, 20) << QPointF(240, 20)
- << QPointF(0, -20) << QPointF(0, -20);
+ << QPointF(0, -20) << QPointF(0, -20) << QPointF(0, -20);
QTest::newRow("Vertical, BottomToTop")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
<< QPointF(0, 0) << QPointF(0, -30)
<< QPointF(0, 320 - 20) << QPointF(240, 320 - 20) // content flow is reversed
- << QPointF(0, -30) << QPointF(0, (-30.0 * 30) - 30);
+ << QPointF(0, -30) << QPointF(0, (-30.0 * 3) - 30) << QPointF(0, (-30.0 * 30) - 30);
QTest::newRow("Horizontal, LeftToRight")
<< QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
<< QPointF(-20, 0) << QPointF(0, 0)
<< QPointF(20, 0) << QPointF(20, 320)
- << QPointF(-20, 0) << QPointF(-20, 0);
+ << QPointF(-20, 0) << QPointF(-20, 0) << QPointF(-20, 0);
QTest::newRow("Horizontal, RightToLeft")
<< QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
<< QPointF(0, 0) << QPointF(-30, 0)
<< QPointF(240 - 20, 0) << QPointF(240 - 20, 320) // content flow is reversed
- << QPointF(-30, 0) << QPointF((-240.0 * 30) - 30, 0);
+ << QPointF(-30, 0) << QPointF((-240.0 * 3) - 30, 0) << QPointF((-240.0 * 30) - 30, 0);
}
void tst_QQuickListView::resetModel_headerFooter()
@@ -7096,6 +7108,15 @@ void tst_QQuickListView::highlightItemGeometryChanges()
}
}
+void tst_QQuickListView::QTBUG_36481()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("headerCrash.qml"));
+
+ // just testing that we don't crash when creating
+ QScopedPointer<QObject> object(component.create());
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 31b323af5d..d0a1c18885 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -933,7 +933,6 @@ void tst_QQuickMouseArea::preventStealing()
void tst_QQuickMouseArea::clickThrough()
{
- QSKIP("QTBUG-23976 Unstable");
//With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
QScopedPointer<QQuickView> window(new QQuickView);
QByteArray errorMessage;