summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-10 04:42:47 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-10 04:42:47 (GMT)
commita5666c0f220e42464758890e29e209c26f9a9fa1 (patch)
treec499f49ae478655242c60b464040e4f2d75e876b /tests
parent4e8b2039ecbbda87b5c23cc0a574b7accfc2ad33 (diff)
parentb5be801a5277cf63185f36d2ca1557b941340ce3 (diff)
downloadQt-a5666c0f220e42464758890e29e209c26f9a9fa1.zip
Qt-a5666c0f220e42464758890e29e209c26f9a9fa1.tar.gz
Qt-a5666c0f220e42464758890e29e209c26f9a9fa1.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (21 commits) Doc Link with the correct library for TCommDbConnPref Remove unused struct update Browser.qml to run again Update Autotests Probably fix compile on windows Fix typo in docs Probably fix compile Fix qdeclarativevaluetype::font() autotest Initialize member variable in QDeclarativeGridViewAttached Handle itemsInserted/Removed/Moved() correctly for repeater. Add QML support for methods returning QList<QObject *> Compile Update configure.exe to include declarative module by default Make QDeclarativeItem NOTIFY signals canonical Integrate QML's object ownership with the JS collector Remove unused data member. Fix warning. Fix warnings and change geometry-related functions to use reals. When flicking with snap, bias towards moving at least one item. ...
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml4
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/simple.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp90
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp92
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp13
10 files changed, 217 insertions, 9 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
index 12b1b7b..5e1891a 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
@@ -10,7 +10,7 @@ Rectangle {
width: 100; height: 100
color: Qt.rgba(1,0,0)
Behavior on x {
- NumberAnimation { objectName: "MyAnim"; running: true }
+ NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true }
}
}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
index 6419a6b..11b2d3a 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
@@ -8,8 +8,8 @@ Rectangle {
width: 100; height: 100; color: "green"
Behavior on x {
objectName: "MyBehavior"
- NumberAnimation { duration: 200 }
- NumberAnimation { duration: 1000 }
+ NumberAnimation {id: na1; duration: 200 }
+ NumberAnimation {id: na2; duration: 1000 }
}
}
MouseArea {
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
index c28fa9a..5e72bca 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
@@ -8,7 +8,7 @@ Rectangle {
width: 100; height: 100; color: "green"
Behavior on x {
objectName: "MyBehavior";
- NumberAnimation { duration: 500; }
+ NumberAnimation {id: na; duration: 500; }
}
}
MouseArea {
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml
new file mode 100644
index 0000000..72edf6e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+QtObject {
+ Component.onCompleted: { var a = getObject(); a = null; }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml
new file mode 100644
index 0000000..5897e2a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+QtObject {
+ property int test: getObjects().length
+ property bool test2: getObjects()[0].trueProperty
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 4838288..bdd2c93 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -126,6 +126,8 @@ private slots:
void attachedPropertyScope();
void scriptConnect();
void scriptDisconnect();
+ void ownership();
+ void qlistqobjectMethods();
void bug1();
@@ -889,6 +891,7 @@ void tst_qdeclarativeecmascript::dynamicDestruction()
}
QVERIFY(!createdQmlObject);
+ QDeclarativeEngine::setObjectOwnership(object, QDeclarativeEngine::JavaScriptOwnership);
QMetaObject::invokeMethod(object, "killMe");
QVERIFY(object);
QTest::qWait(0);
@@ -1890,7 +1893,94 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
delete object;
}
+}
+
+class OwnershipObject : public QObject
+{
+ Q_OBJECT
+public:
+ OwnershipObject() { object = new QObject; }
+
+ QPointer<QObject> object;
+
+public slots:
+ QObject *getObject() { return object; }
+};
+
+void tst_qdeclarativeecmascript::ownership()
+{
+ OwnershipObject own;
+ QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
+ context->addDefaultObject(&own);
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml"));
+
+ QVERIFY(own.object != 0);
+
+ QObject *object = component.create(context);
+ QDeclarativeEnginePrivate::getScriptEngine(&engine)->collectGarbage();
+
+ QCoreApplication::processEvents(QEventLoop::DeferredDeletion);
+
+ QVERIFY(own.object == 0);
+
+ delete object;
+ }
+
+ own.object = new QObject(&own);
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml"));
+
+ QVERIFY(own.object != 0);
+
+ QObject *object = component.create(context);
+ QDeclarativeEnginePrivate::getScriptEngine(&engine)->collectGarbage();
+ QCoreApplication::processEvents(QEventLoop::DeferredDeletion);
+
+ QVERIFY(own.object != 0);
+
+ delete object;
+ }
+}
+
+class QListQObjectMethodsObject : public QObject
+{
+ Q_OBJECT
+public:
+ QListQObjectMethodsObject() {
+ m_objects.append(new MyQmlObject());
+ m_objects.append(new MyQmlObject());
+ }
+
+ ~QListQObjectMethodsObject() {
+ qDeleteAll(m_objects);
+ }
+
+public slots:
+ QList<QObject *> getObjects() { return m_objects; }
+
+private:
+ QList<QObject *> m_objects;
+};
+
+// Tests that returning a QList<QObject*> from a method works
+void tst_qdeclarativeecmascript::qlistqobjectMethods()
+{
+ QListQObjectMethodsObject obj;
+ QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
+ context->addDefaultObject(&obj);
+
+ QDeclarativeComponent component(&engine, TEST_FILE("qlistqobjectMethods.qml"));
+
+ QObject *object = component.create(context);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
}
QTEST_MAIN(tst_qdeclarativeecmascript)
diff --git a/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml b/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml
new file mode 100644
index 0000000..bf4dd85
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ Item {
+ objectName: "item"
+ }
+ Item {
+ objectName: "parentItem"
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index bbcc86e..45d670f 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -60,6 +60,7 @@ private slots:
void clip();
void mapCoordinates();
void mapCoordinates_data();
+ void propertyChanges();
private:
template<typename T>
@@ -289,7 +290,7 @@ void tst_QDeclarativeItem::smooth()
QDeclarativeComponent component(&engine);
component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged()));
+ QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
QVERIFY(item);
QVERIFY(!item->smooth());
@@ -297,6 +298,10 @@ void tst_QDeclarativeItem::smooth()
item->setSmooth(true);
QVERIFY(item->smooth());
QCOMPARE(spy.count(),1);
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
item->setSmooth(true);
QCOMPARE(spy.count(),1);
@@ -314,13 +319,18 @@ void tst_QDeclarativeItem::clip()
QDeclarativeComponent component(&engine);
component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged()));
+ QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
QVERIFY(item);
QVERIFY(!item->clip());
item->setClip(true);
QVERIFY(item->clip());
+
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
QCOMPARE(spy.count(),1);
item->setClip(true);
QCOMPARE(spy.count(),1);
@@ -392,6 +402,84 @@ void tst_QDeclarativeItem::mapCoordinates_data()
QTest::newRow(QTest::toString(i)) << i << i;
}
+void tst_QDeclarativeItem::propertyChanges()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ canvas->show();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item");
+ QDeclarativeItem *parentItem = findItem<QDeclarativeItem>(canvas->rootObject(), "parentItem");
+
+ QVERIFY(item);
+ QVERIFY(parentItem);
+
+ QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *)));
+ QSignalSpy widthSpy(item, SIGNAL(widthChanged(qreal)));
+ QSignalSpy heightSpy(item, SIGNAL(heightChanged(qreal)));
+ QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
+ QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
+ QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
+ QSignalSpy wantsFocusSpy(parentItem, SIGNAL(wantsFocusChanged(bool)));
+
+ item->setParentItem(parentItem);
+ item->setWidth(100.0);
+ item->setHeight(200.0);
+ item->setFocus(true);
+ item->setBaselineOffset(10.0);
+
+ QCOMPARE(item->parentItem(), parentItem);
+ QCOMPARE(parentSpy.count(),1);
+ QList<QVariant> parentArguments = parentSpy.first();
+ QVERIFY(parentArguments.count() == 1);
+ QCOMPARE(item->parentItem(), qvariant_cast<QDeclarativeItem *>(parentArguments.at(0)));
+
+ QCOMPARE(item->width(), 100.0);
+ QCOMPARE(widthSpy.count(),1);
+ QList<QVariant> widthArguments = widthSpy.first();
+ QVERIFY(widthArguments.count() == 1);
+ QCOMPARE(item->width(), widthArguments.at(0).toReal());
+
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(heightSpy.count(),1);
+ QList<QVariant> heightArguments = heightSpy.first();
+ QVERIFY(heightArguments.count() == 1);
+ QCOMPARE(item->height(), heightArguments.at(0).toReal());
+
+ QCOMPARE(item->baselineOffset(), 10.0);
+ QCOMPARE(baselineOffsetSpy.count(),1);
+ QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
+ QVERIFY(baselineOffsetArguments.count() == 1);
+ QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
+
+ QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
+ QCOMPARE(childrenRectSpy.count(),2);
+ QList<QVariant> childrenRectArguments = childrenRectSpy.at(1);
+ QVERIFY(childrenRectArguments.count() == 1);
+ QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
+
+ QCOMPARE(item->hasFocus(), true);
+ QCOMPARE(focusSpy.count(),1);
+ QList<QVariant> focusArguments = focusSpy.first();
+ QVERIFY(focusArguments.count() == 1);
+ 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);
+
+ delete canvas;
+}
+
template<typename T>
T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName)
{
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
index 7a97e60..7da9454 100644
--- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -109,7 +109,7 @@ public:
setRoleNames(roles);
}
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
QVariant rv;
if (role == Name)
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index 51f9a07..eba83ce 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -314,8 +314,17 @@ void tst_qdeclarativevaluetypes::font()
font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
font.setWordSpacing(11.2);
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->font(), font);
+ QFont f = object->font();
+ QCOMPARE(f.family(), font.family());
+ QCOMPARE(f.bold(), font.bold());
+ QCOMPARE(f.weight(), font.weight());
+ QCOMPARE(f.italic(), font.italic());
+ QCOMPARE(f.underline(), font.underline());
+ QCOMPARE(f.strikeOut(), font.strikeOut());
+ QCOMPARE(f.pointSize(), font.pointSize());
+ QCOMPARE(f.capitalization(), font.capitalization());
+ QCOMPARE(f.letterSpacing(), font.letterSpacing());
+ QCOMPARE(f.wordSpacing(), font.wordSpacing());
delete object;
}