summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-03-05 04:01:03 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-03-05 04:01:03 (GMT)
commitcb486319b599eccbc40166d0b3d057d11d92759c (patch)
treecfa2d0f3bb88e266a96f5a8218c3ac70a823cf08 /tests/auto
parent09e39c9c86e8ed346aff348b28c512710862e70e (diff)
parent0c558e05f880cb51078b2d5e5281227352c1de3f (diff)
downloadQt-cb486319b599eccbc40166d0b3d057d11d92759c.zip
Qt-cb486319b599eccbc40166d0b3d057d11d92759c.tar.gz
Qt-cb486319b599eccbc40166d0b3d057d11d92759c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/examples/examples.pro2
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml43
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp66
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp46
-rw-r--r--tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp535
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml10
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp88
-rw-r--r--tests/auto/qprinter/tst_qprinter.cpp23
19 files changed, 485 insertions, 414 deletions
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro
index b9bcd28..85d2a73 100644
--- a/tests/auto/declarative/examples/examples.pro
+++ b/tests/auto/declarative/examples/examples.pro
@@ -3,3 +3,5 @@ contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
SOURCES += tst_examples.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 106a4e0..678dd59 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -168,10 +168,12 @@ void tst_examples::examples_data()
QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
QString demos = QLibraryInfo::location(QLibraryInfo::DemosPath);
+ QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/";
QStringList files;
files << findQmlFiles(QDir(examples));
files << findQmlFiles(QDir(demos));
+ files << findQmlFiles(QDir(snippets));
foreach (const QString &file, files)
QTest::newRow(file.toLatin1().constData()) << file;
diff --git a/tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml b/tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml
new file mode 100644
index 0000000..40a2106
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml
@@ -0,0 +1,43 @@
+import Qt 4.6
+
+Item {
+ id: root; objectName: "root"
+ width: 200; height: 200
+
+ Item { id: itemA; objectName: "itemA"; x: 50; y: 50 }
+
+ Item {
+ x: 50; y: 50
+ Item { id: itemB; objectName: "itemB"; x: 100; y: 100 }
+ }
+
+ function mapAToB(x, y) {
+ var pos = itemA.mapToItem(itemB, x, y)
+ return Qt.point(pos.x, pos.y)
+ }
+
+ function mapAFromB(x, y) {
+ var pos = itemA.mapFromItem(itemB, x, y)
+ return Qt.point(pos.x, pos.y)
+ }
+
+ function mapAToNull(x, y) {
+ var pos = itemA.mapToItem(null, x, y)
+ return Qt.point(pos.x, pos.y)
+ }
+
+ function mapAFromNull(x, y) {
+ var pos = itemA.mapFromItem(null, x, y)
+ return Qt.point(pos.x, pos.y)
+ }
+
+ function checkMapAToInvalid(x, y) {
+ var pos = itemA.mapToItem(1122, x, y)
+ return pos.x == undefined && pos.y == undefined
+ }
+
+ function checkMapAFromInvalid(x, y) {
+ var pos = itemA.mapFromItem(1122, x, y)
+ return pos.x == undefined && pos.y == undefined
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index dbcba16..bbcc86e 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -58,6 +58,8 @@ private slots:
void keyNavigation();
void smooth();
void clip();
+ void mapCoordinates();
+ void mapCoordinates_data();
private:
template<typename T>
@@ -278,6 +280,8 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
QVERIFY(item);
QVERIFY(item->hasFocus());
+
+ delete canvas;
}
void tst_QDeclarativeItem::smooth()
@@ -301,6 +305,8 @@ void tst_QDeclarativeItem::smooth()
QCOMPARE(spy.count(),2);
item->setSmooth(false);
QCOMPARE(spy.count(),2);
+
+ delete item;
}
void tst_QDeclarativeItem::clip()
@@ -324,6 +330,66 @@ void tst_QDeclarativeItem::clip()
QCOMPARE(spy.count(),2);
item->setClip(false);
QCOMPARE(spy.count(),2);
+
+ delete item;
+}
+
+void tst_QDeclarativeItem::mapCoordinates()
+{
+ QFETCH(int, x);
+ QFETCH(int, y);
+
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(300, 300);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+ QDeclarativeItem *a = findItem<QDeclarativeItem>(canvas->rootObject(), "itemA");
+ QVERIFY(a != 0);
+ QDeclarativeItem *b = findItem<QDeclarativeItem>(canvas->rootObject(), "itemB");
+ QVERIFY(b != 0);
+
+ QVariant result;
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAToB",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapToItem(b, x, y));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapFromItem(b, x, y));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapToScene(x, y));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapFromScene(x, y));
+
+ QTest::ignoreMessage(QtWarningMsg, "mapToItem() given argument \"1122\" which is neither null nor an Item");
+ QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QVERIFY(result.toBool());
+
+ QTest::ignoreMessage(QtWarningMsg, "mapFromItem() given argument \"1122\" which is neither null nor an Item");
+ QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QVERIFY(result.toBool());
+
+ delete canvas;
+}
+
+void tst_QDeclarativeItem::mapCoordinates_data()
+{
+ QTest::addColumn<int>("x");
+ QTest::addColumn<int>("y");
+
+ for (int i=-20; i<=20; i+=10)
+ QTest::newRow(QTest::toString(i)) << i << i;
}
template<typename T>
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
new file mode 100644
index 0000000..d4e0cc0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
@@ -0,0 +1 @@
+3:1:Element is not creatable.
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
new file mode 100644
index 0000000..a723269
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Font {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 3ce15cb..da0bf1a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -326,6 +326,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+ QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index a36224f..1df4448 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -450,7 +450,7 @@ void tst_QDeclarativeListView::inserted()
model.insertItem(1, "Will", "9876");
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
@@ -470,7 +470,7 @@ void tst_QDeclarativeListView::inserted()
model.insertItem(0, "Foo", "1111"); // zero index, and current item
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
@@ -491,14 +491,14 @@ void tst_QDeclarativeListView::inserted()
for (int i = model.count(); i < 30; ++i)
model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(500);
+ QTest::qWait(300);
listview->setContentY(80);
- QTest::qWait(500);
+ QTest::qWait(300);
// Insert item outside visible area
model.insertItem(1, "Hello", "1324");
- QTest::qWait(500);
+ QTest::qWait(300);
QVERIFY(listview->contentY() == 80);
@@ -543,7 +543,7 @@ void tst_QDeclarativeListView::removed(bool animated)
model.removeItem(1);
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
QVERIFY(name != 0);
@@ -565,7 +565,7 @@ void tst_QDeclarativeListView::removed(bool animated)
model.removeItem(0); // post: top item starts at 20
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
name = findItem<QDeclarativeText>(viewport, "textName", 0);
QVERIFY(name != 0);
@@ -586,7 +586,7 @@ void tst_QDeclarativeListView::removed(bool animated)
// Remove items not visible
model.removeItem(18);
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
@@ -603,7 +603,7 @@ void tst_QDeclarativeListView::removed(bool animated)
model.removeItem(1); // post: top item will be at 40
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
@@ -617,14 +617,14 @@ void tst_QDeclarativeListView::removed(bool animated)
QVERIFY(listview->currentIndex() == 9);
QDeclarativeItem *oldCurrent = listview->currentItem();
model.removeItem(9);
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(listview->currentIndex(), 9);
QVERIFY(listview->currentItem() != oldCurrent);
listview->setContentY(40); // That's the top now
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
@@ -637,20 +637,20 @@ void tst_QDeclarativeListView::removed(bool animated)
// remove current item beyond visible items.
listview->setCurrentIndex(20);
- QTest::qWait(500);
+ QTest::qWait(300);
listview->setContentY(40);
model.removeItem(20);
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(listview->currentIndex(), 20);
QVERIFY(listview->currentItem() != 0);
// remove item before current, but visible
listview->setCurrentIndex(8);
- QTest::qWait(500);
+ QTest::qWait(300);
oldCurrent = listview->currentItem();
model.removeItem(6);
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(listview->currentIndex(), 7);
QVERIFY(listview->currentItem() == oldCurrent);
@@ -1028,22 +1028,16 @@ void tst_QDeclarativeListView::currentIndex()
QCOMPARE(listview->contentY(), 0.0);
// Test keys
+ qApp->setActiveWindow(canvas);
canvas->show();
+ canvas->setFocus();
qApp->processEvents();
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QEXPECT_FAIL("", "QTBUG-8475", Abort);
QCOMPARE(listview->currentIndex(), 1);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Up);
QCOMPARE(listview->currentIndex(), 0);
// turn off auto highlight
diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
index b120d5d..1dfec50 100644
--- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
+++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include <QtTest/QSignalSpy>
#include <qtest.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
@@ -161,6 +162,18 @@ void tst_qdeclarativetimer::repeat()
QVERIFY(helper.count == oldCount);
QVERIFY(timer->isRunning() == false);
+ QSignalSpy spy(timer, SIGNAL(repeatChanged()));
+
+ timer->setRepeating(false);
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(true);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
@@ -184,6 +197,18 @@ void tst_qdeclarativetimer::triggeredOnStart()
QCOMPARE(helper.count, 2);
QVERIFY(timer->isRunning() == false);
+ QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
+
+ timer->setTriggeredOnStart(false);
+ QVERIFY(!timer->triggeredOnStart());
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(true);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
@@ -250,6 +275,18 @@ void tst_qdeclarativetimer::changeDuration()
QCOMPARE(helper.count, 3);
QVERIFY(timer->isRunning());
+ QSignalSpy spy(timer, SIGNAL(intervalChanged()));
+
+ timer->setInterval(200);
+ QCOMPARE(timer->interval(), 200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(300);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
index 0eadd50..cb01a80 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
@@ -1,6 +1,6 @@
import Test 1.0
MyTypeObject {
- font.capitalization: "MixedCase"
+ font.capitalization: "AllUppercase"
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
index 81f1c92..93f1ed5 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
@@ -1,6 +1,6 @@
import Test 1.0
MyTypeObject {
- font.capitalization: if (1) "MixedCase"
+ font.capitalization: if (1) "AllUppercase"
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
new file mode 100644
index 0000000..3be5099
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ font.capitalization: Font.AllUppercase
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
new file mode 100644
index 0000000..6b494e4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+import Qt 4.6 as MyQt
+
+MyTypeObject {
+ font.capitalization: MyQt.Font.AllUppercase
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index 8732215..51f9a07 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -597,7 +597,7 @@ void tst_qdeclarativevaluetypes::enums()
QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
delete object;
}
@@ -605,7 +605,23 @@ void tst_qdeclarativevaluetypes::enums()
QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.4.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
delete object;
}
}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 27ecef4..4f9f21a 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -100,6 +100,7 @@ void tst_QDeclarativeWorkerScript::source()
QCOMPARE(item->source(), source);
qApp->processEvents();
+ delete item;
}
void tst_QDeclarativeWorkerScript::source_data()
@@ -126,6 +127,7 @@ void tst_QDeclarativeWorkerScript::messaging()
QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
qApp->processEvents();
+ delete item;
}
void tst_QDeclarativeWorkerScript::messaging_data()
@@ -162,6 +164,7 @@ void tst_QDeclarativeWorkerScript::messaging_sendQObjectList()
QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant()));
qApp->processEvents();
+ delete item;
}
void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
@@ -187,6 +190,7 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
QVERIFY(result.toBool());
qApp->processEvents();
+ delete item;
}
QTEST_MAIN(tst_QDeclarativeWorkerScript)
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
index 7dec0ee..01f07ab 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
@@ -69,6 +69,7 @@ private slots:
void constructor();
void defaultState();
void open();
+ void open_data();
void open_invalid_method();
void open_sync();
void open_arg_count();
@@ -82,6 +83,7 @@ private slots:
void send_alreadySent();
void send_ignoreData();
void send_withdata();
+ void send_withdata_data();
void abort();
void abort_unsent();
void abort_opened();
@@ -94,8 +96,11 @@ private slots:
void getAllResponseHeaders_sent();
void getAllResponseHeaders_args();
void status();
+ void status_data();
void statusText();
+ void statusText_data();
void responseText();
+ void responseText_data();
void responseXML_invalid();
void invalidMethodUsage();
void redirects();
@@ -257,99 +262,50 @@ void tst_qdeclarativexmlhttprequest::defaultState()
// Test valid XMLHttpRequest.open() calls
void tst_qdeclarativexmlhttprequest::open()
{
- // Relative url
- {
- QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QString, url);
+ QFETCH(bool, remote);
+
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ QVERIFY(server->wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
}
- // Absolute url
- {
- QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", TEST_FILE("testdocument.html").toString());
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Absolute network url
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
+ QDeclarativeComponent component(&engine, qmlFile);
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", url);
+ component.completeCreate();
- // User/pass
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
- QDeclarativeComponent component(&engine, TEST_FILE("open_user.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
+ TRY_WAIT(object->property("dataOK").toBool() == true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
+ delete server;
+ delete object;
+}
- TRY_WAIT(object->property("dataOK").toBool() == true);
+void tst_qdeclarativexmlhttprequest::open_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<bool>("remote");
- // ### Check that the username/password were sent to the server
+ QTest::newRow("Relative url)") << TEST_FILE("open.qml") << "testdocument.html" << false;
+ QTest::newRow("Absolute url)") << TEST_FILE("open.qml") << TEST_FILE("testdocument.html").toString() << false;
+ QTest::newRow("Absolute network url)") << TEST_FILE("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
- delete object;
- }
+ // ### Check that the username/password were sent to the server
+ QTest::newRow("User/pass") << TEST_FILE("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
}
// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
@@ -594,138 +550,38 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
// Test that send()'ing data works
void tst_qdeclarativexmlhttprequest::send_withdata()
{
- // No content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.1.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QFETCH(QString, file_expected);
+ QFETCH(QString, file_qml);
- delete object;
- }
-
- // Correct content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.2.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Incorrect content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.3.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type - out of order
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.4.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Incorrect content-type - out of order
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.5.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // PUT
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.6.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.6.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE(file_expected),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
- // Correct content-type - no charset
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
+ QDeclarativeComponent component(&engine, TEST_FILE(file_qml));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
- QDeclarativeComponent component(&engine, TEST_FILE("send_data.7.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
+ TRY_WAIT(object->property("dataOK").toBool() == true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ delete object;
+}
- delete object;
- }
+void tst_qdeclarativexmlhttprequest::send_withdata_data()
+{
+ QTest::addColumn<QString>("file_expected");
+ QTest::addColumn<QString>("file_qml");
+
+ QTest::newRow("No content-type") << "send_data.1.expect" << "send_data.1.qml";
+ QTest::newRow("Correct content-type") << "send_data.1.expect" << "send_data.2.qml";
+ QTest::newRow("Incorrect content-type") << "send_data.1.expect" << "send_data.3.qml";
+ QTest::newRow("Correct content-type - out of order") << "send_data.4.expect" << "send_data.4.qml";
+ QTest::newRow("Incorrect content-type - out of order") << "send_data.4.expect" << "send_data.5.qml";
+ QTest::newRow("PUT") << "send_data.6.expect" << "send_data.6.qml";
+ QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml";
}
// Test abort() has no effect in unsent state
@@ -940,200 +796,125 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
void tst_qdeclarativexmlhttprequest::status()
{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", 200);
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QFETCH(QUrl, replyUrl);
+ QFETCH(int, status);
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ replyUrl,
+ TEST_FILE("testdocument.html")));
- delete object;
- }
+ QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", status);
+ component.completeCreate();
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
+ TRY_WAIT(object->property("dataOK").toBool() == true);
- QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", 404);
- component.completeCreate();
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ delete object;
+}
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
+void tst_qdeclarativexmlhttprequest::status_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<int>("status");
- delete object;
- }
+ QTest::newRow("OK") << TEST_FILE("status.200.reply") << 200;
+ QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << 404;
}
void tst_qdeclarativexmlhttprequest::statusText()
{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", "OK");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QFETCH(QUrl, replyUrl);
+ QFETCH(QString, statusText);
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ replyUrl,
+ TEST_FILE("testdocument.html")));
- delete object;
- }
+ QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", statusText);
+ component.completeCreate();
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
+ TRY_WAIT(object->property("dataOK").toBool() == true);
- QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", "Document not found");
- component.completeCreate();
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ delete object;
+}
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
+void tst_qdeclarativexmlhttprequest::statusText_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<QString>("statusText");
- delete object;
- }
+ QTest::newRow("OK") << TEST_FILE("status.200.reply") << "OK";
+ QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << "Document not found";
}
void tst_qdeclarativexmlhttprequest::responseText()
{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", "QML Rocks!\n");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
-
- delete object;
- }
+ QFETCH(QUrl, replyUrl);
+ QFETCH(QUrl, bodyUrl);
+ QFETCH(QString, responseText);
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- QUrl()));
-
- QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ replyUrl,
+ bodyUrl));
- delete object;
- }
+ QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedText", responseText);
+ component.completeCreate();
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
+ TRY_WAIT(object->property("dataOK").toBool() == true);
- QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
+ QCOMPARE(object->property("unsent").toBool(), true);
+ QCOMPARE(object->property("opened").toBool(), true);
+ QCOMPARE(object->property("sent").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("reset").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ delete object;
+}
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
+void tst_qdeclarativexmlhttprequest::responseText_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<QUrl>("bodyUrl");
+ QTest::addColumn<QString>("responseText");
- delete object;
- }
+ QTest::newRow("OK") << TEST_FILE("status.200.reply") << TEST_FILE("testdocument.html") << "QML Rocks!\n";
+ QTest::newRow("empty body") << TEST_FILE("status.200.reply") << QUrl() << "";
+ QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << TEST_FILE("testdocument.html") << "";
}
// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
new file mode 100644
index 0000000..737ec81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+XmlListModel {
+ source: "model.xml"
+ query: "/Pets/Pet"
+ XmlRole { objectName: "role"; name: "name"; query: "name/string()" }
+ XmlRole { name: "type"; query: "type/string()" }
+ XmlRole { name: "age"; query: "age/number()" }
+ XmlRole { name: "size"; query: "size/string()" }
+}
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 68029bc..0e5e1b0 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -74,6 +74,7 @@ private slots:
void useKeys_data();
void noKeysValueChanges();
void keysChanged();
+ void propertyChanges();
private:
QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
@@ -266,6 +267,8 @@ void tst_qdeclarativexmllistmodel::reload()
QCOMPARE(spyRemove[0][0].toInt(), 0);
QCOMPARE(spyRemove[0][1].toInt(), 9);
+
+ delete model;
}
void tst_qdeclarativexmllistmodel::useKeys()
@@ -284,7 +287,7 @@ void tst_qdeclarativexmllistmodel::useKeys()
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
QVERIFY(model != 0);
-
+
model->setXml(oldXml);
QTRY_COMPARE(model->count(), oldCount);
@@ -319,6 +322,8 @@ void tst_qdeclarativexmllistmodel::useKeys()
QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
}
+
+ delete model;
}
void tst_qdeclarativexmllistmodel::useKeys_data()
@@ -440,6 +445,8 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges()
model->setXml(xml);
QTRY_COMPARE(model->count(), 2);
+ model->setXml("");
+
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
@@ -448,18 +455,16 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges()
model->setXml(xml);
// wait for the new xml data to be set, and verify no signals were emitted
- for (int i=0; i<50; i++) {
- QTest::qWait(100);
- if (model->data(0, model->roles()[2]).toString() != QLatin1String("AussieRules"))
- break;
- }
+ QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
QVERIFY(spyInsert.count() == 0);
QVERIFY(spyRemove.count() == 0);
QVERIFY(spyCount.count() == 0);
-
+
QCOMPARE(model->count(), 2);
+
+ delete model;
}
void tst_qdeclarativexmllistmodel::keysChanged()
@@ -476,6 +481,8 @@ void tst_qdeclarativexmllistmodel::keysChanged()
model->setXml(xml);
QTRY_COMPARE(model->count(), 2);
+ model->setXml("");
+
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
@@ -494,6 +501,73 @@ void tst_qdeclarativexmllistmodel::keysChanged()
QCOMPARE(spyRemove[0][1].toInt(), 2);
QCOMPARE(spyCount.count(), 0);
+
+ delete model;
+}
+
+void tst_qdeclarativexmllistmodel::propertyChanges()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QDeclarativeXmlListModelRole *role = model->findChild<QDeclarativeXmlListModelRole*>("role");
+ QVERIFY(role);
+
+ QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
+ QSignalSpy querySpy(role, SIGNAL(queryChanged()));
+ QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
+
+ role->setName("size");
+ role->setQuery("size/string()");
+ role->setIsKey(true);
+
+ QCOMPARE(role->name(), QString("size"));
+ QCOMPARE(role->query(), QString("size/string()"));
+ QVERIFY(role->isKey());
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ role->setName("size");
+ role->setQuery("size/string()");
+ role->setIsKey(true);
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
+ QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
+ QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
+ QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
+
+ model->setSource(QUrl(""));
+ model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setQuery("/Pets");
+ model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(model->source(), QUrl(""));
+ QCOMPARE(model->xml(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
+ QCOMPARE(model->query(), QString("/Pets"));
+ QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ model->setSource(QUrl(""));
+ model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setQuery("/Pets");
+ model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
}
QTEST_MAIN(tst_qdeclarativexmllistmodel)
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
index 7e8ce84..49bddb2 100644
--- a/tests/auto/qprinter/tst_qprinter.cpp
+++ b/tests/auto/qprinter/tst_qprinter.cpp
@@ -107,6 +107,7 @@ private slots:
void printDialogCompleter();
void testCopyCount();
+ void testCurrentPage();
void taskQTBUG4497_reusePrinterOnDifferentFiles();
@@ -1005,5 +1006,27 @@ void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles()
QCOMPARE(file1.readAll(), file2.readAll());
}
+void tst_QPrinter::testCurrentPage()
+{
+ QPrinter printer;
+ printer.setFromTo(1, 10);
+
+ // Test set print range
+ printer.setPrintRange(QPrinter::CurrentPage);
+ QCOMPARE(printer.printRange(), QPrinter::CurrentPage);
+ QCOMPARE(printer.fromPage(), 1);
+ QCOMPARE(printer.toPage(), 10);
+
+ QPrintDialog dialog(&printer);
+
+ // Test default Current Page option to off
+ QCOMPARE(dialog.isOptionEnabled(QPrintDialog::PrintCurrentPage), false);
+
+ // Test enable Current Page option
+ dialog.setOption(QPrintDialog::PrintCurrentPage);
+ QCOMPARE(dialog.isOptionEnabled(QPrintDialog::PrintCurrentPage), true);
+
+}
+
QTEST_MAIN(tst_QPrinter)
#include "tst_qprinter.moc"