diff options
Diffstat (limited to 'tests/auto/declarative')
186 files changed, 1978 insertions, 674 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 2d88058..5441311 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ + examples \ graphicswidgets \ # Cover parserstress \ # Cover qmetaobjectbuilder \ # Cover @@ -41,13 +42,14 @@ SUBDIRS += \ qdeclarativelanguage \ # Cover qdeclarativelistreference \ # Cover qdeclarativelistmodel \ # Cover - qdeclarativeproperty \ # Cover + qdeclarativeproperty \ # Cover qdeclarativemetatype \ # Cover qdeclarativemoduleplugin \ # Cover qdeclarativepixmapcache \ # Cover qdeclarativepropertymap \ # Cover qdeclarativeqt \ # Cover qdeclarativesmoothedanimation \ # Cover + qdeclarativesmoothedfollow\ # Cover qdeclarativespringfollow \ # Cover qdeclarativestates \ # Cover qdeclarativesystempalette \ # Cover @@ -61,7 +63,7 @@ SUBDIRS += \ qdeclarativeimageprovider \ # Cover qdeclarativestyledtext \ # Cover sql \ # Cover - qmlvisual + qmlvisual # Cover contains(QT_CONFIG, webkit) { SUBDIRS += \ diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 678dd59..8fd5ac0 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -185,15 +185,17 @@ void tst_examples::examples() QFileInfo fi(file); QFileInfo dir(fi.path()); - QString script = "data/"+dir.baseName()+"/"+fi.baseName(); + QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName(); QFileInfo testdata(script+".qml"); QStringList arguments; - arguments << "-script" << (testdata.exists() ? script : QLatin1String("data/dummytest")) + arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest")) << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" << file; QProcess p; p.start(qmlruntime, arguments); QVERIFY(p.waitForFinished()); + if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0) + qWarning() << p.readAllStandardOutput() << p.readAllStandardError(); QCOMPARE(p.exitStatus(), QProcess::NormalExit); QCOMPARE(p.exitCode(), 0); } diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index 6ff5515..ee246fa 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -121,10 +121,8 @@ void tst_parserstress::ecmascript() qml+= dataStr + "\n"; qml+= " return 1;\n"; qml+= " }\n"; - qml+= " Script {\n"; - qml+= " function stress() {\n"; + qml+= " function stress() {\n"; qml+= dataStr; - qml+= " }\n"; qml+= " }\n"; qml+= "}\n"; diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index 16ae7fc..9eaa400 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -372,6 +372,16 @@ void tst_qdeclarativeanchors::crash1() QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill."; + + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + + // QT-3245 ... anchor loop detection needs improving. + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QDeclarativeView *view = new QDeclarativeView(source); diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml new file mode 100644 index 0000000..5b0bdcb --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +AnimatedImage { + sourceSize: "240x180" + source: "stickman.gif" +} diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml new file mode 100644 index 0000000..f4d277a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +AnimatedImage { + width: 240 + height: 180 + source: "stickman.gif" +} diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 31efc64..39ce9eb 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -72,6 +72,8 @@ private slots: void frameCount(); void remote(); void remote_data(); + void sourceSize(); + void sourceSizeReadOnly(); void invalidSource(); }; @@ -155,10 +157,32 @@ void tst_qdeclarativeanimatedimage::remote() TRY_WAIT(anim->isPaused()); QCOMPARE(anim->currentFrame(), 2); } + QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error); delete anim; } +void tst_qdeclarativeanimatedimage::sourceSize() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml")); + QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create()); + QVERIFY(anim); + QCOMPARE(anim->width(),240.0); + QCOMPARE(anim->height(),180.0); + QCOMPARE(anim->sourceSize(),QSize(160,120)); + + delete anim; +} + +void tst_qdeclarativeanimatedimage::sourceSizeReadOnly() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanerror1.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); +} + void tst_qdeclarativeanimatedimage::remote_data() { QTest::addColumn<QString>("fileName"); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml new file mode 100644 index 0000000..f3ff620 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + objectName: "innerRect" + height: 100; width: 100; color: "green" + property real targetX: 100 + + x: targetX + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 26c8231..4c9c9ca 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -68,6 +68,7 @@ private slots: void reassignedAnimation(); void disabled(); void dontStart(); + void startup(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -326,6 +327,21 @@ void tst_qdeclarativebehaviors::dontStart() delete rect; } +void tst_qdeclarativebehaviors::startup() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect"); + QVERIFY(innerRect); + + QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately + + delete rect; +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index be20ba1..ae62363 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -228,7 +228,7 @@ private: #define TEST_CONTEXT_PROPERTY(ctxt, name, value) \ { \ QDeclarativeComponent component(&engine); \ - component.setData("import Qt 4.6; QtObject { property var test: " #name " }", QUrl()); \ + component.setData("import Qt 4.6; QtObject { property variant test: " #name " }", QUrl()); \ \ QObject *obj = component.create(ctxt); \ \ @@ -278,7 +278,7 @@ void tst_qdeclarativecontext::setContextProperty() // Changes in context properties { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl()); + component.setData("import Qt 4.6; QtObject { property variant test: a }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -290,7 +290,7 @@ void tst_qdeclarativecontext::setContextProperty() } { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { property var test: b }", QUrl()); + component.setData("import Qt 4.6; QtObject { property variant test: b }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -304,7 +304,7 @@ void tst_qdeclarativecontext::setContextProperty() } { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { property var test: e.a }", QUrl()); + component.setData("import Qt 4.6; QtObject { property variant test: e.a }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -318,7 +318,7 @@ void tst_qdeclarativecontext::setContextProperty() // New context properties { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl()); + component.setData("import Qt 4.6; QtObject { property variant test: a }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -332,7 +332,7 @@ void tst_qdeclarativecontext::setContextProperty() // Setting an object-variant context property { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property var obj: root; }", QUrl()); + component.setData("import Qt 4.6; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl()); QDeclarativeContext ctxt(engine.rootContext()); ctxt.setContextProperty("ctxtProp", QVariant()); @@ -380,7 +380,7 @@ void tst_qdeclarativecontext::setContextObject() // Changes in context properties { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl()); + component.setData("import Qt 4.6; QtObject { property variant test: a }", QUrl()); QObject *obj = component.create(&ctxt); @@ -412,7 +412,7 @@ void tst_qdeclarativecontext::destruction() void tst_qdeclarativecontext::idAsContextProperty() { QDeclarativeComponent component(&engine); - component.setData("import Qt 4.6; QtObject { property var a; a: QtObject { id: myObject } }", QUrl()); + component.setData("import Qt 4.6; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl()); QObject *obj = component.create(); QVERIFY(obj); diff --git a/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir index 5bdd17b..98d6b74 100644 --- a/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir +++ b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir @@ -1 +1,2 @@ -Foo Foo.qml +Foo 1.1 Foo.qml +Foo 1.0 Foo.qml diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index 79b0c36..d391941 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -274,7 +274,7 @@ void tst_qdeclarativedom::loadComposite() void tst_qdeclarativedom::testValueSource() { QByteArray qml = "import Qt 4.6\n" - "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; + "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; to: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; QDeclarativeEngine freshEngine; QDeclarativeDomDocument document; @@ -297,7 +297,7 @@ void tst_qdeclarativedom::testValueSource() QVERIFY(springValue.isLiteral()); QVERIFY(springValue.toLiteral().literal() == "1.4"); - const QDeclarativeDomValue sourceValue = valueSourceObject.property("source").value(); + const QDeclarativeDomValue sourceValue = valueSourceObject.property("to").value(); QVERIFY(!sourceValue.isInvalid()); QVERIFY(sourceValue.isBinding()); QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)"); @@ -333,8 +333,8 @@ void tst_qdeclarativedom::testValueInterceptor() void tst_qdeclarativedom::loadImports() { QByteArray qml = "import Qt 4.6\n" - "import importlib.sublib 4.7\n" - "import importlib.sublib 4.6 as NewFoo\n" + "import importlib.sublib 1.1\n" + "import importlib.sublib 1.0 as NewFoo\n" "import 'import'\n" "import 'import' as X\n" "Item {}"; @@ -356,13 +356,13 @@ void tst_qdeclarativedom::loadImports() QCOMPARE(import.type(), QDeclarativeDomImport::Library); QCOMPARE(import.uri(), QLatin1String("importlib.sublib")); QCOMPARE(import.qualifier(), QString()); - QCOMPARE(import.version(), QLatin1String("4.7")); + QCOMPARE(import.version(), QLatin1String("1.1")); import = document.imports().at(2); QCOMPARE(import.type(), QDeclarativeDomImport::Library); QCOMPARE(import.uri(), QLatin1String("importlib.sublib")); QCOMPARE(import.qualifier(), QLatin1String("NewFoo")); - QCOMPARE(import.version(), QLatin1String("4.6")); + QCOMPARE(import.version(), QLatin1String("1.0")); import = document.imports().at(3); QCOMPARE(import.type(), QDeclarativeDomImport::File); @@ -450,7 +450,7 @@ void tst_qdeclarativedom::loadDynamicProperty() " property url f\n" " property color g\n" " property date h\n" - " property var i\n" + " property variant i\n" " property QtObject j\n" "}"; @@ -483,8 +483,8 @@ void tst_qdeclarativedom::loadDynamicProperty() DP_TEST(5, f, QVariant::Url, 128, 14, "url"); DP_TEST(6, g, QVariant::Color, 147, 16, "color"); DP_TEST(7, h, QVariant::DateTime, 168, 15, "date"); - DP_TEST(8, i, qMetaTypeId<QVariant>(), 188, 14, "var"); - DP_TEST(9, j, -1, 207, 19, "QtObject"); + DP_TEST(8, i, qMetaTypeId<QVariant>(), 188, 18, "variant"); + DP_TEST(9, j, -1, 211, 19, "QtObject"); } { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml index 7c32e56..28252df 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml @@ -3,7 +3,7 @@ import Qt 4.6 QtObject { property int b: obj.prop.a - property var prop; + property variant prop; prop: QtObject { property int a: 10 } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml index 2fec9da..1c88700 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml @@ -38,7 +38,7 @@ QtObject { property int d: 176 property string e: "Hello" property string f: "World" - property var g: 6.7 - property var h: "!" - property var i: true + property variant g: 6.7 + property variant h: "!" + property variant i: true } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml new file mode 100644 index 0000000..6c538fe --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +QtObject { + function calculate() { + return b * 13; + } + + property int a: calculate() + property int b: 3 +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml index 6bc3a17..29eba42 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml @@ -2,7 +2,7 @@ import Qt 4.6 import Qt.test 1.0 QtObject { - property var obj + property variant obj obj: MyQmlObject { id: myObject value: 92 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml index a902312..566f5ed 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml @@ -1,4 +1,5 @@ import Qt.test 1.0 +import Qt 4.6 MyExtendedObject { @@ -7,4 +8,12 @@ MyExtendedObject coreProperty: extendedProperty extendedProperty: 9 + + property QtObject nested: MyExtendedObject { + baseProperty: baseExtendedProperty + baseExtendedProperty: 13 + + coreProperty: extendedProperty + extendedProperty: 9 + } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml new file mode 100644 index 0000000..4aca111 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +QtObject { + function myFunction() { + a = 10; + } + + Component.onCompleted: myFunction(); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml index 2db0fc6..93054f8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml @@ -4,7 +4,7 @@ import Qt 4.6 MyQmlObject { objectProperty: if(1) otherObject - property var obj + property variant obj obj: QtObject { id: otherObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml index f66428d..5ae8b14 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml @@ -4,7 +4,7 @@ import Qt 4.6 MyQmlObject { objectProperty: otherObject - property var obj + property variant obj obj: QtObject { id: otherObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js new file mode 100644 index 0000000..3ffdb33 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js @@ -0,0 +1,6 @@ +.pragma library + +function test(target) +{ + var a = target.a; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml new file mode 100644 index 0000000..9e8408f --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml @@ -0,0 +1,7 @@ +import Qt 4.6 +import "libraryScriptAssert.js" as Test + +QtObject { + id: root + Component.onCompleted: Test.test(root); +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml index 810f9b6..216e916 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml @@ -9,15 +9,12 @@ MyQmlObject { QtObject { property int a: 11 } ] - Script { - function calcTest1() { - var rv = 0; - for (var ii = 0; ii < root.objectListProperty.length; ++ii) { - rv += root.objectListProperty[ii].a; - } - return rv; + function calcTest1() { + var rv = 0; + for (var ii = 0; ii < root.objectListProperty.length; ++ii) { + rv += root.objectListProperty[ii].a; } - + return rv; } property int test1: calcTest1(); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml index 47f4e50..e6d31c7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml @@ -1,5 +1,5 @@ import Qt 4.6 QtObject { - property var test: children + property variant test: children } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml new file mode 100644 index 0000000..1bf0b81 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +QtObject { + property QtObject test + test: if (1) model + property ListModel model +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml b/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml new file mode 100644 index 0000000..30a77e8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml @@ -0,0 +1,18 @@ +import Qt.test 1.0 + +NumberAssignment { + test1: if (1) 6.7 + test2: if (1) "6.7" + test3: if (1) 6 + test4: if (1) "6" + + test5: if (1) 6.7 + test6: if (1) "6.7" + test7: if (1) 6 + test8: if (1) "6" + + test9: if (1) 6.7 + test10: if (1) "6.7" + test11: if (1) 6 + test12: if (1) "6" +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml index 18e488a..edcd340 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { id: root - property var item: child + property variant item: child Item { id: child } property bool test1: child == child diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml new file mode 100644 index 0000000..c66f071 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +QtObject { + id: root + + property int a + property variant b + + Component.onCompleted: { + try { + root.a = undefined; + } catch(e) { + console.log (e.fileName + ":" + e.lineNumber + ":" + e); + } + + try { + root.a = "Hello"; + } catch(e) { + console.log (e.fileName + ":" + e.lineNumber + ":" + e); + } + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml index 6fc8b02..ffbe317 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml @@ -6,9 +6,9 @@ MyQmlObject property int intProperty property real realProperty property color colorProperty - property var variantProperty + property variant variantProperty - signal mySignal(int a, real b, color c, var d) + signal mySignal(int a, real b, color c, variant d) onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml index fa7e01c..bd23544 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml @@ -1,9 +1,9 @@ import Qt 4.6 QtObject { - property var obj: nested + property variant obj: nested - property var obj2 + property variant obj2 obj2: NestedTypeTransientErrors { id: nested } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml b/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml new file mode 100644 index 0000000..5488e1a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +QtObject { + property bool runTest: false + onRunTestChanged: test1 = undefined + + property variant test1: 10 + property variant test2: (runTest == false)?11:undefined +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index a3bcb6a..0d07055 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -80,6 +80,7 @@ void registerTypes() qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject"); qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject"); qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject"); + qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index faad8b7..4424419 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -600,6 +600,71 @@ private: QVariantList m_actuals; }; +class NumberAssignment : public QObject +{ + Q_OBJECT +public: + Q_PROPERTY(qreal test1 READ test1 WRITE setTest1); + qreal _test1; + qreal test1() const { return _test1; } + void setTest1(qreal v) { _test1 = v; } + + Q_PROPERTY(qreal test2 READ test2 WRITE setTest2); + qreal _test2; + qreal test2() const { return _test2; } + void setTest2(qreal v) { _test2 = v; } + + Q_PROPERTY(qreal test3 READ test3 WRITE setTest3); + qreal _test3; + qreal test3() const { return _test3; } + void setTest3(qreal v) { _test3 = v; } + + Q_PROPERTY(qreal test4 READ test4 WRITE setTest4); + qreal _test4; + qreal test4() const { return _test4; } + void setTest4(qreal v) { _test4 = v; } + + Q_PROPERTY(int test5 READ test5 WRITE setTest5); + int _test5; + int test5() const { return _test5; } + void setTest5(int v) { _test5 = v; } + + Q_PROPERTY(int test6 READ test6 WRITE setTest6); + int _test6; + int test6() const { return _test6; } + void setTest6(int v) { _test6 = v; } + + Q_PROPERTY(int test7 READ test7 WRITE setTest7); + int _test7; + int test7() const { return _test7; } + void setTest7(int v) { _test7 = v; } + + Q_PROPERTY(int test8 READ test8 WRITE setTest8); + int _test8; + int test8() const { return _test8; } + void setTest8(int v) { _test8 = v; } + + Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9); + unsigned int _test9; + unsigned int test9() const { return _test9; } + void setTest9(unsigned int v) { _test9 = v; } + + Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10); + unsigned int _test10; + unsigned int test10() const { return _test10; } + void setTest10(unsigned int v) { _test10 = v; } + + Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11); + unsigned int _test11; + unsigned int test11() const { return _test11; } + void setTest11(unsigned int v) { _test11 = v; } + + Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12); + unsigned int _test12; + unsigned int test12() const { return _test12; } + void setTest12(unsigned int v) { _test12 = v; } +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 77dd4b8..c9fb116 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -108,6 +108,8 @@ private slots: void selfDeletingBinding(); void extendedObjectPropertyLookup(); void scriptErrors(); + void functionErrors(); + void propertyAssignmentErrors(); void signalTriggeredBindings(); void listProperties(); void exceptionClearsOnReeval(); @@ -130,10 +132,15 @@ private slots: void qlistqobjectMethods(); void strictlyEquals(); void compiled(); + void numberAssignment(); void bug1(); void dynamicCreationCrash(); void regExpBug(); + void nullObjectBinding(); + void deletedEngine(); + void libraryScriptAssert(); + void variantsAssignedUndefined(); void callQtInvokables(); private: @@ -543,11 +550,20 @@ void tst_qdeclarativeecmascript::extensionObjects() QVERIFY(object != 0); QCOMPARE(object->baseProperty(), 13); QCOMPARE(object->coreProperty(), 9); - object->setProperty("extendedProperty", QVariant(11)); object->setProperty("baseExtendedProperty", QVariant(92)); QCOMPARE(object->coreProperty(), 11); QCOMPARE(object->baseProperty(), 92); + + MyExtendedObject *nested = qobject_cast<MyExtendedObject*>(qvariant_cast<QObject *>(object->property("nested"))); + QVERIFY(nested); + QCOMPARE(nested->baseProperty(), 13); + QCOMPARE(nested->coreProperty(), 9); + nested->setProperty("extendedProperty", QVariant(11)); + nested->setProperty("baseExtendedProperty", QVariant(92)); + QCOMPARE(nested->coreProperty(), 11); + QCOMPARE(nested->baseProperty(), 92); + } void tst_qdeclarativeecmascript::attachedProperties() @@ -986,6 +1002,44 @@ void tst_qdeclarativeecmascript::scriptErrors() } /* +Test file/lineNumbers for inline functions. +*/ +void tst_qdeclarativeecmascript::functionErrors() +{ + QDeclarativeComponent component(&engine, TEST_FILE("functionErrors.qml")); + QString url = component.url().toString(); + + QString warning = url + ":5: Error: Invalid write to global property \"a\""; + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +/* +Test various errors that can occur when assigning a property from script +*/ +void tst_qdeclarativeecmascript::propertyAssignmentErrors() +{ + QDeclarativeComponent component(&engine, TEST_FILE("propertyAssignmentErrors.qml")); + + QString url = component.url().toString(); + + QString warning1 = url + ":11:Error: Cannot assign [undefined] to int"; + QString warning2 = url + ":17:Error: Cannot assign QString to int"; + + QTest::ignoreMessage(QtDebugMsg, warning1.toLatin1().constData()); + QTest::ignoreMessage(QtDebugMsg, warning2.toLatin1().constData()); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +/* Test bindings still work when the reeval is triggered from within a signal script. */ @@ -2065,6 +2119,98 @@ void tst_qdeclarativeecmascript::compiled() delete object; } +// Test that numbers assigned in bindings as strings work consistently +void tst_qdeclarativeecmascript::numberAssignment() +{ + QDeclarativeComponent component(&engine, TEST_FILE("numberAssignment.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("test1") == QVariant((qreal)6.7)); + QVERIFY(object->property("test2") == QVariant((qreal)6.7)); + QVERIFY(object->property("test3") == QVariant((qreal)6)); + QVERIFY(object->property("test4") == QVariant((qreal)6)); + + QVERIFY(object->property("test5") == QVariant((int)7)); + QVERIFY(object->property("test6") == QVariant((int)7)); + QVERIFY(object->property("test7") == QVariant((int)6)); + QVERIFY(object->property("test8") == QVariant((int)6)); + + QVERIFY(object->property("test9") == QVariant((unsigned int)7)); + QVERIFY(object->property("test10") == QVariant((unsigned int)7)); + QVERIFY(object->property("test11") == QVariant((unsigned int)6)); + QVERIFY(object->property("test12") == QVariant((unsigned int)6)); + + delete object; +} + +// Test that assigning a null object works +// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4 +void tst_qdeclarativeecmascript::nullObjectBinding() +{ + QDeclarativeComponent component(&engine, TEST_FILE("nullObjectBinding.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0)); + + delete object; +} + +// Test that bindings don't evaluate once the engine has been destroyed +void tst_qdeclarativeecmascript::deletedEngine() +{ + QDeclarativeEngine *engine = new QDeclarativeEngine; + QDeclarativeComponent component(engine, TEST_FILE("deletedEngine.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("a").toInt(), 39); + object->setProperty("b", QVariant(9)); + QCOMPARE(object->property("a").toInt(), 117); + + delete engine; + + QCOMPARE(object->property("a").toInt(), 117); + object->setProperty("b", QVariant(10)); + QCOMPARE(object->property("a").toInt(), 117); + + delete object; +} + +// Test the crashing part of QTBUG-9705 +void tst_qdeclarativeecmascript::libraryScriptAssert() +{ + QDeclarativeComponent component(&engine, TEST_FILE("libraryScriptAssert.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +void tst_qdeclarativeecmascript::variantsAssignedUndefined() +{ + QDeclarativeComponent component(&engine, TEST_FILE("variantsAssignedUndefined.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), 10); + QCOMPARE(object->property("test2").toInt(), 11); + + object->setProperty("runTest", true); + + QCOMPARE(object->property("test1"), QVariant()); + QCOMPARE(object->property("test2"), QVariant()); + + + delete object; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml index 0b75ec4..da452cf 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml @@ -38,7 +38,7 @@ Rectangle { Keys.onReturnPressed: console.log("Top Left"); KeyNavigation.right: item2 focus: true - wrap: true + wrapMode: TextEdit.WordWrap text: "Box 1" } @@ -79,6 +79,6 @@ Rectangle { Keys.onReturnPressed: console.log("Bottom Left"); KeyNavigation.up: myScope - wrap: true + wrapMode: TextEdit.WordWrap } } diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml index ba6b807..a061ae2 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml @@ -3,7 +3,7 @@ import Qt 4.6 Rectangle { id: root property int added: -1 - property var removed + property variant removed width: 240 height: 320 diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index dd594774..7add9c6 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -578,6 +578,11 @@ void tst_QDeclarativeGridView::moved() QCOMPARE(number->text(), model.number(i)); } + // ensure content position is stable + gridview->setContentY(0); + model.moveItem(10, 0); + QVERIFY(gridview->contentY() == 0); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml index cd5b426..548e498 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var nested + property variant nested nested: QtObject {} } diff --git a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml index a2ce78a..eac0b73 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml @@ -1,8 +1,8 @@ import Qt 4.6 QtObject { - property var nested + property variant nested nested: NestedObject { } - property var nested2: nested.nested + property variant nested2: nested.nested } diff --git a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml index ce05f89..176636a 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var nested + property variant nested nested: QtObject { } diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index c747bfc..f4df130 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -520,12 +520,31 @@ void tst_qdeclarativeinstruction::dump() data->bytecode << i; } + { + QDeclarativeInstruction i; + i.line = 51; + i.type = QDeclarativeInstruction::StoreVariantInteger; + i.storeInteger.value = 11; + i.storeInteger.propertyIndex = 32; + data->bytecode << i; + } + + { + QDeclarativeInstruction i; + i.line = 52; + i.type = QDeclarativeInstruction::StoreVariantDouble; + i.storeDouble.value = 33.7; + i.storeDouble.propertyIndex = 19; + data->bytecode << i; + } + QStringList expect; expect << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments" << "-------------------------------------------------------------------------------" << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1" << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\"" + << "1\t\t1\tCREATE_SIMPLE\t\t-1" << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\"" << "3\t\t3\tSET_DEFAULT" << "4\t\t4\tCREATE_COMPONENT\t3" @@ -574,6 +593,8 @@ void tst_qdeclarativeinstruction::dump() << "47\t\tNA\tDEFER\t\t\t7" << "48\t\t48\tSTORE_IMPORTED_SCRIPT\t2" << "49\t\t50\tXXX UNKOWN INSTRUCTION\t1234" + << "50\t\t51\tSTORE_VARIANT_INTEGER\t\t32\t11" + << "51\t\t52\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" << "-------------------------------------------------------------------------------"; messages = QStringList(); diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenProperty.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenProperty.qml new file mode 100644 index 0000000..dcd4061 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenProperty.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Item { + id: root + + property bool test1: root.children.length == 3 + property bool test2: root.children[0] == item1 + property bool test3: root.children[1] == item2 + property bool test4: root.children[2] == item3 + property bool test5: root.children[3] == null + + children: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] +} + diff --git a/tests/auto/declarative/qdeclarativeitem/data/resourcesProperty.qml b/tests/auto/declarative/qdeclarativeitem/data/resourcesProperty.qml new file mode 100644 index 0000000..fa299be --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/resourcesProperty.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Item { + id: root + + property bool test1 + property bool test2 + property bool test3 + property bool test4 + property bool test5 + + Component.onCompleted: { + test1 = (root.resources.length >= 3) + test2 = root.resources[0] == item1 + test3 = root.resources[1] == item2 + test4 = root.resources[2] == item3 + test5 = root.resources[10] == null + } + + resources: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 46f3517..a6171ae 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -64,6 +64,9 @@ private slots: void transforms(); void transforms_data(); + void childrenProperty(); + void resourcesProperty(); + private: template<typename T> T *findItem(QGraphicsObject *parent, const QString &objectName); @@ -429,6 +432,36 @@ void tst_QDeclarativeItem::transforms() QCOMPARE(item->sceneMatrix(), matrix); } +void tst_QDeclarativeItem::childrenProperty() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/childrenProperty.qml"); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + delete o; +} + +void tst_QDeclarativeItem::resourcesProperty() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/resourcesProperty.qml"); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + delete o; +} + void tst_QDeclarativeItem::propertyChanges() { QDeclarativeView *canvas = new QDeclarativeView(0); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml index 6362b2d..f62c860 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - property var other + property variant other other: MyTypeObject { id: obj } property alias enumAlias: obj.enumProperty; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml index d1e78f8..9050c3a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml @@ -3,7 +3,7 @@ import Qt 4.6 QtObject { property alias obj : otherObj - property var child + property variant child child: QtObject { id: otherObj property int myValue: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml index dc3b382..df8c851 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - property var child + property variant child child: QtObject { id: obj } property alias objAlias: obj; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml index e059937..0b968c2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var other + property variant other other: Alias { id: myAliasObject } property alias value: myAliasObject.aliasValue diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml index 4316d0d..125c518 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml @@ -4,7 +4,7 @@ import Test 1.0 QtObject { property alias otherAlias: otherObject - property var other + property variant other other: MyQmlObject { id: otherObject value: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml index 2b9ad85..629dd2a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var other + property variant other other: Alias3 { id: myAliasObject } property int value: myAliasObject.obj.myValue diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml index a2a41a1..7c072e1 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var other + property variant other other: Alias4 { id: myAliasObject } property int value: myAliasObject.obj.myValue diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml new file mode 100644 index 0000000..91fd833 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +QtObject { + property variant test1: 1 + property variant test2: 1.7 + property variant test3: "Hello world!" + property variant test4: "#FF008800" + property variant test5: "10,10,10x10" + property variant test6: "10,10" + property variant test7: "10x10" + property variant test8: "100,100,100" + property variant test9: String("#FF008800") +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml index 0ff9370..774762a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml @@ -2,6 +2,6 @@ import Test 1.0 import Qt 4.6 QtObject { - property var a; + property variant a; a: MyQmlObject {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml index 0a7249a..e745e91 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var test + property variant test test: ComponentComposite {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml index bedab8c..6411609 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml @@ -9,5 +9,5 @@ QtObject { property color colorProperty: "red" property url urlProperty: "main.qml" property date dateProperty: "1945-09-02" - property var varProperty: "Hello World!" + property variant varProperty: "Hello World!" } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml index 942ed90..e77cb52 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml @@ -1,12 +1,9 @@ import Test 1.0 MyTypeObject { - Script { - function val() { - var áâãäå = 20 - return "Test áâãäå: " + áâãäå - } - + function val() { + var áâãäå = 20 + return "Test áâãäå: " + áâãäå } stringProperty: val() } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml index 90c1483..bf048ea 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml @@ -1,6 +1,6 @@ import Test 1.0 MyContainer { - property var object : myObjectId + property variant object : myObjectId MyTypeObject { id: "myObjectId" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt new file mode 100644 index 0000000..ebc936d --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt @@ -0,0 +1 @@ +1:8:Script import requires a qualifier diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml new file mode 100644 index 0000000..2b2ab6b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml @@ -0,0 +1,3 @@ +import "test.js" + +Item { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml index 1167e39..9012aa6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml @@ -1,6 +1,6 @@ import Qt 4.6 QtObject { - property var o; + property variant o; o.blah: 10 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml index cd86a48..a4a976e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - property var child + property variant child child: HelperAlias { objAlias: QtObject {} } } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt deleted file mode 100644 index 50518cc..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt +++ /dev/null @@ -1 +0,0 @@ -3:1:Invalid use of Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml deleted file mode 100644 index 8dac8b7..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import Qt 4.6 - -Script { -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt deleted file mode 100644 index 13f47d1..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt +++ /dev/null @@ -1 +0,0 @@ -6:9:Component elements may not contain script blocks diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml deleted file mode 100644 index 516e878..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 - -Item { - Component { - Item {} - Script {} - } -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt deleted file mode 100644 index a664203..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml deleted file mode 100644 index 6d2d598..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - QtObject {} - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt deleted file mode 100644 index f8297f5..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt +++ /dev/null @@ -1 +0,0 @@ -4:5:JavaScript declaration outside Script element diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml deleted file mode 100644 index 9ecb5d9..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt 4.6 - -QtObject { - var a -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt deleted file mode 100644 index 8fb3bbd..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Properties cannot be set on Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml deleted file mode 100644 index dce1a41..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - id: myScript - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt deleted file mode 100644 index 8fb3bbd..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Properties cannot be set on Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml deleted file mode 100644 index 8621a9a..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - hello: world - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt deleted file mode 100644 index 49a507f..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script source value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml deleted file mode 100644 index d89817c..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: 10 - } -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt deleted file mode 100644 index 49a507f..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script source value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml deleted file mode 100644 index 8986b3b..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: "hello" + ".js" - } -} - - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt deleted file mode 100644 index 4e53b6b..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script block. Specify either the source property or inline script diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml deleted file mode 100644 index 07e9d78..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: "test.js" - function helloWorld() {} - } -} - - - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt deleted file mode 100644 index dc15ddf..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Variable declarations not allow in inline Script blocks diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml deleted file mode 100644 index fa905e6..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - var a = 10; - } -} - - - - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt deleted file mode 100644 index 450fc16..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt +++ /dev/null @@ -1 +0,0 @@ -6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml deleted file mode 100644 index f600c88..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: "test.js" - source: "test2.js" - } -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt deleted file mode 100644 index 41e8d46..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Component elements may not contain script blocks diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml deleted file mode 100644 index 79aa504..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -Item { - Component { - Script {} - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 722e161..bfb56ba 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -87,6 +87,7 @@ private slots: void assignBasicTypes(); void assignTypeExtremes(); void assignCompositeToType(); + void assignLiteralToVariant(); void customParserTypes(); void rootAsQmlComponent(); void inlineQmlComponents(); @@ -136,7 +137,7 @@ private slots: private: QDeclarativeEngine engine; - void testType(const QString& qml, const QString& type); + void testType(const QString& qml, const QString& type, const QString& error); }; #define VERIFY_ERRORS(errorfile) \ @@ -283,18 +284,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false; QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false; - QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false; - QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false; - QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false; - QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false; - QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false; - QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false; - QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false; - QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false; - QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false; - QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false; - QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false; - QTest::newRow("Script.12") << "script.12.qml" << "script.12.errors.txt" << false; + QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false; QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false; QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false; @@ -490,6 +480,37 @@ void tst_qdeclarativelanguage::assignCompositeToType() QVERIFY(object != 0); } +// Test that literals are stored correctly in variant properties +void tst_qdeclarativelanguage::assignLiteralToVariant() +{ + QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").userType(), (int)QVariant::Int); + QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double); + QCOMPARE(object->property("test3").userType(), (int)QVariant::String); + QCOMPARE(object->property("test4").userType(), (int)QVariant::Color); + QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF); + QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF); + QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); + QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); + QCOMPARE(object->property("test9").userType(), (int)QVariant::String); + + QVERIFY(object->property("test1") == QVariant(1)); + QVERIFY(object->property("test2") == QVariant((double)1.7)); + QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); + QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800))); + QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); + QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); + QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); + QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); + QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); + + delete object; +} + // Tests that custom parser types can be instantiated void tst_qdeclarativelanguage::customParserTypes() { @@ -1069,7 +1090,7 @@ void tst_qdeclarativelanguage::declaredPropertyValues() } // Check that first child of qml is of given type. Empty type insists on error. -void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type) +void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror) { QDeclarativeComponent component(&engine); component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports @@ -1078,6 +1099,13 @@ void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type) if (type.isEmpty()) { QVERIFY(component.isError()); + QString actualerror; + foreach (const QDeclarativeError e, component.errors()) { + if (!actualerror.isEmpty()) + actualerror.append("; "); + actualerror.append(e.description()); + } + QCOMPARE(actualerror,expectederror); } else { VERIFY_ERRORS(0); QObject *object = component.create(); @@ -1097,156 +1125,199 @@ void tst_qdeclarativelanguage::importsBuiltin_data() QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); // import built-ins QTest::newRow("missing import") << "Test {}" - << ""; + << "" + << "Test is not a type"; QTest::newRow("not in version 0.0") << "import com.nokia.Test 0.0\n" "Test {}" - << ""; + << "" + << "Test is not a type"; + QTest::newRow("version not installed") + << "import com.nokia.Test 99.0\n" + "Test {}" + << "" + << "module \"com.nokia.Test\" version 99.0 is not installed"; QTest::newRow("in version 0.0") << "import com.nokia.Test 0.0\n" "TestTP {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified in version 0.0") << "import com.nokia.Test 0.0 as T\n" "T.TestTP {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("in version 1.0") << "import com.nokia.Test 1.0\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified wrong") << "import com.nokia.Test 1.0 as T\n" // QT-610 "Test {}" - << ""; + << "" + << "Test is not a type"; QTest::newRow("qualified right") << "import com.nokia.Test 1.0 as T\n" "T.Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified right but not in version 0.0") << "import com.nokia.Test 0.0 as T\n" "T.Test {}" - << ""; + << "" + << "T.Test is not a type"; QTest::newRow("in version 1.1") << "import com.nokia.Test 1.1\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("in version 1.3") << "import com.nokia.Test 1.3\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("in version 1.5") << "import com.nokia.Test 1.5\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("changed in version 1.8") << "import com.nokia.Test 1.8\n" "Test {}" - << "TestType2"; + << "TestType2" + << ""; QTest::newRow("in version 1.12") << "import com.nokia.Test 1.12\n" "Test {}" - << "TestType2"; + << "TestType2" + << ""; QTest::newRow("old in version 1.9") << "import com.nokia.Test 1.9\n" "OldTest {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("old in version 1.11") << "import com.nokia.Test 1.11\n" "OldTest {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("multiversion 1") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "Test {}" - << "TestType2"; + << "TestType2" + << ""; QTest::newRow("multiversion 2") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "OldTest {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified multiversion 3") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" "T0.Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified multiversion 4") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" "T8.Test {}" - << "TestType2"; + << "TestType2" + << ""; } void tst_qdeclarativelanguage::importsBuiltin() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } void tst_qdeclarativelanguage::importsLocal_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); // import locals QTest::newRow("local import") << "import \"subdir\"\n" // QT-613 "Test {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("local import second") << "import Qt 4.6\nimport \"subdir\"\n" "Test {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("local import subsubdir") << "import Qt 4.6\nimport \"subdir/subsubdir\"\n" "SubTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("local import QTBUG-7721 A") << "subdir.Test {}" // no longer allowed (QTBUG-7721) - << ""; + << "" + << "subdir.Test is not a type"; QTest::newRow("local import QTBUG-7721 B") << "import \"subdir\" as X\n" "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721) - << ""; + << "" + << "X.subsubdir.SubTest is not a type"; QTest::newRow("local import as") << "import \"subdir\" as T\n" "T.Test {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("wrong local import as") << "import \"subdir\" as T\n" "Test {}" - << ""; + << "" + << "Test is not a type"; QTest::newRow("library precedence over local import") << "import \"subdir\"\n" "import com.nokia.Test 1.0\n" "Test {}" - << "TestType"; + << "TestType" + << ""; } void tst_qdeclarativelanguage::importsLocal() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } void tst_qdeclarativelanguage::importsRemote_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage"; - QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle"; - QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText"; - QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage"; - QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << ""; - QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << ""; - QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << ""; + QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle" + << ""; + QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText" + << ""; + QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage" + << ""; + QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << "" + << "WrongTestLocal is not a type"; + QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << "" + << "LocalInternal is not a type"; + QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << "" + << "UndeclaredLocal is not a type"; } #include "testhttpserver.h" @@ -1255,11 +1326,12 @@ void tst_qdeclarativelanguage::importsRemote() { QFETCH(QString, qml); QFETCH(QString, type); + QFETCH(QString, error); TestHTTPServer server(14445); server.serveDirectory(SRCDIR); - testType(qml,type); + testType(qml,type,error); } void tst_qdeclarativelanguage::importsInstalled_data() @@ -1268,43 +1340,57 @@ void tst_qdeclarativelanguage::importsInstalled_data() QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); // import installed QTest::newRow("installed import 0") << "import com.nokia.installedtest 0.0\n" "InstalledTestTP {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 0 as TP") << "import com.nokia.installedtest 0.0 as TP\n" "TP.InstalledTestTP {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 1") << "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 2") << "import com.nokia.installedtest 1.3\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 3") << "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << "QDeclarativeText"; - QTest::newRow("installed import 4") + << "QDeclarativeText" + << ""; + QTest::newRow("installed import minor version not available") // QTBUG-9627 << "import com.nokia.installedtest 1.10\n" "InstalledTest {}" - << "QDeclarativeText"; + << "" + << "module \"com.nokia.installedtest\" version 1.10 is not installed"; + QTest::newRow("installed import major version not available") // QTBUG-9627 + << "import com.nokia.installedtest 9.0\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 9.0 is not installed"; QTest::newRow("installed import visibility") // QT-614 << "import com.nokia.installedtest 1.4\n" "PrivateType {}" - << ""; + << "" + << "PrivateType is not a type"; } void tst_qdeclarativelanguage::importsInstalled() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } @@ -1312,65 +1398,77 @@ void tst_qdeclarativelanguage::importsOrder_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); QTest::newRow("installed import overrides 1") << "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("installed import overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import re-overrides 1") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("installed import re-overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import versus builtin 1") << "import com.nokia.installedtest 1.5\n" "import Qt 4.6\n" "Rectangle {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import versus builtin 2") << "import Qt 4.6\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("namespaces cannot be overridden by types 1") << "import Qt 4.6 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" - << ""; + << "" + << "Namespace Rectangle cannot be used as a type"; QTest::newRow("namespaces cannot be overridden by types 2") << "import Qt 4.6 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle.Image {}" - << "QDeclarativeImage"; + << "QDeclarativeImage" + << ""; QTest::newRow("local last 1") << "LocalLast {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("local last 2") << "import com.nokia.installedtest 1.0\n" "LocalLast {}" - << "QDeclarativeRectangle"; // i.e. from com.nokia.installedtest, not data/LocalLast.qml + << "QDeclarativeRectangle" + << ""; // i.e. from com.nokia.installedtest, not data/LocalLast.qml } void tst_qdeclarativelanguage::importsOrder() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() diff --git a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml index 1792500..5c2178f 100644 --- a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml +++ b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml @@ -5,29 +5,26 @@ Item { id: resizable width:300 height:300 - - GraphicsObjectContainer { - anchors.fill: parent - synchronizedResizing: true - - QGraphicsWidget { - - layout: QGraphicsLinearLayout { - spacing: 0 - LayoutItem { - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent } - } - LayoutItem { - objectName: "right" - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rectangle { objectName: "greenRect"; color: "green"; anchors.fill: parent } - } + QGraphicsWidget { + x : resizable.x + y : resizable.y + width : resizable.width + height : resizable.height + layout: QGraphicsLinearLayout { + spacing: 0 + LayoutItem { + objectName: "left" + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent } + } + LayoutItem { + objectName: "right" + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rectangle { objectName: "greenRect"; color: "green"; anchors.fill: parent } } } } diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml b/tests/auto/declarative/qdeclarativelistmodel/data/model.qml index ebd4ebf..4019948 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml +++ b/tests/auto/declarative/qdeclarativelistmodel/data/model.qml @@ -2,9 +2,9 @@ import Qt 4.6 Item { id: item - property var model + property variant model property bool done: false - property var result + property variant result function evalExpressionViaWorker(commands) { done = false diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index d02f54f..5962a42 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -337,7 +337,6 @@ void tst_QDeclarativeListModel::dynamic_worker() } delete item; - QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running"); qApp->processEvents(); } @@ -367,7 +366,6 @@ void tst_QDeclarativeListModel::convertNestedToFlat_fail() QCOMPARE(model.count(), 2); delete item; - QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running"); qApp->processEvents(); } @@ -427,7 +425,6 @@ void tst_QDeclarativeListModel::convertNestedToFlat_ok() QCOMPARE(model.count(), count+1); delete item; - QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running"); qApp->processEvents(); } @@ -528,7 +525,11 @@ void tst_QDeclarativeListModel::error_data() QTest::newRow("default properties not allowed in ListElement") << "import Qt 4.6\nListModel { ListElement { Item { } } }" - << "QTBUG-6082 ListElement should not allow child objects"; + << "ListElement: cannot contain nested elements"; + + QTest::newRow("QML elements not allowed in ListElement") + << "import Qt 4.6\nListModel { ListElement { a: Item { } } }" + << "ListElement: cannot contain nested elements"; } void tst_QDeclarativeListModel::error() @@ -543,8 +544,6 @@ void tst_QDeclarativeListModel::error() if (error.isEmpty()) { QVERIFY(!component.isError()); } else { - if (error.startsWith(QLatin1String("QTBUG-"))) - QEXPECT_FAIL("",error.toLatin1(),Abort); QVERIFY(component.isError()); QList<QDeclarativeError> errors = component.errors(); QCOMPARE(errors.count(),1); diff --git a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml index 0c2d0aa..d64be0f 100644 --- a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml +++ b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml @@ -4,7 +4,7 @@ QtObject { property list<QtObject> myList; myList: QtObject {} - property var value: myList + property variant value: myList property int test: value.length } diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 05d968c..abdd210 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -133,7 +133,7 @@ void tst_QDeclarativeLoader::component() QVERIFY(c); QCOMPARE(loader->sourceComponent(), c); - delete loader; + delete item; } void tst_QDeclarativeLoader::invalidUrl() @@ -196,7 +196,7 @@ void tst_QDeclarativeLoader::clear() QCOMPARE(loader->status(), QDeclarativeLoader::Null); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); - delete loader; + delete item; } } @@ -242,7 +242,7 @@ void tst_QDeclarativeLoader::componentToUrl() QCOMPARE(loader->width(), 120.0); QCOMPARE(loader->height(), 60.0); - delete loader; + delete item; } void tst_QDeclarativeLoader::sizeLoaderToItem() @@ -275,6 +275,8 @@ void tst_QDeclarativeLoader::sizeLoaderToItem() QCOMPARE(spy.count(),1); loader->setResizeMode(QDeclarativeLoader::NoResize); QCOMPARE(spy.count(),1); + + delete loader; } void tst_QDeclarativeLoader::sizeItemToLoader() @@ -303,6 +305,8 @@ void tst_QDeclarativeLoader::sizeItemToLoader() rect->setHeight(45); QCOMPARE(loader->width(), 160.0); QCOMPARE(loader->height(), 45.0); + + delete loader; } void tst_QDeclarativeLoader::noResize() @@ -317,6 +321,8 @@ void tst_QDeclarativeLoader::noResize() QVERIFY(rect); QCOMPARE(rect->width(), 120.0); QCOMPARE(rect->height(), 60.0); + + delete loader; } void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() @@ -344,6 +350,8 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() loader->setHeight(30); QCOMPARE(widget->size().width(), 180.0); QCOMPARE(widget->size().height(), 30.0); + + delete loader; } void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() @@ -374,6 +382,8 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() widget->resize(QSizeF(160,45)); QCOMPARE(loader->width(), 160.0); QCOMPARE(loader->height(), 45.0); + + delete loader; } void tst_QDeclarativeLoader::noResizeGraphicsWidget() @@ -391,6 +401,8 @@ void tst_QDeclarativeLoader::noResizeGraphicsWidget() QVERIFY(widget); QCOMPARE(widget->size().width(), 250.0); QCOMPARE(widget->size().height(), 250.0); + + delete loader; } void tst_QDeclarativeLoader::networkRequestUrl() diff --git a/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml b/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml new file mode 100644 index 0000000..e800f98 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Item { + id: root + property bool clicked: false + property bool held: false + + MouseArea { + width: 200; height: 200 + onClicked: { root.clicked = true } + onPressAndHold: { root.held = true } + } +} diff --git a/tests/auto/declarative/qdeclarativemousearea/data/dragreset.qml b/tests/auto/declarative/qdeclarativemousearea/data/dragreset.qml new file mode 100644 index 0000000..4bfb9c3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/dragreset.qml @@ -0,0 +1,28 @@ +import Qt 4.6 +Rectangle { + id: whiteRect + width: 200 + height: 200 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + MouseArea { + objectName: "mouseregion" + anchors.fill: parent + drag.target: haveTarget ? blackRect : undefined + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: whiteRect.width-blackRect.width + drag.minimumY: 0 + drag.maximumY: whiteRect.height-blackRect.height + } + } + } diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 9b664e5..bdb8eca 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -44,20 +44,24 @@ #include <private/qdeclarativemousearea_p.h> #include <private/qdeclarativerectangle_p.h> #include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativecontext.h> class tst_QDeclarativeMouseArea: public QObject { Q_OBJECT private slots: void dragProperties(); + void resetDrag(); void updateMouseAreaPosOnClick(); + void noOnClickedWithPressAndHold(); private: - QDeclarativeView *createView(const QString &filename); + QDeclarativeView *createView(); }; void tst_QDeclarativeMouseArea::dragProperties() { - QDeclarativeView *canvas = createView(SRCDIR "/data/dragproperties.qml"); + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragproperties.qml")); canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); @@ -127,19 +131,49 @@ void tst_QDeclarativeMouseArea::dragProperties() delete canvas; } -QDeclarativeView *tst_QDeclarativeMouseArea::createView(const QString &filename) +void tst_QDeclarativeMouseArea::resetDrag() +{ + QDeclarativeView *canvas = createView(); + + canvas->rootContext()->setContextProperty("haveTarget", QVariant(true)); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragreset.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarativeMouseArea*>("mouseregion"); + QDeclarativeDrag *drag = mouseRegion->drag(); + QVERIFY(mouseRegion != 0); + QVERIFY(drag != 0); + + // target + QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == drag->target()); + QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject()); + QVERIFY(rootItem != 0); + QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); + QVERIFY(drag->target() != 0); + canvas->rootContext()->setContextProperty("haveTarget", QVariant(false)); + QCOMPARE(targetSpy.count(),1); + QVERIFY(drag->target() == 0); + + delete canvas; +} + + +QDeclarativeView *tst_QDeclarativeMouseArea::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; } void tst_QDeclarativeMouseArea::updateMouseAreaPosOnClick() { - QDeclarativeView *canvas = createView(SRCDIR "/data/updateMousePosOnClick.qml"); + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnClick.qml")); canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); @@ -169,6 +203,36 @@ void tst_QDeclarativeMouseArea::updateMouseAreaPosOnClick() delete canvas; } +void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clickandhold.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QGraphicsScene *scene = canvas->scene(); + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setScenePos(QPointF(100, 100)); + pressEvent.setButton(Qt::LeftButton); + pressEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &pressEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + QVERIFY(!canvas->rootObject()->property("held").toBool()); + + QTest::qWait(1000); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMousePress); + releaseEvent.setScenePos(QPointF(100, 100)); + releaseEvent.setButton(Qt::LeftButton); + releaseEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &releaseEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + QVERIFY(canvas->rootObject()->property("held").toBool()); +} + QTEST_MAIN(tst_QDeclarativeMouseArea) #include "tst_qdeclarativemousearea.moc" diff --git a/tests/auto/declarative/qdeclarativeqt/data/darker.qml b/tests/auto/declarative/qdeclarativeqt/data/darker.qml index 2df067e..b265a0e 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/darker.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/darker.qml @@ -1,11 +1,11 @@ import Qt 4.6 QtObject { - property var test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) - property var test2: Qt.darker() - property var test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10) - property var test4: Qt.darker("red"); - property var test5: Qt.darker("perfectred"); // Non-existant color - property var test6: Qt.darker(10); + property variant test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) + property variant test2: Qt.darker() + property variant test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10) + property variant test4: Qt.darker("red"); + property variant test5: Qt.darker("perfectred"); // Non-existant color + property variant test6: Qt.darker(10); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml index e62749a..4cf0602 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml @@ -6,13 +6,13 @@ QtObject { property string test2: Qt.formatDate(date1, Qt.DefaultLocaleLongDate) property string test3: Qt.formatDate(date1, "ddd MMMM d yy") - property var time1: new Date(0,0,0,14,15,38,200) + property variant time1: new Date(0,0,0,14,15,38,200) property string test4: Qt.formatTime(time1) property string test5: Qt.formatTime(time1, Qt.DefaultLocaleLongDate) property string test6: Qt.formatTime(time1, "H:m:s a") property string test7: Qt.formatTime(time1, "hh:mm:ss.zzz") - property var dateTime1: new Date(1978,2,4,9,13,54) + property variant dateTime1: new Date(1978,2,4,9,13,54) property string test8: Qt.formatDateTime(dateTime1) property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate) property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a") diff --git a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml b/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml new file mode 100644 index 0000000..d986492 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +QtObject { + id: root + + property QtObject nullObject + + property bool test1: Qt.isQtObject(root) + property bool test2: Qt.isQtObject(nullObject) + property bool test3: Qt.isQtObject(10) + property bool test4: Qt.isQtObject(null) + property bool test5: Qt.isQtObject({ a: 10, b: 11 }) +} + diff --git a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml index 4e0c431..2d2b835 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml @@ -1,10 +1,10 @@ import Qt 4.6 QtObject { - property var test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) - property var test2: Qt.lighter() - property var test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10) - property var test4: Qt.lighter("red"); - property var test5: Qt.lighter("perfectred"); // Non-existant color - property var test6: Qt.lighter(10); + property variant test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) + property variant test2: Qt.lighter() + property variant test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10) + property variant test4: Qt.lighter("red"); + property variant test5: Qt.lighter("perfectred"); // Non-existant color + property variant test6: Qt.lighter(10); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/point.qml b/tests/auto/declarative/qdeclarativeqt/data/point.qml index c383beb..1054ac9 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/point.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/point.qml @@ -1,9 +1,9 @@ import Qt 4.6 QtObject { - property var test1: Qt.point(19, 34); - property var test2: Qt.point(-3, 109.2); - property var test3: Qt.point(-3); - property var test4: Qt.point(-3, 109.2, 1); + property variant test1: Qt.point(19, 34); + property variant test2: Qt.point(-3, 109.2); + property variant test3: Qt.point(-3); + property variant test4: Qt.point(-3, 109.2, 1); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/rect.qml b/tests/auto/declarative/qdeclarativeqt/data/rect.qml index 82b6428..e008656 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/rect.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/rect.qml @@ -1,9 +1,9 @@ import Qt 4.6 QtObject { - property var test1: Qt.rect(10, 13, 100, 109) - property var test2: Qt.rect(-10, 13, 100, 109.6) - property var test3: Qt.rect(10, 13); - property var test4: Qt.rect(10, 13, 100, 109, 10) - property var test5: Qt.rect(10, 13, 100, -109) + property variant test1: Qt.rect(10, 13, 100, 109) + property variant test2: Qt.rect(-10, 13, 100, 109.6) + property variant test3: Qt.rect(10, 13); + property variant test4: Qt.rect(10, 13, 100, 109, 10) + property variant test5: Qt.rect(10, 13, 100, -109) } diff --git a/tests/auto/declarative/qdeclarativeqt/data/size.qml b/tests/auto/declarative/qdeclarativeqt/data/size.qml index 05b0317..93577f2 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/size.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/size.qml @@ -1,11 +1,11 @@ import Qt 4.6 QtObject { - property var test1: Qt.size(19, 34); - property var test2: Qt.size(3, 109.2); - property var test3: Qt.size(-3, 10); - property var test4: Qt.size(3); - property var test5: Qt.size(3, 109.2, 1); + property variant test1: Qt.size(19, 34); + property variant test2: Qt.size(3, 109.2); + property variant test3: Qt.size(-3, 10); + property variant test4: Qt.size(3); + property variant test5: Qt.size(3, 109.2, 1); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector.qml b/tests/auto/declarative/qdeclarativeqt/data/vector.qml index a471c7a..16716db 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/vector.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/vector.qml @@ -1,8 +1,8 @@ import Qt 4.6 QtObject { - property var test1: Qt.vector3d(1, 0, 0.9); - property var test2: Qt.vector3d(102, -10, -982.1); - property var test3: Qt.vector3d(102, -10); - property var test4: Qt.vector3d(102, -10, -982.1, 10); + property variant test1: Qt.vector3d(1, 0, 0.9); + property variant test2: Qt.vector3d(102, -10, -982.1); + property variant test3: Qt.vector3d(102, -10); + property variant test4: Qt.vector3d(102, -10, -982.1, 10); } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 48d5235..98f1200 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -73,6 +73,7 @@ private slots: void createQmlObject(); void consoleLog(); void formatting(); + void isQtObject(); private: QDeclarativeEngine engine; @@ -392,6 +393,21 @@ void tst_qdeclarativeqt::formatting() delete object; } +void tst_qdeclarativeqt::isQtObject() +{ + QDeclarativeComponent component(&engine, TEST_FILE("isQtObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), false); + QCOMPARE(object->property("test3").toBool(), false); + QCOMPARE(object->property("test4").toBool(), false); + QCOMPARE(object->property("test5").toBool(), false); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeqt) #include "tst_qdeclarativeqt.moc" diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 09c4879..419f5ea 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -181,6 +181,7 @@ void tst_QDeclarativeRepeater::numberModel() QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); + delete testObject; delete canvas; } @@ -204,6 +205,9 @@ void tst_QDeclarativeRepeater::objectList() QVERIFY(repeater != 0); QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data QCOMPARE(repeater->property("instantiated").toInt(), 100); + + qDeleteAll(data); + delete canvas; } /* @@ -293,6 +297,9 @@ void tst_QDeclarativeRepeater::dataModel() testModel.removeItem(2); QCOMPARE(container->childItems().count(), 4); + + delete testObject; + delete canvas; } void tst_QDeclarativeRepeater::itemModel() @@ -323,6 +330,7 @@ void tst_QDeclarativeRepeater::itemModel() QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3"); QVERIFY(container->childItems().at(3) == repeater); + delete testObject; delete canvas; } @@ -352,6 +360,8 @@ void tst_QDeclarativeRepeater::properties() QCOMPARE(delegateSpy.count(),1); repeater->setDelegate(&rectComponent); QCOMPARE(delegateSpy.count(),1); + + delete rootObject; } QDeclarativeView *tst_QDeclarativeRepeater::createView() diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml index eb06344..ec35067 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml @@ -17,7 +17,8 @@ Rectangle { color: "green" width: 60; height: 60; x: rect1.x; y: rect1.y; - Behavior on x { SmoothedAnimation { objectName: "easeX"; velocity: 400 } } - Behavior on y { SmoothedAnimation { objectName: "easeY"; velocity: 400 } } + // id are needed for SmoothedAnimation in order to avoid deferred creation + Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } } + Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } } } } diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml new file mode 100644 index 0000000..c162e7a --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml @@ -0,0 +1,3 @@ +import Qt 4.6 + +SmoothedFollow {} diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml new file mode 100644 index 0000000..d45001f --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +SmoothedFollow { + to: 10; duration: 300; reversingMode: SmoothedFollow.Immediate +} diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml new file mode 100644 index 0000000..c09fb8e --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +SmoothedFollow { + to: 10; velocity: 250; reversingMode: SmoothedFollow.Sync + maximumEasingTime: 150 +} diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml new file mode 100644 index 0000000..131f674 --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Rectangle { + width: 300; height: 300; + Rectangle { + objectName: "theRect" + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedFollow on x { id: animX; objectName: "animX"; to: 200; enabled: true; duration: 200 } + SmoothedFollow on y { id: animY; objectName: "animY"; to: 200; enabled: false; duration: 200 } + } +} diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml new file mode 100644 index 0000000..514537c --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Rectangle { + width: 300; height: 300; + Rectangle { + objectName: "theRect" + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedFollow on x { objectName: "easeX"; to: 200; velocity: 500 } + SmoothedFollow on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 } + } +} diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro new file mode 100644 index 0000000..f8e97a0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativesmoothedfollow.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp b/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp new file mode 100644 index 0000000..ac750d9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativeview.h> + +#include <private/qdeclarativesmoothedfollow_p.h> +#include <private/qdeclarativerectangle_p.h> +#include <private/qdeclarativevaluetype_p.h> +#include "../../../shared/util.h" + +class tst_qdeclarativesmoothedfollow : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativesmoothedfollow(); + +private slots: + void defaultValues(); + void values(); + void disabled(); + void valueSource(); + void followTo(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativesmoothedfollow::tst_qdeclarativesmoothedfollow() +{ +} + +void tst_qdeclarativesmoothedfollow::defaultValues() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollow1.qml")); + QDeclarativeSmoothedFollow *obj = qobject_cast<QDeclarativeSmoothedFollow*>(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 0.); + QCOMPARE(obj->velocity(), 200.); + QCOMPARE(obj->duration(), -1); + QCOMPARE(obj->maximumEasingTime(), -1); + QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedFollow::Eased); + + delete obj; +} + +void tst_qdeclarativesmoothedfollow::values() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollow2.qml")); + QDeclarativeSmoothedFollow *obj = qobject_cast<QDeclarativeSmoothedFollow*>(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 10.); + QCOMPARE(obj->velocity(), 200.); + QCOMPARE(obj->duration(), 300); + QCOMPARE(obj->maximumEasingTime(), -1); + QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedFollow::Immediate); + + delete obj; +} + +void tst_qdeclarativesmoothedfollow::disabled() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollow3.qml")); + QDeclarativeSmoothedFollow *obj = qobject_cast<QDeclarativeSmoothedFollow*>(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 10.); + QCOMPARE(obj->velocity(), 250.); + QCOMPARE(obj->maximumEasingTime(), 150); + QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedFollow::Sync); + + delete obj; +} + +void tst_qdeclarativesmoothedfollow::valueSource() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollowValueSource.qml")); + + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *theRect = rect->findChild<QDeclarativeRectangle*>("theRect"); + QVERIFY(theRect); + + QDeclarativeSmoothedFollow *easeX = rect->findChild<QDeclarativeSmoothedFollow*>("easeX"); + QVERIFY(easeX); + QVERIFY(easeX->enabled()); + + QDeclarativeSmoothedFollow *easeY = rect->findChild<QDeclarativeSmoothedFollow*>("easeY"); + QVERIFY(easeY); + QVERIFY(easeY->enabled()); + + // XXX get the proper duration + QTest::qWait(200); + + QTRY_COMPARE(theRect->x(), easeX->to()); + QTRY_COMPARE(theRect->y(), easeY->to()); + + QTRY_COMPARE(theRect->x(), qreal(200)); + QTRY_COMPARE(theRect->y(), qreal(200)); +} + +void tst_qdeclarativesmoothedfollow::followTo() +{ + QDeclarativeView canvas; + canvas.setFixedSize(240,320); + + canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/smoothedfollowDisabled.qml")); + canvas.show(); + canvas.setFocus(); + QVERIFY(canvas.rootObject() != 0); + + QDeclarativeRectangle *rect = canvas.rootObject()->findChild<QDeclarativeRectangle*>("theRect"); + QVERIFY(rect != 0); + + QDeclarativeSmoothedFollow *animX = canvas.rootObject()->findChild<QDeclarativeSmoothedFollow*>("animX"); + QVERIFY(animX != 0); + QDeclarativeSmoothedFollow *animY = canvas.rootObject()->findChild<QDeclarativeSmoothedFollow*>("animY"); + QVERIFY(animY != 0); + + QVERIFY(animX->enabled()); + QVERIFY(!animY->enabled()); + + // animX should track 'to' + animX->setTo(50.0); + // animY should not track this 'to' change + animY->setTo(50.0); + + // XXX get the proper duration + QTest::qWait(250); + + QTRY_COMPARE(rect->x(), animX->to()); + + QCOMPARE(rect->x(), 50.0); + QCOMPARE(rect->y(), 100.0); +} + +QTEST_MAIN(tst_qdeclarativesmoothedfollow) + +#include "tst_qdeclarativesmoothedfollow.moc" diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml index 7c81fb5..ffbf7d5 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml +++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml @@ -1,7 +1,7 @@ import Qt 4.6 SpringFollow { - source: 1.44; velocity: 0.9 + to: 1.44; velocity: 0.9 spring: 1.0; damping: 0.5 epsilon: 0.25; modulus: 360.0 mass: 2.0; enabled: true diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml index 6fec55b..9a8f6f3 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml +++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml @@ -1,7 +1,7 @@ import Qt 4.6 SpringFollow { - source: 1.44; velocity: 0.9 + to: 1.44; velocity: 0.9 spring: 1.0; damping: 0.5 epsilon: 0.25; modulus: 360.0 mass: 2.0; enabled: false diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp index 7a60e78..8a07d6b 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp +++ b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp @@ -72,7 +72,7 @@ void tst_qdeclarativespringfollow::defaultValues() QVERIFY(obj != 0); - QCOMPARE(obj->sourceValue(), 0.); + QCOMPARE(obj->to(), 0.); QCOMPARE(obj->velocity(), 0.); QCOMPARE(obj->spring(), 0.); QCOMPARE(obj->damping(), 0.); @@ -94,7 +94,7 @@ void tst_qdeclarativespringfollow::values() QVERIFY(obj != 0); - QCOMPARE(obj->sourceValue(), 1.44); + QCOMPARE(obj->to(), 1.44); QCOMPARE(obj->velocity(), 0.9); QCOMPARE(obj->spring(), 1.0); QCOMPARE(obj->damping(), 0.5); @@ -117,7 +117,7 @@ void tst_qdeclarativespringfollow::disabled() QVERIFY(obj != 0); - QCOMPARE(obj->sourceValue(), 1.44); + QCOMPARE(obj->to(), 1.44); QCOMPARE(obj->velocity(), 0.9); QCOMPARE(obj->spring(), 1.0); QCOMPARE(obj->damping(), 0.5); diff --git a/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml new file mode 100644 index 0000000..1872de8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml @@ -0,0 +1,32 @@ +import Qt 4.7 + +Item { + Column { + anchors.centerIn: parent + Image { id: image1; objectName: "image1" } + Image { id: image2; objectName: "image2" } + Image { id: image3; objectName: "image3" } + } + + states: State { + name: "SetImageState" + PropertyChanges { + target: image1 + source: "images/qt-logo.png" + } + PropertyChanges { + target: image2 + source: "images/" + "qt-logo.png" + } + PropertyChanges { + target: image3 + source: "images/" + (true ? "qt-logo.png" : "") + } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "SetImageState" + } + +} diff --git a/tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.png Binary files differnew file mode 100644 index 0000000..14ddf2a --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/Implementation/images/qt-logo.png diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml new file mode 100644 index 0000000..861ef8f --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Rectangle { + id: container + width: 400 + height: 400 + + states: State { + name: "reanchored" + AnchorChanges { + anchors.top: container.top + } + } +} diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml index 8e9b13a..7da80b3 100644 --- a/tests/auto/declarative/qdeclarativestates/data/reset.qml +++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml @@ -6,7 +6,7 @@ Rectangle { Text { id: theText width: 40 - wrap: true + wrapMode: Text.WordWrap text: "a text string that is longer than 40 pixels" } diff --git a/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml b/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml new file mode 100644 index 0000000..8995b56 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml @@ -0,0 +1,12 @@ +import Qt 4.7 +import "Implementation" + +Rectangle { + width: 100 + height: 200 + + MyType { + objectName: "MyType" + anchors.fill: parent + } +} diff --git a/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml new file mode 100644 index 0000000..7369c63 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Rectangle { + property bool condition1: false + property bool condition2: false + + states: [ + State { name: "state1"; when: condition1 }, + State { name: "state2"; when: condition2 } + ] +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 2ab21a4..578bcb4 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -43,6 +43,7 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativeanchors_p_p.h> #include <private/qdeclarativerectangle_p.h> +#include <private/qdeclarativeimage_p.h> #include <private/qdeclarativetext_p.h> #include <private/qdeclarativepropertychanges_p.h> #include <private/qdeclarativestategroup_p.h> @@ -94,6 +95,7 @@ private slots: void anchorChanges3(); void anchorChanges4(); void anchorChanges5(); + void anchorChangesCrash(); void script(); void restoreEntryValues(); void explicitChanges(); @@ -107,6 +109,8 @@ private slots: void nonExistantProperty(); void reset(); void illegalObjectCreation(); + void whenOrdering(); + void urlResolution(); }; void tst_qdeclarativestates::initTestCase() @@ -716,6 +720,20 @@ void tst_qdeclarativestates::anchorChanges5() delete rect; } +//QTBUG-9609 +void tst_qdeclarativestates::anchorChangesCrash() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChangesCrash.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + rect->setState("reanchored"); + + delete rect; +} + void tst_qdeclarativestates::script() { QDeclarativeEngine engine; @@ -978,6 +996,49 @@ void tst_qdeclarativestates::illegalObjectCreation() QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); } +void tst_qdeclarativestates::whenOrdering() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->state(), QLatin1String("")); + rect->setProperty("condition2", true); + QCOMPARE(rect->state(), QLatin1String("state2")); + rect->setProperty("condition1", true); + QCOMPARE(rect->state(), QLatin1String("state1")); + rect->setProperty("condition2", false); + QCOMPARE(rect->state(), QLatin1String("state1")); + rect->setProperty("condition2", true); + QCOMPARE(rect->state(), QLatin1String("state1")); + rect->setProperty("condition1", false); + rect->setProperty("condition2", false); + QCOMPARE(rect->state(), QLatin1String("")); +} + +void tst_qdeclarativestates::urlResolution() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/urlResolution.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect != 0); + + QDeclarativeItem *myType = rect->findChild<QDeclarativeItem*>("MyType"); + QDeclarativeImage *image1 = rect->findChild<QDeclarativeImage*>("image1"); + QDeclarativeImage *image2 = rect->findChild<QDeclarativeImage*>("image2"); + QDeclarativeImage *image3 = rect->findChild<QDeclarativeImage*>("image3"); + QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); + + myType->setState("SetImageState"); + QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png"); + QCOMPARE(image1->source(), resolved); + QCOMPARE(image2->source(), resolved); + QCOMPARE(image3->source(), resolved); +} + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" diff --git a/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp index 7b1293e..e475d42 100644 --- a/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp +++ b/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp @@ -71,11 +71,16 @@ void tst_qdeclarativestyledtext::textOutput_data() QTest::newRow("missing </b>") << "<b>text" << "text"; QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic"; QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text"; + QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text"; QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text"; QTest::newRow("font empty") << "<font>text</font>" << "text"; QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text"; QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << ""; QTest::newRow("extra close") << "<b>text</b></b>" << "text"; + QTest::newRow("extra space") << "<b >text</b>" << "text"; + QTest::newRow("entities") << "<b>this & that</b>" << "<b>this & that</b>"; + QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") ; + QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") ; QTest::newRow("empty") << "" << ""; } diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index bbbbd83..bf7d110 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -251,18 +251,18 @@ void tst_qdeclarativetext::wrap() // for specified width and wrap set true { QDeclarativeComponent textComponent(&engine); - textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl::fromLocalFile("")); + textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); textHeight = textObject->height(); QVERIFY(textObject != 0); - QVERIFY(textObject->wrap() == true); + QVERIFY(textObject->wrapMode() == QDeclarativeText::WordWrap); QCOMPARE(textObject->width(), 300.); } for (int i = 0; i < standard.size(); i++) { - QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + standard.at(i) + "\" }"; + QString componentStr = "import Qt 4.6\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); @@ -278,7 +278,7 @@ void tst_qdeclarativetext::wrap() for (int i = 0; i < richText.size(); i++) { - QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + richText.at(i) + "\" }"; + QString componentStr = "import Qt 4.6\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); diff --git a/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml b/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml index 8d7dbbc..1aed8d8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml +++ b/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - property var myInput: input + property variant myInput: input width: 800; height: 600; color: "blue" diff --git a/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml index 103a627..69a6479 100644 --- a/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml +++ b/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - property var myInput: input + property variant myInput: input width: 800; height: 600; color: "blue" diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index b1935df..d578f68 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -235,7 +235,7 @@ void tst_qdeclarativetextedit::wrap() // for specified width and wrap set true { QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl()); + texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -244,7 +244,7 @@ void tst_qdeclarativetextedit::wrap() for (int i = 0; i < standard.size(); i++) { - QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }"; + QString componentStr = "import Qt 4.6\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); @@ -255,7 +255,7 @@ void tst_qdeclarativetextedit::wrap() for (int i = 0; i < richText.size(); i++) { - QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }"; + QString componentStr = "import Qt 4.6\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); diff --git a/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml index 493db5b..04f06da 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - property var myInput: input + property variant myInput: input width: 800; height: 600; color: "blue" diff --git a/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml index c47371a..41e8b59 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - property var myInput: input + property variant myInput: input width: 800; height: 600; color: "blue" diff --git a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml index 531a232..4b1ba27 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml @@ -1,9 +1,9 @@ import Qt 4.7 Item { - property var intInput: intInput - property var dblInput: dblInput - property var strInput: strInput + property variant intInput: intInput + property variant dblInput: dblInput + property variant strInput: strInput width: 800; height: 600; diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index b6f55dd..dd74c09 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -73,6 +73,7 @@ private slots: void sendRequestSoftwareInputPanelEvent(); void setHAlignClearCache(); + void focusOutClearSelection(); private: void simulateKey(QDeclarativeView *, int key); @@ -112,6 +113,8 @@ void tst_qdeclarativetextinput::text() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), QString("")); + + delete textinputObject; } for (int i = 0; i < standard.size(); i++) @@ -123,6 +126,8 @@ void tst_qdeclarativetextinput::text() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), standard.at(i)); + + delete textinputObject; } } @@ -137,6 +142,8 @@ void tst_qdeclarativetextinput::width() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), 1.);//1 for the cursor + + delete textinputObject; } for (int i = 0; i < standard.size(); i++) @@ -152,6 +159,8 @@ void tst_qdeclarativetextinput::width() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor + + delete textinputObject; } } @@ -168,6 +177,8 @@ void tst_qdeclarativetextinput::font() QCOMPARE(textinputObject->font().pointSize(), 40); QCOMPARE(textinputObject->font().bold(), false); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -179,6 +190,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().bold(), true); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -190,6 +203,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().italic(), true); QCOMPARE(textinputObject->font().bold(), false); + + delete textinputObject; } { @@ -202,6 +217,8 @@ void tst_qdeclarativetextinput::font() QCOMPARE(textinputObject->font().family(), QString("Helvetica")); QCOMPARE(textinputObject->font().bold(), false); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -212,6 +229,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().family(), QString("")); + + delete textinputObject; } } @@ -226,6 +245,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); + + delete textinputObject; } //test selection color @@ -237,6 +258,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); + + delete textinputObject; } //test selected text color @@ -248,6 +271,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); + + delete textinputObject; } { @@ -262,6 +287,8 @@ void tst_qdeclarativetextinput::color() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), testColor); + + delete textinputObject; } } @@ -344,6 +371,8 @@ void tst_qdeclarativetextinput::selection() QVERIFY(textinputObject->selectedText().size() == 10); textinputObject->setSelectionEnd(100); QVERIFY(textinputObject->selectedText().size() == 10); + + delete textinputObject; } void tst_qdeclarativetextinput::maxLength() @@ -371,6 +400,8 @@ void tst_qdeclarativetextinput::maxLength() QTest::keyPress(canvas, Qt::Key_A); QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); } + + delete canvas; } void tst_qdeclarativetextinput::masks() @@ -393,6 +424,8 @@ void tst_qdeclarativetextinput::masks() QTest::keyPress(canvas, Qt::Key_A); QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); } + + delete canvas; } void tst_qdeclarativetextinput::validators() @@ -485,6 +518,8 @@ void tst_qdeclarativetextinput::validators() QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); QCOMPARE(strInput->text(), QLatin1String("aaaa")); QCOMPARE(strInput->hasAcceptableInput(), true); + + delete canvas; } void tst_qdeclarativetextinput::inputMethodHints() @@ -499,6 +534,8 @@ void tst_qdeclarativetextinput::inputMethodHints() QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly); + + delete canvas; } /* @@ -536,6 +573,8 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasFocus() == true); + + delete canvas; } void tst_qdeclarativetextinput::cursorDelegate() @@ -563,6 +602,8 @@ void tst_qdeclarativetextinput::cursorDelegate() //Test Delegate gets deleted textInputObject->setCursorDelegate(0); QVERIFY(!textInputObject->findChild<QDeclarativeItem*>("cursorInstance")); + + delete view; } void tst_qdeclarativetextinput::readOnly() @@ -585,6 +626,8 @@ void tst_qdeclarativetextinput::readOnly() simulateKey(canvas, Qt::Key_Space); simulateKey(canvas, Qt::Key_Escape); QCOMPARE(input->text(), initial); + + delete canvas; } void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key) @@ -683,6 +726,29 @@ void tst_qdeclarativetextinput::setHAlignClearCache() QCOMPARE(input.nbPaint, 2); } +void tst_qdeclarativetextinput::focusOutClearSelection() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QDeclarativeTextInput input; + QDeclarativeTextInput input2; + input.setText(QLatin1String("Hello world")); + input.setFocus(true); + scene.addItem(&input2); + scene.addItem(&input); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + input.setSelectionStart(2); + input.setSelectionEnd(5); + //The selection should work + QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); + input2.setFocus(true); + QApplication::processEvents(); + //The input lost the focus selection should be cleared + QTRY_COMPARE(input.selectedText(), QLatin1String("")); +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml index c82b533..d431b4a 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml @@ -1,7 +1,7 @@ import Test 1.0 MyTypeObject { - property var value + property variant value rect: value diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml index 691a56c..3a48c8b 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml @@ -1,7 +1,7 @@ import Test 1.0 MyTypeObject { - property var object + property variant object object: MyTypeObject { rect.x: 19 rect.y: 33 diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml index 05459f4..7c22775 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml @@ -1,12 +1,11 @@ import Test 1.0 import Qt 4.6 +import "deletedObject.js" as JS MyTypeObject { - property var object - - Script { source: "deletedObject.js" } + property variant object object: MyTypeObject {} - Component.onCompleted: startup() - onRunScript: afterDelete() + Component.onCompleted: JS.startup() + onRunScript: JS.afterDelete() } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml index e1d1ce0..d73bb13 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml @@ -13,6 +13,6 @@ MyTypeObject { property int f_capitalization: font.capitalization property real f_letterSpacing: font.letterSpacing property real f_wordSpacing: font.wordSpacing; - property var copy: font + property variant copy: font } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml new file mode 100644 index 0000000..2ec69d7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + font.pointSize: 19 + font.pixelSize: 10 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml new file mode 100644 index 0000000..4c12f21 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import Test 1.0 + +Item { + MyTypeObject { + objectName: "object1" + font.pixelSize: 19 + } + MyTypeObject { + objectName: "object2" + font.pointSize: 14 + } +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml index 3e67de6..4bb6c53 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml @@ -3,5 +3,5 @@ import Test 1.0 MyTypeObject { property int p_x: point.x property int p_y: point.y - property var copy: point + property variant copy: point } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml index d845a5b..0eab6da 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml @@ -3,6 +3,6 @@ import Test 1.0 MyTypeObject { property real p_x: pointf.x property real p_y: pointf.y - property var copy: pointf + property variant copy: pointf } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml index 5364431..c3b37a7 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml @@ -5,6 +5,6 @@ MyTypeObject { property int r_y: rect.y property int r_width: rect.width property int r_height: rect.height - property var copy: rect + property variant copy: rect } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml index aeb9f41..6ff3ce3 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml @@ -5,6 +5,6 @@ MyTypeObject { property real r_y: rectf.y property real r_width: rectf.width property real r_height: rectf.height - property var copy: rectf + property variant copy: rectf } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml index 29157e8..42fccfa 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml @@ -1,7 +1,7 @@ import Test 1.0 MyTypeObject { - property var object + property variant object object: MyTypeObject { rect.x: 19 rect.y: 33 diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml index 86dba03..a49fd9f 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml @@ -3,6 +3,6 @@ import Test 1.0 MyTypeObject { property int s_width: size.width property int s_height: size.height - property var copy: size + property variant copy: size } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml index c6f34e4..96cd425 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml @@ -3,7 +3,7 @@ import Test 1.0 MyTypeObject { property real s_width: sizef.width property real s_height: sizef.height - property var copy: sizef + property variant copy: sizef } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml new file mode 100644 index 0000000..7f708a0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int s_width: sizereadonly.width + property int s_height: sizereadonly.height + property variant copy: sizereadonly +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml new file mode 100644 index 0000000..3254557 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly: "13x88" +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml new file mode 100644 index 0000000..656d718 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly.width: if (true) 13 + sizereadonly.height: if (true) 88 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml new file mode 100644 index 0000000..b8e3f0d --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly.width: 13 + sizereadonly.height: 88 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml new file mode 100644 index 0000000..8ae2ef8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + Component.onCompleted: { + sizereadonly.width = 13; + } +} + + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml index abdf9f0..f1e876d 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml @@ -4,6 +4,6 @@ MyTypeObject { property real v_x: vector.x property real v_y: vector.y property real v_z: vector.z - property var copy: vector + property variant copy: vector } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 0ad8449..9057b4f 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -63,6 +63,7 @@ class MyTypeObject : public QObject Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed) Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed) + Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed) Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed) Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed) Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed) @@ -134,6 +135,7 @@ QML_DECLARE_TYPE(MyTypeObject); class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource { Q_OBJECT + Q_INTERFACES(QDeclarativePropertyValueSource) public: virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); } }; @@ -142,6 +144,7 @@ QML_DECLARE_TYPE(MyConstantValueSource); class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor { Q_OBJECT + Q_INTERFACES(QDeclarativePropertyValueInterceptor) public: virtual void setTarget(const QDeclarativeProperty &p) { prop = p; } virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 4e254eb..e653abf 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -59,6 +59,7 @@ private slots: void pointf(); void size(); void sizef(); + void sizereadonly(); void rect(); void rectf(); void vector3d(); @@ -193,6 +194,50 @@ void tst_qdeclarativevaluetypes::sizef() } } +void tst_qdeclarativevaluetypes::sizereadonly() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("s_width").toInt(), 1912); + QCOMPARE(object->property("s_height").toInt(), 1913); + QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913))); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror2.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror3.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror4.qml")); + + QObject *object = component.create(); + QVERIFY(object); + + QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913)); + + delete object; + } +} + void tst_qdeclarativevaluetypes::rect() { { @@ -352,6 +397,30 @@ void tst_qdeclarativevaluetypes::font() delete object; } + { + QDeclarativeComponent component(&engine, TEST_FILE("font_write.4.qml")); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->font().pixelSize(), 10); + + delete object; + } + { + QDeclarativeComponent component(&engine, TEST_FILE("font_write.5.qml")); + QObject *object = qobject_cast<QObject *>(component.create()); + QVERIFY(object != 0); + MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1"); + QVERIFY(object1 != 0); + MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2"); + QVERIFY(object2 != 0); + + QCOMPARE(object1->font().pixelSize(), 19); + QCOMPARE(object2->font().pointSize(), 14); + + delete object; + } } // Test bindings can write to value types diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml index 1fce155..ca989f8 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml @@ -4,7 +4,7 @@ WorkerScript { id: worker source: "script.js" - property var response + property variant response signal done() diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml index 9049fc7..0b4badc 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml @@ -4,55 +4,53 @@ QtObject { property bool xmlTest: false property bool dataOK: false - Script { - function checkAttr(documentElement, attr) - { - if (attr == null) - return; + function checkAttr(documentElement, attr) + { + if (attr == null) + return; - if (attr.name != "attr") - return; + if (attr.name != "attr") + return; - if (attr.value != "myvalue") - return; + if (attr.value != "myvalue") + return; - if (attr.ownerElement.tagName != documentElement.tagName) - return; + if (attr.ownerElement.tagName != documentElement.tagName) + return; - if (attr.nodeName != "attr") - return; + if (attr.nodeName != "attr") + return; - if (attr.nodeValue != "myvalue") - return; + if (attr.nodeValue != "myvalue") + return; - if (attr.nodeType != 2) - return; + if (attr.nodeType != 2) + return; - if (attr.childNodes.length != 0) - return; + if (attr.childNodes.length != 0) + return; - if (attr.firstChild != null) - return; + if (attr.firstChild != null) + return; - if (attr.lastChild != null) - return; + if (attr.lastChild != null) + return; - if (attr.previousSibling != null) - return; + if (attr.previousSibling != null) + return; - if (attr.nextSibling != null) - return; + if (attr.nextSibling != null) + return; - if (attr.attributes != null) - return; + if (attr.attributes != null) + return; - xmlTest = true; - } + xmlTest = true; + } - function checkXML(document) - { - checkAttr(document.documentElement, document.documentElement.attributes[0]); - } + function checkXML(document) + { + checkAttr(document.documentElement, document.documentElement.attributes[0]); } Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml index b2d0209..928e514 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml @@ -4,108 +4,106 @@ QtObject { property bool xmlTest: false property bool dataOK: false - Script { - function checkCData(text, whitespacetext) - { - // This is essentially a copy of text.qml/checkText() + function checkCData(text, whitespacetext) + { + // This is essentially a copy of text.qml/checkText() - if (text == null) - return; + if (text == null) + return; - if (text.nodeName != "#cdata-section") - return; + if (text.nodeName != "#cdata-section") + return; - if (text.nodeValue != "Hello world!") - return; + if (text.nodeValue != "Hello world!") + return; - if (text.nodeType != 4) - return; + if (text.nodeType != 4) + return; - if (text.parentNode.nodeName != "item") - return; + if (text.parentNode.nodeName != "item") + return; - if (text.childNodes.length != 0) - return; + if (text.childNodes.length != 0) + return; - if (text.firstChild != null) - return; + if (text.firstChild != null) + return; - if (text.lastChild != null) - return; + if (text.lastChild != null) + return; - if (text.previousSibling != null) - return; + if (text.previousSibling != null) + return; - if (text.nextSibling != null) - return; + if (text.nextSibling != null) + return; - if (text.attributes != null) - return; + if (text.attributes != null) + return; - if (text.wholeText != "Hello world!") - return; + if (text.wholeText != "Hello world!") + return; - if (text.data != "Hello world!") - return; + if (text.data != "Hello world!") + return; - if (text.length != 12) - return; + if (text.length != 12) + return; - if (text.isElementContentWhitespace != false) - return; + if (text.isElementContentWhitespace != false) + return; - if (whitespacetext.nodeName != "#cdata-section") - return; + if (whitespacetext.nodeName != "#cdata-section") + return; - if (whitespacetext.nodeValue != " ") - return; + if (whitespacetext.nodeValue != " ") + return; - if (whitespacetext.nodeType != 4) - return; + if (whitespacetext.nodeType != 4) + return; - if (whitespacetext.parentNode.nodeName != "item") - return; + if (whitespacetext.parentNode.nodeName != "item") + return; - if (whitespacetext.childNodes.length != 0) - return; + if (whitespacetext.childNodes.length != 0) + return; - if (whitespacetext.firstChild != null) - return; + if (whitespacetext.firstChild != null) + return; - if (whitespacetext.lastChild != null) - return; + if (whitespacetext.lastChild != null) + return; - if (whitespacetext.previousSibling != null) - return; + if (whitespacetext.previousSibling != null) + return; - if (whitespacetext.nextSibling != null) - return; + if (whitespacetext.nextSibling != null) + return; - if (whitespacetext.attributes != null) - return; + if (whitespacetext.attributes != null) + return; - if (whitespacetext.wholeText != " ") - return; + if (whitespacetext.wholeText != " ") + return; - if (whitespacetext.data != " ") - return; + if (whitespacetext.data != " ") + return; - if (whitespacetext.length != 3) - return; + if (whitespacetext.length != 3) + return; - if (whitespacetext.isElementContentWhitespace != true) - return; + if (whitespacetext.isElementContentWhitespace != true) + return; - xmlTest = true; - } + xmlTest = true; + } - function checkXML(document) - { - checkCData(document.documentElement.childNodes[0].childNodes[0], - document.documentElement.childNodes[1].childNodes[0]); + function checkXML(document) + { + checkCData(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); - } } Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml index e372361..682ea9f 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml @@ -4,34 +4,32 @@ QtObject { property bool xmlTest: false property bool dataOK: false - Script { - function checkXML(document) - { - if (document.xmlVersion != "1.0") - return; + function checkXML(document) + { + if (document.xmlVersion != "1.0") + return; - if (document.xmlEncoding != "UTF-8") - return; + if (document.xmlEncoding != "UTF-8") + return; - if (document.xmlStandalone != true) - return; + if (document.xmlStandalone != true) + return; - if (document.documentElement == null) - return; + if (document.documentElement == null) + return; - if (document.nodeName != "#document") - return; + if (document.nodeName != "#document") + return; - if (document.nodeValue != null) - return; + if (document.nodeValue != null) + return; - if (document.parentNode != null) - return; + if (document.parentNode != null) + return; - // ### Test other node properties - // ### test encoding (what is a valid qt encoding?) - xmlTest = true; - } + // ### Test other node properties + // ### test encoding (what is a valid qt encoding?) + xmlTest = true; } Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml index 78c0374..200214f 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml @@ -4,122 +4,120 @@ QtObject { property bool xmlTest: false property bool dataOK: false - Script { - function checkElement(e, person, fruit) - { - if (e.tagName != "root") - return; + function checkElement(e, person, fruit) + { + if (e.tagName != "root") + return; - if (e.nodeName != "root") - return; + if (e.nodeName != "root") + return; - if (e.nodeValue != null) - return; + if (e.nodeValue != null) + return; - if (e.nodeType != 1) - return; + if (e.nodeType != 1) + return; - var childTagNames = [ "person", "fruit" ]; + var childTagNames = [ "person", "fruit" ]; - if (e.childNodes.length != childTagNames.length) - return; + if (e.childNodes.length != childTagNames.length) + return; - for (var ii = 0; ii < childTagNames.length; ++ii) { - if (e.childNodes[ii].tagName != childTagNames[ii]) - return; - } - - if (e.childNodes[childTagNames.length + 1] != null) + for (var ii = 0; ii < childTagNames.length; ++ii) { + if (e.childNodes[ii].tagName != childTagNames[ii]) return; + } - // Check writing fails - e.childNodes[0] = null; - if (e.childNodes[0] == null) - return; + if (e.childNodes[childTagNames.length + 1] != null) + return; - e.childNodes[10] = 10; - if (e.childNodes[10] != null) - return; + // Check writing fails + e.childNodes[0] = null; + if (e.childNodes[0] == null) + return; - if (e.firstChild.tagName != e.childNodes[0].tagName) - return; + e.childNodes[10] = 10; + if (e.childNodes[10] != null) + return; - if (e.lastChild.tagName != e.childNodes[1].tagName) - return; + if (e.firstChild.tagName != e.childNodes[0].tagName) + return; - if (e.previousSibling != null) - return; + if (e.lastChild.tagName != e.childNodes[1].tagName) + return; - if (e.nextSibling != null) - return; + if (e.previousSibling != null) + return; - if (e.attributes == null) - return; + if (e.nextSibling != null) + return; - if (e.attributes.length != 2) - return; + if (e.attributes == null) + return; - var attr1 = e.attributes["attr"]; - if (attr1.nodeValue != "value") - return; + if (e.attributes.length != 2) + return; - var attrIdx = e.attributes[0]; - if (attrIdx.nodeValue != "value") - return; + var attr1 = e.attributes["attr"]; + if (attr1.nodeValue != "value") + return; - var attr2 = e.attributes["attr2"]; - if (attr2.nodeValue != "value2") - return; + var attrIdx = e.attributes[0]; + if (attrIdx.nodeValue != "value") + return; - var attr3 = e.attributes["attr3"]; - if (attr3 != null) - return; + var attr2 = e.attributes["attr2"]; + if (attr2.nodeValue != "value2") + return; - var attrIdx2 = e.attributes[11]; - if (attrIdx2 != null) - return; + var attr3 = e.attributes["attr3"]; + if (attr3 != null) + return; - // Check writing fails - e.attributes[0] = null; - if (e.attributes[0] == null) - return; + var attrIdx2 = e.attributes[11]; + if (attrIdx2 != null) + return; - e.attributes["attr"] = null; - if (e.attributes["attr"] == null) - return; + // Check writing fails + e.attributes[0] = null; + if (e.attributes[0] == null) + return; - e.attributes["attr3"] = 10; - if (e.attributes["attr3"] != null) - return; + e.attributes["attr"] = null; + if (e.attributes["attr"] == null) + return; - // Check person and fruit sub elements - if (person.parentNode.nodeName != "root") - return; + e.attributes["attr3"] = 10; + if (e.attributes["attr3"] != null) + return; - if (person.previousSibling != null) - return; + // Check person and fruit sub elements + if (person.parentNode.nodeName != "root") + return; - if (person.nextSibling.nodeName != "fruit") - return; + if (person.previousSibling != null) + return; - if (fruit.parentNode.nodeName != "root") - return; + if (person.nextSibling.nodeName != "fruit") + return; - if (fruit.previousSibling.nodeName != "person") - return; + if (fruit.parentNode.nodeName != "root") + return; - if (fruit.nextSibling != null) - return; + if (fruit.previousSibling.nodeName != "person") + return; - xmlTest = true; - } + if (fruit.nextSibling != null) + return; - function checkXML(document) - { - checkElement(document.documentElement, - document.documentElement.childNodes[0], - document.documentElement.childNodes[1]); - } + xmlTest = true; + } + + function checkXML(document) + { + checkElement(document.documentElement, + document.documentElement.childNodes[0], + document.documentElement.childNodes[1]); } Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml index 4615a07..0eb31d5 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml @@ -4,105 +4,103 @@ QtObject { property bool xmlTest: false property bool dataOK: false - Script { - function checkText(text, whitespacetext) - { - if (text == null) - return; + function checkText(text, whitespacetext) + { + if (text == null) + return; - if (text.nodeName != "#text") - return; + if (text.nodeName != "#text") + return; - if (text.nodeValue != "Hello world!") - return; + if (text.nodeValue != "Hello world!") + return; - if (text.nodeType != 3) - return; + if (text.nodeType != 3) + return; - if (text.parentNode.nodeName != "item") - return; + if (text.parentNode.nodeName != "item") + return; - if (text.childNodes.length != 0) - return; + if (text.childNodes.length != 0) + return; - if (text.firstChild != null) - return; + if (text.firstChild != null) + return; - if (text.lastChild != null) - return; + if (text.lastChild != null) + return; - if (text.previousSibling != null) - return; + if (text.previousSibling != null) + return; - if (text.nextSibling != null) - return; + if (text.nextSibling != null) + return; - if (text.attributes != null) - return; + if (text.attributes != null) + return; - if (text.wholeText != "Hello world!") - return; + if (text.wholeText != "Hello world!") + return; - if (text.data != "Hello world!") - return; + if (text.data != "Hello world!") + return; - if (text.length != 12) - return; + if (text.length != 12) + return; - if (text.isElementContentWhitespace != false) - return; + if (text.isElementContentWhitespace != false) + return; - if (whitespacetext.nodeName != "#text") - return; + if (whitespacetext.nodeName != "#text") + return; - if (whitespacetext.nodeValue != " ") - return; + if (whitespacetext.nodeValue != " ") + return; - if (whitespacetext.nodeType != 3) - return; + if (whitespacetext.nodeType != 3) + return; - if (whitespacetext.parentNode.nodeName != "item") - return; + if (whitespacetext.parentNode.nodeName != "item") + return; - if (whitespacetext.childNodes.length != 0) - return; + if (whitespacetext.childNodes.length != 0) + return; - if (whitespacetext.firstChild != null) - return; + if (whitespacetext.firstChild != null) + return; - if (whitespacetext.lastChild != null) - return; + if (whitespacetext.lastChild != null) + return; - if (whitespacetext.previousSibling != null) - return; + if (whitespacetext.previousSibling != null) + return; - if (whitespacetext.nextSibling != null) - return; + if (whitespacetext.nextSibling != null) + return; - if (whitespacetext.attributes != null) - return; + if (whitespacetext.attributes != null) + return; - if (whitespacetext.wholeText != " ") - return; + if (whitespacetext.wholeText != " ") + return; - if (whitespacetext.data != " ") - return; + if (whitespacetext.data != " ") + return; - if (whitespacetext.length != 3) - return; + if (whitespacetext.length != 3) + return; - if (whitespacetext.isElementContentWhitespace != true) - return; + if (whitespacetext.isElementContentWhitespace != true) + return; - xmlTest = true; - } + xmlTest = true; + } - function checkXML(document) - { - checkText(document.documentElement.childNodes[0].childNodes[0], - document.documentElement.childNodes[1].childNodes[0]); + function checkXML(document) + { + checkText(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); - } } Component.onCompleted: { diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/colorAnimation.qml b/tests/auto/declarative/qmlvisual/animation/colorAnimation/colorAnimation-visual.qml index f205ae8..f205ae8 100644 --- a/tests/auto/declarative/qmlvisual/animation/colorAnimation/colorAnimation.qml +++ b/tests/auto/declarative/qmlvisual/animation/colorAnimation/colorAnimation-visual.qml diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.qml b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.qml index 4d0959a..4d0959a 100644 --- a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.qml +++ b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.qml diff --git a/tests/auto/declarative/qmlvisual/animation/easing/pics/qtlogo.png b/tests/auto/declarative/qmlvisual/animation/easing/pics/qtlogo.png Binary files differdeleted file mode 100644 index 399bd0b..0000000 --- a/tests/auto/declarative/qmlvisual/animation/easing/pics/qtlogo.png +++ /dev/null diff --git a/tests/auto/declarative/qmlvisual/animation/parallelAnimation/data/parallelAnimation.qml b/tests/auto/declarative/qmlvisual/animation/parallelAnimation/data/parallelAnimation-visual.qml index 5f5b8fc..5f5b8fc 100644 --- a/tests/auto/declarative/qmlvisual/animation/parallelAnimation/data/parallelAnimation.qml +++ b/tests/auto/declarative/qmlvisual/animation/parallelAnimation/data/parallelAnimation-visual.qml diff --git a/tests/auto/declarative/qmlvisual/animation/parallelAnimation/parallelAnimation.qml b/tests/auto/declarative/qmlvisual/animation/parallelAnimation/parallelAnimation-visual.qml index 1980b91..ba606f4 100644 --- a/tests/auto/declarative/qmlvisual/animation/parallelAnimation/parallelAnimation.qml +++ b/tests/auto/declarative/qmlvisual/animation/parallelAnimation/parallelAnimation-visual.qml @@ -1,5 +1,13 @@ import Qt 4.6 +/* + This test verifies that a single animation animating two properties is visually the same as two + animations in a parallel group animating the same properties. Visually, you should see a red + rectangle at 0,0 stretching from the top of the window to the bottom. This rect will be moved to + the right side of the window while turning purple. If the bottom half is visually different + than the top half, there is a problem. +*/ + Rectangle { width: 400; height: 200 Rectangle { diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.qml b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.qml index 7c8c233..7c8c233 100644 --- a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.qml +++ b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.qml diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/qmlvisual/animation/propertyAction/propertyAction-visual.qml index e18e770..5651b87 100644 --- a/tests/auto/declarative/qmlvisual/animation/propertyAction/propertyAction.qml +++ b/tests/auto/declarative/qmlvisual/animation/propertyAction/propertyAction-visual.qml @@ -1,5 +1,12 @@ import Qt 4.6 +/* +This test starts with a red rectangle at 0,0. It should animate a color change to blue, +then jump 50 pixels right, and then animate moving 50 pixels down. Afer this it should +do an exact visual reversal (animate up 50 pixels, jump left 50 pixels, and then animate +a change back to red). +*/ + Rectangle { width: 400; height: 400 Rectangle { diff --git a/tests/auto/declarative/qmlvisual/animation/scriptAction/data/scriptAction.qml b/tests/auto/declarative/qmlvisual/animation/scriptAction/data/scriptAction-visual.qml index 01da490..01da490 100644 --- a/tests/auto/declarative/qmlvisual/animation/scriptAction/data/scriptAction.qml +++ b/tests/auto/declarative/qmlvisual/animation/scriptAction/data/scriptAction-visual.qml diff --git a/tests/auto/declarative/qmlvisual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/qmlvisual/animation/scriptAction/scriptAction-visual.qml index fc9ccc8..dc2fcee 100644 --- a/tests/auto/declarative/qmlvisual/animation/scriptAction/scriptAction.qml +++ b/tests/auto/declarative/qmlvisual/animation/scriptAction/scriptAction-visual.qml @@ -1,5 +1,10 @@ import Qt 4.6 +/* +This test starts with a red rectangle at 0,0. It should animate moving 50 pixels right, +then immediately change blue, and then animate moving 50 pixels down. +*/ + Rectangle { width: 400; height: 400 Rectangle { diff --git a/tests/auto/declarative/qmlvisual/fillmode/fillmode.qml b/tests/auto/declarative/qmlvisual/fillmode/fillmode.qml index 8450bf2..7c3b486 100644 --- a/tests/auto/declarative/qmlvisual/fillmode/fillmode.qml +++ b/tests/auto/declarative/qmlvisual/fillmode/fillmode.qml @@ -1,5 +1,10 @@ import Qt 4.6 +/* + This is a static display test of the various Image fill modes. See the png file in the data + subdirectory to see what the image should look like. +*/ + Rectangle { id: screen; width: 750; height: 600; color: "gray" property string source: "face.png" diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png Binary files differindex cf36d60..5b7b426 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png Binary files differindex 6069df8..7c27310 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png Binary files differindex b8bd5f3..cbfdb23 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png Binary files differindex cf36d60..5b7b426 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png Binary files differindex 831d6b4..5af705e 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png Binary files differindex f7079dc..af4395e 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png Binary files differindex a5f4451..cd12bc9 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png Binary files differindex e1261d0..471c86b 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml index 5a131e9..f3071e4 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml @@ -486,7 +486,7 @@ VisualTest { } Frame { msec: 1840 - hash: "b6b4b2c7acddd23609caa9727911b981" + hash: "668cc6d9d699b947a7c0f3ff4b26853f" } Mouse { type: 5 @@ -498,7 +498,7 @@ VisualTest { } Frame { msec: 1856 - hash: "b6b4b2c7acddd23609caa9727911b981" + hash: "668cc6d9d699b947a7c0f3ff4b26853f" } Mouse { type: 5 @@ -510,7 +510,7 @@ VisualTest { } Frame { msec: 1872 - hash: "022610222cfbcf9e9a8991cdb60c7bbb" + hash: "668cc6d9d699b947a7c0f3ff4b26853f" } Mouse { type: 5 @@ -522,7 +522,7 @@ VisualTest { } Frame { msec: 1888 - hash: "9b5201a3201a102b20592d81218b5e74" + hash: "668cc6d9d699b947a7c0f3ff4b26853f" } Mouse { type: 5 diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml new file mode 100644 index 0000000..5dee0c6 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml @@ -0,0 +1,40 @@ +import Qt 4.6 + +Rectangle { + width: 800; height: 240; color: "gray" + + Rectangle { + id: rect + width: 50; height: 20; y: 30; color: "black" + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: 50; to: 700; duration: 2000 } + NumberAnimation { from: 700; to: 50; duration: 2000 } + } + } + + Rectangle { + width: 50; height: 20; y: 60; color: "red" + SmoothedFollow on x { to: rect.x; velocity: 400; enabled: true } + } + + Rectangle { + width: 50; height: 20; y: 90; color: "yellow" + SmoothedFollow on x { to: rect.x; velocity: 300; reversingMode: SmoothedAnimation.Immediate; enabled: true } + } + + Rectangle { + width: 50; height: 20; y: 120; color: "green" + SmoothedFollow on x { to: rect.x; reversingMode: SmoothedAnimation.Sync; enabled: true } + } + + Rectangle { + width: 50; height: 20; y: 150; color: "purple" + SmoothedFollow on x { to: rect.x; maximumEasingTime: 200; enabled: true } + } + + Rectangle { + width: 50; height: 20; y: 180; color: "blue" + SmoothedFollow on x { to: rect.x; duration: 300; enabled: true } + } +} diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml index 21bbc7f..0ddcca4 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml @@ -5,9 +5,9 @@ Rectangle { color: "gray" width: 200; height: 200 - property var hours: 10 - property var minutes: 28 - property var seconds: 0 + property variant hours: 10 + property variant minutes: 28 + property variant seconds: 0 Timer { interval: 1000; running: true; repeat: true; triggeredOnStart: true @@ -25,7 +25,7 @@ Rectangle { origin.x: 7.5; origin.y: 73; angle: 0 SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 - source: (clock.hours * 30) + (clock.minutes * 0.5) + to: (clock.hours * 30) + (clock.minutes * 0.5) } } } @@ -39,7 +39,7 @@ Rectangle { origin.x: 6.5; origin.y: 83; angle: 0 SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 - source: clock.minutes * 6 + to: clock.minutes * 6 } } } @@ -53,7 +53,7 @@ Rectangle { origin.x: 2.5; origin.y: 80; angle: 0 SpringFollow on angle { spring: 5; damping: 0.25; modulus: 360 - source: clock.seconds * 6 + to: clock.seconds * 6 } } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml index 1659bb7..5368349 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml @@ -26,7 +26,7 @@ Rectangle { color: "#ff0000" x: rect.width; width: rect.width; height: 20 y: 200 - SpringFollow on y { source: rect.y; velocity: 200 } + SpringFollow on y { to: rect.y; velocity: 200 } } // Spring @@ -34,13 +34,13 @@ Rectangle { color: "#ff0000" x: rect.width * 2; width: rect.width/2; height: 20 y: 200 - SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2 } + SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2 } } Rectangle { color: "#880000" x: rect.width * 2.5; width: rect.width/2; height: 20 y: 200 - SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object + SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object } // Follow mouse @@ -52,8 +52,8 @@ Rectangle { width: 20; height: 20 radius: 10 color: "#0000ff" - SpringFollow on x { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } - SpringFollow on y { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } + SpringFollow on x { id: f1; to: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } + SpringFollow on y { id: f2; to: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } states: [ State { name: "following" diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml index a3aa929..90b5411 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml @@ -61,7 +61,7 @@ Rectangle { text: s.text; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignBottom; width: 800; height: 20 } Text { - text: s.text; font.pixelSize: 18; style: Text.Outline; styleColor: "white"; wrap: true; width: 200 + text: s.text; font.pixelSize: 18; style: Text.Outline; styleColor: "white"; wrapMode: Text.WordWrap; width: 200 } Text { text: s.text; elide: Text.ElideLeft; width: 200 @@ -73,13 +73,19 @@ Rectangle { text: s.text; elide: Text.ElideRight; width: 200 } Text { - text: s.text; elide: Text.ElideLeft; width: 200; wrap: true + text: s.text; elide: Text.ElideLeft; width: 200; wrapMode: Text.WordWrap } Text { - text: s.text; elide: Text.ElideMiddle; width: 200; wrap: true + text: s.text; elide: Text.ElideMiddle; width: 200; wrapMode: Text.WordWrap } Text { - text: s.text; elide: Text.ElideRight; width: 200; wrap: true + text: s.text; elide: Text.ElideRight; width: 200; wrapMode: Text.WordWrap + } + Text { + text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAnywhere + } + Text { + text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAtWordBoundaryOrAnywhere } } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml index 35aa232..0dba47c 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml @@ -61,7 +61,7 @@ Rectangle { text: s.text; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignBottom; width: 800; height: 20 } Text { - text: s.text; font.pixelSize: 18; style: Text.Outline; styleColor: "white"; wrap: true; width: 200 + text: s.text; font.pixelSize: 18; style: Text.Outline; styleColor: "white"; wrapMode: Text.WordWrap; width: 200 } Text { text: s.text; elide: Text.ElideLeft; width: 200 @@ -73,13 +73,19 @@ Rectangle { text: s.text; elide: Text.ElideRight; width: 200 } Text { - text: s.text; elide: Text.ElideLeft; width: 200; wrap: true + text: s.text; elide: Text.ElideLeft; width: 200; wrapMode: Text.WordWrap } Text { - text: s.text; elide: Text.ElideMiddle; width: 200; wrap: true + text: s.text; elide: Text.ElideMiddle; width: 200; wrapMode: Text.WordWrap } Text { - text: s.text; elide: Text.ElideRight; width: 200; wrap: true + text: s.text; elide: Text.ElideRight; width: 200; wrapMode: Text.WordWrap + } + Text { + text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAnywhere + } + Text { + text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAtWordBoundaryOrAnywhere } } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml index f9fe025..b2a0754 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml @@ -5,17 +5,30 @@ Item { width: 200 TextEdit { width: 200 - height: 200 - wrap: true + height: 100 + wrapMode: TextEdit.WordWrap focus: true } //With QTBUG-6273 only the bottom one would be wrapped TextEdit { width: 200 - height: 200 - wrap: true + height: 100 + wrapMode: TextEdit.WordWrap text: "This is a test that text edit wraps correctly." + y:100 + } + TextEdit { + width: 150 + height: 100 + wrapMode: TextEdit.WrapAnywhere + text: "This is a test that text edit wraps correctly. thisisaverylongstringwithnospaces" y:200 } - + TextEdit { + width: 150 + height: 100 + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + text: "This is a test that text edit wraps correctly. thisisaverylongstringwithnospaces" + y:300 + } } diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 91f8486..05c2ebd 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -101,11 +101,19 @@ void tst_qmlvisual::visual_data() files << findQmlFiles(QDir(QT_TEST_SOURCE_DIR)); else { //these are tests we think are stable and useful enough to be run by the CI system - files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/mousearea-visual.qml"; - files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/drag.qml"; - files << QT_TEST_SOURCE_DIR "/animation/pauseAnimation/pauseAnimation-visual.qml"; + files << QT_TEST_SOURCE_DIR "/animation/bindinganimation/bindinganimation.qml"; + files << QT_TEST_SOURCE_DIR "/animation/colorAnimation/colorAnimation-visual.qml"; + files << QT_TEST_SOURCE_DIR "/animation/easing/easing.qml"; + files << QT_TEST_SOURCE_DIR "/animation/loop/loop.qml"; + files << QT_TEST_SOURCE_DIR "/animation/parallelAnimation/parallelAnimation-visual.qml"; files << QT_TEST_SOURCE_DIR "/animation/parentAnimation/parentAnimation-visual.qml"; + files << QT_TEST_SOURCE_DIR "/animation/pauseAnimation/pauseAnimation-visual.qml"; + files << QT_TEST_SOURCE_DIR "/animation/propertyAction/propertyAction-visual.qml"; files << QT_TEST_SOURCE_DIR "/animation/reanchor/reanchor.qml"; + files << QT_TEST_SOURCE_DIR "/animation/scriptAction/scriptAction-visual.qml"; + files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/mousearea-visual.qml"; + files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/drag.qml"; + files << QT_TEST_SOURCE_DIR "/fillmode/fillmode.qml"; } foreach (const QString &file, files) { diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml b/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml index fe1bb70..711a747 100644 --- a/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml +++ b/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml @@ -1,8 +1,8 @@ import Qt 4.6 Item { - property var period : 250 - property var color : "black" + property variant period : 250 + property variant color : "black" id: root Item { diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp index e8a5e0c..1bab2d2 100644 --- a/tests/auto/declarative/sql/tst_sql.cpp +++ b/tests/auto/declarative/sql/tst_sql.cpp @@ -197,11 +197,13 @@ void tst_sql::testQml() QString qml= "import Qt 4.6\n" - "Text { Script { source: \""+jsfile+"\" } text: test() }"; + "import \""+jsfile+"\" as JS\n" + "Text { text: JS.test() }"; engine->setOfflineStoragePath(dbDir()); QDeclarativeComponent component(engine); component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports + QVERIFY(!component.isError()); QDeclarativeText *text = qobject_cast<QDeclarativeText*>(component.create()); QVERIFY(text != 0); QCOMPARE(text->text(),QString("passed")); |