aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorTony Sarajärvi <tony.sarajarvi@digia.com>2014-04-24 10:38:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-24 10:38:56 +0200
commitd71fb383337b45c31653e54345bff58cf419af19 (patch)
treecedb42b21569992a17f715394b0efe88a3d29128 /tests/auto
parent6c733c2c2ffd3fb1fb5c43af9cce59b9a7b8a510 (diff)
parent7d16c2f40a2995c6bdff3a1999a7cb6100fdf301 (diff)
Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp34
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignNullStrings.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h11
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp14
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml2
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml23
-rw-r--r--tests/auto/qmltest/pathview/tst_pathview.qml35
-rw-r--r--tests/auto/quick/qquickitem2/data/keysforward.qml84
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp73
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp2
-rw-r--r--tests/auto/quick/qquicktextinput/qquicktextinput.pro2
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp3
12 files changed, 284 insertions, 8 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 0a56c2f6d0..64c6754aa7 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -48,6 +48,7 @@
#include <qstandarditemmodel.h>
#include <QtCore/qnumeric.h>
#include <qqmlengine.h>
+#include <qqmlcomponent.h>
#include <stdlib.h>
#include <private/qv4alloca_p.h>
@@ -2964,11 +2965,34 @@ void tst_QJSEngine::prototypeChainGc()
void tst_QJSEngine::dynamicProperties()
{
- QJSEngine engine;
- QObject *obj = new QObject;
- QJSValue wrapper = engine.newQObject(obj);
- wrapper.setProperty("someRandomProperty", 42);
- QCOMPARE(wrapper.property("someRandomProperty").toInt(), 42);
+ {
+ QJSEngine engine;
+ QObject *obj = new QObject;
+ QJSValue wrapper = engine.newQObject(obj);
+ wrapper.setProperty("someRandomProperty", 42);
+ QCOMPARE(wrapper.property("someRandomProperty").toInt(), 42);
+ QVERIFY(!qmlContext(obj));
+ }
+ {
+ QQmlEngine qmlEngine;
+ QQmlComponent component(&qmlEngine);
+ component.setData("import QtQml 2.0; QtObject { property QtObject subObject: QtObject {} }", QUrl());
+ QObject *root = component.create(0);
+ QVERIFY(root);
+ QVERIFY(qmlContext(root));
+
+ QJSValue wrapper = qmlEngine.newQObject(root);
+ wrapper.setProperty("someRandomProperty", 42);
+ QVERIFY(!wrapper.hasProperty("someRandomProperty"));
+
+ QObject *subObject = qvariant_cast<QObject*>(root->property("subObject"));
+ QVERIFY(subObject);
+ QVERIFY(qmlContext(subObject));
+
+ wrapper = qmlEngine.newQObject(subObject);
+ wrapper.setProperty("someRandomProperty", 42);
+ QVERIFY(!wrapper.hasProperty("someRandomProperty"));
+ }
}
QTEST_MAIN(tst_QJSEngine)
diff --git a/tests/auto/qml/qqmllanguage/data/assignNullStrings.qml b/tests/auto/qml/qqmllanguage/data/assignNullStrings.qml
new file mode 100644
index 0000000000..5e1c3a9b03
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/assignNullStrings.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+MyTypeObject {
+ stringProperty: ""
+ byteArrayProperty: ""
+ function assignNullStringsFromJs() {
+ stringProperty = ""
+ byteArrayProperty = ""
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 6a6b2eba45..1c13a2e21c 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -236,6 +236,7 @@ class MyTypeObject : public QObject
Q_PROPERTY(MyMirroredEnum mirroredEnumProperty READ mirroredEnumProperty WRITE setMirroredEnumProperty NOTIFY mirroredEnumPropertyChanged)
Q_PROPERTY(MyEnumContainer::RelatedEnum relatedEnumProperty READ relatedEnumProperty WRITE setRelatedEnumProperty)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringPropertyChanged)
+ Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty NOTIFY byteArrayPropertyChanged)
Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty NOTIFY uintPropertyChanged)
Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty NOTIFY realPropertyChanged)
@@ -357,6 +358,15 @@ public:
emit stringPropertyChanged();
}
+ QByteArray byteArrayPropertyValue;
+ QByteArray byteArrayProperty() const {
+ return byteArrayPropertyValue;
+ }
+ void setByteArrayProperty(const QByteArray &v) {
+ byteArrayPropertyValue = v;
+ emit byteArrayPropertyChanged();
+ }
+
uint uintPropertyValue;
uint uintProperty() const {
return uintPropertyValue;
@@ -570,6 +580,7 @@ signals:
void qtEnumPropertyChanged();
void mirroredEnumPropertyChanged();
void stringPropertyChanged();
+ void byteArrayPropertyChanged();
void uintPropertyChanged();
void intPropertyChanged();
void realPropertyChanged();
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 55d07e78da..87f811cbbc 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -110,6 +110,7 @@ private slots:
void assignLiteralToVariant();
void assignLiteralToVar();
void assignLiteralToJSValue();
+ void assignNullStrings();
void bindJSValueToVar();
void bindJSValueToVariant();
void bindJSValueToType();
@@ -873,6 +874,19 @@ void tst_qqmllanguage::assignLiteralToJSValue()
}
}
+void tst_qqmllanguage::assignNullStrings()
+{
+ QQmlComponent component(&engine, testFileUrl("assignNullStrings.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->stringProperty().isNull());
+ QVERIFY(object->byteArrayProperty().isNull());
+ QMetaObject::invokeMethod(object, "assignNullStringsFromJs", Qt::DirectConnection);
+ QVERIFY(object->stringProperty().isNull());
+ QVERIFY(object->byteArrayProperty().isNull());
+}
+
void tst_qqmllanguage::bindJSValueToVar()
{
QQmlComponent component(&engine, testFileUrl("assignLiteralToJSValue.qml"));
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml b/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml
index f44f4f926c..b35c31d513 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml
@@ -8,7 +8,7 @@ Item {
SequentialAnimation {
id: anim
- PauseAnimation { duration: 525 } // delay mode is 500 msec.
+ PauseAnimation { duration: 1000 } // delay mode is 500 msec.
ScriptAction { script: loadcomponent(0) }
PauseAnimation { duration: 525 } // delay mode is 500 msec.
ScriptAction { script: loadcomponent(1) }
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml
index 0589e7c46b..03be57909f 100644
--- a/tests/auto/qmltest/listview/tst_listview.qml
+++ b/tests/auto/qmltest/listview/tst_listview.qml
@@ -102,6 +102,23 @@ Item {
}
}
+ ListView {
+ id: listViewDelegateModelAfterCreate
+ anchors.fill: parent
+ property int createdDelegates: 0
+ }
+
+ Component {
+ id: delegateModelAfterCreateComponent
+ Rectangle {
+ width: 140
+ height: 140
+ border.color: "black"
+ color: "red"
+ Component.onCompleted: listViewDelegateModelAfterCreate.createdDelegates++;
+ }
+ }
+
ListModel { id: emptymodel }
ListModel { id: manyitems }
ListModel { id: firstmodel; ListElement { name: "FirstModelElement0" } }
@@ -249,5 +266,11 @@ Item {
asyncListViewLoaderView.currentIndex = 4;
}
}
+
+ function test_set_delegate_model_after_list_creation() {
+ listViewDelegateModelAfterCreate.delegate = delegateModelAfterCreateComponent;
+ listViewDelegateModelAfterCreate.model = 40;
+ verify(listViewDelegateModelAfterCreate.createdDelegates > 0);
+ }
}
}
diff --git a/tests/auto/qmltest/pathview/tst_pathview.qml b/tests/auto/qmltest/pathview/tst_pathview.qml
new file mode 100644
index 0000000000..820034c960
--- /dev/null
+++ b/tests/auto/qmltest/pathview/tst_pathview.qml
@@ -0,0 +1,35 @@
+import QtQuick 2.1
+import QtTest 1.0
+
+Item {
+ id: top
+
+ PathView {
+ id: pathViewDelegateModelAfterCreate
+ anchors.fill: parent
+ property int createdDelegates: 0
+ path: Path { startX: 120; startY: 100 }
+ }
+
+ Component {
+ id: delegateModelAfterCreateComponent
+ Rectangle {
+ width: 140
+ height: 140
+ border.color: "black"
+ color: "red"
+ Component.onCompleted: pathViewDelegateModelAfterCreate.createdDelegates++;
+ }
+ }
+
+ TestCase {
+ name: "PathView"
+ when: windowShown
+
+ function test_set_delegate_model_after_path_creation() {
+ pathViewDelegateModelAfterCreate.delegate = delegateModelAfterCreateComponent;
+ pathViewDelegateModelAfterCreate.model = 40;
+ verify(pathViewDelegateModelAfterCreate.createdDelegates > 0);
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/data/keysforward.qml b/tests/auto/quick/qquickitem2/data/keysforward.qml
new file mode 100644
index 0000000000..f0cb4d9508
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/keysforward.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ property alias source: source
+ property alias primaryTarget: primaryTarget
+ property alias secondaryTarget: secondaryTarget
+
+ property var pressedKeys: []
+ property var releasedKeys: []
+ Keys.onPressed: { var keys = pressedKeys; keys.push(event.key); pressedKeys = keys }
+ Keys.onReleased: { var keys = releasedKeys; keys.push(event.key); releasedKeys = keys }
+
+ Item {
+ id: primaryTarget
+ objectName: "primary"
+ property var pressedKeys: []
+ property var releasedKeys: []
+ Keys.forwardTo: secondaryTarget
+ Keys.onPressed: { event.accepted = event.key === Qt.Key_P; var keys = pressedKeys; keys.push(event.key); pressedKeys = keys }
+ Keys.onReleased: { event.accepted = event.key === Qt.Key_P; var keys = releasedKeys; keys.push(event.key); releasedKeys = keys }
+
+ Item {
+ id: source
+ objectName: "source"
+ property var pressedKeys: []
+ property var releasedKeys: []
+ Keys.forwardTo: primaryTarget
+ Keys.onPressed: { var keys = pressedKeys; keys.push(event.key); pressedKeys = keys }
+ Keys.onReleased: { var keys = releasedKeys; keys.push(event.key); releasedKeys = keys }
+ }
+ }
+
+ Item {
+ id: secondaryTarget
+ objectName: "secondary"
+ property var pressedKeys: []
+ property var releasedKeys: []
+ Keys.onPressed: { event.accepted = event.key === Qt.Key_S; var keys = pressedKeys; keys.push(event.key); pressedKeys = keys }
+ Keys.onReleased: { event.accepted = event.key === Qt.Key_S; var keys = releasedKeys; keys.push(event.key); releasedKeys = keys }
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index e6fd98ac35..6778d6a8b6 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -85,6 +85,7 @@ private slots:
void standardKeys();
void keysProcessingOrder();
void keysim();
+ void keysForward();
void keyNavigation_data();
void keyNavigation();
void keyNavigation_RightToLeft();
@@ -1386,6 +1387,78 @@ void tst_QQuickItem::keysim()
delete window;
}
+void tst_QQuickItem::keysForward()
+{
+ QQuickView window;
+ window.setBaseSize(QSize(240,320));
+
+ window.setSource(testFileUrl("keysforward.qml"));
+ window.show();
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QVERIFY(QGuiApplication::focusWindow() == &window);
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(window.rootObject());
+ QVERIFY(rootItem);
+ QQuickItem *sourceItem = rootItem->property("source").value<QQuickItem *>();
+ QVERIFY(sourceItem);
+ QQuickItem *primaryTarget = rootItem->property("primaryTarget").value<QQuickItem *>();
+ QVERIFY(primaryTarget);
+ QQuickItem *secondaryTarget = rootItem->property("secondaryTarget").value<QQuickItem *>();
+ QVERIFY(secondaryTarget);
+
+ // primary target accepts/consumes Key_P
+ QKeyEvent pressKeyP(QEvent::KeyPress, Qt::Key_P, Qt::NoModifier, "P");
+ QCoreApplication::sendEvent(sourceItem, &pressKeyP);
+ QCOMPARE(rootItem->property("pressedKeys").toList(), QVariantList());
+ QCOMPARE(sourceItem->property("pressedKeys").toList(), QVariantList());
+ QCOMPARE(primaryTarget->property("pressedKeys").toList(), QVariantList() << Qt::Key_P);
+ QCOMPARE(secondaryTarget->property("pressedKeys").toList(), QVariantList() << Qt::Key_P);
+ QVERIFY(pressKeyP.isAccepted());
+
+ QKeyEvent releaseKeyP(QEvent::KeyRelease, Qt::Key_P, Qt::NoModifier, "P");
+ QCoreApplication::sendEvent(sourceItem, &releaseKeyP);
+ QCOMPARE(rootItem->property("releasedKeys").toList(), QVariantList());
+ QCOMPARE(sourceItem->property("releasedKeys").toList(), QVariantList());
+ QCOMPARE(primaryTarget->property("releasedKeys").toList(), QVariantList() << Qt::Key_P);
+ QCOMPARE(secondaryTarget->property("releasedKeys").toList(), QVariantList() << Qt::Key_P);
+ QVERIFY(releaseKeyP.isAccepted());
+
+ // secondary target accepts/consumes Key_S
+ QKeyEvent pressKeyS(QEvent::KeyPress, Qt::Key_S, Qt::NoModifier, "S");
+ QCoreApplication::sendEvent(sourceItem, &pressKeyS);
+ QCOMPARE(rootItem->property("pressedKeys").toList(), QVariantList());
+ QCOMPARE(sourceItem->property("pressedKeys").toList(), QVariantList());
+ QCOMPARE(primaryTarget->property("pressedKeys").toList(), QVariantList() << Qt::Key_P);
+ QCOMPARE(secondaryTarget->property("pressedKeys").toList(), QVariantList() << Qt::Key_P << Qt::Key_S);
+ QVERIFY(pressKeyS.isAccepted());
+
+ QKeyEvent releaseKeyS(QEvent::KeyRelease, Qt::Key_S, Qt::NoModifier, "S");
+ QCoreApplication::sendEvent(sourceItem, &releaseKeyS);
+ QCOMPARE(rootItem->property("releasedKeys").toList(), QVariantList());
+ QCOMPARE(sourceItem->property("releasedKeys").toList(), QVariantList());
+ QCOMPARE(primaryTarget->property("releasedKeys").toList(), QVariantList() << Qt::Key_P);
+ QCOMPARE(secondaryTarget->property("releasedKeys").toList(), QVariantList() << Qt::Key_P << Qt::Key_S);
+ QVERIFY(releaseKeyS.isAccepted());
+
+ // neither target accepts/consumes Key_Q
+ QKeyEvent pressKeyQ(QEvent::KeyPress, Qt::Key_Q, Qt::NoModifier, "Q");
+ QCoreApplication::sendEvent(sourceItem, &pressKeyQ);
+ QCOMPARE(rootItem->property("pressedKeys").toList(), QVariantList());
+ QCOMPARE(sourceItem->property("pressedKeys").toList(), QVariantList() << Qt::Key_Q);
+ QCOMPARE(primaryTarget->property("pressedKeys").toList(), QVariantList() << Qt::Key_P << Qt::Key_Q);
+ QCOMPARE(secondaryTarget->property("pressedKeys").toList(), QVariantList() << Qt::Key_P << Qt::Key_S << Qt::Key_Q);
+ QVERIFY(!pressKeyQ.isAccepted());
+
+ QKeyEvent releaseKeyQ(QEvent::KeyRelease, Qt::Key_Q, Qt::NoModifier, "Q");
+ QCoreApplication::sendEvent(sourceItem, &releaseKeyQ);
+ QCOMPARE(rootItem->property("releasedKeys").toList(), QVariantList());
+ QCOMPARE(sourceItem->property("releasedKeys").toList(), QVariantList() << Qt::Key_Q);
+ QCOMPARE(primaryTarget->property("releasedKeys").toList(), QVariantList() << Qt::Key_P << Qt::Key_Q);
+ QCOMPARE(secondaryTarget->property("releasedKeys").toList(), QVariantList() << Qt::Key_P << Qt::Key_S << Qt::Key_Q);
+ QVERIFY(!releaseKeyQ.isAccepted());
+}
+
QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString)
{
QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 91a6886bf0..45d23abbf6 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -1296,7 +1296,7 @@ void tst_qquicktextedit::selectionOnFocusOut()
QVERIFY(edit2->hasActiveFocus());
edit2->setFocus(false, Qt::PopupFocusReason);
- QVERIFY(!edit2->hasActiveFocus());
+ QVERIFY(edit2->hasActiveFocus());
QCOMPARE(edit2->selectedText(), QLatin1String("text 2"));
}
diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
index c14b09c545..521f41df43 100644
--- a/tests/auto/quick/qquicktextinput/qquicktextinput.pro
+++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
@@ -14,3 +14,5 @@ TESTDATA = data/*
QT += core-private gui-private qml-private quick-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+macx: CONFIG+=insignificant_test # QTBUG-38363
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 273c0de660..e125c33a56 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -3605,7 +3605,8 @@ void tst_qquicktextinput::focusOutNotClearSelection()
input.setFocus(false, Qt::PopupFocusReason);
QGuiApplication::processEvents();
QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
- QTRY_COMPARE(input.hasActiveFocus(), false);
+ // QTBUG-36332 and 36292: a popup window does not take focus
+ QTRY_COMPARE(input.hasActiveFocus(), true);
input.setFocus(true);
QTRY_COMPARE(input.hasActiveFocus(), true);