aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-23 10:49:37 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-23 10:49:37 +0100
commit5d4cbf4094c9b290626aab89e4bd92edd29ce49f (patch)
treeeac893652c724f057fba493688b16e212fd844dd /tests
parent13cf5f02ce788f19a73e5d5c3da76e57291761a5 (diff)
parent07cde200e55ee03bf9e2f9af89c20f91072deccc (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/qml/jsruntime/qv4object_p.h Change-Id: Iff4d3aba7710a999b8befdc493cbe959e1ce02f9
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp27
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.h2
-rw-r--r--tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml9
-rw-r--r--tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp27
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp12
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorHeight.qml20
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp38
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml14
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml14
9 files changed, 157 insertions, 6 deletions
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index d28bbc1ffa..12c33909cf 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -1372,6 +1372,33 @@ void tst_QJSValue::hasProperty_changePrototype()
QVERIFY(obj.hasOwnProperty("foo"));
}
+void tst_QJSValue::hasProperty_QTBUG56830_data()
+{
+ QTest::addColumn<QString>("key");
+ QTest::addColumn<QString>("lookup");
+
+ QTest::newRow("bugreport-1") << QStringLiteral("240000000000") << QStringLiteral("3776798720");
+ QTest::newRow("bugreport-2") << QStringLiteral("240000000001") << QStringLiteral("3776798721");
+ QTest::newRow("biggest-ok-before-bug") << QStringLiteral("238609294221") << QStringLiteral("2386092941");
+ QTest::newRow("smallest-bugged") << QStringLiteral("238609294222") << QStringLiteral("2386092942");
+ QTest::newRow("biggest-bugged") << QStringLiteral("249108103166") << QStringLiteral("12884901886");
+ QTest::newRow("smallest-ok-after-bug") << QStringLiteral("249108103167") << QStringLiteral("12884901887");
+}
+
+void tst_QJSValue::hasProperty_QTBUG56830()
+{
+ QFETCH(QString, key);
+ QFETCH(QString, lookup);
+
+ QJSEngine eng;
+ const QJSValue value(42);
+
+ QJSValue obj = eng.newObject();
+ obj.setProperty(key, value);
+ QVERIFY(obj.hasProperty(key));
+ QVERIFY(!obj.hasProperty(lookup));
+}
+
void tst_QJSValue::deleteProperty_basic()
{
QJSEngine eng;
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
index 6ed880c865..b8b9f4403c 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
@@ -92,6 +92,8 @@ private slots:
void hasProperty_basic();
void hasProperty_globalObject();
void hasProperty_changePrototype();
+ void hasProperty_QTBUG56830_data();
+ void hasProperty_QTBUG56830();
void deleteProperty_basic();
void deleteProperty_globalObject();
diff --git a/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml
new file mode 100644
index 0000000000..d5aa0f102a
--- /dev/null
+++ b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Item {
+ width: 50
+
+ property bool tested: false
+
+ Connections { onWidthChanged: tested = true }
+}
diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
index 615de0885a..b3ac1ce958 100644
--- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
+++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
@@ -52,6 +52,7 @@ private slots:
void rewriteErrors();
void singletonTypeTarget();
void enableDisable_QTBUG_36350();
+ void clearImplicitTarget();
private:
QQmlEngine engine;
@@ -352,6 +353,32 @@ void tst_qqmlconnections::enableDisable_QTBUG_36350()
delete item;
}
+//QTBUG-56499
+void tst_qqmlconnections::clearImplicitTarget()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection-implicit.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ // normal case: fire Connections
+ item->setWidth(100.);
+ QCOMPARE(item->property("tested").toBool(), true);
+
+ item->setProperty("tested", false);
+ // clear the implicit target
+ QQmlConnections *connections = item->findChild<QQmlConnections*>();
+ QVERIFY(connections);
+ connections->setTarget(0);
+
+ // target cleared: no longer fire Connections
+ item->setWidth(150.);
+ QCOMPARE(item->property("tested").toBool(), false);
+
+ delete item;
+}
+
QTEST_MAIN(tst_qqmlconnections)
#include "tst_qqmlconnections.moc"
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 6554d749dd..78322b44a1 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -2726,9 +2726,9 @@ struct TestListener : public QQuickItemChangeListener
{
TestListener(bool remove = false) : remove(remove) { }
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &diff) override
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &oldGeometry) override
{
- record(item, QQuickItemPrivate::Geometry, diff);
+ record(item, QQuickItemPrivate::Geometry, oldGeometry);
}
void itemSiblingOrderChanged(QQuickItem *item) override
{
@@ -2810,20 +2810,20 @@ void tst_QQuickItem::changeListener()
item->setImplicitWidth(10);
QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitWidth), 1);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 1);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,0)));
item->setImplicitHeight(20);
QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitHeight), 1);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 2);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,20)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0)));
item->setWidth(item->width() + 30);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 3);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,30,0)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,20)));
item->setHeight(item->height() + 40);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 4);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,40)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,40,20)));
item->setOpacity(0.5);
QCOMPARE(itemListener.count(QQuickItemPrivate::Opacity), 1);
diff --git a/tests/auto/quick/qquicktextedit/data/cursorHeight.qml b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml
new file mode 100644
index 0000000000..b831a9eb6f
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 300
+ height: 300
+ color: "white"
+
+ TextEdit {
+ objectName: "textEditObject"
+ width: 300
+ height: 300
+ text: "<span style=\"font-size:20pt;\">Blah</span><br>blah"
+ textFormat: TextEdit.RichText
+ cursorDelegate: Rectangle {
+ objectName: "cursorInstance"
+ color: "red"
+ width: 2
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 5ed0e9eea7..5d30cc8c94 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -140,6 +140,7 @@ private slots:
void cursorVisible();
void delegateLoading_data();
void delegateLoading();
+ void cursorDelegateHeight();
void navigation();
void readOnly();
#ifndef QT_NO_CLIPBOARD
@@ -2848,6 +2849,43 @@ void tst_qquicktextedit::delegateLoading()
//QVERIFY(!delegate);
}
+void tst_qquicktextedit::cursorDelegateHeight()
+{
+ QQuickView view(testFileUrl("cursorHeight.qml"));
+ view.show();
+ view.requestActivate();
+ QTest::qWaitForWindowActive(&view);
+ QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
+ QVERIFY(textEditObject);
+ // Delegate creation is deferred until focus in or cursor visibility is forced.
+ QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
+ QVERIFY(!textEditObject->isCursorVisible());
+
+ // Test that the delegate gets created.
+ textEditObject->setFocus(true);
+ QVERIFY(textEditObject->isCursorVisible());
+ QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+
+ const int largerHeight = textEditObject->cursorRectangle().height();
+
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x());
+ QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y());
+ QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height());
+
+ // Move the cursor to the next line, which has a smaller font.
+ textEditObject->setCursorPosition(5);
+ QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x());
+ QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y());
+ QVERIFY(textEditObject->cursorRectangle().height() < largerHeight);
+ QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height());
+
+ // Test that the delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
/*
TextEdit element should only handle left/right keys until the cursor reaches
the extent of the text, then they should ignore the keys.
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml
new file mode 100644
index 0000000000..b8f0458818
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ Text {
+ anchors.centerIn: parent
+ font.family: "Arial"
+ font.pixelSize: 16
+ textFormat: Text.RichText
+ text: "<img width=16 height=16 src=\"data/logo.png\" />This image is in the start of the text"
+ }
+}
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml
new file mode 100644
index 0000000000..e5bea08e62
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ Text {
+ anchors.centerIn: parent
+ font.family: "Arial"
+ font.pixelSize: 16
+ textFormat: Text.RichText
+ text: "<img width=16 height=16 src=\"data/logo.png\" />هو أمّا حكومة"
+ }
+}