diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-07-15 13:14:37 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-07-15 13:14:37 (GMT) |
commit | 8106f716043c22d71ff3dcdf9cd8a4db258fa81f (patch) | |
tree | fef8ef2bcc78da549037c94451058fde10268edd /tests | |
parent | a98bda4b42b068c9c3220ae2aded41a263387ac2 (diff) | |
parent | 03c01176ebf423085e56ceabcf8335ca5027a786 (diff) | |
download | Qt-8106f716043c22d71ff3dcdf9cd8a4db258fa81f.zip Qt-8106f716043c22d71ff3dcdf9cd8a4db258fa81f.tar.gz Qt-8106f716043c22d71ff3dcdf9cd8a4db258fa81f.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
src/gui/kernel/qapplication.h
Diffstat (limited to 'tests')
139 files changed, 2518 insertions, 883 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/data/runningTrueBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml new file mode 100644 index 0000000..2c5207e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml @@ -0,0 +1,30 @@ +import Qt 4.7 +Rectangle { + color: "skyblue" + width: 500 + height: 200 + Rectangle { + objectName: "cloud" + color: "white" + y: 50 + width: 100 + height: 100 + + SequentialAnimation on x { + loops: Animation.Infinite + running: true + NumberAnimation { + id: firstAnimation + from: 0 + to: 500 + duration: 5000 + } + NumberAnimation { + id: secondAnimation + from: -100 + to: 0 + duration: 1000 + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 5cf4c23..3e80c2c 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -81,6 +81,7 @@ private slots: void dontStart(); void easingProperties(); void rotation(); + void runningTrueBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -309,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 @@ -733,6 +734,20 @@ void tst_qdeclarativeanimations::rotation() QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4)); } +void tst_qdeclarativeanimations::runningTrueBug() +{ + //ensure we start correctly when "running: true" is explicitly set + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *cloud = rect->findChild<QDeclarativeRectangle*>("cloud"); + QVERIFY(cloud); + QTest::qWait(1000); + QVERIFY(cloud->x() > qreal(0)); +} + QTEST_MAIN(tst_qdeclarativeanimations) #include "tst_qdeclarativeanimations.moc" 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 e2d3ee4..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 @@ -694,7 +742,7 @@ void tst_QDeclarativeDebug::queryExpressionResult() delete q_expr; q_expr = m_dbg->queryExpressionResult(objectId, expr, this); - QCOMPARE(q_expr->expression(), expr); + QCOMPARE(q_expr->expression().toString(), expr); waitForQuery(q_expr); QCOMPARE(q_expr->result(), result); 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/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml index bc2df98..aab39be 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml @@ -16,7 +16,11 @@ QtObject { test1 = (eval("a") == 7); test2 = (eval("b") == 9); - test3 = (eval("c") == undefined); + try { + eval("c"); + } catch(e) { + test3 = true; + } test4 = (eval("console") == console); test5 = (eval("Qt") == Qt); } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml index b435f58..80d6ef4 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml @@ -14,6 +14,10 @@ QtObject { test1 = (func1(4) == 11); test2 = (func2("Hello World!") == Qt.atob("Hello World!")); - test3 = (func3() == undefined); + try { + func3(); + } catch(e) { + test3 = true; + } } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js new file mode 100644 index 0000000..092bc2b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js @@ -0,0 +1 @@ +; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml new file mode 100644 index 0000000..56e7885 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml @@ -0,0 +1,8 @@ +import Qt 4.7 +import "qtbug_11600.js" as Test + +QtObject { + id: goo + + property bool test: undefined == goo.Test.foo +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml new file mode 100644 index 0000000..6efb9c1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +QtObject { + property bool test: false + Component.onCompleted: { + try { + console.log(sorryNoSuchProperty); + } catch (e) { + test = true; + } + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml index 4395ba3..2548005 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml @@ -1,10 +1,10 @@ import Qt 4.7 +import Qt.test 1.0 -Item { +MyQmlObject { id: root property int foo: 12 - property int console: 11 property bool test1: foo == 12 property bool test2: console != 11 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml index e8f7b62..f601f49 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml @@ -4,7 +4,7 @@ import "scriptErrors.js" as Script MyQmlObject { property int t: a.value property int w: Script.getValue(); - property int x: undefinedObject + property int x: undefined property int y: (a.value, undefinedObject) onBasicSignal: { console.log(a.value); } diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 7bb8a8e..19bfd37 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -86,6 +86,7 @@ class MyQmlObject : public QObject Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT) Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT) Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int console READ console CONSTANT) Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT) @@ -142,6 +143,7 @@ public: QRegExp regExp() { return m_regExp; } void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } + int console() const { return 11; } signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c); @@ -555,7 +557,9 @@ Q_DECLARE_METATYPE(QScriptValue); class MyInvokableObject : public QObject { Q_OBJECT + Q_ENUMS(TestEnum) public: + enum TestEnum { EnumValue1, EnumValue2 }; MyInvokableObject() { reset(); } int invoked() const { return m_invoked; } @@ -568,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; } @@ -587,6 +591,8 @@ public: Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; } Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; } + Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(18); m_actuals << (int)e; } + private: void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;} int m_invoked; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 16e7ec5..a6d2dac 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -155,6 +155,8 @@ private slots: void eval(); void function(); void qtbug_10696(); + void qtbug_11606(); + void qtbug_11600(); void include(); @@ -177,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)); @@ -205,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)); @@ -278,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")); } } @@ -1002,10 +1004,10 @@ void tst_qdeclarativeecmascript::scriptErrors() QString url = component.url().toString(); QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; - QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object."; + QString warning2 = url + ":5: ReferenceError: Can't find variable: a"; QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; - QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object."; + QString warning4 = url + ":10: ReferenceError: Can't find variable: a"; + QString warning5 = url + ":8: ReferenceError: Can't find variable: a"; QString warning6 = url + ":7: Unable to assign [undefined] to int x"; QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\""; @@ -1322,7 +1324,12 @@ void tst_qdeclarativeecmascript::callQtInvokables() QDeclarativeEngine qmlengine; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine); QScriptEngine *engine = &ep->scriptEngine; - ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); + + QStringList names; QList<QScriptValue> values; + names << QLatin1String("object"); values << ep->objectClass->newQObject(&o); + names << QLatin1String("undefined"); values << engine->undefinedValue(); + + ep->globalClass->explicitSetProperty(names, values); // Non-existent methods o.reset(); @@ -1380,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); @@ -1714,6 +1721,13 @@ void tst_qdeclarativeecmascript::callQtInvokables() QCOMPARE(o.actuals().count(), 2); QCOMPARE(o.actuals().at(0), QVariant(10)); QCOMPARE(o.actuals().at(1), QVariant(11)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_with_enum(9)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 18); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(9)); } // QTBUG-5675 @@ -1804,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; @@ -1817,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; @@ -1830,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; @@ -1843,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; @@ -1856,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; @@ -1869,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; @@ -1885,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; @@ -1904,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; @@ -1923,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; @@ -1941,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; @@ -2498,6 +2512,25 @@ void tst_qdeclarativeecmascript::qtbug_10696() delete o; } +void tst_qdeclarativeecmascript::qtbug_11606() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11606.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qdeclarativeecmascript::qtbug_11600() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11600.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml index aa156ed..a840a01 100644 --- a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml @@ -1,6 +1,12 @@ import Qt 4.7 Flickable { + property bool ok: false + function check() { + if (column.parent == contentItem) + ok = true; + } + width: 100; height: 100 contentWidth: column.width; contentHeight: column.height pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 2ba5574..678996b 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -147,6 +147,10 @@ void tst_qdeclarativeflickable::properties() QCOMPARE(obj->pressDelay(), 200); QCOMPARE(obj->maximumFlickVelocity(), 2000.); + QVERIFY(obj->property("ok").toBool() == false); + QMetaObject::invokeMethod(obj, "check"); + QVERIFY(obj->property("ok").toBool() == true); + delete obj; } 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/qdeclarativegridview/data/footer.qml b/tests/auto/declarative/qdeclarativegridview/data/footer.qml new file mode 100644 index 0000000..170b2b5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/footer.qml @@ -0,0 +1,32 @@ +import Qt 4.7 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + width: 80 + height: 60 + border.color: "blue" + Text { + text: index + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + } + } + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + footer: Text { objectName: "footer"; text: "Footer"; height: 30 } + } +} diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml index 9331243..a5d651d 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml @@ -43,7 +43,7 @@ Rectangle { focus: true width: 240 height: 320 - currentIndex: 5 + currentIndex: 35 cellWidth: 80 cellHeight: 60 delegate: myDelegate diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 4e35bc0..1a28b71 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -81,6 +81,7 @@ private slots: void enforceRange(); void QTBUG_8456(); void manualHighlight(); + void footer(); private: QDeclarativeView *createView(); @@ -147,6 +148,14 @@ public: emit dataChanged(index(idx,0), index(idx,0)); } + void clear() { + int count = list.count(); + emit beginRemoveRows(QModelIndex(), 0, count-1); + list.clear(); + emit endRemoveRows(); + } + + private: QList<QPair<QString,QString> > list; }; @@ -178,17 +187,17 @@ void tst_QDeclarativeGridView::items() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_COMPARE(gridview->count(), model.count()); - QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item for (int i = 0; i < model.count(); ++i) { - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -197,7 +206,7 @@ void tst_QDeclarativeGridView::items() TestModel model2; ctxt->setContextProperty("testModel", &model2); - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); QTRY_VERIFY(itemCount == 0); delete canvas; @@ -226,14 +235,14 @@ void tst_QDeclarativeGridView::changed() QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.modifyItem(1, "Will", "9876"); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -259,17 +268,17 @@ void tst_QDeclarativeGridView::inserted() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.insertItem(1, "Will", "9876"); - QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -279,19 +288,19 @@ void tst_QDeclarativeGridView::inserted() // Confirm items positioned correctly for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); QTRY_COMPARE(item->x(), (i%3)*80.0); QTRY_COMPARE(item->y(), (i/3)*60.0); } model.insertItem(0, "Foo", "1111"); // zero index, and current item - QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - name = findItem<QDeclarativeText>(viewport, "textName", 0); + name = findItem<QDeclarativeText>(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + number = findItem<QDeclarativeText>(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -299,7 +308,7 @@ void tst_QDeclarativeGridView::inserted() // Confirm items positioned correctly for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); QTRY_VERIFY(item->x() == (i%3)*80); QTRY_VERIFY(item->y() == (i/3)*60); } @@ -335,15 +344,15 @@ void tst_QDeclarativeGridView::removed() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.removeItem(1); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -352,9 +361,9 @@ void tst_QDeclarativeGridView::removed() QTRY_COMPARE(removed, QString("Item1")); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); @@ -364,17 +373,17 @@ void tst_QDeclarativeGridView::removed() // Remove first item (which is the current item); model.removeItem(0); - name = findItem<QDeclarativeText>(viewport, "textName", 0); + name = findItem<QDeclarativeText>(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + number = findItem<QDeclarativeText>(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); @@ -385,9 +394,9 @@ void tst_QDeclarativeGridView::removed() model.removeItem(25); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); @@ -405,7 +414,7 @@ void tst_QDeclarativeGridView::removed() // Confirm items positioned correctly for (int i = 6; i < 18; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); @@ -424,9 +433,9 @@ void tst_QDeclarativeGridView::removed() QTest::qWait(100); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); @@ -478,29 +487,29 @@ void tst_QDeclarativeGridView::moved() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.moveItem(1, 8); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); - name = findItem<QDeclarativeText>(viewport, "textName", 8); + name = findItem<QDeclarativeText>(contentItem, "textName", 8); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(8)); - number = findItem<QDeclarativeText>(viewport, "textNumber", 8); + number = findItem<QDeclarativeText>(contentItem, "textNumber", 8); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(8)); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); @@ -513,17 +522,17 @@ void tst_QDeclarativeGridView::moved() model.moveItem(1, 25); // Confirm items positioned correctly and indexes correct - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1; + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count()-1; for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal((i%3)*80)); QTRY_COMPARE(item->y(), qreal((i/3)*60)); - name = findItem<QDeclarativeText>(viewport, "textName", i); + name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem<QDeclarativeText>(viewport, "textNumber", i); + number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -533,15 +542,15 @@ void tst_QDeclarativeGridView::moved() // Confirm items positioned correctly and indexes correct for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); QTRY_VERIFY(item->y() == (i/3)*60); - name = findItem<QDeclarativeText>(viewport, "textName", i); + name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem<QDeclarativeText>(viewport, "textNumber", i); + number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -557,7 +566,7 @@ void tst_QDeclarativeGridView::moved() void tst_QDeclarativeGridView::currentIndex() { TestModel model; - for (int i = 0; i < 30; i++) + for (int i = 0; i < 60; i++) model.addItem("Item" + QString::number(i), QString::number(i)); QDeclarativeView *canvas = new QDeclarativeView(0); @@ -572,57 +581,58 @@ void tst_QDeclarativeGridView::currentIndex() qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); + QVERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); // current item should be third item - QTRY_COMPARE(gridview->currentIndex(), 5); - QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5)); - QTRY_COMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y()); + QCOMPARE(gridview->currentIndex(), 35); + QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35)); + QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y()); + QCOMPARE(gridview->contentY(), 399.0); gridview->moveCurrentIndexRight(); - QTRY_COMPARE(gridview->currentIndex(), 6); + QCOMPARE(gridview->currentIndex(), 36); gridview->moveCurrentIndexDown(); - QTRY_COMPARE(gridview->currentIndex(), 9); + QCOMPARE(gridview->currentIndex(), 39); gridview->moveCurrentIndexUp(); - QTRY_COMPARE(gridview->currentIndex(), 6); + QCOMPARE(gridview->currentIndex(), 36); gridview->moveCurrentIndexLeft(); - QTRY_COMPARE(gridview->currentIndex(), 5); + QCOMPARE(gridview->currentIndex(), 35); // no wrap gridview->setCurrentIndex(0); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); gridview->moveCurrentIndexUp(); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); gridview->moveCurrentIndexLeft(); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); gridview->setCurrentIndex(model.count()-1); - QTRY_COMPARE(gridview->currentIndex(), model.count()-1); + QCOMPARE(gridview->currentIndex(), model.count()-1); gridview->moveCurrentIndexRight(); - QTRY_COMPARE(gridview->currentIndex(), model.count()-1); + QCOMPARE(gridview->currentIndex(), model.count()-1); gridview->moveCurrentIndexDown(); - QTRY_COMPARE(gridview->currentIndex(), model.count()-1); + QCOMPARE(gridview->currentIndex(), model.count()-1); // with wrap gridview->setWrapEnabled(true); gridview->setCurrentIndex(0); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); gridview->moveCurrentIndexLeft(); - QTRY_COMPARE(gridview->currentIndex(), model.count()-1); + QCOMPARE(gridview->currentIndex(), model.count()-1); - QTRY_COMPARE(gridview->contentY(), 279.0); + QTRY_COMPARE(gridview->contentY(), 879.0); gridview->moveCurrentIndexRight(); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); QTRY_COMPARE(gridview->contentY(), 0.0); @@ -638,30 +648,30 @@ void tst_QDeclarativeGridView::currentIndex() qApp->processEvents(); QTest::keyClick(canvas, Qt::Key_Down); - QTRY_COMPARE(gridview->currentIndex(), 3); + QCOMPARE(gridview->currentIndex(), 3); QTest::keyClick(canvas, Qt::Key_Up); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); gridview->setFlow(QDeclarativeGridView::TopToBottom); QTest::keyClick(canvas, Qt::Key_Right); - QTRY_COMPARE(gridview->currentIndex(), 5); + QCOMPARE(gridview->currentIndex(), 5); QTest::keyClick(canvas, Qt::Key_Left); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); QTest::keyClick(canvas, Qt::Key_Down); - QTRY_COMPARE(gridview->currentIndex(), 1); + QCOMPARE(gridview->currentIndex(), 1); QTest::keyClick(canvas, Qt::Key_Up); - QTRY_COMPARE(gridview->currentIndex(), 0); + QCOMPARE(gridview->currentIndex(), 0); // turn off auto highlight gridview->setHighlightFollowsCurrentItem(false); - QTRY_VERIFY(gridview->highlightFollowsCurrentItem() == false); - QTRY_VERIFY(gridview->highlightItem()); + QVERIFY(gridview->highlightFollowsCurrentItem() == false); + QVERIFY(gridview->highlightItem()); qreal hlPosX = gridview->highlightItem()->x(); qreal hlPosY = gridview->highlightItem()->y(); @@ -695,21 +705,21 @@ void tst_QDeclarativeGridView::changeFlow() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); // Confirm items positioned correctly and indexes correct - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal((i%3)*80)); QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -717,17 +727,17 @@ void tst_QDeclarativeGridView::changeFlow() ctxt->setContextProperty("testTopToBottom", QVariant(true)); // Confirm items positioned correctly and indexes correct - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal((i/5)*80)); QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -913,13 +923,13 @@ void tst_QDeclarativeGridView::positionViewAtIndex() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), (i%3)*80.); @@ -931,9 +941,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex() QTRY_COMPARE(gridview->contentY(), 60.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), (i%3)*80.); @@ -945,9 +955,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex() QTRY_COMPARE(gridview->contentY(), 420.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), (i%3)*80.); @@ -959,9 +969,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex() QTRY_COMPARE(gridview->contentY(), 520.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), (i%3)*80.); @@ -973,9 +983,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex() QTRY_COMPARE(gridview->contentY(), 0.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), (i%3)*80.); @@ -1043,13 +1053,13 @@ void tst_QDeclarativeGridView::resetModel() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_COMPARE(gridview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i); + QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1061,7 +1071,7 @@ void tst_QDeclarativeGridView::resetModel() QTRY_COMPARE(gridview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i); + QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1088,22 +1098,22 @@ void tst_QDeclarativeGridView::enforceRange() QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); // view should be positioned at the top of the range. - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0); QTRY_VERIFY(item); QTRY_COMPARE(gridview->contentY(), -100.0); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); - // Check currentIndex is updated when viewport moves + // Check currentIndex is updated when contentItem moves gridview->setContentY(0); QTRY_COMPARE(gridview->currentIndex(), 2); @@ -1145,22 +1155,54 @@ void tst_QDeclarativeGridView::manualHighlight() QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); - QDeclarativeItem *viewport = gridview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0)); QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); gridview->setCurrentIndex(2); QTRY_COMPARE(gridview->currentIndex(), 2); - QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2)); QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); } +void tst_QDeclarativeGridView::footer() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 7; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *footer = findItem<QDeclarativeText>(contentItem, "footer"); + QVERIFY(footer); + + QCOMPARE(footer->y(), 180.0); + + model.removeItem(2); + QTRY_COMPARE(footer->y(), 120.0); + + model.clear(); + QTRY_COMPARE(footer->y(), 0.0); +} + QDeclarativeView *tst_QDeclarativeGridView::createView() { 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/invalidProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt new file mode 100644 index 0000000..c83e5ae --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt @@ -0,0 +1 @@ +4:5:Illegal property name diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml new file mode 100644 index 0000000..6077de4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +QtObject { + property int parseInt +} 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 413843a..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; @@ -370,6 +371,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false; QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false; QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false; + QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false; } @@ -1475,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" << ""; @@ -1499,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/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 3d66733..858c26d 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -193,8 +193,9 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << ""; - QTest::newRow("get2") << "{get(-1)}" << 0 << ""; + QTest::newRow("get1") << "{get(0) === undefined}" << 1 << ""; + QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << ""; + QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << ""; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -292,8 +293,6 @@ void tst_qdeclarativelistmodel::dynamic() if (e.hasError()) qDebug() << e.error(); // errors not expected - if (QTest::currentDataTag() != QLatin1String("clear3") && QTest::currentDataTag() != QLatin1String("remove3")) - QVERIFY(!e.hasError()); QCOMPARE(actual,result); } @@ -308,6 +307,9 @@ void tst_qdeclarativelistmodel::dynamic_worker() QFETCH(int, result); QFETCH(QString, warning); + // This is same as dynamic() except it applies the test to a ListModel called + // from a WorkerScript (i.e. testing the internal NestedListModel class) + QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); @@ -559,6 +561,18 @@ void tst_qdeclarativelistmodel::error_data() QTest::newRow("QML elements not allowed in ListElement") << "import Qt 4.7\nListModel { ListElement { a: Item { } } }" << "ListElement: cannot contain nested elements"; + + QTest::newRow("qualified ListElement supported") + << "import Qt 4.7 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" + << ""; + + QTest::newRow("qualified ListElement required") + << "import Qt 4.7 as Foo\nFoo.ListModel { ListElement { a: 123 } }" + << "ListElement is not a type"; + + QTest::newRow("unknown qualified ListElement not allowed") + << "import Qt 4.7\nListModel { Foo.ListElement { a: 123 } }" + << "Foo.ListElement - Foo is not a namespace"; } void tst_qdeclarativelistmodel::error() diff --git a/tests/auto/declarative/qdeclarativelistview/data/footer.qml b/tests/auto/declarative/qdeclarativelistview/data/footer.qml new file mode 100644 index 0000000..11cbe16 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/footer.qml @@ -0,0 +1,30 @@ +import Qt 4.7 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + height: 20 + width: 240 + Text { + text: index + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + } + } + ListView { + id: list + objectName: "list" + focus: true + width: 240 + height: 320 + model: testModel + delegate: myDelegate + footer: Text { objectName: "footer"; text: "Footer"; height: 30 } + } +} diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml index 0599ddd..f3c2910 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml @@ -40,7 +40,7 @@ Rectangle { id: list objectName: "list" focus: true - currentIndex: 3 + currentIndex: 20 width: 240 height: 320 keyNavigationWraps: testWrap diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml index a6f3ab8..9a5ea55 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml @@ -10,10 +10,10 @@ Rectangle { Item { id: wrapper objectName: "wrapper" - height: ListView.prevSection != ListView.section ? 40 : 20; + height: ListView.previousSection != ListView.section ? 40 : 20; width: 240 Rectangle { - y: wrapper.ListView.prevSection != wrapper.ListView.section ? 20 : 0 + y: wrapper.ListView.previousSection != wrapper.ListView.section ? 20 : 0 height: 20 width: parent.width color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white" @@ -27,21 +27,26 @@ Rectangle { text: name } Text { - x: 120 + x: 100 id: textNumber objectName: "textNumber" text: number } Text { + objectName: "nextSection" + x: 150 + text: wrapper.ListView.nextSection + } + Text { x: 200 text: wrapper.y } } Rectangle { color: "#99bb99" - height: wrapper.ListView.prevSection != wrapper.ListView.section ? 20 : 0 + height: wrapper.ListView.previousSection != wrapper.ListView.section ? 20 : 0 width: parent.width - visible: wrapper.ListView.prevSection != wrapper.ListView.section ? true : false + visible: wrapper.ListView.previousSection != wrapper.ListView.section ? true : false Text { text: wrapper.ListView.section } } } diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index cd42b63..9c24e03 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -97,6 +97,7 @@ private slots: void QTBUG_9791(); void manualHighlight(); void QTBUG_11105(); + void footer(); private: template <class T> void items(); @@ -336,24 +337,24 @@ void tst_QDeclarativeListView::items() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QTRY_VERIFY(testObject->error() == false); QTRY_VERIFY(listview->highlightItem() != 0); QTRY_COMPARE(listview->count(), model.count()); - QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item // current item should be first item - QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0)); for (int i = 0; i < model.count(); ++i) { - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -382,7 +383,7 @@ void tst_QDeclarativeListView::items() T model2; ctxt->setContextProperty("testModel", &model2); - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); QTRY_VERIFY(itemCount == 0); QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0); @@ -414,14 +415,14 @@ void tst_QDeclarativeListView::changed() QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.modifyItem(1, "Will", "9876"); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -450,34 +451,34 @@ void tst_QDeclarativeListView::inserted() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.insertItem(1, "Will", "9876"); - QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); // Confirm items positioned correctly for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); QTRY_COMPARE(item->y(), i*20.0); } model.insertItem(0, "Foo", "1111"); // zero index, and current item - QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - name = findItem<QDeclarativeText>(viewport, "textName", 0); + name = findItem<QDeclarativeText>(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + number = findItem<QDeclarativeText>(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -485,7 +486,7 @@ void tst_QDeclarativeListView::inserted() // Confirm items positioned correctly for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); QTRY_COMPARE(item->y(), i*20.0); } @@ -501,13 +502,13 @@ void tst_QDeclarativeListView::inserted() // Confirm items positioned correctly for (int i = 5; i < 5+15; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.0 - 20.0); } -// QTRY_COMPARE(listview->viewportHeight(), model.count() * 20.0); +// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0); delete canvas; } @@ -534,22 +535,22 @@ void tst_QDeclarativeListView::removed(bool animated) QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.removeItem(1); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*20); @@ -560,17 +561,17 @@ void tst_QDeclarativeListView::removed(bool animated) QTest::qWait(300); - name = findItem<QDeclarativeText>(viewport, "textName", 0); + name = findItem<QDeclarativeText>(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + number = findItem<QDeclarativeText>(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(),i*20.0 + 20.0); @@ -581,9 +582,9 @@ void tst_QDeclarativeListView::removed(bool animated) qApp->processEvents(); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(),i*20.0+20.0); @@ -598,7 +599,7 @@ void tst_QDeclarativeListView::removed(bool animated) // Confirm items positioned correctly for (int i = 2; i < 18; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(),40+i*20.0); @@ -617,9 +618,9 @@ void tst_QDeclarativeListView::removed(bool animated) QTest::qWait(300); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(),40+i*20.0); @@ -665,8 +666,8 @@ void tst_QDeclarativeListView::clear() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.clear(); @@ -699,29 +700,29 @@ void tst_QDeclarativeListView::moved() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); model.moveItem(1, 4); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); - name = findItem<QDeclarativeText>(viewport, "textName", 4); + name = findItem<QDeclarativeText>(contentItem, "textName", 4); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(4)); - number = findItem<QDeclarativeText>(viewport, "textNumber", 4); + number = findItem<QDeclarativeText>(contentItem, "textNumber", 4); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(4)); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*20); @@ -734,14 +735,14 @@ void tst_QDeclarativeListView::moved() // Confirm items positioned correctly and indexes correct for (int i = 3; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.0 + 20); - name = findItem<QDeclarativeText>(viewport, "textName", i); + name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem<QDeclarativeText>(viewport, "textNumber", i); + number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -751,14 +752,14 @@ void tst_QDeclarativeListView::moved() // Confirm items positioned correctly and indexes correct for (int i = 3; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.0 + 20); - name = findItem<QDeclarativeText>(viewport, "textName", i); + name = findItem<QDeclarativeText>(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem<QDeclarativeText>(viewport, "textNumber", i); + number = findItem<QDeclarativeText>(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -787,22 +788,22 @@ void tst_QDeclarativeListView::enforceRange() QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); QTRY_COMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); // view should be positioned at the top of the range. - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0); QTRY_VERIFY(item); QTRY_COMPARE(listview->contentY(), -100.0); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); - // Check currentIndex is updated when viewport moves + // Check currentIndex is updated when contentItem moves listview->setContentY(20); QTRY_COMPARE(listview->currentIndex(), 6); @@ -838,13 +839,13 @@ void tst_QDeclarativeListView::spacing() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*20); @@ -854,9 +855,9 @@ void tst_QDeclarativeListView::spacing() QTRY_VERIFY(listview->spacing() == 10); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*30); @@ -865,9 +866,9 @@ void tst_QDeclarativeListView::spacing() listview->setSpacing(0); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.0); @@ -893,44 +894,46 @@ void tst_QDeclarativeListView::sections() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); QTRY_VERIFY(item); QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); + QDeclarativeText *next = findItem<QDeclarativeText>(item, "nextSection"); + QCOMPARE(next->text().toInt(), (i+1)/5); } // Remove section boundary model.removeItem(5); // New section header created - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 40.0); model.insertItem(3, "New Item", "0"); // Section header moved - item = findItem<QDeclarativeItem>(viewport, "wrapper", 5); + item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 20.0); - item = findItem<QDeclarativeItem>(viewport, "wrapper", 6); + item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 40.0); // insert item which will become a section header model.insertItem(6, "Replace header", "1"); - item = findItem<QDeclarativeItem>(viewport, "wrapper", 6); + item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 40.0); - item = findItem<QDeclarativeItem>(viewport, "wrapper", 7); + item = findItem<QDeclarativeItem>(contentItem, "wrapper", 7); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 20.0); @@ -942,7 +945,7 @@ void tst_QDeclarativeListView::sections() listview->setContentY(20); QTRY_COMPARE(listview->currentSection(), QString("0")); - item = findItem<QDeclarativeItem>(viewport, "wrapper", 1); + item = findItem<QDeclarativeItem>(contentItem, "wrapper", 1); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 20.0); @@ -970,37 +973,39 @@ void tst_QDeclarativeListView::currentIndex() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); - // current item should be third item - QTRY_COMPARE(listview->currentIndex(), 3); - QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3)); - QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); + // current item should be 20th item at startup + // and current item should be in view + QCOMPARE(listview->currentIndex(), 20); + QCOMPARE(listview->contentY(), 99.0); + QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 20)); + QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); // no wrap listview->setCurrentIndex(0); - QTRY_COMPARE(listview->currentIndex(), 0); + QCOMPARE(listview->currentIndex(), 0); listview->incrementCurrentIndex(); - QTRY_COMPARE(listview->currentIndex(), 1); + QCOMPARE(listview->currentIndex(), 1); listview->decrementCurrentIndex(); - QTRY_COMPARE(listview->currentIndex(), 0); + QCOMPARE(listview->currentIndex(), 0); listview->decrementCurrentIndex(); - QTRY_COMPARE(listview->currentIndex(), 0); + QCOMPARE(listview->currentIndex(), 0); // with wrap ctxt->setContextProperty("testWrap", QVariant(true)); - QTRY_VERIFY(listview->isWrapEnabled()); + QVERIFY(listview->isWrapEnabled()); listview->decrementCurrentIndex(); - QTRY_COMPARE(listview->currentIndex(), model.count()-1); + QCOMPARE(listview->currentIndex(), model.count()-1); QTRY_COMPARE(listview->contentY(), 279.0); listview->incrementCurrentIndex(); - QTRY_COMPARE(listview->currentIndex(), 0); + QCOMPARE(listview->currentIndex(), 0); QTRY_COMPARE(listview->contentY(), 0.0); @@ -1016,16 +1021,16 @@ void tst_QDeclarativeListView::currentIndex() qApp->processEvents(); QTest::keyClick(canvas, Qt::Key_Down); - QTRY_COMPARE(listview->currentIndex(), 1); + QCOMPARE(listview->currentIndex(), 1); QTest::keyClick(canvas, Qt::Key_Up); - QTRY_COMPARE(listview->currentIndex(), 0); + QCOMPARE(listview->currentIndex(), 0); // turn off auto highlight listview->setHighlightFollowsCurrentItem(false); - QTRY_VERIFY(listview->highlightFollowsCurrentItem() == false); + QVERIFY(listview->highlightFollowsCurrentItem() == false); - QTRY_VERIFY(listview->highlightItem()); + QVERIFY(listview->highlightItem()); qreal hlPos = listview->highlightItem()->y(); listview->setCurrentIndex(4); @@ -1049,8 +1054,8 @@ void tst_QDeclarativeListView::itemList() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "view"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild<QDeclarativeVisualItemModel*>("itemModel"); QTRY_VERIFY(model != 0); @@ -1058,21 +1063,21 @@ void tst_QDeclarativeListView::itemList() QTRY_VERIFY(model->count() == 3); QTRY_COMPARE(listview->currentIndex(), 0); - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "item1"); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "item1"); QTRY_VERIFY(item); QTRY_COMPARE(item->x(), 0.0); - QDeclarativeText *text = findItem<QDeclarativeText>(viewport, "text1"); + QDeclarativeText *text = findItem<QDeclarativeText>(contentItem, "text1"); QTRY_VERIFY(text); QTRY_COMPARE(text->text(), QLatin1String("index: 0")); listview->setCurrentIndex(2); - item = findItem<QDeclarativeItem>(viewport, "item3"); + item = findItem<QDeclarativeItem>(contentItem, "item3"); QTRY_VERIFY(item); QTRY_COMPARE(item->x(), 480.0); - text = findItem<QDeclarativeText>(viewport, "text3"); + text = findItem<QDeclarativeText>(contentItem, "text3"); QTRY_VERIFY(text); QTRY_COMPARE(text->text(), QLatin1String("index: 2")); @@ -1099,16 +1104,16 @@ void tst_QDeclarativeListView::cacheBuffer() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_VERIFY(listview->delegate() != 0); QTRY_VERIFY(listview->model() != 0); QTRY_VERIFY(listview->highlight() != 0); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*20); @@ -1117,12 +1122,12 @@ void tst_QDeclarativeListView::cacheBuffer() testObject->setCacheBuffer(400); QTRY_VERIFY(listview->cacheBuffer() == 400); - int newItemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int newItemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); QTRY_VERIFY(newItemCount > itemCount); // Confirm items positioned correctly for (int i = 0; i < model.count() && i < newItemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*20); @@ -1151,13 +1156,13 @@ void tst_QDeclarativeListView::positionViewAtIndex() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); @@ -1168,9 +1173,9 @@ void tst_QDeclarativeListView::positionViewAtIndex() QTRY_COMPARE(listview->contentY(), 60.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); @@ -1181,9 +1186,9 @@ void tst_QDeclarativeListView::positionViewAtIndex() QTRY_COMPARE(listview->contentY(), 440.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); @@ -1194,9 +1199,9 @@ void tst_QDeclarativeListView::positionViewAtIndex() QTRY_COMPARE(listview->contentY(), 480.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); @@ -1207,9 +1212,9 @@ void tst_QDeclarativeListView::positionViewAtIndex() QTRY_COMPARE(listview->contentY(), 0.); // Confirm items positioned correctly - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.); @@ -1276,13 +1281,13 @@ void tst_QDeclarativeListView::resetModel() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_COMPARE(listview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i); + QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1294,7 +1299,7 @@ void tst_QDeclarativeListView::resetModel() QTRY_COMPARE(listview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i); + QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1453,8 +1458,8 @@ void tst_QDeclarativeListView::QTBUG_9791() QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(canvas->rootObject()); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_VERIFY(listview->delegate() != 0); QTRY_VERIFY(listview->model() != 0); @@ -1462,11 +1467,11 @@ void tst_QDeclarativeListView::QTBUG_9791() qApp->processEvents(); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); QVERIFY(itemCount == 3); for (int i = 0; i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->x(), i*300.0); @@ -1493,17 +1498,17 @@ void tst_QDeclarativeListView::manualHighlight() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); QTRY_COMPARE(listview->currentIndex(), 0); - QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0)); QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); listview->setCurrentIndex(2); QTRY_COMPARE(listview->currentIndex(), 2); - QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2)); QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); } @@ -1527,13 +1532,13 @@ void tst_QDeclarativeListView::QTBUG_11105() QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QTRY_VERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); // Confirm items positioned correctly - int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->y() == i*20); @@ -1548,12 +1553,43 @@ void tst_QDeclarativeListView::QTBUG_11105() ctxt->setContextProperty("testModel", &model2); - itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); QCOMPARE(itemCount, 5); delete canvas; } +void tst_QDeclarativeListView::footer() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 3; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *footer = findItem<QDeclarativeText>(contentItem, "footer"); + QVERIFY(footer); + QCOMPARE(footer->y(), 60.0); + + model.removeItem(1); + QTRY_COMPARE(footer->y(), 40.0); + + model.clear(); + QTRY_COMPARE(footer->y(), 0.0); +} + void tst_QDeclarativeListView::qListModelInterface_items() { items<TestModel>(); diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index d047a2a..b0b7a3b 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -47,6 +47,7 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativeloader_p.h> #include "testhttpserver.h" +#include "../../../shared/util.h" #define SERVER_PORT 14450 @@ -176,9 +177,7 @@ void tst_QDeclarativeLoader::clear() QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); - QTest::qWait(500); - - QVERIFY(loader->item() == 0); + QTRY_VERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); QCOMPARE(loader->status(), QDeclarativeLoader::Null); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); @@ -239,8 +238,8 @@ void tst_QDeclarativeLoader::urlToComponent() "}" ) , TEST_FILE("")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); - QTest::qWait(500); - QVERIFY(loader != 0); + QTest::qWait(200); + QTRY_VERIFY(loader != 0); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); 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/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml new file mode 100644 index 0000000..6dd108e --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Rectangle { + width: 300; height: 200; + + property bool leftToRight: false + + Flow { + objectName: "flow" + flow: leftToRight ? Flow.LeftToRight : Flow.TopToBottom + spacing: 20 + anchors.horizontalCenter: parent.horizontalCenter + Rectangle { color: "red"; width: 100; height: 50 } + Rectangle { color: "blue"; width: 100; height: 50 } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 62ec707..0663991 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -75,6 +75,7 @@ private slots: void test_repeater(); void test_flow(); void test_flow_resize(); + void test_flow_implicit_resize(); void test_conflictinganchors(); private: QDeclarativeView *createView(const QString &filename); @@ -655,6 +656,28 @@ void tst_QDeclarativePositioners::test_flow_resize() delete canvas; } +void tst_QDeclarativePositioners::test_flow_implicit_resize() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml"); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlow *flow = canvas->rootObject()->findChild<QDeclarativeFlow*>("flow"); + QVERIFY(flow != 0); + + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + canvas->rootObject()->setProperty("leftToRight", true); + QCOMPARE(flow->width(), 220.0); + QCOMPARE(flow->height(), 50.0); + + canvas->rootObject()->setProperty("leftToRight", false); + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + delete canvas; +} + QString warningMessage; void interceptWarnings(QtMsgType type, const char *msg) diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js index c165e29..30499e9 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js @@ -5,3 +5,7 @@ function loadComponent() { return component.status; } +function createComponent() { + var component = Qt.createComponent("createComponentData.qml"); + return component.createObject(null); +} diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml index aae7a91..33203c7 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml @@ -3,8 +3,10 @@ import "createComponent_lib.js" as Test Item { property int status: Component.Null + property int readValue: 0 Component.onCompleted: { status = Test.loadComponent() + readValue = Test.createComponent().test; } } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index fb100a5..895ee6c 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -365,14 +365,12 @@ void tst_qdeclarativeqt::createComponent() void tst_qdeclarativeqt::createComponent_pragmaLibrary() { // Currently, just loading createComponent_lib.qml causes crash on some platforms - /* QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); - - QEXPECT_FAIL("", "QTBUG-11507", Continue); QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready)); - */ + QCOMPARE(object->property("readValue").toInt(), int(1913)); + delete object; } void tst_qdeclarativeqt::createQmlObject() 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/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 2913ddd..639b2f3 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -263,7 +263,6 @@ void tst_qdeclarativestates::attachedPropertyChanges() MyAttached *att = qobject_cast<MyAttached*>(attObj); QVERIFY(att); - QEXPECT_FAIL("", "QTBUG-11283", Abort); QCOMPARE(att->foo(), 1); } diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml new file mode 100644 index 0000000..762e2b6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml @@ -0,0 +1,41 @@ +import Qt 4.7 + +Rectangle { + id: top + width: 70; height: 70; + + property alias horizontalAlignment: t.horizontalAlignment + property alias verticalAlignment: t.verticalAlignment + property alias wrapMode: t.wrapMode + property alias running: timer.running + property string txt: "Test" + + Rectangle { + anchors.centerIn: parent + width: 40 + height: 40 + color: "green" + + Text { + id: t + + anchors.fill: parent + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignBottom + wrapMode: Text.WordWrap + text: top.txt + } + Timer { + id: timer + + interval: 1 + running: true + repeat: true + onTriggered: { + top.txt = top.txt + "<br>more " + top.txt.length; + if (top.txt.length > 50) + running = false + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png Binary files differnew file mode 100644 index 0000000..99de219 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png Binary files differnew file mode 100644 index 0000000..cb85251 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png Binary files differnew file mode 100644 index 0000000..ddca549 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png Binary files differnew file mode 100644 index 0000000..1b50a81 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png Binary files differnew file mode 100644 index 0000000..f041b86 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png Binary files differnew file mode 100644 index 0000000..c75e0d1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png Binary files differnew file mode 100644 index 0000000..b06a5da --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png Binary files differnew file mode 100644 index 0000000..e468857 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png Binary files differnew file mode 100644 index 0000000..576715f --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 01120b1..80198eb 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -47,6 +47,8 @@ #include <QFontMetrics> #include <QGraphicsSceneMouseEvent> #include <qmath.h> +#include <QDeclarativeView> +#include <private/qapplication_p.h> #include "../../../shared/util.h" #include "testhttpserver.h" @@ -70,6 +72,9 @@ private slots: void elide(); void textFormat(); + void alignments_data(); + void alignments(); + void embeddedImages_data(); void embeddedImages(); @@ -108,6 +113,8 @@ private: QStringList colorStrings; QDeclarativeEngine engine; + + QDeclarativeView *createView(const QString &filename); }; tst_qdeclarativetext::tst_qdeclarativetext() @@ -163,6 +170,14 @@ tst_qdeclarativetext::tst_qdeclarativetext() // } +QDeclarativeView *tst_qdeclarativetext::createView(const QString &filename) +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + + canvas->setSource(QUrl::fromLocalFile(filename)); + return canvas; +} + void tst_qdeclarativetext::text() { { @@ -383,6 +398,67 @@ void tst_qdeclarativetext::textFormat() } } + +void tst_qdeclarativetext::alignments_data() +{ + QTest::addColumn<int>("hAlign"); + 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("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("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"; +} + + +void tst_qdeclarativetext::alignments() +{ + QFETCH(int, hAlign); + 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(); + 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); + ob->setProperty("verticalAlignment",vAlign); + QTRY_COMPARE(ob->property("running").toBool(),false); + QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); + actual.fill(qRgb(255,255,255)); + QPainter p(&actual); + canvas->render(&p); + + QImage expect(expectfile); + +#ifdef Q_WS_X11 + // Font-specific, but not likely platform-specific, so only test on one platform + if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") { + QCOMPARE(actual,expect); + } +#endif +} + //the alignment tests may be trivial o.oa void tst_qdeclarativetext::horizontalAlignment() { diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml new file mode 100644 index 0000000..9281a06 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml @@ -0,0 +1,41 @@ +import Qt 4.7 + +Rectangle { + id: top + width: 70; height: 70; + + property alias horizontalAlignment: t.horizontalAlignment + property alias verticalAlignment: t.verticalAlignment + property alias wrapMode: t.wrapMode + property alias running: timer.running + property string txt: "Test" + + Rectangle { + anchors.centerIn: parent + width: 40 + height: 40 + color: "green" + + TextEdit { + id: t + + anchors.fill: parent + horizontalAlignment: TextEdit.AlignRight + verticalAlignment: TextEdit.AlignBottom + wrapMode: TextEdit.WordWrap + text: top.txt + } + Timer { + id: timer + + interval: 1 + running: true + repeat: true + onTriggered: { + top.txt = top.txt + "<br>more " + top.txt.length; + if (top.txt.length > 50) + running = false + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png Binary files differnew file mode 100644 index 0000000..99de219 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png Binary files differnew file mode 100644 index 0000000..cb85251 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png Binary files differnew file mode 100644 index 0000000..ddca549 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png Binary files differnew file mode 100644 index 0000000..1b50a81 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png Binary files differnew file mode 100644 index 0000000..f041b86 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png Binary files differnew file mode 100644 index 0000000..c75e0d1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png Binary files differnew file mode 100644 index 0000000..b06a5da --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png Binary files differnew file mode 100644 index 0000000..e468857 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png Binary files differnew file mode 100644 index 0000000..576715f --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index f7ba7a1..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 { @@ -73,6 +93,8 @@ private slots: void width(); void wrap(); void textFormat(); + void alignments(); + void alignments_data(); // ### these tests may be trivial void hAlign(); @@ -92,6 +114,7 @@ private slots: void delegateLoading(); void navigation(); void readOnly(); + void copyAndPaste(); void openInputPanelOnClick(); void openInputPanelOnFocus(); void geometrySignals(); @@ -204,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++) @@ -220,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++) @@ -237,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)); } } @@ -297,6 +320,57 @@ void tst_qdeclarativetextedit::textFormat() } } +void tst_qdeclarativetextedit::alignments_data() +{ + QTest::addColumn<int>("hAlign"); + QTest::addColumn<int>("vAlign"); + QTest::addColumn<QString>("expectfile"); + + 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) << "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) << "alignments_lc"; + QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc"; + QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc"; +} + + +void tst_qdeclarativetextedit::alignments() +{ + QFETCH(int, hAlign); + QFETCH(int, vAlign); + QFETCH(QString, expectfile); + + QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.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); + ob->setProperty("verticalAlignment",vAlign); + QTRY_COMPARE(ob->property("running").toBool(),false); + 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); +} + + //the alignment tests may be trivial o.oa void tst_qdeclarativetextedit::hAlign() { @@ -428,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++) { @@ -760,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 f30f758..b08da0f 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -43,6 +43,7 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeitem.h> +#include <QtGui/qmenubar.h> #include "../../../shared/util.h" #include "qmlruntime.h" #include "../../../shared/util.h" @@ -52,6 +53,12 @@ #define SRCDIR "." #endif +#if defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) +# define MENUBAR_HEIGHT(mw) 0 +#else +# define MENUBAR_HEIGHT(mw) (mw->menuBar()->height()) +#endif + class tst_QDeclarativeViewer : public QObject { @@ -75,28 +82,34 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer() { } +#define TEST_INITIAL_SIZES(viewer) { \ + QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); \ + QVERIFY(rootItem); \ +\ + QCOMPARE(rootItem->width(), 200.0); \ + QCOMPARE(rootItem->height(), 300.0); \ + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); \ + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); \ + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); \ + QCOMPARE(viewer->size(), viewer->sizeHint()); \ +} + void tst_QDeclarativeViewer::orientation() { - QWidget window; - QDeclarativeViewer *viewer = new QDeclarativeViewer(&window); + QDeclarativeViewer *viewer = new QDeclarativeViewer(); QVERIFY(viewer); viewer->open(SRCDIR "/data/orientation.qml"); QVERIFY(viewer->view()); QVERIFY(viewer->menuBar()); QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); QVERIFY(rootItem); - window.show(); + viewer->show(); - QApplication::setActiveWindow(&window); - QTest::qWaitForWindowShown(&window); - QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&window)); + QApplication::setActiveWindow(viewer); + QTest::qWaitForWindowShown(viewer); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer)); - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->rotateOrientation(); qApp->processEvents(); @@ -105,7 +118,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->height(), 200.0); QTRY_COMPARE(viewer->view()->size(), QSize(300, 200)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); - QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(300, 200 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->rotateOrientation(); @@ -115,8 +128,10 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->height(), 300.0); QTRY_COMPARE(viewer->view()->size(), 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::loading() @@ -135,23 +150,17 @@ void tst_QDeclarativeViewer::loading() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer)); - // initial size - QTRY_COMPARE(rootItem->width(), 200.0); - QTRY_COMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->resize(QSize(400, 500)); qApp->processEvents(); // 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()); @@ -165,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)); @@ -173,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()); @@ -190,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() @@ -226,6 +237,8 @@ void tst_QDeclarativeViewer::fileBrowser() QVERIFY(viewer->view()); QVERIFY(viewer->menuBar()); QVERIFY(browserItem); + + delete viewer; } void tst_QDeclarativeViewer::resizing() @@ -243,14 +256,7 @@ void tst_QDeclarativeViewer::resizing() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer)); - // initial size - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - 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(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->setSizeToView(false); @@ -261,10 +267,10 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(rootItem->width(), 150.0); QCOMPARE(rootItem->height(), 200.0); - QCOMPARE(viewer->view()->size(), QSize(150, 200)); + 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)); @@ -278,16 +284,18 @@ void tst_QDeclarativeViewer::resizing() qApp->processEvents(); QTRY_COMPARE(rootItem->width(), 250.0); - QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height()); - QCOMPARE(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() @@ -300,6 +308,8 @@ void tst_QDeclarativeViewer::paths() viewer->addPluginPath("miscPluginPath"); viewer->view()->engine()->pluginPathList().contains("miscPluginPath"); + + delete viewer; } void tst_QDeclarativeViewer::slowMode() @@ -309,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/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 90c9c6f..43d4d06 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -173,10 +173,10 @@ void tst_qdeclarativevisualdatamodel::objectListModel() QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject()); QVERIFY(listview != 0); - QDeclarativeItem *viewport = listview->viewport(); - QVERIFY(viewport != 0); + QDeclarativeItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); - QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "name", 0); + QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 0); QCOMPARE(name->text(), QString("Item 1")); dataList[0]->setProperty("name", QLatin1String("Changed")); diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml index a5a8d34..ff5d3fd 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/basic.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/basic.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 WebView { url: "basic.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml index 5af76ed..3adfff8 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/elements.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/elements.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 WebView { url: "elements.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml index 4141166..9f07a51 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 WebView { url: "javaScript.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml index 2061b5f..a0cc4c8 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 WebView { url: "does-not-exist.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml index d066c07..e5967b5 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml @@ -1,7 +1,7 @@ // Demonstrates opening new WebViews from HTML import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 Grid { columns: 3 diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml index 45684ff..569f4a5 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 Item { width: 240 diff --git a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml index b14bcf9..1edd436 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import org.webkit 1.0 +import QtWebKit 1.0 WebView { html: "<p>This is a <b>string</b> set on the WebView" diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp index f33e5a4..2bded6b 100644 --- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -156,10 +156,8 @@ void tst_qdeclarativewebview::basicProperties() QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png")); QCOMPARE(wv->property("statusText").toString(),QString("status here")); QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); - QCOMPARE(wv->property("width").toDouble(), 123.0); QCOMPARE(wv->property("preferredWidth").toInt(), 0); QCOMPARE(wv->property("preferredHeight").toInt(), 0); - QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0); QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); @@ -258,9 +256,7 @@ void tst_qdeclarativewebview::historyNav() QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png")); QCOMPARE(wv->property("statusText").toString(),QString("status here")); QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); - QCOMPARE(wv->property("width").toDouble(), 123.0); QCOMPARE(wv->property("preferredWidth").toDouble(), 0.0); - QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0); QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); 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/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp index fdb384e..3b2c2d2 100644 --- a/tests/auto/linguist/lrelease/tst_lrelease.cpp +++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp @@ -171,7 +171,12 @@ void tst_lrelease::mixedcodecs() { QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/mixedcodecs-ts11.ts")); QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/mixedcodecs-ts20.ts")); +#ifdef Q_OS_WIN + QVERIFY(!QProcess::execute("fc /b testdata\\mixedcodecs-ts11.qm testdata\\mixedcodecs-ts20.qm")); +#else QVERIFY(!QProcess::execute("cmp testdata/mixedcodecs-ts11.qm testdata/mixedcodecs-ts20.qm")); +#endif + QTranslator translator; QVERIFY(translator.load("testdata/mixedcodecs-ts11.qm")); qApp->installTranslator(&translator); diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index a56d842..19f3677 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -1322,6 +1322,25 @@ public slots: void foo(struct const_ *) {}; }; + +template<typename T1, typename T2> +class TestTemplate2 +{ +}; + +class QTBUG11647_constInTemplateParameter : public QObject +{ Q_OBJECT +public slots: + void testSlot(TestTemplate2<const int, const short*>) {} + void testSlot2(TestTemplate2<int, short const * const >) {} + void testSlot3(TestTemplate2<TestTemplate2 < const int, const short* > const *, + TestTemplate2< TestTemplate2 < void, int > , unsigned char *> > ) {} + +signals: + void testSignal(TestTemplate2<const int, const short*>); +}; + + QTEST_APPLESS_MAIN(tst_Moc) #include "tst_moc.moc" diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 47c54a5..0900b35 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -1456,6 +1456,12 @@ void tst_QDateTime::fromString() dt = QDateTime::fromString("2002-10-01", Qt::ISODate); QCOMPARE(dt, QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0))); + dt = QDateTime::fromString("1987-02-13T13:24:51+01:00", Qt::ISODate); + QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC)); + + dt = QDateTime::fromString("1987-02-13T13:24:51-01:00", Qt::ISODate); + QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC)); + dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT"); QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index fe68c8e..3634ce9 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -422,6 +422,7 @@ private slots: void setGraphicsEffect(); void panel(); void addPanelToActiveScene(); + void panelWithFocusItem(); void activate(); void setActivePanelOnInactiveScene(); void activationOnShowHide(); @@ -442,6 +443,7 @@ private slots: void updateMicroFocus(); void textItem_shortcuts(); void scroll(); + void stopClickFocusPropagation(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -461,6 +463,7 @@ private slots: void sortItemsWhileAdding(); void doNotMarkFullUpdateIfNotInScene(); void itemDiesDuringDraggingOperation(); + void QTBUG_12112_focusItem(); private: QList<QGraphicsItem *> paintedItems; @@ -8415,6 +8418,54 @@ void tst_QGraphicsItem::panel() QVERIFY(!panel1->isActive()); } +void tst_QGraphicsItem::panelWithFocusItem() +{ + QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + + QGraphicsRectItem *parentPanel = new QGraphicsRectItem; + QGraphicsRectItem *parentPanelFocusItem = new QGraphicsRectItem(parentPanel); + parentPanel->setFlag(QGraphicsItem::ItemIsPanel); + parentPanelFocusItem->setFlag(QGraphicsItem::ItemIsFocusable); + parentPanelFocusItem->setFocus(); + scene.addItem(parentPanel); + + QVERIFY(parentPanel->isActive()); + QVERIFY(parentPanelFocusItem->hasFocus()); + QCOMPARE(parentPanel->focusItem(), (QGraphicsItem *)parentPanelFocusItem); + QCOMPARE(parentPanelFocusItem->focusItem(), (QGraphicsItem *)parentPanelFocusItem); + + QGraphicsRectItem *childPanel = new QGraphicsRectItem; + QGraphicsRectItem *childPanelFocusItem = new QGraphicsRectItem(childPanel); + childPanel->setFlag(QGraphicsItem::ItemIsPanel); + childPanelFocusItem->setFlag(QGraphicsItem::ItemIsFocusable); + childPanelFocusItem->setFocus(); + + QVERIFY(!childPanelFocusItem->hasFocus()); + QCOMPARE(childPanel->focusItem(), (QGraphicsItem *)childPanelFocusItem); + QCOMPARE(childPanelFocusItem->focusItem(), (QGraphicsItem *)childPanelFocusItem); + + childPanel->setParentItem(parentPanel); + + QVERIFY(!parentPanel->isActive()); + QVERIFY(!parentPanelFocusItem->hasFocus()); + QCOMPARE(parentPanel->focusItem(), (QGraphicsItem *)parentPanelFocusItem); + QCOMPARE(parentPanelFocusItem->focusItem(), (QGraphicsItem *)parentPanelFocusItem); + + QVERIFY(childPanel->isActive()); + QVERIFY(childPanelFocusItem->hasFocus()); + QCOMPARE(childPanel->focusItem(), (QGraphicsItem *)childPanelFocusItem); + QCOMPARE(childPanelFocusItem->focusItem(), (QGraphicsItem *)childPanelFocusItem); + + childPanel->hide(); + + QVERIFY(parentPanel->isActive()); + QVERIFY(parentPanelFocusItem->hasFocus()); + QCOMPARE(parentPanel->focusItem(), (QGraphicsItem *)parentPanelFocusItem); + QCOMPARE(parentPanelFocusItem->focusItem(), (QGraphicsItem *)parentPanelFocusItem); +} + void tst_QGraphicsItem::addPanelToActiveScene() { QGraphicsScene scene; @@ -10268,6 +10319,59 @@ void tst_QGraphicsItem::scroll() QCOMPARE(item2->lastExposedRect, expectedItem2Expose); } +void tst_QGraphicsItem::stopClickFocusPropagation() +{ + class MyItem : public QGraphicsRectItem + { + public: + MyItem() : QGraphicsRectItem(0, 0, 100, 100) {} + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->fillRect(boundingRect(), hasFocus() ? QBrush(Qt::red) : brush()); + } + }; + + QGraphicsScene scene(-50, -50, 400, 400); + scene.setStickyFocus(true); + + QGraphicsRectItem *noFocusOnTop = new MyItem; + noFocusOnTop->setBrush(Qt::yellow); + noFocusOnTop->setFlag(QGraphicsItem::ItemStopsClickFocusPropagation); + + QGraphicsRectItem *focusableUnder = new MyItem; + focusableUnder->setBrush(Qt::blue); + focusableUnder->setFlag(QGraphicsItem::ItemIsFocusable); + focusableUnder->setPos(50, 50); + + QGraphicsRectItem *itemWithFocus = new MyItem; + itemWithFocus->setBrush(Qt::black); + itemWithFocus->setFlag(QGraphicsItem::ItemIsFocusable); + itemWithFocus->setPos(250, 10); + + scene.addItem(noFocusOnTop); + scene.addItem(focusableUnder); + scene.addItem(itemWithFocus); + focusableUnder->stackBefore(noFocusOnTop); + itemWithFocus->setFocus(); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QApplication::setActiveWindow(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + QVERIFY(itemWithFocus->hasFocus()); + + QPointF mousePressPoint = noFocusOnTop->mapToScene(QPointF()); + mousePressPoint.rx() += 60; + mousePressPoint.ry() += 60; + const QList<QGraphicsItem *> itemsAtMousePressPosition = scene.items(mousePressPoint); + QVERIFY(itemsAtMousePressPosition.contains(focusableUnder)); + + sendMousePress(&scene, mousePressPoint); + QVERIFY(itemWithFocus->hasFocus()); +} + void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem @@ -10621,5 +10725,31 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation() delete item; QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0); } + +void tst_QGraphicsItem::QTBUG_12112_focusItem() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, 20, 20); + item1->setFlag(QGraphicsItem::ItemIsFocusable); + QGraphicsRectItem *item2 = new QGraphicsRectItem(20, 20, 20, 20); + item2->setFlag(QGraphicsItem::ItemIsFocusable); + item1->setFocus(); + scene.addItem(item2); + scene.addItem(item1); + + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + + QVERIFY(item1->focusItem()); + QVERIFY(!item2->focusItem()); + + item2->setFocus(); + QVERIFY(!item1->focusItem()); + QVERIFY(item2->focusItem()); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index ed8ff04..a771332 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -176,6 +176,7 @@ private slots: void task243004_setStyleCrash(); void task250119_shortcutContext(); void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems(); + void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems(); }; @@ -3089,6 +3090,25 @@ void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() //This should not crash } +void tst_QGraphicsWidget::QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems() +{ + QGraphicsScene scene; + QGraphicsWidget* item1 = new QGraphicsWidget; + QGraphicsWidget* item2 = new QGraphicsWidget; + QGraphicsWidget* item3 = new QGraphicsWidget; + + scene.addItem(item1); + scene.addItem(item2); + + scene.removeItem(item2); + scene.removeItem(item1); + delete item2; + delete item1; + + scene.addItem(item3); + + //This should not crash +} QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 2164b05..4219920 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -945,11 +945,11 @@ void tst_QImage::rotate() const int n = original.colorTable().size(); for (int x = 0; x < w; ++x) { original.setPixel(x, 0, x % n); - original.setPixel(x,h - 1, n - (x % n)); + original.setPixel(x, h - 1, n - (x % n) - 1); } for (int y = 0; y < h; ++y) { original.setPixel(0, y, y % n); - original.setPixel(w - 1, y, n - (y % n)); + original.setPixel(w - 1, y, n - (y % n) - 1); } } diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 4cb63a1..cc9fb0c 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -168,6 +168,7 @@ private slots: void task256322_highlight(); void menubarSizeHint(); void taskQTBUG4965_escapeEaten(); + void taskQTBUG11823_crashwithInvisibleActions(); #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); @@ -1690,6 +1691,34 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten() QTRY_VERIFY(!menubar.isVisible()); } +void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions() +{ + QMenuBar menubar; + menubar.setNativeMenuBar(false); //we can't check the geometry of native menubars + + QAction * m = menubar.addAction( "&m" ); + QAction * a = menubar.addAction( "&a" ); + + menubar.show(); + QApplication::setActiveWindow(&menubar); + QTest::qWaitForWindowShown(&menubar); + menubar.setActiveAction(m); + QCOMPARE(menubar.activeAction(), m); + QTest::keyClick(0, Qt::Key_Right); + QCOMPARE(menubar.activeAction(), a); + QTest::keyClick(0, Qt::Key_Right); + QCOMPARE(menubar.activeAction(), m); + a->setVisible(false); + + menubar.setActiveAction(m); + QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed + + //it used to crash here because the action is invisible + QTest::keyClick(0, Qt::Key_Right); + QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed +} + + #if defined(QT3_SUPPORT) void tst_QMenuBar::indexBasedInsertion_data() { diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index f1dde48..df75ae8 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -876,6 +876,8 @@ void tst_QMetaObject::normalizedType_data() QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList< ::Foo::Bar>"; QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>"; QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int> >"; + QTest::newRow("template8") << "QMap<const int, const short*>" << "QMap<const int,const short*>"; + QTest::newRow("template9") << "QPair<const QPair<int, int const *> , QPair<QHash<int, const char*> > >" << "QPair<const QPair<int,const int*>,QPair<QHash<int,const char*> > >"; QTest::newRow("value1") << "const QString &" << "QString"; QTest::newRow("value2") << "QString const &" << "QString"; QTest::newRow("constInName1") << "constconst" << "constconst"; diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 701dc2e..27ee6e7 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -2648,12 +2648,16 @@ void tst_QPainter::setOpacity() p.drawImage(imageRect, src, imageRect); p.end(); - QImage expected(imageSize, destFormat); - p.begin(&expected); - p.fillRect(imageRect, QColor(127, 127, 127)); - p.end(); - - QCOMPARE(dest, expected); + QImage actual = dest.convertToFormat(QImage::Format_RGB32); + + for (int y = 0; y < actual.height(); ++y) { + QRgb *p = (QRgb *)actual.scanLine(y); + for (int x = 0; x < actual.width(); ++x) { + QVERIFY(qAbs(qRed(p[x]) - 127) <= 0xf); + QVERIFY(qAbs(qGreen(p[x]) - 127) <= 0xf); + QVERIFY(qAbs(qBlue(p[x]) - 127) <= 0xf); + } + } } void tst_QPainter::drawhelper_blend_untransformed_data() diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gif b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gif Binary files differnew file mode 100644 index 0000000..f813c05 --- /dev/null +++ b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha_animated.gif diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 179f068..f22edf6 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -44,6 +44,7 @@ #include <qpixmap.h> #include <qbitmap.h> #include <qimage.h> +#include <qimagereader.h> #include <qmatrix.h> #include <qdesktopwidget.h> #include <qpaintengine.h> @@ -175,6 +176,11 @@ private slots: void loadFromDataImage_data(); void loadFromDataImage(); + void fromImageReader_data(); + void fromImageReader(); + + void fromImageReaderAnimatedGif(); + void preserveDepth(); void splash_crash(); @@ -1577,6 +1583,61 @@ void tst_QPixmap::loadFromDataImage() QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap)); } +void tst_QPixmap::fromImageReader_data() +{ + QTest::addColumn<QString>("imagePath"); +#ifdef Q_OS_SYMBIAN + const QString prefix = QLatin1String(SRCDIR) + "loadFromData"; +#else + const QString prefix = QLatin1String(SRCDIR) + "/loadFromData"; +#endif + QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png"; + QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png"; + QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png"; + QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png"; + QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif"; + QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif"; + QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg"; +} + +void tst_QPixmap::fromImageReader() +{ + QFETCH(QString, imagePath); + + QImage imageRef(imagePath); + QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef); + + QImageReader imageReader(imagePath); + + QPixmap directLoadingPixmap = QPixmap::fromImageReader(&imageReader); + + QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap)); +} + +void tst_QPixmap::fromImageReaderAnimatedGif() +{ +#ifdef Q_OS_SYMBIAN + const QString prefix = QLatin1String(SRCDIR) + "loadFromData"; +#else + const QString prefix = QLatin1String(SRCDIR) + "/loadFromData"; +#endif + const QString path = prefix + QString::fromLatin1("/designer_indexed8_with_alpha_animated.gif"); + + QImageReader referenceReader(path); + QImageReader pixmapReader(path); + + Q_ASSERT(referenceReader.canRead()); + Q_ASSERT(referenceReader.imageCount() > 1); + + for (int i = 0; i < referenceReader.imageCount(); ++i) { + QImage refImage = referenceReader.read(); + QPixmap refPixmap = QPixmap::fromImage(refImage); + + QPixmap directLoadingPixmap = QPixmap::fromImageReader(&pixmapReader); + QVERIFY(pixmapsAreEqual(&refPixmap, &directLoadingPixmap)); + } +} + void tst_QPixmap::task_246446() { // This crashed without the bugfix in 246446 diff --git a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp index d842934..ae5d3ae 100644 --- a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp +++ b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp @@ -44,9 +44,14 @@ int main(int argc, char ** argv) { -#if defined(__SYMBIAN32__) +#if defined(__SYMBIAN32__) || defined(WINCE) || defined(_WIN32_WCE) +# if defined(__SYMBIAN32__) // Printing to stdout messes up the out.txt, so open a file and print there. FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","w+"); +# else + // No pipes on this "OS" + FILE* file = fopen("\\temp\\qprocess_args_test.txt","w+"); +# endif for (int i = 0; i < argc; ++i) { if (i) fprintf(file, "|"); diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 8dae9a0..fd310f4 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -93,6 +93,7 @@ private slots: void getSetCheck(); void constructing(); void simpleStart(); + void execute(); void startDetached(); void crashTest(); void crashTest2(); @@ -131,6 +132,9 @@ private slots: void waitForBytesWrittenInABytesWrittenSlot(); void spaceArgsTest_data(); void spaceArgsTest(); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + void nativeArguments(); +#endif void exitCodeTest(); void setEnvironment_data(); void setEnvironment(); @@ -284,6 +288,14 @@ void tst_QProcess::simpleStart() QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning); } //----------------------------------------------------------------------------- +void tst_QProcess::execute() +{ + QCOMPARE(QProcess::execute("testProcessNormal/testProcessNormal", + QStringList() << "arg1" << "arg2"), 0); + QCOMPARE(QProcess::execute("nonexistingexe"), -2); +} + +//----------------------------------------------------------------------------- void tst_QProcess::startDetached() { QProcess proc; @@ -1621,6 +1633,55 @@ void tst_QProcess::spaceArgsTest() process = 0; } +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + +//----------------------------------------------------------------------------- +void tst_QProcess::nativeArguments() +{ + QProcess proc; + + // This doesn't actually need special quoting, so it is pointless to use + // native arguments here, but that's not the point of this test. + proc.setNativeArguments("hello kitty, \"*\"!"); + + proc.start(QString::fromLatin1("testProcessSpacesArgs/nospace"), QStringList()); + +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) + QVERIFY(proc.waitForStarted(5000)); + QVERIFY(proc.waitForFinished(5000)); +#else + QVERIFY(proc.waitForStarted(10000)); + QVERIFY(proc.waitForFinished(10000)); +#endif + +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE) + // Symbian test outputs to a file, so check that +# ifdef Q_OS_SYMBIAN + FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","r"); +# else + FILE* file = fopen("\\temp\\qprocess_args_test.txt","r"); +# endif + char buf[256]; + fgets(buf, 256, file); + fclose(file); + QStringList actual = QString::fromLatin1(buf).split("|"); +#else + QStringList actual = QString::fromLatin1(proc.readAll()).split("|"); +#endif + QVERIFY(!actual.isEmpty()); + // not interested in the program name, it might be different. + actual.removeFirst(); + QStringList expected; +#if defined(Q_OS_WINCE) + expected << "hello" << "kitty," << "\"*\"!"; // Weird, weird ... +#else + expected << "hello" << "kitty," << "*!"; +#endif + QCOMPARE(actual, expected); +} + +#endif + //----------------------------------------------------------------------------- void tst_QProcess::exitCodeTest() { diff --git a/tests/benchmarks/declarative/script/data/block.qml b/tests/benchmarks/declarative/script/data/block.qml index 4e5006e..f7b2ab3 100644 --- a/tests/benchmarks/declarative/script/data/block.qml +++ b/tests/benchmarks/declarative/script/data/block.qml @@ -47,7 +47,7 @@ Rectangle { function doSomethingDirect() { theObject.prop1 = 0; - for (var i = 0; i < 60; ++i) + for (var i = 0; i < 1000; ++i) theObject.prop1 += theObject.prop2; theObject.prop3 = theObject.prop1; @@ -57,7 +57,7 @@ Rectangle { theObject.prop1 = 0; var incrementObj = theObject; - for (var i = 0; i < 60; ++i) + for (var i = 0; i < 1000; ++i) incrementObj.prop1 += incrementObj.prop2; incrementObj.prop3 = incrementObj.prop1; @@ -67,7 +67,7 @@ Rectangle { theObject.prop1 = 0; var increment = theObject.prop2; - for (var i = 0; i < 60; ++i) + for (var i = 0; i < 1000; ++i) theObject.prop1 += increment; theObject.prop3 = theObject.prop1; diff --git a/tests/benchmarks/declarative/script/data/global.js b/tests/benchmarks/declarative/script/data/global.js new file mode 100644 index 0000000..5b86b4d --- /dev/null +++ b/tests/benchmarks/declarative/script/data/global.js @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +var incVar = 1; +var total; + +function doSomething() { + for (var i = 0; i < 10000; ++i) + Math.sin(90); +} + +function doIncrement() { + total = 0; + for (var i = 0; i < 100000; ++i) + total += incVar; +} diff --git a/tests/benchmarks/declarative/script/data/global_prop.qml b/tests/benchmarks/declarative/script/data/global_prop.qml new file mode 100644 index 0000000..4fb7ee7 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/global_prop.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +import Qt 4.7 +import "global.js" as Program + +Rectangle { + width: 200; height: 200 + + signal triggered + signal incrementTriggered + + onTriggered: Program.doSomething(); + onIncrementTriggered: Program.doIncrement(); +} diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 99f294c..5a7e151 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -92,7 +92,12 @@ private slots: void block_data(); void block(); -private: + + void global_property_js(); + void global_property_qml(); + void global_property_qml_js(); + + void scriptfile_property(); }; inline QUrl TEST_FILE(const QString &filename) @@ -625,6 +630,74 @@ void tst_script::block() delete rect; } +#define GLOBALPROPERTY_PROGRAM \ + "(function() { " \ + " for (var ii = 0; ii < 10000; ++ii) { " \ + " Math.sin(90); " \ + " } " \ + "})" + +void tst_script::global_property_js() +{ + QScriptEngine engine; + + QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::global_property_qml() +{ + QDeclarativeEngine qmlengine; + + QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); + QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::global_property_qml_js() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create()); + QVERIFY(rect != 0); + + int index = rect->metaObject()->indexOfMethod("triggered()"); + QVERIFY(index != -1); + QMetaMethod method = rect->metaObject()->method(index); + + QBENCHMARK { + method.invoke(rect, Qt::DirectConnection); + } + + delete rect; +} + +void tst_script::scriptfile_property() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create()); + QVERIFY(rect != 0); + + int index = rect->metaObject()->indexOfMethod("incrementTriggered()"); + QVERIFY(index != -1); + QMetaMethod method = rect->metaObject()->method(index); + + QBENCHMARK { + method.invoke(rect, Qt::DirectConnection); + } + + delete rect; +} + QTEST_MAIN(tst_script) #include "tst_script.moc" diff --git a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp index 8e9de4a..27e5025 100644 --- a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp @@ -40,9 +40,12 @@ ****************************************************************************/ #include <qtest.h> -#include <QPixmap> #include <QBitmap> +#include <QDir> +#include <QImage> +#include <QImageReader> #include <QPainter> +#include <QPixmap> #include <private/qpixmap_raster_p.h> class tst_QPixmap : public QObject @@ -62,6 +65,9 @@ private slots: void transformed(); void mask_data(); void mask(); + + void fromImageReader_data(); + void fromImageReader(); }; Q_DECLARE_METATYPE(QImage::Format) @@ -248,6 +254,62 @@ void tst_QPixmap::mask() } } +void tst_QPixmap::fromImageReader_data() +{ + const QString tempDir = QDir::tempPath(); + QTest::addColumn<QString>("filename"); + + QImage image(2000, 2000, QImage::Format_ARGB32); + image.fill(0); + { + // Generate an image with opaque and transparent pixels + // with an interesting distribution. + QPainter painter(&image); + + QRadialGradient radialGrad(QPointF(1000, 1000), 1000); + radialGrad.setColorAt(0, QColor(255, 0, 0, 255)); + radialGrad.setColorAt(0.5, QColor(0, 255, 0, 255)); + radialGrad.setColorAt(0.9, QColor(0, 0, 255, 100)); + radialGrad.setColorAt(1, QColor(0, 0, 0, 0)); + + painter.fillRect(image.rect(), radialGrad); + } + image.save("test.png"); + + // RGB32 + const QString rgb32Path = tempDir + QString::fromLatin1("/rgb32.jpg"); + image.save(rgb32Path); + QTest::newRow("gradient RGB32") << rgb32Path; + + // ARGB32 + const QString argb32Path = tempDir + QString::fromLatin1("/argb32.png"); + image.save(argb32Path); + QTest::newRow("gradient ARGB32") << argb32Path; + + // Indexed 8 + const QString indexed8Path = tempDir + QString::fromLatin1("/indexed8.gif"); + image.save(indexed8Path); + QTest::newRow("gradient indexed8") << indexed8Path; + +} + +void tst_QPixmap::fromImageReader() +{ + QFETCH(QString, filename); + // warmup + { + QImageReader imageReader(filename); + QPixmap::fromImageReader(&imageReader); + } + + QBENCHMARK { + QImageReader imageReader(filename); + QPixmap::fromImageReader(&imageReader); + } + QFile::remove(filename); +} + + QTEST_MAIN(tst_QPixmap) #include "tst_qpixmap.moc" diff --git a/tests/benchmarks/gui/text/qtext/main.cpp b/tests/benchmarks/gui/text/qtext/main.cpp index d4f3165..63daae0 100644 --- a/tests/benchmarks/gui/text/qtext/main.cpp +++ b/tests/benchmarks/gui/text/qtext/main.cpp @@ -82,7 +82,13 @@ private slots: void constructControl(); void constructDocument(); + void newLineReplacement(); + void formatManipulation(); + void fontResolution(); + + void layout_data(); void layout(); + void formattedLayout(); void paintLayoutToPixmap(); void paintLayoutToPixmap_painterFill(); @@ -95,7 +101,7 @@ private slots: void paintControlToPixmap_painterFill(); private: - QSize setupTextLayout(QTextLayout *layout); + QSize setupTextLayout(QTextLayout *layout, bool wrap = true, int wrapWidth = 100); QString m_lorem; QString m_shortLorem; @@ -227,10 +233,8 @@ void tst_QText::odfWriting_images() delete doc; } -QSize tst_QText::setupTextLayout(QTextLayout *layout) +QSize tst_QText::setupTextLayout(QTextLayout *layout, bool wrap, int wrapWidth) { - bool wrap = true; - int wrapWidth = 300; layout->setCacheEnabled(true); int height = 0; @@ -242,7 +246,6 @@ QSize tst_QText::setupTextLayout(QTextLayout *layout) lineWidth = wrapWidth; layout->beginLayout(); - while (1) { QTextLine line = layout->createLine(); if (!line.isValid()) @@ -284,13 +287,95 @@ void tst_QText::constructDocument() } } +//this step is needed before giving the string to a QTextLayout +void tst_QText::newLineReplacement() +{ + QString text = QString::fromLatin1("H\ne\nl\nl\no\n\nW\no\nr\nl\nd"); + + QBENCHMARK { + QString tmp = text; + tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + } +} + +void tst_QText::formatManipulation() +{ + QFont font; + + QBENCHMARK { + QTextCharFormat format; + format.setFont(font); + } +} + +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"); + QTest::newRow("wrap") << true; + QTest::newRow("nowrap") << false; +} + void tst_QText::layout() { + QFETCH(bool,wrap); + QTextLayout layout(m_shortLorem); + setupTextLayout(&layout, wrap); + + QBENCHMARK { + QTextLayout layout(m_shortLorem); + setupTextLayout(&layout, wrap); + } +} + +//### requires tst_QText to be a friend of QTextLayout +/*void tst_QText::stackTextLayout() +{ + QStackTextEngine engine(m_shortLorem, qApp->font()); + QTextLayout layout(&engine); + setupTextLayout(&layout); + + QBENCHMARK { + QStackTextEngine engine(m_shortLorem, qApp->font()); + QTextLayout layout(&engine); + setupTextLayout(&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); } } diff --git a/tests/benchmarks/opengl/main.cpp b/tests/benchmarks/opengl/main.cpp index beb4d43..c042fce 100644 --- a/tests/benchmarks/opengl/main.cpp +++ b/tests/benchmarks/opengl/main.cpp @@ -75,6 +75,10 @@ private slots: void gradients_data(); void gradients(); + void textureUpload_data(); + void textureUpload(); + + private: QGLPixelBuffer *pb; }; @@ -374,6 +378,53 @@ void OpenGLBench::gradients() } } +void OpenGLBench::textureUpload_data() +{ + QTest::addColumn<int>("size"); + QTest::addColumn<int>("flags"); + QTest::addColumn<int>("format"); + + int sizes[] = { 8, 10, 16, 20, 32, 50, 64, 100, 128, 200, 256, 500, 512, 1000, 1024, 2000, 2048, -1 }; + int flags[] = { QGLContext::InternalBindOption, + QGLContext::DefaultBindOption, + -1 }; + int formats[] = { GL_RGB, GL_RGBA, -1 }; + + for (int s = 0; sizes[s] != -1; ++s) { + for (int f = 0; flags[f] != -1; ++f) { + for (int a = 0; formats[a] != -1; ++a) { + QByteArray name; + name.append("size=").append(QByteArray::number(sizes[s])); + name.append(", flags=").append(f == 0 ? "internal" : "default"); + name.append(", format=").append(a == 0 ? "RGB" : "RGBA"); + QTest::newRow(name.constData()) << sizes[s] << flags[f] << formats[a]; + } + } + } +} + +void OpenGLBench::textureUpload() +{ + QFETCH(int, size); + QFETCH(int, flags); + QFETCH(int, format); + + QPixmap pixmap(size, size); + + if (format == GL_RGB) + pixmap.fill(Qt::red); + else + pixmap.fill(Qt::transparent); + + pb->makeCurrent(); + QGLContext *context = const_cast<QGLContext *>(QGLContext::currentContext()); + QTime time; + + time.start(); + context->bindTexture(pixmap, GL_TEXTURE_2D, format, (QGLContext::BindOptions) flags); + QTest::setBenchmarkResult(time.elapsed(), QTest::WalltimeMilliseconds); +} + QTEST_MAIN(OpenGLBench) #include "main.moc" diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp new file mode 100644 index 0000000..a39e094 --- /dev/null +++ b/tests/manual/qtabletevent/regular_widgets/main.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** 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 FOO module 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 <QApplication> +#include <QDebug> +#include <QMouseEvent> +#include <QTabletEvent> +#include <QWidget> + +class EventReportWidget : public QWidget +{ +public: + EventReportWidget(); +protected: + void mouseDoubleClickEvent(QMouseEvent *event) { outputMouseEvent(event); } + void mouseMoveEvent(QMouseEvent *event) { outputMouseEvent(event); } + void mousePressEvent(QMouseEvent *event) { outputMouseEvent(event); } + void mouseReleaseEvent(QMouseEvent *event) { outputMouseEvent(event); } + + void tabletEvent(QTabletEvent *); + +private: + void outputMouseEvent(QMouseEvent *event); + + bool m_lastIsMouseMove; + bool m_lastIsTabletMove; +}; + +EventReportWidget::EventReportWidget() + : m_lastIsMouseMove(false) + , m_lastIsTabletMove(false) +{ } + +void EventReportWidget::tabletEvent(QTabletEvent *event) +{ + QWidget::tabletEvent(event); + + QString type; + switch (event->type()) { + case QEvent::TabletEnterProximity: + m_lastIsTabletMove = false; + type = QString::fromLatin1("TabletEnterProximity"); + break; + case QEvent::TabletLeaveProximity: + m_lastIsTabletMove = false; + type = QString::fromLatin1("TabletLeaveProximity"); + break; + case QEvent::TabletMove: + if (m_lastIsTabletMove) + return; + + m_lastIsTabletMove = true; + type = QString::fromLatin1("TabletMove"); + break; + case QEvent::TabletPress: + m_lastIsTabletMove = false; + type = QString::fromLatin1("TabletPress"); + break; + case QEvent::TabletRelease: + m_lastIsTabletMove = false; + type = QString::fromLatin1("TabletRelease"); + break; + default: + Q_ASSERT(false); + break; + } + + qDebug() << "Tablet event, type = " << type + << " position = " << event->pos() + << " global position = " << event->globalPos(); +} + +void EventReportWidget::outputMouseEvent(QMouseEvent *event) +{ + QString type; + switch (event->type()) { + case QEvent::MouseButtonDblClick: + m_lastIsMouseMove = false; + type = QString::fromLatin1("MouseButtonDblClick"); + break; + case QEvent::MouseButtonPress: + m_lastIsMouseMove = false; + type = QString::fromLatin1("MouseButtonPress"); + break; + case QEvent::MouseButtonRelease: + m_lastIsMouseMove = false; + type = QString::fromLatin1("MouseButtonRelease"); + break; + case QEvent::MouseMove: + if (m_lastIsMouseMove) + return; // only show one move to keep things readable + + m_lastIsMouseMove = true; + type = QString::fromLatin1("MouseMove"); + break; + default: + Q_ASSERT(false); + break; + } + + qDebug() << "Mouse event, type = " << type + << " position = " << event->pos() + << " global position = " << event->globalPos(); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + EventReportWidget widget; + widget.show(); + return app.exec(); +} diff --git a/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro b/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro new file mode 100644 index 0000000..9f0da76 --- /dev/null +++ b/tests/manual/qtabletevent/regular_widgets/regular_widgets.pro @@ -0,0 +1,3 @@ +TEMPLATE = app + +SOURCES += main.cpp |