diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-10-30 09:13:04 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-10-30 09:13:04 +0100 |
commit | 970ff81a14c93c4f41f384026220d4baad8eec70 (patch) | |
tree | b99ff97b74be8ddcddd5b5037f172aea06623581 /tests | |
parent | 4b73acd49cc4f08a5169efba8169f968094063e0 (diff) | |
parent | 4e33b069c426c975319d91e11223114fd0d8ad40 (diff) |
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'tests')
46 files changed, 707 insertions, 148 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/negativeyear.qml b/tests/auto/qml/qqmlecmascript/data/negativeyear.qml new file mode 100644 index 0000000000..11defbe914 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/negativeyear.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + function check_negative() { + return "result: " + new Date(-2000, 0, 1); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/updateCall.qml b/tests/auto/qml/qqmlecmascript/data/updateCall.qml index 341a360d25..d310dcac9e 100644 --- a/tests/auto/qml/qqmlecmascript/data/updateCall.qml +++ b/tests/auto/qml/qqmlecmascript/data/updateCall.qml @@ -1,10 +1,10 @@ -import QtQuick 2.1
-
-Rectangle {
- MouseArea {
- anchors.fill: parent;
- Component.onCompleted: {
- update();
- }
- }
-}
+import QtQuick 2.1 + +Rectangle { + MouseArea { + anchors.fill: parent; + Component.onCompleted: { + update(); + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 196f6b96f9..019d6790e1 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -200,6 +200,7 @@ private slots: void sequenceSort(); void dateParse(); void utcDate(); + void negativeYear(); void qtbug_22464(); void qtbug_21580(); void singleV8BindingDestroyedDuringEvaluation(); @@ -7378,6 +7379,22 @@ void tst_qqmlecmascript::utcDate() QVERIFY(q.toBool() == true); } +void tst_qqmlecmascript::negativeYear() +{ + QQmlComponent component(&engine, testFileUrl("negativeyear.qml")); + + QObject *object = component.create(); + if (object == 0) + qDebug() << component.errorString(); + QVERIFY(object != 0); + + QVariant q; + QMetaObject::invokeMethod(object, "check_negative", + Q_RETURN_ARG(QVariant, q)); + // Strip the timezone. It should be irrelevant as the date was created with the same one. + QCOMPARE(q.toString().left(32), QStringLiteral("result: Mon Jan 1 00:00:00 -2000")); +} + void tst_qqmlecmascript::concatenatedStringPropertyAccess() { QQmlComponent component(&engine, testFileUrl("concatenatedStringPropertyAccess.qml")); diff --git a/tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml b/tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml new file mode 100644 index 0000000000..1aefdf0c42 --- /dev/null +++ b/tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Test 1.0 +TestObject { + scriptString: { return "success"; } +} + diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp index 12cb2dce83..f53ef82891 100644 --- a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp +++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp @@ -47,6 +47,7 @@ public: private slots: void scriptString(); void syntaxError(); + void expressionFromDataComponent(); }; class TestObject : public QObject @@ -108,6 +109,31 @@ void tst_qqmlexpression::syntaxError() QCOMPARE(v, QVariant()); } +void tst_qqmlexpression::expressionFromDataComponent() +{ + qmlRegisterType<TestObject>("Test", 1, 0, "TestObject"); + + QQmlEngine engine; + QQmlComponent c(&engine); + + QUrl url = testFileUrl("expressionFromDataComponent.qml"); + + { + QFile f(url.toLocalFile()); + QVERIFY(f.open(QIODevice::ReadOnly)); + c.setData(f.readAll(), url); + } + + QScopedPointer<TestObject> object; + object.reset(qobject_cast<TestObject*>(c.create())); + Q_ASSERT(!object.isNull()); + + QQmlExpression expression(object->scriptString()); + QVariant result = expression.evaluate(); + QVERIFY(result.type() == QVariant::String); + QCOMPARE(result.toString(), QStringLiteral("success")); +} + QTEST_MAIN(tst_qqmlexpression) #include "tst_qqmlexpression.moc" diff --git a/tests/auto/qml/qqmllanguage/data/badListItemType.errors.txt b/tests/auto/qml/qqmllanguage/data/badListItemType.errors.txt new file mode 100644 index 0000000000..76809dc9a1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badListItemType.errors.txt @@ -0,0 +1 @@ +4:15:Cannot assign object to list diff --git a/tests/auto/qml/qqmllanguage/data/badListItemType.qml b/tests/auto/qml/qqmllanguage/data/badListItemType.qml new file mode 100644 index 0000000000..d612bb47b9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badListItemType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + children: Component { Item {} } // QTBUG-41848 +} diff --git a/tests/auto/qml/qqmllanguage/data/readonlyObjectProperty.qml b/tests/auto/qml/qqmllanguage/data/readonlyObjectProperty.qml new file mode 100644 index 0000000000..3fc332f565 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readonlyObjectProperty.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 + +QtObject { + readonly property QtObject subObject: QtObject { + property int readWrite: 42 + } +} diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro index 3b0518cfdf..f0c8bb6c1b 100644 --- a/tests/auto/qml/qqmllanguage/qqmllanguage.pro +++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro @@ -16,3 +16,6 @@ QT += core-private gui-private qml-private network testlib include (../../shared/util.pri) DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +OTHER_FILES += \ + data/readonlyObjectProperty.qml diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index d6d2911285..12d2f53596 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -118,6 +118,7 @@ private slots: void dynamicProperties(); void dynamicPropertiesNested(); void listProperties(); + void badListItemType(); void dynamicObjectProperties(); void dynamicSignalsAndSlots(); void simpleBindings(); @@ -150,6 +151,7 @@ private slots: void nestedComponentRoots(); void registrationOrder(); void readonly(); + void readonlyObjectProperties(); void receivers(); void registeredCompositeType(); void implicitImportsLast(); @@ -1332,6 +1334,13 @@ void tst_qqmllanguage::listProperties() QCOMPARE(object->property("test").toInt(), 2); } +void tst_qqmllanguage::badListItemType() +{ + QQmlComponent component(&engine, testFileUrl("badListItemType.qml")); + QVERIFY(component.isError()); + VERIFY_ERRORS("badListItemType.errors.txt"); +} + // Tests the creation and assignment of dynamic object properties // ### Not complete void tst_qqmllanguage::dynamicObjectProperties() @@ -3266,6 +3275,24 @@ void tst_qqmllanguage::readonly() delete o; } +void tst_qqmllanguage::readonlyObjectProperties() +{ + QQmlComponent component(&engine, testFileUrl("readonlyObjectProperty.qml")); + + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + + QQmlProperty prop(o.data(), QStringLiteral("subObject"), &engine); + QVERIFY(!prop.isWritable()); + QVERIFY(!prop.write(QVariant::fromValue(o.data()))); + + QObject *subObject = qvariant_cast<QObject*>(prop.read()); + QVERIFY(subObject); + QCOMPARE(subObject->property("readWrite").toInt(), int(42)); + subObject->setProperty("readWrite", QVariant::fromValue(int(100))); + QCOMPARE(subObject->property("readWrite").toInt(), int(100)); +} + void tst_qqmllanguage::receivers() { QQmlComponent component(&engine, testFileUrl("receivers.qml")); diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 6cd1eafafd..62ccec5794 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -1157,6 +1157,17 @@ void tst_qqmlproperty::read() QVERIFY(v.canConvert(QMetaType::QObjectStar)); QVERIFY(qvariant_cast<QObject *>(v) == o.qObject()); } + { + QQmlEngine engine; + PropertyObject o; + QQmlProperty p(&o, "qObject", &engine); + QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object); + + QCOMPARE(p.propertyType(), qMetaTypeId<MyQObject*>()); + QVariant v = p.read(); + QVERIFY(v.canConvert(QMetaType::QObjectStar)); + QVERIFY(qvariant_cast<QObject *>(v) == o.qObject()); + } // Object property { @@ -1432,6 +1443,23 @@ void tst_qqmlproperty::write() QCOMPARE(newData.value<QObject*>(), newObject); QCOMPARE(newData.value<MyQObject*>(), newObject); } + { + QQmlEngine engine; + PropertyObject o; + QQmlProperty p(&o, QString("qObject"), &engine); + QCOMPARE(o.qObject(), (QObject*)0); + QObject *newObject = new MyQObject(this); + QCOMPARE(p.write(QVariant::fromValue(newObject)), true); + QCOMPARE(o.qObject(), newObject); + QVariant data = p.read(); + QCOMPARE(data.value<QObject*>(), newObject); + QCOMPARE(data.value<MyQObject*>(), newObject); + // Incompatible types can not be written. + QCOMPARE(p.write(QVariant::fromValue(new MyQmlObject(this))), false); + QVariant newData = p.read(); + QCOMPARE(newData.value<QObject*>(), newObject); + QCOMPARE(newData.value<MyQObject*>(), newObject); + } } void tst_qqmlproperty::reset() diff --git a/tests/auto/qmltest/animators/tst_behavior.qml b/tests/auto/qmltest/animators/tst_behavior.qml index 0b74a74d53..87b0efff17 100644 --- a/tests/auto/qmltest/animators/tst_behavior.qml +++ b/tests/auto/qmltest/animators/tst_behavior.qml @@ -47,8 +47,9 @@ Item { compare(box.scaleChangeCounter, 1); compare(box.scale, 2); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(1, 0, 0, 1)); - compare(image.pixel(199, 199), Qt.rgba(0, 0, 1, 1)); + + verify(image.pixel(0, 0) == Qt.rgba(1, 0, 0)); + verify(image.pixel(199, 199) == Qt.rgba(0, 0, 1)); } } @@ -58,7 +59,7 @@ Item { } Timer { - interval: 1000; + interval: 100; repeat: false running: true onTriggered: box.scale = 2 diff --git a/tests/auto/qmltest/animators/tst_mixedparallel.qml b/tests/auto/qmltest/animators/tst_mixedparallel.qml index da5fb9c7ea..2b6ebfc17a 100644 --- a/tests/auto/qmltest/animators/tst_mixedparallel.qml +++ b/tests/auto/qmltest/animators/tst_mixedparallel.qml @@ -48,8 +48,8 @@ Item { compare(box.scale, 2); compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); - compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(0, 0, 1)); + verify(image.pixel(199, 199) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_mixedsequential.qml b/tests/auto/qmltest/animators/tst_mixedsequential.qml index 02caa3cae0..6165cf5438 100644 --- a/tests/auto/qmltest/animators/tst_mixedsequential.qml +++ b/tests/auto/qmltest/animators/tst_mixedsequential.qml @@ -48,8 +48,8 @@ Item { compare(box.scale, 2); compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); - compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(0, 0, 1)); + verify(image.pixel(199, 199) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_opacity.qml b/tests/auto/qmltest/animators/tst_opacity.qml index e8c3edd46c..37603a9ced 100644 --- a/tests/auto/qmltest/animators/tst_opacity.qml +++ b/tests/auto/qmltest/animators/tst_opacity.qml @@ -42,10 +42,9 @@ Item { TestCase { id: testCase name: "animators-opacity" - when: !animation.running + when: box.opacity == 0.5 function test_endresult() { compare(box.opacityChangeCounter, 1); - compare(box.opacity, 0.5); var image = grabImage(root); compare(image.red(50, 50), 255); verify(image.green(50, 50) > 0); diff --git a/tests/auto/qmltest/animators/tst_parallel.qml b/tests/auto/qmltest/animators/tst_parallel.qml index e9efbda237..7702dd7dd8 100644 --- a/tests/auto/qmltest/animators/tst_parallel.qml +++ b/tests/auto/qmltest/animators/tst_parallel.qml @@ -49,8 +49,8 @@ Item { compare(box.scale, 2); compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); - compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(0, 0, 1)); + verify(image.pixel(199, 199) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_rotation.qml b/tests/auto/qmltest/animators/tst_rotation.qml index 8c29df0623..9ff4278527 100644 --- a/tests/auto/qmltest/animators/tst_rotation.qml +++ b/tests/auto/qmltest/animators/tst_rotation.qml @@ -42,12 +42,11 @@ Item { TestCase { id: testCase name: "animators-rotation" - when: !animation.running + when: box.rotation == 180 function test_endresult() { compare(box.rotationChangeCounter, 1); - compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(50, 50), Qt.rgba(0, 0, 1)); + verify(image.pixel(50, 50) == Qt.rgba(0, 0, 1)); } } diff --git a/tests/auto/qmltest/animators/tst_scale.qml b/tests/auto/qmltest/animators/tst_scale.qml index 83ab2e5746..10f3430c84 100644 --- a/tests/auto/qmltest/animators/tst_scale.qml +++ b/tests/auto/qmltest/animators/tst_scale.qml @@ -42,12 +42,11 @@ Item { TestCase { id: testCase name: "animators-scale" - when: !animation.running + when: box.scale == 2; function test_endresult() { compare(box.scaleChangeCounter, 1); - compare(box.scale, 2); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(1, 0, 0)); + verify(image.pixel(0, 0) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_transformorigin.qml b/tests/auto/qmltest/animators/tst_transformorigin.qml index 5dfe070e80..bd3483dad5 100644 --- a/tests/auto/qmltest/animators/tst_transformorigin.qml +++ b/tests/auto/qmltest/animators/tst_transformorigin.qml @@ -61,60 +61,60 @@ Item { // topleft - compare(image.pixel(40, 40), white); - compare(image.pixel(60, 40), white); - compare(image.pixel(40, 60), white); - compare(image.pixel(60, 60), blue); + verify(image.pixel(40, 40) == white); + verify(image.pixel(60, 40) == white); + verify(image.pixel(40, 60) == white); + verify(image.pixel(60, 60) == blue); // top - compare(image.pixel(140, 40), white); - compare(image.pixel(160, 40), white); - compare(image.pixel(140, 60), blue); - compare(image.pixel(160, 60), blue); + verify(image.pixel(140, 40) == white); + verify(image.pixel(160, 40) == white); + verify(image.pixel(140, 60) == blue); + verify(image.pixel(160, 60) == blue); // topright - compare(image.pixel(240, 40), white); - compare(image.pixel(260, 40), white); - compare(image.pixel(240, 60), blue); - compare(image.pixel(260, 60), white); + verify(image.pixel(240, 40) == white); + verify(image.pixel(260, 40) == white); + verify(image.pixel(240, 60) == blue); + verify(image.pixel(260, 60) == white); // left - compare(image.pixel(40, 140), white); - compare(image.pixel(60, 140), blue); - compare(image.pixel(40, 160), white); - compare(image.pixel(60, 160), blue); + verify(image.pixel(40, 140) == white); + verify(image.pixel(60, 140) == blue); + verify(image.pixel(40, 160) == white); + verify(image.pixel(60, 160) == blue); // center - compare(image.pixel(140, 140), blue); - compare(image.pixel(160, 140), blue); - compare(image.pixel(140, 160), blue); - compare(image.pixel(160, 160), blue); + verify(image.pixel(140, 140) == blue); + verify(image.pixel(160, 140) == blue); + verify(image.pixel(140, 160) == blue); + verify(image.pixel(160, 160) == blue); // right - compare(image.pixel(240, 140), blue); - compare(image.pixel(260, 140), white); - compare(image.pixel(240, 160), blue); - compare(image.pixel(260, 160), white); + verify(image.pixel(240, 140) == blue); + verify(image.pixel(260, 140) == white); + verify(image.pixel(240, 160) == blue); + verify(image.pixel(260, 160) == white); // bottomleft - compare(image.pixel(40, 240), white); - compare(image.pixel(60, 240), blue); - compare(image.pixel(40, 260), white); - compare(image.pixel(60, 260), white); + verify(image.pixel(40, 240) == white); + verify(image.pixel(60, 240) == blue); + verify(image.pixel(40, 260) == white); + verify(image.pixel(60, 260) == white); // bottom - compare(image.pixel(140, 240), blue); - compare(image.pixel(160, 240), blue); - compare(image.pixel(140, 260), white); - compare(image.pixel(160, 260), white); + verify(image.pixel(140, 240) == blue); + verify(image.pixel(160, 240) == blue); + verify(image.pixel(140, 260) == white); + verify(image.pixel(160, 260) == white); // bottomright - compare(image.pixel(240, 240), blue); - compare(image.pixel(260, 240), white); - compare(image.pixel(240, 260), white); - compare(image.pixel(260, 260), white); + verify(image.pixel(240, 240) == blue); + verify(image.pixel(260, 240) == white); + verify(image.pixel(240, 260) == white); + verify(image.pixel(260, 260) == white); } } diff --git a/tests/auto/qmltest/animators/tst_transition.qml b/tests/auto/qmltest/animators/tst_transition.qml index 72dcd343a7..67230d2adf 100644 --- a/tests/auto/qmltest/animators/tst_transition.qml +++ b/tests/auto/qmltest/animators/tst_transition.qml @@ -47,8 +47,8 @@ Item { compare(box.scaleChangeCounter, 1); compare(box.scale, 2); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(1, 0, 0)); - compare(image.pixel(199, 199), Qt.rgba(0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(1, 0, 0)); + verify(image.pixel(199, 199) == Qt.rgba(0, 0, 1)); } } @@ -75,7 +75,7 @@ Item { } Timer { - interval: 1000; + interval: 100; repeat: false running: true onTriggered: root.state = "two" diff --git a/tests/auto/qmltest/animators/tst_x.qml b/tests/auto/qmltest/animators/tst_x.qml index 8236a82797..35e410e8e2 100644 --- a/tests/auto/qmltest/animators/tst_x.qml +++ b/tests/auto/qmltest/animators/tst_x.qml @@ -42,13 +42,12 @@ Item { TestCase { id: testCase name: "animators-x" - when: !animation.running + when: box.x == 100 function test_endresult() { compare(box.xChangeCounter, 1); - compare(box.x, 100); var image = grabImage(root); - compare(image.pixel(100, 50), Qt.rgba(1, 0, 0)); - compare(image.pixel(99, 50), Qt.rgba(1, 1, 1)); // outside on the left + verify(image.pixel(100, 0) == Qt.rgba(1, 0, 0)); + verify(image.pixel(99, 0) == Qt.rgba(1, 1, 1)); // outside on the left } } diff --git a/tests/auto/qmltest/animators/tst_y.qml b/tests/auto/qmltest/animators/tst_y.qml index 37400ebd85..79fd50e8bf 100644 --- a/tests/auto/qmltest/animators/tst_y.qml +++ b/tests/auto/qmltest/animators/tst_y.qml @@ -42,13 +42,12 @@ Item { TestCase { id: testCase name: "animators-y" - when: !animation.running + when: box.y == 100 function test_endresult() { compare(box.yChangeCounter, 1); - compare(box.y, 100); var image = grabImage(root); - compare(image.pixel(50, 100), Qt.rgba(1, 0, 0)); - compare(image.pixel(50, 99), Qt.rgba(1, 1, 1)); // outside on the left + verify(image.pixel(0, 100) == Qt.rgba(1, 0, 0)); + verify(image.pixel(0, 99) == Qt.rgba(1, 1, 1)); // outside on the top } } diff --git a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml index cce5f8dcb7..b05d5c67a9 100644 --- a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml +++ b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml @@ -31,12 +31,12 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { StateMachine { - StateBase { + State { } } name: "anonymousState" diff --git a/tests/auto/qmltest/statemachine/tst_guardcondition.qml b/tests/auto/qmltest/statemachine/tst_guardcondition.qml index 71171b2079..0390b5f8fa 100644 --- a/tests/auto/qmltest/statemachine/tst_guardcondition.qml +++ b/tests/auto/qmltest/statemachine/tst_guardcondition.qml @@ -39,15 +39,15 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { id: testCase StateMachine { id: machine initialState: startState - StateBase { + State { id: startState SignalTransition { id: signalTrans diff --git a/tests/auto/qmltest/statemachine/tst_historystate.qml b/tests/auto/qmltest/statemachine/tst_historystate.qml index f2fc110c24..6e2aa70417 100644 --- a/tests/auto/qmltest/statemachine/tst_historystate.qml +++ b/tests/auto/qmltest/statemachine/tst_historystate.qml @@ -31,8 +31,8 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { @@ -40,7 +40,7 @@ TestCase { id: stateMachine initialState: historyState1 - StateBase { + State { id: state1 SignalTransition { id: st1 @@ -48,14 +48,14 @@ TestCase { } } - StateBase { + State { id: state2 initialState: historyState2 HistoryState { id: historyState2 defaultState: state21 } - StateBase { + State { id: state21 } } diff --git a/tests/auto/qmltest/statemachine/tst_initialstate.qml b/tests/auto/qmltest/statemachine/tst_initialstate.qml index 6d5fbadf26..c08b3f7001 100644 --- a/tests/auto/qmltest/statemachine/tst_initialstate.qml +++ b/tests/auto/qmltest/statemachine/tst_initialstate.qml @@ -31,15 +31,15 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { StateMachine { id: myStateMachine initialState: myState; running: true - StateBase { + State { id: myState } } diff --git a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml index 2906de2986..443771f8f4 100644 --- a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml +++ b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml @@ -31,20 +31,20 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { StateMachine { id: myStateMachine initialState: parentState - StateBase { + State { id: parentState initialState: childState1 - StateBase { + State { id: childState1 } - StateBase { + State { id: childState2 } } diff --git a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml index 41a2c2a852..f584b7cd01 100644 --- a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml +++ b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml @@ -31,23 +31,23 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { StateMachine { id: myStateMachine initialState: parentState - StateBase { + State { id: parentState initialState: childStateMachine StateMachine { id: childStateMachine initialState: childState2 - StateBase { + State { id: childState1 } - StateBase { + State { id: childState2 } } diff --git a/tests/auto/qmltest/statemachine/tst_parallelmachine.qml b/tests/auto/qmltest/statemachine/tst_parallelmachine.qml index 0f35af0d99..2e3a5efdfd 100644 --- a/tests/auto/qmltest/statemachine/tst_parallelmachine.qml +++ b/tests/auto/qmltest/statemachine/tst_parallelmachine.qml @@ -31,30 +31,30 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { StateMachine { id: myStateMachine - childMode: StateBase.ParallelStates - StateBase { + childMode: State.ParallelStates + State { id: childState1 - childMode: StateBase.ParallelStates - StateBase { + childMode: State.ParallelStates + State { id: childState11 } - StateBase { + State { id: childState12 } } - StateBase { + State { id: childState2 initialState: childState21 - StateBase { + State { id: childState21 } - StateBase { + State { id: childState22 } } diff --git a/tests/auto/qmltest/statemachine/tst_trafficlight.qml b/tests/auto/qmltest/statemachine/tst_trafficlight.qml index 8a7cad8268..3f731a4014 100644 --- a/tests/auto/qmltest/statemachine/tst_trafficlight.qml +++ b/tests/auto/qmltest/statemachine/tst_trafficlight.qml @@ -31,8 +31,8 @@ ** ****************************************************************************/ -import QtQml.StateMachine 1.0 import QtTest 1.0 +import QtQml.StateMachine 1.0 TestCase { StateMachine { @@ -42,10 +42,10 @@ TestCase { id: finalState } - StateBase { + State { id: red initialState: justRed - StateBase { + State { id: justRed SignalTransition { id: e1 @@ -56,7 +56,7 @@ TestCase { targetState: finalState } } - StateBase { + State { id: waitingForGreen TimeoutTransition { id: e2 @@ -65,7 +65,7 @@ TestCase { } } } - StateBase { + State { id: yellowred TimeoutTransition { id: e3 @@ -73,7 +73,7 @@ TestCase { timeout: 10 } } - StateBase { + State { id: green TimeoutTransition { id: e4 @@ -81,7 +81,7 @@ TestCase { timeout: 50 } } - StateBase { + State { id: yellow TimeoutTransition { id: e5 diff --git a/tests/auto/quick/qquickaccessible/data/checkbuttons.qml b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml index 8769c04095..8424e3b2d5 100644 --- a/tests/auto/quick/qquickaccessible/data/checkbuttons.qml +++ b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml @@ -3,6 +3,7 @@ import QtQuick 2.0 Item { width: 400 height: 400 + Accessible.name: "root" // button, not checkable Rectangle { diff --git a/tests/auto/quick/qquickaccessible/data/hittest.qml b/tests/auto/quick/qquickaccessible/data/hittest.qml index 07e2bbaaf6..f081f5476e 100644 --- a/tests/auto/quick/qquickaccessible/data/hittest.qml +++ b/tests/auto/quick/qquickaccessible/data/hittest.qml @@ -40,6 +40,8 @@ Rectangle { width: 640 height: 480 color: "white" + Accessible.name: "root" + Accessible.role: Accessible.Client Rectangle { id: header color: "#c0c0c0" @@ -165,4 +167,45 @@ Rectangle { } } + TextRect { + x: 0 + y: 300 + text: "rect3" + width: 200 + height: 100 + color: "#ffa0a0" + TextRect { + x: 10 + y: 10 + text: "rect30" + width: 80 + height: 80 + color: "#ffa0a0" + TextRect { + x: 30 + y: 50 + text: "rect300" + width: 80 + height: 80 + color: "#ffa0a0" + } + } + TextRect { + x: 100 + y: 10 + text: "rect31" + width: 80 + height: 80 + color: "#ffa0a0" + TextRect { + x: -50 + y: 60 + z: -3 + text: "rect310" + width: 80 + height: 80 + color: "#ffa0a0" + } + } + } } diff --git a/tests/auto/quick/qquickaccessible/data/ignored.qml b/tests/auto/quick/qquickaccessible/data/ignored.qml new file mode 100644 index 0000000000..1caf6ccb56 --- /dev/null +++ b/tests/auto/quick/qquickaccessible/data/ignored.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +import "widgets" + + +Rectangle { + id: page + width: 640 + height: 480 + function col(str) { + return Qt.hsla((str.charCodeAt(0)-65)/9, 1.0, 0.5, 1) + } + color: col(Accessible.name) + Accessible.name: "A" + Accessible.role: Accessible.StaticText + + Rectangle { + id: b + width: 20 + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + color: col(Accessible.name) + Accessible.name: "B" + Accessible.role: Accessible.StaticText + } + + Rectangle { + x: 20 + width: 80 + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + color: col(Accessible.name) + Accessible.ignored: true + Accessible.name: "C" + Accessible.role: Accessible.StaticText + + Rectangle { + width: 20 + color: col(Accessible.name) + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + Accessible.name: "E" + Accessible.role: Accessible.StaticText + } + + Rectangle { + x: 20 + width: 20 + color: col(Accessible.name) + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + Accessible.name: "F" + Accessible.role: Accessible.StaticText + } + + Rectangle { + x: 40 + width: 20 + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + color: col(Accessible.name) + Accessible.ignored: true + Accessible.name: "G" + Accessible.role: Accessible.StaticText + Rectangle { + width: 20 + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + color: col(Accessible.name) + Accessible.name: "I" + Accessible.role: Accessible.StaticText + } + } + Rectangle { + x: 60 + width: 20 + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + color: col(Accessible.name) + Accessible.name: "H" + Accessible.role: Accessible.StaticText + } + } + + Rectangle { + x: 100 + width: 20 + height: parent.height/2 + anchors.verticalCenter: parent.verticalCenter + color: col(Accessible.name) + Accessible.name: "D" + Accessible.role: Accessible.StaticText + } +} diff --git a/tests/auto/quick/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml index 7cf1b707a0..1092f33daf 100644 --- a/tests/auto/quick/qquickaccessible/data/statictext.qml +++ b/tests/auto/quick/qquickaccessible/data/statictext.qml @@ -3,6 +3,8 @@ import QtQuick 2.0 Item { width: 400 height: 400 + Accessible.name: "root" + Accessible.role: Accessible.Client Text { x: 100 diff --git a/tests/auto/quick/qquickaccessible/qquickaccessible.pro b/tests/auto/quick/qquickaccessible/qquickaccessible.pro index 99c3834147..bdbe2e3fb4 100644 --- a/tests/auto/quick/qquickaccessible/qquickaccessible.pro +++ b/tests/auto/quick/qquickaccessible/qquickaccessible.pro @@ -10,10 +10,11 @@ include (../../shared/util.pri) TESTDATA = data/* -OTHER_FILES += data/checkbuttons.qml -OTHER_FILES += data/hittest.qml -OTHER_FILES += data/pushbutton.qml -OTHER_FILES += data/statictext.qml +OTHER_FILES += data/checkbuttons.qml \ + data/hittest.qml \ + data/pushbutton.qml \ + data/statictext.qml \ + data/ignored.qml \ CONFIG += parallel_test diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 2806c41bef..921c81ae89 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -106,6 +106,7 @@ private slots: void basicPropertiesTest(); void hitTest(); void checkableTest(); + void ignoredTest(); }; tst_QQuickAccessible::tst_QQuickAccessible() @@ -332,40 +333,46 @@ void tst_QQuickAccessible::hitTest() // check the root item from app QAccessibleInterface *appIface = QAccessible::queryAccessibleInterface(qApp); QVERIFY(appIface); - QAccessibleInterface *itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50)); + QAccessibleInterface *itemHit = appIface->childAt(rootRect.x() + 200, rootRect.y() + 50); QVERIFY(itemHit); - QCOMPARE(rootRect, itemHit->rect()); - - // hit rect1 - QAccessibleInterface *rect1(rootItem->child(0)); - QRect rect1Rect = rect1->rect(); - QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10); - QVERIFY(rootItemIface); - QCOMPARE(rect1Rect, rootItemIface->rect()); - QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1")); - - // should also work from top level (app) - QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp)); - QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10)); - QVERIFY(itemHit2); - QCOMPARE(itemHit2->rect(), rect1Rect); - QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); - - // hit rect201 - QAccessibleInterface *rect2(rootItem->child(1)); - QVERIFY(rect2); - // FIXME: This is seems broken on mac - // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100)); - QAccessibleInterface *rect20(rect2->child(0)); - QVERIFY(rect20); - QAccessibleInterface *rect201(rect20->child(1)); - QVERIFY(rect201); - - QRect rect201Rect = rect201->rect(); - rootItemIface = windowIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20); - QVERIFY(rootItemIface); - QCOMPARE(rootItemIface->rect(), rect201Rect); - QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201")); + QCOMPARE(itemHit->rect(), rootRect); + + QAccessibleInterface *rootItemIface; + for (int c = 0; c < rootItem->childCount(); ++c) { + QAccessibleInterface *iface = rootItem->child(c); + QString name = iface->text(QAccessible::Name); + if (name == QLatin1String("rect1")) { + // hit rect1 + QAccessibleInterface *rect1 = iface; + QRect rect1Rect = rect1->rect(); + QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10); + QVERIFY(rootItemIface); + QCOMPARE(rect1Rect, rootItemIface->rect()); + QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1")); + + // should also work from top level (app) + QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp)); + QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10)); + QVERIFY(itemHit2); + QCOMPARE(itemHit2->rect(), rect1Rect); + QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); + } else if (name == QLatin1String("rect2")) { + QAccessibleInterface *rect2 = iface; + // FIXME: This is seems broken on OS X + // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100)); + QAccessibleInterface *rect20 = rect2->child(0); + QVERIFY(rect20); + QCOMPARE(rect20->text(QAccessible::Name), QLatin1String("rect20")); + QPoint p = rect20->rect().bottomRight() + QPoint(20, 20); + QAccessibleInterface *rect201 = rect20->childAt(p.x(), p.y()); + QVERIFY(rect201); + QCOMPARE(rect201->text(QAccessible::Name), QLatin1String("rect201")); + rootItemIface = topLevelChildAt(windowIface, p.x(), p.y()); + QVERIFY(rootItemIface); + QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201")); + + } + } delete window; QTestAccessibility::clearEvents(); @@ -450,6 +457,38 @@ void tst_QQuickAccessible::checkableTest() QTestAccessibility::clearEvents(); } +void tst_QQuickAccessible::ignoredTest() +{ + QScopedPointer<QQuickView> window(new QQuickView()); + window->setSource(testFileUrl("ignored.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + + QQuickItem *contentItem = window->contentItem(); + QVERIFY(contentItem); + QQuickItem *rootItem = contentItem->childItems().first(); + QVERIFY(rootItem); + + // the window becomes active + QAccessible::State activatedChange; + activatedChange.active = true; + + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window.data()); + QVERIFY(iface); + QAccessibleInterface *rectangleA = iface->child(0); + + QCOMPARE(rectangleA->role(), QAccessible::StaticText); + QCOMPARE(rectangleA->text(QAccessible::Name), QLatin1String("A")); + static const char *expected = "BEFIHD"; + // check if node "C" and "G" is skipped and that the order is as expected. + for (int i = 0; i < rectangleA->childCount(); ++i) { + QAccessibleInterface *child = rectangleA->child(i); + QCOMPARE(child->text(QAccessible::Name), QString(QLatin1Char(expected[i]))); + } + QTestAccessibility::clearEvents(); +} + QTEST_MAIN(tst_QQuickAccessible) #include "tst_qquickaccessible.moc" diff --git a/tests/auto/quick/qquickpathview/data/pathview4.qml b/tests/auto/quick/qquickpathview/data/pathview4.qml new file mode 100644 index 0000000000..c42986d5a3 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview4.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: root + property bool currentItemIsNull: view.currentItem === null + + PathView { + id: view + objectName: "view" + model: testModel + delegate: Item {} + + path: Path { + PathLine { + y: 0 + x: 0 + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index fd6dc4da60..0e9994899f 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -90,6 +90,7 @@ private slots: void pathview2(); void pathview3(); void initialCurrentIndex(); + void initialCurrentItem(); void insertModel_data(); void insertModel(); void removeModel_data(); @@ -237,6 +238,27 @@ void tst_QQuickPathView::items() QCOMPARE(pathview->highlightItem()->position() + offset, start); } +void tst_QQuickPathView::initialCurrentItem() +{ + QScopedPointer<QQuickView> window(createView()); + + QaimModel model; + model.addItem("Jules", "12345"); + model.addItem("Vicent", "2345"); + model.addItem("Marvin", "54321"); + + QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + window->setSource(testFileUrl("pathview4.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem<QQuickPathView>(window->rootObject(), "view"); + QVERIFY(pathview != 0); + QVERIFY(pathview->currentIndex() != -1); + QVERIFY(!window->rootObject()->property("currentItemIsNull").toBool()); +} + void tst_QQuickPathView::pathview2() { QQmlEngine engine; diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index 6e5314f4f2..c2ea9cc0d6 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -1934,6 +1934,9 @@ void tst_qquickpositioners::test_mirroring() QScopedPointer<QQuickView> windowB(createView(testFile(qmlFile))); QQuickItem *rootB = qobject_cast<QQuickItem*>(windowB->rootObject()); + // On OS X the windows might get positioned exactly on top of each other + // that means no repaint for the bottom window will ever occur + windowB->setPosition(windowB->position() + QPoint(10, 10)); rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft diff --git a/tests/auto/quick/qquickscreen/data/screen.qml b/tests/auto/quick/qquickscreen/data/screen.qml index dc3803f4e3..c246b3cd83 100644 --- a/tests/auto/quick/qquickscreen/data/screen.qml +++ b/tests/auto/quick/qquickscreen/data/screen.qml @@ -9,6 +9,7 @@ Item { property int curOrientation: Window.Screen.orientation property int priOrientation: Window.Screen.primaryOrientation property int updateMask: Window.Screen.orientationUpdateMask + property real devicePixelRatio: Window.Screen.devicePixelRatio Window.Screen.orientationUpdateMask: Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation } diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp index be543e8022..70ecff51eb 100644 --- a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp +++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp @@ -63,6 +63,8 @@ void tst_qquickscreen::basicProperties() QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt()); QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt()); QCOMPARE(int(screen->orientationUpdateMask()), root->property("updateMask").toInt()); + QCOMPARE(screen->devicePixelRatio(), root->property("devicePixelRatio").toReal()); + QVERIFY(screen->devicePixelRatio() >= 1.0); } QTEST_MAIN(tst_qquickscreen) diff --git a/tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml b/tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml new file mode 100644 index 0000000000..189458ad90 --- /dev/null +++ b/tests/auto/quick/qquickspritesequence/data/spriteaftergoal.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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:LGPL21$ +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// QTBUG-40595 +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 320 + + SpriteSequence + { + anchors.centerIn: parent + + width: 300 + height: 300 + + goalSprite: "foobar" + + sprites: + [ + Sprite + { + name: "foobar" + source: "squarefacesprite.png" + } + ] + } +} + diff --git a/tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml b/tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml new file mode 100644 index 0000000000..23326fb5cc --- /dev/null +++ b/tests/auto/quick/qquickspritesequence/data/spritebeforegoal.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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:LGPL21$ +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// QTBUG-40595 +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 320 + + SpriteSequence + { + anchors.centerIn: parent + + width: 300 + height: 300 + + sprites: + [ + Sprite + { + name: "foobar" + source: "squarefacesprite.png" + } + ] + + goalSprite: "foobar" + } +} + diff --git a/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp index 6cfdc90364..26ddff1009 100644 --- a/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp +++ b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp @@ -46,6 +46,8 @@ private slots: void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine void test_huge();//Separate codepath for QQuickSpriteEngine void test_jumpToCrash(); + void test_spriteBeforeGoal(); + void test_spriteAfterGoal(); }; void tst_qquickspritesequence::test_properties() @@ -119,6 +121,30 @@ void tst_qquickspritesequence::test_jumpToCrash() delete window; } +void tst_qquickspritesequence::test_spriteBeforeGoal() +{ + QQuickView *window = new QQuickView(0); + + window->setSource(testFileUrl("spritebeforegoal.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + //verify: Don't crash + + delete window; +} + +void tst_qquickspritesequence::test_spriteAfterGoal() +{ + QQuickView *window = new QQuickView(0); + + window->setSource(testFileUrl("spriteaftergoal.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + //verify: Don't crash + + delete window; +} + QTEST_MAIN(tst_qquickspritesequence) #include "tst_qquickspritesequence.moc" diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index b7335ccc4a..2e5212d5d8 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -416,6 +416,35 @@ void tst_qquicktext::wrap() delete textObject; } + // Check that increasing width from idealWidth will cause a relayout + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; textFormat: Text.RichText; width: 30; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->height() > textHeight); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); + QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->extra.isAllocated()); + + QTextDocument *doc = textPrivate->extra->doc; + QVERIFY(doc != 0); + textObject->setWidth(doc->idealWidth()); + QCOMPARE(textObject->width(), doc->idealWidth()); + QVERIFY(textObject->height() > textHeight); + + qreal oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); + + delete textObject; + } + // richtext again with a fixed height for (int i = 0; i < richText.size(); i++) { diff --git a/tests/manual/accessibility/textandbuttons.qml b/tests/manual/accessibility/textandbuttons.qml index 48ce6e26e9..74c3bf3897 100644 --- a/tests/manual/accessibility/textandbuttons.qml +++ b/tests/manual/accessibility/textandbuttons.qml @@ -50,9 +50,8 @@ Rectangle { Accessible.role : Accessible.Button - function accessibleAction(action) { - if (action == Qt.Press) - buttonAction() + Accessible.onPressAction: { + buttonAction() } function buttonAction() { |