aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-11-15 16:40:38 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2016-11-15 16:44:16 +0100
commitb7a8b5a284bdf306a45b11e1c5ce308be007d1de (patch)
tree35ebcf4b3440abb24df67b579e00847417d42c19 /tests
parent441e6bbdb01733c0f9860ce881b61f5907d2d2f8 (diff)
parent365a3ac6ae50eb53253eca92bfdf4c527b3a5c05 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/qml/jsruntime/qv4string.cpp The conflict resolution for qv4tsring.cpp is to essentially omit the change of commit 64714ea431f2fd355ed27edc69dba4e992511e75 as the code in 5.8 already uses the add/mul_overflow functions. This merge also reverts commit f4ac007f4a19bc095ff15d415a6629986de78e49 as we can deal with dead store elimination now. Change-Id: Iee08c87cbe1a2ff23a73ce621d56262b4e007c56
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/qquicktextedit/data/cursorHeight.qml20
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp38
6 files changed, 123 insertions, 0 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/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.