diff options
author | Martin Smith <martin.smith@nokia.com> | 2010-07-13 09:33:02 (GMT) |
---|---|---|
committer | Martin Smith <martin.smith@nokia.com> | 2010-07-13 09:33:02 (GMT) |
commit | e305732c0df93332a514a957b08e0ce283cb747f (patch) | |
tree | 603522227e5d4e9f2994408afd5d5523951ba648 /tests | |
parent | c93c9bbfe94cd271aeda9e2730d343e3eee31ec5 (diff) | |
parent | a296749eaea94ae4ed36086b632d32c87d3d99c9 (diff) | |
download | Qt-e305732c0df93332a514a957b08e0ce283cb747f.zip Qt-e305732c0df93332a514a957b08e0ce283cb747f.tar.gz Qt-e305732c0df93332a514a957b08e0ce283cb747f.tar.bz2 |
Fixing merge conflicts.
Merge branch '4.7-upstream' into 4.7
Conflicts:
doc/src/declarative/advtutorial.qdoc
src/declarative/graphicsitems/qdeclarativeloader.cpp
src/declarative/graphicsitems/qdeclarativetextedit.cpp
src/declarative/qml/qdeclarativeengine.cpp
src/declarative/util/qdeclarativexmllistmodel.cpp
Diffstat (limited to 'tests')
64 files changed, 823 insertions, 564 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 3d2dbf0..a7fb3b8 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -52,8 +52,7 @@ SUBDIRS += \ qdeclarativeqt \ qdeclarativerepeater \ qdeclarativesmoothedanimation \ - qdeclarativesmoothedfollow\ - qdeclarativespringfollow \ + qdeclarativespringanimation \ qdeclarativesqldatabase \ qdeclarativestates \ qdeclarativestyledtext \ diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index a965ef3..3e80c2c 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -310,7 +310,7 @@ void tst_qdeclarativeanimations::badTypes() c.create(); QVERIFY(c.errors().count() == 1); - QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected")); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected")); } //make sure we get a compiler error diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml new file mode 100644 index 0000000..d439875 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +Rectangle { + id: root + width:200; height:200 + + property real myValue: 0 + + Rectangle { + anchors.centerIn: parent + width: 100 + height: 100 + color: "green" + smooth: true + rotation: myValue + Behavior on rotation { + RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest } + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 70739fb..5c2c145 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> +#include <qsignalspy.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativeview.h> @@ -78,6 +79,7 @@ private slots: void dontStart(); void startup(); void groupedPropertyCrash(); + void runningTrue(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -366,6 +368,22 @@ void tst_qdeclarativebehaviors::groupedPropertyCrash() QVERIFY(rect); //don't crash } +//QTBUG-5491 +void tst_qdeclarativebehaviors::runningTrue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeAbstractAnimation *animation = rect->findChild<QDeclarativeAbstractAnimation*>("rotAnim"); + QVERIFY(animation); + + QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool))); + rect->setProperty("myValue", 180); + QTRY_VERIFY(runningSpy.count() > 0); +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index dcd1a85..4a945f3 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -71,7 +71,7 @@ class tst_QDeclarativeDebug : public QObject Q_OBJECT private: - QDeclarativeDebugObjectReference findRootObject(); + QDeclarativeDebugObjectReference findRootObject(int context = 0); QDeclarativeDebugPropertyReference findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const; void waitForQuery(QDeclarativeDebugQuery *query); @@ -111,9 +111,11 @@ private slots: void tst_QDeclarativeDebugObjectReference(); void tst_QDeclarativeDebugContextReference(); void tst_QDeclarativeDebugPropertyReference(); + + void setMethodBody(); }; -QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject() +QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int context) { QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); waitForQuery(q_engines); @@ -125,7 +127,7 @@ QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject() if (q_context->rootContext().objects().count() == 0) return QDeclarativeDebugObjectReference(); - QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this); + QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[context], this); waitForQuery(q_obj); QDeclarativeDebugObjectReference result = q_obj->object(); @@ -290,10 +292,19 @@ void tst_QDeclarativeDebug::initTestCase() "onEntered: { console.log('hello') }" "}" "}"; + // add second component to test multiple root contexts qml << "import Qt 4.7\n" "Item {}"; + // and a third to test methods + qml << "import Qt 4.7\n" + "Item {" + "function myMethodNoArgs() { return 3; }\n" + "function myMethod(a) { return a + 9; }\n" + "function myMethodIndirect() { myMethod(3); }\n" + "}"; + for (int i=0; i<qml.count(); i++) { QDeclarativeComponent component(m_engine); component.setData(qml[i], QUrl::fromLocalFile("")); @@ -322,6 +333,43 @@ void tst_QDeclarativeDebug::cleanupTestCase() qDeleteAll(m_components); } +void tst_QDeclarativeDebug::setMethodBody() +{ + QDeclarativeDebugObjectReference obj = findRootObject(2); + + QObject *root = m_components.at(2); + // Without args + { + QVariant rv; + QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv))); + QVERIFY(rv == QVariant(qreal(3))); + + + QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7")); + QTest::qWait(100); + + QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv))); + QVERIFY(rv == QVariant(qreal(7))); + } + + // With args + { + QVariant rv; + QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); + QVERIFY(rv == QVariant(qreal(28))); + + QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7")); + QTest::qWait(100); + + QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); + QVERIFY(rv == QVariant(qreal(26))); + } +} + void tst_QDeclarativeDebug::watch_property() { QDeclarativeDebugObjectReference obj = findRootObject(); @@ -581,7 +629,7 @@ void tst_QDeclarativeDebug::queryRootContexts() QCOMPARE(context.debugId(), QDeclarativeDebugService::idForObject(actualContext)); QCOMPARE(context.name(), actualContext->objectName()); - QCOMPARE(context.objects().count(), 2); // 2 qml component objects created for context in main() + QCOMPARE(context.objects().count(), 3); // 3 qml component objects created for context in main() // root context query sends only root object data - it doesn't fill in // the children or property info diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index 13960b1..5028ba1 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -279,7 +279,7 @@ void tst_qdeclarativedom::loadComposite() void tst_qdeclarativedom::testValueSource() { QByteArray qml = "import Qt 4.7\n" - "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; to: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; + "Rectangle { SpringAnimation on height { spring: 1.4; damping: .15; to: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; QDeclarativeEngine freshEngine; QDeclarativeDomDocument document; @@ -295,7 +295,7 @@ void tst_qdeclarativedom::testValueSource() QDeclarativeDomObject valueSourceObject = valueSource.object(); QVERIFY(valueSourceObject.isValid()); - QVERIFY(valueSourceObject.objectType() == "Qt/SpringFollow"); + QVERIFY(valueSourceObject.objectType() == "Qt/SpringAnimation"); const QDeclarativeDomValue springValue = valueSourceObject.property("spring").value(); QVERIFY(!springValue.isInvalid()); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml index db7f2b5..2c79729 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml @@ -7,7 +7,7 @@ MyTypeObject { uintProperty: if(1) 10 intProperty: if(1) -19 realProperty: if(1) 23.2 - doubleProperty: if(1) -19.7 + doubleProperty: if(1) -19.75 floatProperty: if(1) 8.5 colorProperty: if(1) "red" dateProperty: if(1) "1982-11-25" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml index 72ae865..1cd78a5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml @@ -9,7 +9,7 @@ MyTypeObject { uintProperty = 10 intProperty = -19 realProperty = 23.2 - doubleProperty = -19.7 + doubleProperty = -19.75 floatProperty = 8.5 colorProperty = "red" dateProperty = "1982-11-25" diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 849879e..19bfd37 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -572,7 +572,7 @@ public: Q_INVOKABLE void method_NoArgs() { invoke(0); } Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; } - Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.7; } + Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; } Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); } Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; } Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 43900ae..a6d2dac 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -179,7 +179,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes() QCOMPARE(object->uintProperty(), uint(10)); QCOMPARE(object->intProperty(), -19); QCOMPARE((float)object->realProperty(), float(23.2)); - QCOMPARE((float)object->doubleProperty(), float(-19.7)); + QCOMPARE((float)object->doubleProperty(), float(-19.75)); QCOMPARE((float)object->floatProperty(), float(8.5)); QCOMPARE(object->colorProperty(), QColor("red")); QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); @@ -207,7 +207,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes() QCOMPARE(object->uintProperty(), uint(10)); QCOMPARE(object->intProperty(), -19); QCOMPARE((float)object->realProperty(), float(23.2)); - QCOMPARE((float)object->doubleProperty(), float(-19.7)); + QCOMPARE((float)object->doubleProperty(), float(-19.75)); QCOMPARE((float)object->floatProperty(), float(8.5)); QCOMPARE(object->colorProperty(), QColor("red")); QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); @@ -280,8 +280,8 @@ void tst_qdeclarativeecmascript::signalAssignment() MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->string(), QString()); - emit object->argumentSignal(19, "Hello world!", 10.3); - QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3")); + emit object->argumentSignal(19, "Hello world!", 10.25); + QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25")); } } @@ -1387,7 +1387,7 @@ void tst_qdeclarativeecmascript::callQtInvokables() QCOMPARE(o.actuals().count(), 0); o.reset(); - QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7))); + QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.75))); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), 2); QCOMPARE(o.actuals().count(), 0); @@ -1818,7 +1818,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1831,7 +1831,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1844,7 +1844,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1857,7 +1857,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->methodCalled(), true); delete object; @@ -1870,7 +1870,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->methodCalled(), true); delete object; @@ -1883,7 +1883,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -1899,13 +1899,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -1918,13 +1918,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -1937,13 +1937,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 3); delete object; @@ -1955,13 +1955,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 3); delete object; diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml new file mode 100644 index 0000000..6c39f20 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml @@ -0,0 +1,28 @@ +import Qt 4.7 + +Rectangle { + id: root + width:300; height:400 + + property bool focus1: root.wantsFocus + property bool focus2: item1.wantsFocus + property bool focus3: fs1.wantsFocus + property bool focus4: fs2.wantsFocus + property bool focus5: theItem.wantsFocus + + Item { + id: item1 + FocusScope { + id: fs1 + focus: true + FocusScope { + id: fs2 + focus: true + Item { + id: theItem + focus: true + } + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml index 5904fd6..af9c420 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml @@ -8,10 +8,10 @@ Rectangle { FocusScope { id: firstScope + objectName: "item0" focus: true Rectangle { - objectName: "item0" height: 120; width: 420 color: "transparent" @@ -44,9 +44,9 @@ Rectangle { FocusScope { id: secondScope + objectName: "item3" Rectangle { - objectName: "item3" y: 160; height: 120; width: 420 color: "transparent" diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml index 6b09c29..aa43ba8 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml @@ -9,12 +9,12 @@ Rectangle { FocusScope { id: myScope + objectName: "item0" focus: true Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { - objectName: "item0" height: 120 width: 420 diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml index d67ec57..cdb5164 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml @@ -9,12 +9,12 @@ Rectangle { FocusScope { id: myScope + objectName: "item0" focus: true Keys.onReturnPressed: console.log("Error - FocusScope") Rectangle { - objectName: "item0" height: 120 width: 420 diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 7732e6d..2559087 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -68,6 +68,7 @@ private slots: void noFocus(); void textEdit(); void forceFocus(); + void noParentFocus(); }; /* @@ -97,7 +98,7 @@ void tst_qdeclarativefocusscope::basic() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml")); - QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0")); + QDeclarativeFocusScope *item0 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item0")); QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1")); QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2")); QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3")); @@ -228,7 +229,7 @@ void tst_qdeclarativefocusscope::textEdit() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml")); - QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0")); + QDeclarativeFocusScope *item0 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item0")); QDeclarativeTextEdit *item1 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item1")); QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2")); QDeclarativeTextEdit *item3 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item3")); @@ -283,10 +284,10 @@ void tst_qdeclarativefocusscope::forceFocus() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forcefocus.qml")); - QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0")); + QDeclarativeFocusScope *item0 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item0")); QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1")); QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2")); - QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3")); + QDeclarativeFocusScope *item3 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item3")); QDeclarativeRectangle *item4 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item4")); QDeclarativeRectangle *item5 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item5")); QVERIFY(item0 != 0); @@ -333,6 +334,20 @@ void tst_qdeclarativefocusscope::forceFocus() delete view; } +void tst_qdeclarativefocusscope::noParentFocus() +{ + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml")); + QVERIFY(view->rootObject()); + + QVERIFY(view->rootObject()->property("focus1") == true); + QVERIFY(view->rootObject()->property("focus2") == false); + QVERIFY(view->rootObject()->property("focus3") == true); + QVERIFY(view->rootObject()->property("focus4") == true); + QVERIFY(view->rootObject()->property("focus5") == true); + + delete view; +} QTEST_MAIN(tst_qdeclarativefocusscope) diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png Binary files differnew file mode 100644 index 0000000..3245027 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png Binary files differnew file mode 100644 index 0000000..b16db76 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index c09f7fc..38fd458 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -88,7 +88,6 @@ private slots: void resized(); void preserveAspectRatio(); void smooth(); - void pixmap(); void svg(); void big(); void tiling_QTBUG_6716(); @@ -124,8 +123,8 @@ void tst_qdeclarativeimage::noSource() void tst_qdeclarativeimage::imageSource_data() { QTest::addColumn<QString>("source"); - QTest::addColumn<qreal>("width"); - QTest::addColumn<qreal>("height"); + QTest::addColumn<double>("width"); + QTest::addColumn<double>("height"); QTest::addColumn<bool>("remote"); QTest::addColumn<bool>("async"); QTest::addColumn<QString>("error"); @@ -146,8 +145,8 @@ void tst_qdeclarativeimage::imageSource_data() void tst_qdeclarativeimage::imageSource() { QFETCH(QString, source); - QFETCH(qreal, width); - QFETCH(qreal, height); + QFETCH(double, width); + QFETCH(double, height); QFETCH(bool, remote); QFETCH(bool, async); QFETCH(QString, error); @@ -178,8 +177,8 @@ void tst_qdeclarativeimage::imageSource() if (error.isEmpty()) { TRY_WAIT(obj->status() == QDeclarativeImage::Ready); - QCOMPARE(obj->width(), width); - QCOMPARE(obj->height(), height); + QCOMPARE(obj->width(), qreal(width)); + QCOMPARE(obj->height(), qreal(height)); QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); QCOMPARE(obj->progress(), 1.0); } else { @@ -261,36 +260,6 @@ void tst_qdeclarativeimage::smooth() delete obj; } -void tst_qdeclarativeimage::pixmap() -{ - QString componentStr = "import Qt 4.7\nImage { pixmap: testPixmap }"; - - QPixmap pixmap; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("testPixmap", pixmap); - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - - QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->source(), QUrl()); - QVERIFY(obj->status() == QDeclarativeImage::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); - QCOMPARE(obj->progress(), 0.0); - QVERIFY(obj->pixmap().isNull()); - - pixmap = QPixmap(SRCDIR "/data/colors.png"); - ctxt->setContextProperty("testPixmap", pixmap); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - QVERIFY(obj->status() == QDeclarativeImage::Ready); - - delete obj; -} - void tst_qdeclarativeimage::svg() { QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.svg").toString(); @@ -307,6 +276,8 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-mac.png")); #elif defined(Q_OS_WIN32) QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png")); +#elif defined(QT_ARCH_ARM) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-arm.png")); #else QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); #endif @@ -321,6 +292,8 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-mac.png")); #elif defined(Q_OS_WIN32) QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png")); +#elif defined(QT_ARCH_ARM) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-arm.png")); #else QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); #endif diff --git a/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png Binary files differdeleted file mode 100644 index 399bd0b..0000000 --- a/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png +++ /dev/null diff --git a/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png Binary files differdeleted file mode 100644 index 399bd0b..0000000 --- a/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png +++ /dev/null diff --git a/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png Binary files differdeleted file mode 100644 index 399bd0b..0000000 --- a/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png +++ /dev/null diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index 4185790..e0b46f0 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -61,6 +61,8 @@ QVERIFY((expr)); \ } while (false) +Q_DECLARE_METATYPE(QDeclarativeImageProvider*); + class tst_qdeclarativeimageprovider : public QObject { @@ -71,43 +73,103 @@ public: } private slots: - void imageSource(); - void imageSource_data(); + void requestImage_sync_data(); + void requestImage_sync(); + void requestImage_async_data(); + void requestImage_async(); + + void requestPixmap_sync_data(); + void requestPixmap_sync(); + void requestPixmap_async(); + + void removeProvider_data(); void removeProvider(); private: - QDeclarativeEngine engine; + QString newImageFileName() const; + void fillRequestTestsData(const QString &id); + void runTest(bool async, QDeclarativeImageProvider *provider); +}; + + +class TestQImageProvider : public QDeclarativeImageProvider +{ +public: + TestQImageProvider() + : QDeclarativeImageProvider(Image) + { + } + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + if (id == QLatin1String("no-such-file.png")) + return QImage(); + + int width = 100; + int height = 100; + QImage image(width, height, QImage::Format_RGB32); + if (size) + *size = QSize(width, height); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } }; +Q_DECLARE_METATYPE(TestQImageProvider*); + -class TestProvider : public QDeclarativeImageProvider +class TestQPixmapProvider : public QDeclarativeImageProvider { public: - QImage request(const QString &id, QSize *size, const QSize& requested_size) { - QImageReader io(SRCDIR "/data/" + id); - if (size) *size = io.size(); - if (requested_size.isValid()) - io.setScaledSize(requested_size); - return io.read(); + TestQPixmapProvider() + : QDeclarativeImageProvider(Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) + { + if (id == QLatin1String("no-such-file.png")) + return QPixmap(); + + int width = 100; + int height = 100; + QPixmap image(width, height); + if (size) + *size = QSize(width, height); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; } }; +Q_DECLARE_METATYPE(TestQPixmapProvider*); -void tst_qdeclarativeimageprovider::imageSource_data() + +QString tst_qdeclarativeimageprovider::newImageFileName() const +{ + // need to generate new filenames each time or else images are loaded + // from cache and we won't get loading status changes when testing + // async loading + static int count = 0; + return QString("image://test/image-%1.png").arg(count++); +} + +void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id) { QTest::addColumn<QString>("source"); QTest::addColumn<QString>("properties"); QTest::addColumn<QSize>("size"); QTest::addColumn<QString>("error"); - QTest::newRow("exists") << "image://test/exists.png" << "" << QSize(100,100) << ""; - QTest::newRow("scaled") << "image://test/exists.png" << "sourceSize: \"80x30\"" << QSize(80,30) << ""; - QTest::newRow("missing") << "image://test/no-such-file.png" << "" << QSize() + QTest::newRow(QTest::toString(id + " exists")) << newImageFileName() << "" << QSize(100,100) << ""; + QTest::newRow(QTest::toString(id + " scaled")) << newImageFileName() << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + + QTest::newRow(QTest::toString(id + " missing")) << "image://test/no-such-file.png" << "" << QSize() << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; - QTest::newRow("unknown provider") << "image://bogus/exists.png" << "" << QSize() + QTest::newRow(QTest::toString(id + " unknown provider")) << "image://bogus/exists.png" << "" << QSize() << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; - } - -void tst_qdeclarativeimageprovider::imageSource() + +void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider) { QFETCH(QString, source); QFETCH(QString, properties); @@ -117,21 +179,29 @@ void tst_qdeclarativeimageprovider::imageSource() if (!error.isEmpty()) QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - engine.addImageProvider("test", new TestProvider); + QDeclarativeEngine engine; + + engine.addImageProvider("test", provider); QVERIFY(engine.imageProvider("test") != 0); - QString componentStr = "import Qt 4.7\nImage { source: \"" + source + "\"; " + properties + " }"; + QString componentStr = "import Qt 4.7\nImage { source: \"" + source + "\"; " + + (async ? "asynchronous: true; " : "") + + properties + " }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); QVERIFY(obj != 0); - TRY_WAIT(obj->status() == QDeclarativeImage::Loading); + if (async) + TRY_WAIT(obj->status() == QDeclarativeImage::Loading); QCOMPARE(obj->source(), QUrl(source)); if (error.isEmpty()) { - TRY_WAIT(obj->status() == QDeclarativeImage::Ready); + if (async) + TRY_WAIT(obj->status() == QDeclarativeImage::Ready); + else + QVERIFY(obj->status() == QDeclarativeImage::Ready); QCOMPARE(obj->width(), 100.0); QCOMPARE(obj->height(), 100.0); QCOMPARE(obj->pixmap().width(), size.width()); @@ -139,40 +209,98 @@ void tst_qdeclarativeimageprovider::imageSource() QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); QCOMPARE(obj->progress(), 1.0); } else { - TRY_WAIT(obj->status() == QDeclarativeImage::Error); + if (async) + TRY_WAIT(obj->status() == QDeclarativeImage::Error); + else + QVERIFY(obj->status() == QDeclarativeImage::Error); } delete obj; } +void tst_qdeclarativeimageprovider::requestImage_sync_data() +{ + fillRequestTestsData("qimage|sync"); +} + +void tst_qdeclarativeimageprovider::requestImage_sync() +{ + runTest(false, new TestQImageProvider); +} + +void tst_qdeclarativeimageprovider::requestImage_async_data() +{ + fillRequestTestsData("qimage|async"); +} + +void tst_qdeclarativeimageprovider::requestImage_async() +{ + runTest(true, new TestQImageProvider); +} + +void tst_qdeclarativeimageprovider::requestPixmap_sync_data() +{ + fillRequestTestsData("qpixmap"); +} + +void tst_qdeclarativeimageprovider::requestPixmap_sync() +{ + runTest(false, new TestQPixmapProvider); +} + +void tst_qdeclarativeimageprovider::requestPixmap_async() +{ + QDeclarativeEngine engine; + QDeclarativeImageProvider *provider = new TestQPixmapProvider; + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + // pixmaps are loaded synchronously regardless of 'asynchronous' value + QString componentStr = "import Qt 4.7\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); + QVERIFY(obj != 0); + + delete obj; +} + +void tst_qdeclarativeimageprovider::removeProvider_data() +{ + QTest::addColumn<QDeclarativeImageProvider*>("provider"); + + QTest::newRow("qimage") << static_cast<QDeclarativeImageProvider*>(new TestQImageProvider); + QTest::newRow("qpixmap") << static_cast<QDeclarativeImageProvider*>(new TestQPixmapProvider); +} + void tst_qdeclarativeimageprovider::removeProvider() { - engine.addImageProvider("test2", new TestProvider); - QVERIFY(engine.imageProvider("test2") != 0); + QFETCH(QDeclarativeImageProvider*, provider); + + QDeclarativeEngine engine; + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); // add provider, confirm it works - QString componentStr = "import Qt 4.7\nImage { source: \"image://test2/exists1.png\" }"; + QString componentStr = "import Qt 4.7\nImage { source: \"" + newImageFileName() + "\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); QVERIFY(obj != 0); - TRY_WAIT(obj->status() == QDeclarativeImage::Loading); - TRY_WAIT(obj->status() == QDeclarativeImage::Ready); - - QCOMPARE(obj->width(), 100.0); + QCOMPARE(obj->status(), QDeclarativeImage::Ready); // remove the provider and confirm - QString error("file::2:1: QML Image: Failed to get image from provider: image://test2/exists2.png"); - + QString fileName = newImageFileName(); + QString error("file::2:1: QML Image: Failed to get image from provider: " + fileName); QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - engine.removeImageProvider("test2"); - - obj->setSource(QUrl("image://test2/exists2.png")); + engine.removeImageProvider("test"); - TRY_WAIT(obj->status() == QDeclarativeImage::Loading); - TRY_WAIT(obj->status() == QDeclarativeImage::Error); + obj->setSource(QUrl(fileName)); + QCOMPARE(obj->status(), QDeclarativeImage::Error); delete obj; } diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 4a57def..ffb2105 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -703,11 +703,8 @@ void tst_QDeclarativeItem::propertyChanges() QCOMPARE(focusArguments.at(0).toBool(), true); QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(parentItem->wantsFocus(), true); - QCOMPARE(wantsFocusSpy.count(),1); - QList<QVariant> wantsFocusArguments = wantsFocusSpy.first(); - QVERIFY(wantsFocusArguments.count() == 1); - QCOMPARE(wantsFocusArguments.at(0).toBool(), true); + QCOMPARE(parentItem->wantsFocus(), false); + QCOMPARE(wantsFocusSpy.count(),0); delete canvas; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt new file mode 100644 index 0000000..3fdac09 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt @@ -0,0 +1 @@ +1:1:"MyComponent.qml": no such directory diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml b/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml new file mode 100644 index 0000000..a0d8410 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml @@ -0,0 +1,3 @@ +import "MyComponent.qml" 1.0 + +MyComponent { text: "Hello" } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir index 0adb0f6..d15720a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir @@ -2,4 +2,3 @@ Rectangle 1.5 InstalledTest2.qml LocalLast 1.0 LocalLast.qml InstalledTest 1.4 InstalledTest2.qml InstalledTest 1.0 InstalledTest.qml -InstalledTestTP 0.0 InstalledTest.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml new file mode 100644 index 0000000..303b5a5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml @@ -0,0 +1,2 @@ +import Qt 4.7 as Qt47 +Qt47.Rectangle {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml new file mode 100644 index 0000000..8c953cb --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml @@ -0,0 +1,2 @@ +import Qt 4.7 +Text {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir new file mode 100644 index 0000000..b301226 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir @@ -0,0 +1,2 @@ +InstalledTest 1.4 InstalledTest2.qml +InstalledTestTP 0.0 InstalledTest.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt index 886da55..6e11786 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt @@ -1,2 +1,2 @@ 4:5:Unable to create type NestedErrorsType -4:8:Invalid property assignment: double expected +4:8:Invalid property assignment: number expected diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt index d0a0b00..d2b8c54 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt @@ -1 +1 @@ -3:19:Invalid property assignment: double expected +3:19:Invalid property assignment: number expected diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 3ce356e..fcdf926 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -289,6 +289,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("importNonExistOlder (installed)") << "importNonExistOlder.qml" << "importNonExistOlder.errors.txt" << false; QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false; QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false; + QTest::newRow("importFile") << "importFile.qml" << "importFile.errors.txt" << false; QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false; QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; @@ -1476,12 +1477,12 @@ void tst_qdeclarativelanguage::importsInstalled_data() // import installed QTest::newRow("installed import 0") - << "import com.nokia.installedtest 0.0\n" + << "import com.nokia.installedtest0 0.0\n" "InstalledTestTP {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 0 as TP") - << "import com.nokia.installedtest 0.0 as TP\n" + << "import com.nokia.installedtest0 0.0 as TP\n" "TP.InstalledTestTP {}" << "QDeclarativeRectangle" << ""; @@ -1500,6 +1501,11 @@ void tst_qdeclarativelanguage::importsInstalled_data() "InstalledTest {}" << "QDeclarativeText" << ""; + QTest::newRow("installed import minor version not available") // QTBUG-11936 + << "import com.nokia.installedtest 0.1\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 0.1 is not installed"; QTest::newRow("installed import minor version not available") // QTBUG-9627 << "import com.nokia.installedtest 1.10\n" "InstalledTest {}" diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 8964f8a..b06ad7c 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -124,6 +124,7 @@ QML_DECLARE_TYPE(ValueInterceptorTestType); { \ cpptype v = (value); cpptype v2 = (value); \ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, 0)); \ + QCOMPARE((cpptype)(v),(cpptype)(defaultvalue)); \ QVERIFY(v == (defaultvalue)); \ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, &v2)); \ QVERIFY(v == (value)); \ @@ -273,7 +274,7 @@ void tst_qdeclarativemetatype::copy() QWidget widgetValue; COPY_TEST(QObject *, QObjectStar, &objectValue, 0); COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0); - COPY_TEST(qreal, QReal, 10.2, 0); + COPY_TEST(qreal, QReal, 10.5, 0); { QVariant tv = QVariant::fromValue(QVariant(10)); diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index f1018b2..0c7780c 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -138,42 +138,37 @@ void tst_qdeclarativepixmapcache::single() expectedError = "Cannot open: " + target.toString(); } - QPixmap pixmap; + QDeclarativePixmap pixmap; QVERIFY(pixmap.width() <= 0); // Check Qt assumption - QString errorString; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap, &errorString); + + pixmap.load(&engine, target); if (incache) { - QCOMPARE(errorString, expectedError); + QCOMPARE(pixmap.error(), expectedError); if (exists) { - QVERIFY(status == QDeclarativePixmapReply::Ready); + QVERIFY(pixmap.status() == QDeclarativePixmap::Ready); QVERIFY(pixmap.width() > 0); } else { - QVERIFY(status == QDeclarativePixmapReply::Error); + QVERIFY(pixmap.status() == QDeclarativePixmap::Error); QVERIFY(pixmap.width() <= 0); } } else { - QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(&engine, target); - QVERIFY(reply); QVERIFY(pixmap.width() <= 0); Slotter getter; - connect(reply, SIGNAL(finished()), &getter, SLOT(got())); + pixmap.connectFinished(&getter, SLOT(got())); QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(getter.gotslot); - QString errorString; if (exists) { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Ready); + QVERIFY(pixmap.status() == QDeclarativePixmap::Ready); QVERIFY(pixmap.width() > 0); } else { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Error); + QVERIFY(pixmap.status() == QDeclarativePixmap::Error); QVERIFY(pixmap.width() <= 0); } - QCOMPARE(errorString, expectedError); + QCOMPARE(pixmap.error(), expectedError); } - - QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0); } void tst_qdeclarativepixmapcache::parallel_data() @@ -185,47 +180,36 @@ void tst_qdeclarativepixmapcache::parallel_data() QTest::addColumn<QUrl>("target2"); QTest::addColumn<int>("incache"); QTest::addColumn<int>("cancel"); // which one to cancel - QTest::addColumn<int>("requests"); QTest::newRow("local") << thisfile.resolved(QUrl("data/exists1.png")) << thisfile.resolved(QUrl("data/exists2.png")) << (localfile_optimized ? 2 : 0) - << -1 - << (localfile_optimized ? 0 : 2) - ; + << -1; QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists2.png") << QUrl("http://127.0.0.1:14452/exists3.png") << 0 - << -1 - << 2 - ; + << -1; QTest::newRow("remoteagain") << QUrl("http://127.0.0.1:14452/exists2.png") << QUrl("http://127.0.0.1:14452/exists3.png") << 2 - << -1 - << 0 - ; + << -1; QTest::newRow("remotecopy") << QUrl("http://127.0.0.1:14452/exists4.png") << QUrl("http://127.0.0.1:14452/exists4.png") << 0 - << -1 - << 1 - ; + << -1; QTest::newRow("remotecopycancel") << QUrl("http://127.0.0.1:14452/exists5.png") << QUrl("http://127.0.0.1:14452/exists5.png") << 0 - << 0 - << 1 - ; + << 0; } void tst_qdeclarativepixmapcache::parallel() @@ -234,38 +218,38 @@ void tst_qdeclarativepixmapcache::parallel() QFETCH(QUrl, target2); QFETCH(int, incache); QFETCH(int, cancel); - QFETCH(int, requests); QList<QUrl> targets; targets << target1 << target2; - QList<QDeclarativePixmapReply*> replies; + QList<QDeclarativePixmap *> pixmaps; + QList<bool> pending; QList<Slotter*> getters; + for (int i=0; i<targets.count(); ++i) { QUrl target = targets.at(i); - QPixmap pixmap; - QString errorString; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap, &errorString); - QDeclarativePixmapReply *reply = 0; - QVERIFY(status != QDeclarativePixmapReply::Error); - if (status != QDeclarativePixmapReply::Error && status != QDeclarativePixmapReply::Ready) - reply = QDeclarativePixmapCache::request(&engine, target); - replies.append(reply); - if (!reply) { - QVERIFY(pixmap.width() > 0); + QDeclarativePixmap *pixmap = new QDeclarativePixmap; + + pixmap->load(&engine, target); + + QVERIFY(pixmap->status() != QDeclarativePixmap::Error); + pixmaps.append(pixmap); + if (pixmap->isReady()) { + QVERIFY(pixmap->width() > 0); getters.append(0); + pending.append(false); } else { - QVERIFY(pixmap.width() <= 0); + QVERIFY(pixmap->width() <= 0); getters.append(new Slotter); - connect(reply, SIGNAL(finished()), getters[i], SLOT(got())); + pixmap->connectFinished(getters[i], SLOT(got())); + pending.append(true); } } QCOMPARE(incache+slotters, targets.count()); - QCOMPARE(QDeclarativePixmapCache::pendingRequests(), requests); if (cancel >= 0) { - QDeclarativePixmapCache::cancel(targets.at(cancel), getters[cancel]); + pixmaps.at(cancel)->clear(getters[cancel]); slotters--; } @@ -275,22 +259,21 @@ void tst_qdeclarativepixmapcache::parallel() } for (int i=0; i<targets.count(); ++i) { - QDeclarativePixmapReply *reply = replies[i]; - if (reply) { - if (i == cancel) { - QVERIFY(!getters[i]->gotslot); - } else { + QDeclarativePixmap *pixmap = pixmaps[i]; + + if (i == cancel) { + QVERIFY(!getters[i]->gotslot); + } else { + if (pending[i]) QVERIFY(getters[i]->gotslot); - QPixmap pixmap; - QString errorString; - QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap, &errorString) == QDeclarativePixmapReply::Ready); - QVERIFY(pixmap.width() > 0); - } + + QVERIFY(pixmap->isReady()); + QVERIFY(pixmap->width() > 0); delete getters[i]; } } - QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0); + qDeleteAll(pixmaps); } QTEST_MAIN(tst_qdeclarativepixmapcache) diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml deleted file mode 100644 index 8c9d8ad..0000000 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml +++ /dev/null @@ -1,3 +0,0 @@ -import Qt 4.7 - -SmoothedFollow {} diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml deleted file mode 100644 index a634302..0000000 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index c60da7f..0000000 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index 486bdee..0000000 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index 2e01d74..0000000 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.7 - -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/tst_qdeclarativesmoothedfollow.cpp b/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp deleted file mode 100644 index b9ac23f..0000000 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** 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" - -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -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/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml new file mode 100644 index 0000000..07587bd --- /dev/null +++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml @@ -0,0 +1,4 @@ +import Qt 4.7 + +SpringAnimation { +} diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml index 31a740a..562f44a 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml +++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml @@ -1,8 +1,9 @@ import Qt 4.7 -SpringFollow { +SpringAnimation { to: 1.44; velocity: 0.9 spring: 1.0; damping: 0.5 epsilon: 0.25; modulus: 360.0 - mass: 2.0; enabled: true + mass: 2.0; + running: true; } diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml index 0fa4aa9..9f70bf4 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml +++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml @@ -1,8 +1,8 @@ import Qt 4.7 -SpringFollow { +SpringAnimation { to: 1.44; velocity: 0.9 spring: 1.0; damping: 0.5 epsilon: 0.25; modulus: 360.0 - mass: 2.0; enabled: false + mass: 2.0; running: false } diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro index dff4922..213b262 100644 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro +++ b/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro @@ -2,7 +2,7 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative gui macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativesmoothedfollow.cpp +SOURCES += tst_qdeclarativespringanimation.cpp symbian: { importFiles.sources = data diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp index e0e2892..4b17a47 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp +++ b/tests/auto/declarative/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp @@ -41,7 +41,7 @@ #include <qtest.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> -#include <private/qdeclarativespringfollow_p.h> +#include <private/qdeclarativespringanimation_p.h> #include <private/qdeclarativevaluetype_p.h> #include "../../../shared/util.h" @@ -50,11 +50,11 @@ #define SRCDIR "." #endif -class tst_qdeclarativespringfollow : public QObject +class tst_qdeclarativespringanimation : public QObject { Q_OBJECT public: - tst_qdeclarativespringfollow(); + tst_qdeclarativespringanimation(); private slots: void defaultValues(); @@ -65,15 +65,15 @@ private: QDeclarativeEngine engine; }; -tst_qdeclarativespringfollow::tst_qdeclarativespringfollow() +tst_qdeclarativespringanimation::tst_qdeclarativespringanimation() { } -void tst_qdeclarativespringfollow::defaultValues() +void tst_qdeclarativespringanimation::defaultValues() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow1.qml")); - QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create()); + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation1.qml")); + QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create()); QVERIFY(obj != 0); @@ -83,19 +83,17 @@ void tst_qdeclarativespringfollow::defaultValues() QCOMPARE(obj->damping(), 0.); QCOMPARE(obj->epsilon(), 0.01); QCOMPARE(obj->modulus(), 0.); - QCOMPARE(obj->value(), 0.); QCOMPARE(obj->mass(), 1.); - QCOMPARE(obj->enabled(), true); - QCOMPARE(obj->inSync(), true); + QCOMPARE(obj->isRunning(), false); delete obj; } -void tst_qdeclarativespringfollow::values() +void tst_qdeclarativespringanimation::values() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow2.qml")); - QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create()); + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation2.qml")); + QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create()); QVERIFY(obj != 0); @@ -106,19 +104,18 @@ void tst_qdeclarativespringfollow::values() QCOMPARE(obj->epsilon(), 0.25); QCOMPARE(obj->modulus(), 360.0); QCOMPARE(obj->mass(), 2.0); - QCOMPARE(obj->enabled(), true); + QCOMPARE(obj->isRunning(), true); - QTRY_COMPARE(obj->value(), 1.44); - QTRY_COMPARE(obj->inSync(), true); + QTRY_COMPARE(obj->isRunning(), false); delete obj; } -void tst_qdeclarativespringfollow::disabled() +void tst_qdeclarativespringanimation::disabled() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow3.qml")); - QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create()); + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation3.qml")); + QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create()); QVERIFY(obj != 0); @@ -129,14 +126,11 @@ void tst_qdeclarativespringfollow::disabled() QCOMPARE(obj->epsilon(), 0.25); QCOMPARE(obj->modulus(), 360.0); QCOMPARE(obj->mass(), 2.0); - QCOMPARE(obj->enabled(), false); - - QCOMPARE(obj->value(), 0.0); - QCOMPARE(obj->inSync(), false); + QCOMPARE(obj->isRunning(), false); delete obj; } -QTEST_MAIN(tst_qdeclarativespringfollow) +QTEST_MAIN(tst_qdeclarativespringanimation) -#include "tst_qdeclarativespringfollow.moc" +#include "tst_qdeclarativespringanimation.moc" diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml deleted file mode 100644 index 8528cfa..0000000 --- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import Qt 4.7 - -SpringFollow { -} diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro deleted file mode 100644 index 1c17ba0..0000000 --- a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro +++ /dev/null @@ -1,16 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativespringfollow.cpp - -symbian: { - importFiles.sources = data - importFiles.path = . - DEPLOYMENT = importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml index b1f701b..762e2b6 100644 --- a/tests/auto/declarative/qdeclarativetext/data/alignments.qml +++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml @@ -20,9 +20,9 @@ Rectangle { id: t anchors.fill: parent - horizontalAlignment: TextEdit.AlignRight - verticalAlignment: TextEdit.AlignBottom - wrapMode: TextEdit.WordWrap + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignBottom + wrapMode: Text.WordWrap text: top.txt } Timer { diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 8a4f152..80198eb 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -48,6 +48,7 @@ #include <QGraphicsSceneMouseEvent> #include <qmath.h> #include <QDeclarativeView> +#include <private/qapplication_p.h> #include "../../../shared/util.h" #include "testhttpserver.h" @@ -452,7 +453,9 @@ void tst_qdeclarativetext::alignments() #ifdef Q_WS_X11 // Font-specific, but not likely platform-specific, so only test on one platform - QCOMPARE(actual,expect); + if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") { + QCOMPARE(actual,expect); + } #endif } diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml index b1f701b..9281a06 100644 --- a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml @@ -16,7 +16,7 @@ Rectangle { height: 40 color: "green" - Text { + TextEdit { id: t anchors.fill: parent diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index f1a367f..4783bc7 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -53,14 +53,34 @@ #include <private/qdeclarativetextedit_p_p.h> #include <QFontMetrics> #include <QDeclarativeView> +#include <QDir> #include <QStyle> #include <QInputContext> +#include <private/qapplication_p.h> +#include <private/qtextcontrol_p.h> #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif +QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +{ + // XXX This will be replaced by some clever persistent platform image store. + QString persistent_dir = SRCDIR "/data"; + QString arch = "unknown-architecture"; // QTest needs to help with this. + + QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; + + if (!QFile::exists(expectfile)) { + actual.save(expectfile); + qWarning() << "created" << expectfile; + } + + return expectfile; +} + + class tst_qdeclarativetextedit : public QObject { @@ -94,6 +114,7 @@ private slots: void delegateLoading(); void navigation(); void readOnly(); + void copyAndPaste(); void openInputPanelOnClick(); void openInputPanelOnFocus(); void geometrySignals(); @@ -206,7 +227,7 @@ void tst_qdeclarativetextedit::width() QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 1.);//+1 for cursor + QCOMPARE(textEditObject->width(), 0.0); } for (int i = 0; i < standard.size(); i++) @@ -222,7 +243,7 @@ void tst_qdeclarativetextedit::width() QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character. + QCOMPARE(textEditObject->width(), qreal(metricWidth)); } for (int i = 0; i < richText.size(); i++) @@ -239,7 +260,7 @@ void tst_qdeclarativetextedit::width() QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3)); + QCOMPARE(textEditObject->width(), qreal(documentWidth)); } } @@ -305,17 +326,17 @@ void tst_qdeclarativetextedit::alignments_data() QTest::addColumn<int>("vAlign"); QTest::addColumn<QString>("expectfile"); - QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png"; - QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png"; - QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png"; + QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt"; + QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt"; + QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct"; - QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png"; - QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png"; - QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png"; + QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb"; + QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb"; + QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb"; - QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png"; - QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png"; - QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png"; + QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc"; + QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc"; + QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc"; } @@ -325,13 +346,6 @@ void tst_qdeclarativetextedit::alignments() QFETCH(int, vAlign); QFETCH(QString, expectfile); -#ifdef Q_WS_X11 - // Font-specific, but not likely platform-specific, so only test on one platform - QFont fn; - fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*"); - QApplication::setFont(fn); -#endif - QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml"); canvas->show(); @@ -349,12 +363,11 @@ void tst_qdeclarativetextedit::alignments() QPainter p(&actual); canvas->render(&p); + expectfile = createExpectedFileIfNotFound(expectfile, actual); + QImage expect(expectfile); -#ifdef Q_WS_X11 - // Font-specific, but not likely platform-specific, so only test on one platform QCOMPARE(actual,expect); -#endif } @@ -489,6 +502,23 @@ void tst_qdeclarativetextedit::font() void tst_qdeclarativetextedit::color() { + //test initial color + { + QString componentStr = "import Qt 4.7\nTextEdit { text: \"Hello World\" }"; + QDeclarativeComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); + + QDeclarativeTextEditPrivate *textEditPrivate = static_cast<QDeclarativeTextEditPrivate*>(QDeclarativeItemPrivate::get(textEditObject)); + + QVERIFY(textEditObject); + QVERIFY(textEditPrivate); + QVERIFY(textEditPrivate->control); + + QPalette pal = textEditPrivate->control->palette(); + QCOMPARE(textEditPrivate->color, QColor("black")); + QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); + } //test normal for (int i = 0; i < colorStrings.size(); i++) { @@ -821,6 +851,52 @@ void tst_qdeclarativetextedit::navigation() QVERIFY(input->hasFocus() == true); } +void tst_qdeclarativetextedit::copyAndPaste() { +#ifndef QT_NO_CLIPBOARD + +#ifdef Q_WS_MAC + { + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + else + QSKIP("This machine doesn't support the clipboard", SkipAll); + } +#endif + + QString componentStr = "import Qt 4.7\nTextEdit { text: \"Hello world!\" }"; + QDeclarativeComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextEdit *textEdit = qobject_cast<QDeclarativeTextEdit*>(textEditComponent.create()); + QVERIFY(textEdit != 0); + + // copy and paste + QCOMPARE(textEdit->text().length(), 12); + textEdit->select(0, textEdit->text().length());; + textEdit->copy(); + QCOMPARE(textEdit->selectedText(), QString("Hello world!")); + QCOMPARE(textEdit->selectedText().length(), 12); + textEdit->setCursorPosition(0); + textEdit->paste(); + QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); + QCOMPARE(textEdit->text().length(), 24); + + // select word + textEdit->setCursorPosition(0); + textEdit->selectWord(); + QCOMPARE(textEdit->selectedText(), QString("Hello")); + + // select all and cut + textEdit->selectAll(); + textEdit->cut(); + QCOMPARE(textEdit->text().length(), 0); + textEdit->paste(); + QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); + QCOMPARE(textEdit->text().length(), 24); +#endif +} + void tst_qdeclarativetextedit::readOnly() { QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml"); diff --git a/tests/auto/declarative/qdeclarativetextinput/data/halign_center.png b/tests/auto/declarative/qdeclarativetextinput/data/halign_center.png Binary files differnew file mode 100644 index 0000000..53e09a8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/halign_center.png diff --git a/tests/auto/declarative/qdeclarativetextinput/data/halign_left.png b/tests/auto/declarative/qdeclarativetextinput/data/halign_left.png Binary files differnew file mode 100644 index 0000000..247acbc --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/halign_left.png diff --git a/tests/auto/declarative/qdeclarativetextinput/data/halign_right.png b/tests/auto/declarative/qdeclarativetextinput/data/halign_right.png Binary files differnew file mode 100644 index 0000000..691bc75 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/halign_right.png diff --git a/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment.qml b/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment.qml new file mode 100644 index 0000000..b97f18e --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +Rectangle { + id: top + width: 70; height: 70; + + property alias horizontalAlignment: text.horizontalAlignment + property string text: "Test" + + Rectangle { + anchors.centerIn: parent + width: 60 + height: 20 + color: "green" + + TextInput { + id: text + anchors.fill: parent + text: top.text + } + } +} diff --git a/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml b/tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml index da6b81f..405ee22 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml @@ -3,4 +3,5 @@ import Qt 4.7 TextInput { text: "Hello world!" inputMethodHints: Qt.ImhNoPredictiveText + Keys.onLeftPressed: {} } diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index a55b42e..a48bc39 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -47,14 +47,32 @@ #include <private/qdeclarativetextinput_p.h> #include <private/qdeclarativetextinput_p_p.h> #include <QDebug> +#include <QDir> #include <QStyle> #include <QInputContext> +#include <private/qapplication_p.h> #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif +QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +{ + // XXX This will be replaced by some clever persistent platform image store. + QString persistent_dir = SRCDIR "/data"; + QString arch = "unknown-architecture"; // QTest needs to help with this. + + QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; + + if (!QFile::exists(expectfile)) { + actual.save(expectfile); + qWarning() << "created" << expectfile; + } + + return expectfile; +} + class tst_qdeclarativetextinput : public QObject { @@ -63,21 +81,26 @@ public: tst_qdeclarativetextinput(); private slots: + void text(); void width(); void font(); void color(); void selection(); + void horizontalAlignment_data(); + void horizontalAlignment(); + void positionAt(); void maxLength(); void masks(); void validators(); - void inputMethodHints(); + void inputMethods(); void cursorDelegate(); void navigation(); + void copyAndPaste(); void readOnly(); void openInputPanelOnClick(); @@ -153,7 +176,7 @@ void tst_qdeclarativetextinput::width() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->width(), 1.);//1 for the cursor + QCOMPARE(textinputObject->width(), 0.0); delete textinputObject; } @@ -170,7 +193,8 @@ void tst_qdeclarativetextinput::width() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor + int delta = abs(int(textinputObject->width()) - metricWidth); + QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform. delete textinputObject; } @@ -370,6 +394,46 @@ void tst_qdeclarativetextinput::selection() delete textinputObject; } +void tst_qdeclarativetextinput::horizontalAlignment_data() +{ + QTest::addColumn<int>("hAlign"); + QTest::addColumn<QString>("expectfile"); + + QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left"; + QTest::newRow("R") << int(Qt::AlignRight) << "halign_right"; + QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center"; +} + +void tst_qdeclarativetextinput::horizontalAlignment() +{ + QFETCH(int, hAlign); + QFETCH(QString, expectfile); + + QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment.qml"); + + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + QObject *ob = canvas->rootObject(); + QVERIFY(ob != 0); + ob->setProperty("horizontalAlignment",hAlign); + QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); + actual.fill(qRgb(255,255,255)); + { + QPainter p(&actual); + canvas->render(&p); + } + + expectfile = createExpectedFileIfNotFound(expectfile, actual); + + QImage expect(expectfile); + + QCOMPARE(actual,expect); + + delete canvas; +} + void tst_qdeclarativetextinput::positionAt() { QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); @@ -412,11 +476,13 @@ void tst_qdeclarativetextinput::positionAt() void tst_qdeclarativetextinput::maxLength() { - //QString componentStr = "import Qt 4.7\nTextInput { maximumLength: 10; }"; QDeclarativeView *canvas = createView(SRCDIR "/data/maxLength.qml"); + QVERIFY(canvas->rootObject() != 0); canvas->show(); canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); QVERIFY(textinputObject != 0); QVERIFY(textinputObject->text().isEmpty()); @@ -557,18 +623,31 @@ void tst_qdeclarativetextinput::validators() delete canvas; } -void tst_qdeclarativetextinput::inputMethodHints() +void tst_qdeclarativetextinput::inputMethods() { - QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethods.qml"); canvas->show(); canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + // test input method hints QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); - QVERIFY(textinputObject != 0); - QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); - textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); - QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly); + QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); + QVERIFY(input != 0); + QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); + input->setInputMethodHints(Qt::ImhUppercaseOnly); + QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly); + + QVERIFY(canvas->rootObject() != 0); + + input->setFocus(true); + QVERIFY(input->hasFocus() == true); + // test that input method event is committed + QInputMethodEvent event; + event.setCommitString( "My ", -12, 0); + QApplication::sendEvent(canvas, &event); + QCOMPARE(input->text(), QString("My Hello world!")); delete canvas; } @@ -619,6 +698,52 @@ void tst_qdeclarativetextinput::navigation() delete canvas; } +void tst_qdeclarativetextinput::copyAndPaste() { +#ifndef QT_NO_CLIPBOARD + +#ifdef Q_WS_MAC + { + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + else + QSKIP("This machine doesn't support the clipboard", SkipAll); + } +#endif + + QString componentStr = "import Qt 4.7\nTextInput { text: \"Hello world!\" }"; + QDeclarativeComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput*>(textInputComponent.create()); + QVERIFY(textInput != 0); + + // copy and paste + QCOMPARE(textInput->text().length(), 12); + textInput->select(0, textInput->text().length());; + textInput->copy(); + QCOMPARE(textInput->selectedText(), QString("Hello world!")); + QCOMPARE(textInput->selectedText().length(), 12); + textInput->setCursorPosition(0); + textInput->paste(); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); + + // select word + textInput->setCursorPosition(0); + textInput->selectWord(); + QCOMPARE(textInput->selectedText(), QString("Hello")); + + // select all and cut + textInput->selectAll(); + textInput->cut(); + QCOMPARE(textInput->text().length(), 0); + textInput->paste(); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); +#endif +} + void tst_qdeclarativetextinput::cursorDelegate() { QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); @@ -930,7 +1055,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QCOMPARE(ic.openInputPanelReceived, false); // input method should be disabled - // if TextEdit loses focus + // if TextInput loses focus input.setFocus(false); QApplication::processEvents(); QVERIFY(view.inputContext() == 0); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 81334f2..a4819f3 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -141,8 +141,8 @@ void tst_qdeclarativevaluetypes::pointf() MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->property("p_x").toDouble(), 11.3); - QCOMPARE(object->property("p_y").toDouble(), -10.9); + QCOMPARE(float(object->property("p_x").toDouble()), float(11.3)); + QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9)); QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9))); delete object; @@ -191,8 +191,8 @@ void tst_qdeclarativevaluetypes::sizef() MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->property("s_width").toDouble(), 0.1); - QCOMPARE(object->property("s_height").toDouble(), 100923.2); + QCOMPARE(float(object->property("s_width").toDouble()), float(0.1)); + QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2)); QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2))); delete object; @@ -287,10 +287,10 @@ void tst_qdeclarativevaluetypes::rectf() MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->property("r_x").toDouble(), 103.8); - QCOMPARE(object->property("r_y").toDouble(), 99.2); - QCOMPARE(object->property("r_width").toDouble(), 88.1); - QCOMPARE(object->property("r_height").toDouble(), 77.6); + QCOMPARE(float(object->property("r_x").toDouble()), float(103.8)); + QCOMPARE(float(object->property("r_y").toDouble()), float(99.2)); + QCOMPARE(float(object->property("r_width").toDouble()), float(88.1)); + QCOMPARE(float(object->property("r_height").toDouble()), float(77.6)); QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6))); delete object; diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 9660430..b08da0f 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -113,7 +113,6 @@ void tst_QDeclarativeViewer::orientation() viewer->rotateOrientation(); qApp->processEvents(); - qApp->processEvents(); // one extra round for the delayed updateSizeHints() call QCOMPARE(rootItem->width(), 300.0); QCOMPARE(rootItem->height(), 200.0); @@ -124,7 +123,6 @@ void tst_QDeclarativeViewer::orientation() viewer->rotateOrientation(); qApp->processEvents(); - qApp->processEvents(); // one extra round for the delayed updateSizeHints() call QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); @@ -132,6 +130,8 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); + + delete viewer; } void tst_QDeclarativeViewer::loading() @@ -157,10 +157,10 @@ void tst_QDeclarativeViewer::loading() // window resized QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); - QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); + QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), QSize(400, 500)); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -174,7 +174,7 @@ void tst_QDeclarativeViewer::loading() QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->resize(QSize(400, 500)); @@ -182,10 +182,10 @@ void tst_QDeclarativeViewer::loading() // window resized again QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); - QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); + QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), QSize(400, 500)); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -199,8 +199,10 @@ void tst_QDeclarativeViewer::loading() QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); + + delete viewer; } void tst_QDeclarativeViewer::fileBrowser() @@ -235,6 +237,8 @@ void tst_QDeclarativeViewer::fileBrowser() QVERIFY(viewer->view()); QVERIFY(viewer->menuBar()); QVERIFY(browserItem); + + delete viewer; } void tst_QDeclarativeViewer::resizing() @@ -266,7 +270,7 @@ void tst_QDeclarativeViewer::resizing() QTRY_COMPARE(viewer->view()->size(), QSize(150, 200)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); - QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(150, 200 + MENUBAR_HEIGHT(viewer))); // do not size root object to view viewer->resize(QSize(180,250)); @@ -280,16 +284,18 @@ void tst_QDeclarativeViewer::resizing() qApp->processEvents(); QTRY_COMPARE(rootItem->width(), 250.0); - QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height()); - QTRY_COMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height())); + QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); + QTRY_COMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), QSize(250, 350)); // do not size view to root object rootItem->setWidth(150); rootItem->setHeight(200); QTRY_COMPARE(viewer->size(), QSize(250, 350)); + + delete viewer; } void tst_QDeclarativeViewer::paths() @@ -302,6 +308,8 @@ void tst_QDeclarativeViewer::paths() viewer->addPluginPath("miscPluginPath"); viewer->view()->engine()->pluginPathList().contains("miscPluginPath"); + + delete viewer; } void tst_QDeclarativeViewer::slowMode() @@ -311,6 +319,8 @@ void tst_QDeclarativeViewer::slowMode() viewer->setSlowMode(true); viewer->setSlowMode(false); + + delete viewer; } QTEST_MAIN(tst_QDeclarativeViewer) diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 8e98874..3140265 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -134,7 +134,7 @@ void tst_QDeclarativeWorkerScript::messaging_data() QTest::newRow("invalid") << QVariant(); QTest::newRow("bool") << qVariantFromValue(true); QTest::newRow("int") << qVariantFromValue(1001); - QTest::newRow("real") << qVariantFromValue(10334.323); + QTest::newRow("real") << qVariantFromValue(10334.375); QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!")); QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c")); } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml index 7ca0ca5..0df727b 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml @@ -14,27 +14,27 @@ Rectangle { } Rectangle { - width: 50; height: 20; y: 60; color: "red" - SmoothedFollow on x { to: rect.x; velocity: 400; enabled: true } + width: 50; height: 20; x: rect.x; y: 60; color: "red" + Behavior on x { SmoothedAnimation { velocity: 400 } } } Rectangle { - width: 50; height: 20; y: 90; color: "yellow" - SmoothedFollow on x { to: rect.x; velocity: 300; reversingMode: SmoothedAnimation.Immediate; enabled: true } + width: 50; height: 20; x: rect.x; y: 90; color: "yellow" + Behavior on x { SmoothedAnimation { velocity: 300; reversingMode: SmoothedAnimation.Immediate } } } Rectangle { - width: 50; height: 20; y: 120; color: "green" - SmoothedFollow on x { to: rect.x; reversingMode: SmoothedAnimation.Sync; enabled: true } + width: 50; height: 20; x: rect.x; y: 120; color: "green" + Behavior on x { SmoothedAnimation { reversingMode: SmoothedAnimation.Sync } } } Rectangle { - width: 50; height: 20; y: 150; color: "purple" - SmoothedFollow on x { to: rect.x; maximumEasingTime: 200; enabled: true } + width: 50; height: 20; x: rect.x; y: 150; color: "purple" + Behavior on x { SmoothedAnimation { maximumEasingTime: 200 } } } Rectangle { - width: 50; height: 20; y: 180; color: "blue" - SmoothedFollow on x { to: rect.x; duration: 300; enabled: true } + width: 50; height: 20; x: rect.x; y: 180; color: "blue" + Behavior on x { SmoothedAnimation { duration: 300 } } } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml index d981763..c64497a 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml @@ -22,10 +22,11 @@ Rectangle { smooth: true transform: Rotation { id: hourRotation - origin.x: 7.5; origin.y: 73; angle: 0 - SpringFollow on angle { - spring: 2; damping: 0.2; modulus: 360 - to: (clock.hours * 30) + (clock.minutes * 0.5) + origin.x: 7.5; origin.y: 73 + angle: (clock.hours * 30) + (clock.minutes * 0.5) + + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } } } } @@ -36,10 +37,11 @@ Rectangle { smooth: true transform: Rotation { id: minuteRotation - origin.x: 6.5; origin.y: 83; angle: 0 - SpringFollow on angle { - spring: 2; damping: 0.2; modulus: 360 - to: clock.minutes * 6 + origin.x: 6.5; origin.y: 83 + angle: clock.minutes * 6 + + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } } } } @@ -50,10 +52,11 @@ Rectangle { smooth: true transform: Rotation { id: secondRotation - origin.x: 2.5; origin.y: 80; angle: 0 - SpringFollow on angle { - spring: 5; damping: 0.25; modulus: 360 - to: clock.seconds * 6 + origin.x: 2.5; origin.y: 80 + angle: clock.seconds * 6 + + Behavior on angle { + SpringAnimation { spring: 5; damping: 0.25; modulus: 360 } } } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml index cabdce7..05b93df 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml @@ -3,6 +3,7 @@ import Qt 4.7 Rectangle { color: "#ffffff" width: 320; height: 240 + Rectangle { id: rect color: "#00ff00" @@ -25,22 +26,22 @@ Rectangle { Rectangle { color: "#ff0000" x: rect.width; width: rect.width; height: 20 - y: 200 - SpringFollow on y { to: rect.y; velocity: 200 } + y: rect.y + Behavior on y { SpringAnimation { velocity: 200 } } } // Spring Rectangle { color: "#ff0000" x: rect.width * 2; width: rect.width/2; height: 20 - y: 200 - SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2 } + y: rect.y + Behavior on y { SpringAnimation { 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 { to: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object + y: rect.y + Behavior on y { SpringAnimation { spring: 1.0; damping: 0.2; mass: 3.0 } } // "heavier" object } // Follow mouse @@ -49,15 +50,22 @@ Rectangle { anchors.fill: parent Rectangle { id: ball + property int targetX: mouseRegion.mouseX - 10 + property int targetY: mouseRegion.mouseY - 10 + + x: targetX + y: targetY width: 20; height: 20 radius: 10 color: "#0000ff" - 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 } + + Behavior on x { SpringAnimation { spring: 1.0; damping: 0.05; epsilon: 0.25 } } + Behavior on y { SpringAnimation { spring: 1.0; damping: 0.05; epsilon: 0.25 } } + states: [ State { name: "following" - when: !f1.inSync || !f2.inSync + when: ball.x != ball.targetX || ball.y != ball.targetY PropertyChanges { target: ball; color: "#ff0000" } } ] diff --git a/tests/benchmarks/gui/text/qtext/main.cpp b/tests/benchmarks/gui/text/qtext/main.cpp index eaa23e9..63daae0 100644 --- a/tests/benchmarks/gui/text/qtext/main.cpp +++ b/tests/benchmarks/gui/text/qtext/main.cpp @@ -84,9 +84,11 @@ private slots: void newLineReplacement(); void formatManipulation(); + void fontResolution(); void layout_data(); void layout(); + void formattedLayout(); void paintLayoutToPixmap(); void paintLayoutToPixmap_painterFill(); @@ -306,6 +308,18 @@ void tst_QText::formatManipulation() } } +void tst_QText::fontResolution() +{ + QFont font; + QFont font2; + font.setFamily("DejaVu"); + font2.setBold(true); + + QBENCHMARK { + QFont res = font.resolve(font2); + } +} + void tst_QText::layout_data() { QTest::addColumn<bool>("wrap"); @@ -339,6 +353,33 @@ void tst_QText::layout() } }*/ +void tst_QText::formattedLayout() +{ + //set up formatting + QList<QTextLayout::FormatRange> ranges; + { + QTextCharFormat format; + format.setForeground(QColor("steelblue")); + + QTextLayout::FormatRange formatRange; + formatRange.format = format; + formatRange.start = 0; + formatRange.length = 50; + + ranges.append(formatRange); + } + + QTextLayout layout(m_shortLorem); + layout.setAdditionalFormats(ranges); + setupTextLayout(&layout); + + QBENCHMARK { + QTextLayout layout(m_shortLorem); + layout.setAdditionalFormats(ranges); + setupTextLayout(&layout); + } +} + void tst_QText::paintLayoutToPixmap() { QTextLayout layout(m_shortLorem); |