summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp9
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h17
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp43
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml16
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp61
15 files changed, 176 insertions, 12 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
index 804559c..d41add3 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
@@ -11,7 +11,7 @@ Rectangle {
width: 100
height: 100
Behavior on x {
- NumberAnimation {}
+ NumberAnimation { duration: 500 }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 896d69e..d4d8bf6 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -655,6 +655,15 @@ void tst_QDeclarativeGridView::currentIndex()
gridview->setFlow(QDeclarativeGridView::TopToBottom);
+ qApp->setActiveWindow(canvas);
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(canvas);
+#endif
+ QTRY_VERIFY(canvas->hasFocus());
+ QTRY_VERIFY(canvas->scene()->hasFocus());
+ qApp->processEvents();
+
QTest::keyClick(canvas, Qt::Key_Right);
QCOMPARE(gridview->currentIndex(), 5);
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
index 6d5a357..d0afc8a 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -389,6 +389,7 @@ void tst_qdeclarativeimageprovider::threadTest()
}
provider->ok = true;
provider->cond.wakeAll();
+ QTest::qWait(250);
foreach(QDeclarativeImage *img, images) {
TRY_WAIT(img->status() == QDeclarativeImage::Ready);
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml b/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml
new file mode 100644
index 0000000..1f8eac8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml
@@ -0,0 +1,4 @@
+import Test 1.0
+
+MyParserStatus {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml b/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml
new file mode 100644
index 0000000..df048cc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+Item {
+ property QtObject object: DontDoubleCallClassBeginItem {}
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
index 6e11786..53e752b 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:5:Type NestedErrorsType unavailable
4:8:Invalid property assignment: number expected
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
index 5d87404..20cd976 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -50,6 +50,7 @@ void registerTypes()
qmlRegisterType<MyDotPropertyObject>("Test",1,0,"MyDotPropertyObject");
qmlRegisterType<MyNamespace::MyNamespacedType>("Test",1,0,"MyNamespacedType");
qmlRegisterType<MyNamespace::MySecondNamespacedType>("Test",1,0,"MySecondNamespacedType");
+ qmlRegisterType<MyParserStatus>("Test",1,0,"MyParserStatus");
qmlRegisterType<MyGroupedObject>();
qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser);
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index acbe219..19790f1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -170,7 +170,6 @@ private:
QML_DECLARE_TYPE(MyQmlObject)
QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-
class MyGroupedObject : public QObject
{
Q_OBJECT
@@ -576,6 +575,22 @@ public:
void setCustomData(QObject *, const QByteArray &) {}
};
+class MyParserStatus : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+public:
+ MyParserStatus() : m_cbc(0), m_ccc(0) {}
+
+ int classBeginCount() const { return m_cbc; }
+ int componentCompleteCount() const { return m_ccc; }
+
+ virtual void classBegin() { m_cbc++; }
+ virtual void componentComplete() { m_ccc++; }
+private:
+ int m_cbc;
+ int m_ccc;
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index fcdf926..b43fbf4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -126,6 +126,7 @@ private slots:
void scriptString();
void defaultPropertyListOrder();
void declaredPropertyValues();
+ void dontDoubleCallClassBegin();
void basicRemote_data();
void basicRemote();
@@ -1192,6 +1193,20 @@ void tst_qdeclarativelanguage::declaredPropertyValues()
VERIFY_ERRORS(0);
}
+void tst_qdeclarativelanguage::dontDoubleCallClassBegin()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ MyParserStatus *o2 = qobject_cast<MyParserStatus *>(qvariant_cast<QObject *>(o->property("object")));
+ QVERIFY(o2);
+ QCOMPARE(o2->classBeginCount(), 1);
+ QCOMPARE(o2->componentCompleteCount(), 1);
+
+ delete o;
+}
+
// Check that first child of qml is of given type. Empty type insists on error.
void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
{
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
index 3b2db5e..d5d3365 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
@@ -4,6 +4,12 @@ Rectangle {
width: 240
height: 320
color: "#ffffff"
+
+ property real hr: list.visibleArea.heightRatio
+ function heightRatio() {
+ return list.visibleArea.heightRatio
+ }
+
function checkProperties() {
testObject.error = false;
if (list.model != testModel) {
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index bf4754d..377a9e5 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void manualHighlight();
void QTBUG_11105();
void footer();
+ void resizeView();
private:
template <class T> void items();
@@ -1591,6 +1592,48 @@ void tst_QDeclarativeListView::footer()
QTRY_COMPARE(footer->y(), 0.0);
}
+void tst_QDeclarativeListView::resizeView()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ QVariant heightRatio;
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.4);
+
+ listview->setHeight(200);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.25);
+}
+
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 b0b7a3b..3baf848 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -146,7 +146,7 @@ void tst_QDeclarativeLoader::component()
void tst_QDeclarativeLoader::invalidUrl()
{
- QTest::ignoreMessage(QtWarningMsg, QString("<Unknown File>: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString()).toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found").toUtf8().constData());
QDeclarativeComponent component(&engine);
component.setData(QByteArray("import Qt 4.7\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
@@ -508,7 +508,7 @@ void tst_QDeclarativeLoader::failNetworkRequest()
QVERIFY(server.isValid());
server.serveDirectory(SRCDIR "/data");
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Network error for URL http://127.0.0.1:14450/IDontExist.qml");
+ QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
QDeclarativeComponent component(&engine);
component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml"));
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 56a3121..84f4230 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -777,7 +777,7 @@ void tst_qdeclarativetextedit::delegateLoading_data()
// import installed
QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
- QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "<Unknown File>: Network error for URL http://localhost:42332/FailItem.qml ";
+ QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection ";
QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type ";
}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
index a798f77..c5e945a 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
@@ -4,12 +4,16 @@ ListView {
width: 100
height: 100
anchors.fill: parent
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- Text { objectName: "display"; text: display }
+ model: VisualDataModel {
+ id: visualModel
+ objectName: "visualModel"
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { objectName: "display"; text: display }
+ }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 3cd786f..95ef4fc 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -84,6 +84,7 @@ public:
private slots:
void rootIndex();
void updateLayout();
+ void childChanged();
void objectListModel();
private:
@@ -174,22 +175,82 @@ void tst_qdeclarativevisualdatamodel::updateLayout()
QVERIFY(contentItem != 0);
QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 1 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 2 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 2 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 1 Item"));
}
+void tst_qdeclarativevisualdatamodel::childChanged()
+{
+ QDeclarativeView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeVisualDataModel *vdm = listview->findChild<QDeclarativeVisualDataModel*>("visualModel");
+ vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Child Item"));
+
+ model.item(1,0)->child(0,0)->setText("Row 2 updated child");
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 updated child"));
+
+ model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
+ QTest::qWait(300);
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
+
+ model.item(1,0)->takeRow(1);
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name == 0);
+
+ vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
+ QTest::qWait(300);
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+}
+
void tst_qdeclarativevisualdatamodel::objectListModel()
{
QDeclarativeView view;