summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-02-16 00:05:25 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-02-16 00:05:25 (GMT)
commit5cef28d2fe4a6ac814b30cbd03a259fa9e371008 (patch)
tree2f1ac0d92439c593f6fccdb42d294ecda091ea4f /tests/auto
parent89505af1661fab0c12585416b66322cd09a30bdf (diff)
parent0c0cde558139d12531c4b1e820622bcb81b8eaa5 (diff)
downloadQt-5cef28d2fe4a6ac814b30cbd03a259fa9e371008.zip
Qt-5cef28d2fe4a6ac814b30cbd03a259fa9e371008.tar.gz
Qt-5cef28d2fe4a6ac814b30cbd03a259fa9e371008.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmldebug/tst_qmldebug.cpp40
-rw-r--r--tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp1
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp117
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml1
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/validators.qml2
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp13
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/abort.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply1
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp21
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h25
-rw-r--r--tests/auto/declarative/shared/testhttpserver.cpp11
18 files changed, 136 insertions, 104 deletions
diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
index 82e74ce..a51fd29 100644
--- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
+++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
@@ -288,10 +288,11 @@ void tst_QmlDebug::watch_property()
QmlDebugPropertyWatch *watch;
- QmlEngineDebug unconnected(0);
- watch = unconnected.addWatch(prop, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QmlDebugWatch::Dead);
delete watch;
+ delete unconnected;
watch = m_dbg->addWatch(QmlDebugPropertyReference(), this);
QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
@@ -346,10 +347,11 @@ void tst_QmlDebug::watch_object()
QmlDebugWatch *watch;
- QmlEngineDebug unconnected(0);
- watch = unconnected.addWatch(obj, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, this);
QCOMPARE(watch->state(), QmlDebugWatch::Dead);
delete watch;
+ delete unconnected;
watch = m_dbg->addWatch(QmlDebugObjectReference(), this);
QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
@@ -409,10 +411,11 @@ void tst_QmlDebug::watch_expression()
QmlDebugObjectExpressionWatch *watch;
- QmlEngineDebug unconnected(0);
- watch = unconnected.addWatch(obj, expr, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, expr, this);
QCOMPARE(watch->state(), QmlDebugWatch::Dead);
delete watch;
+ delete unconnected;
watch = m_dbg->addWatch(QmlDebugObjectReference(), expr, this);
QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
@@ -487,10 +490,11 @@ void tst_QmlDebug::queryAvailableEngines()
{
QmlDebugEnginesQuery *q_engines;
- QmlEngineDebug unconnected(0);
- q_engines = unconnected.queryAvailableEngines(0);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_engines = unconnected->queryAvailableEngines(0);
QCOMPARE(q_engines->state(), QmlDebugQuery::Error);
delete q_engines;
+ delete unconnected;
q_engines = m_dbg->queryAvailableEngines(this);
delete q_engines;
@@ -519,10 +523,11 @@ void tst_QmlDebug::queryRootContexts()
QmlDebugRootContextQuery *q_context;
- QmlEngineDebug unconnected(0);
- q_context = unconnected.queryRootContexts(engineId, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QmlDebugQuery::Error);
delete q_context;
+ delete unconnected;
q_context = m_dbg->queryRootContexts(engineId, this);
delete q_context;
@@ -563,10 +568,11 @@ void tst_QmlDebug::queryObject()
QmlDebugObjectQuery *q_obj = 0;
- QmlEngineDebug unconnected(0);
- q_obj = recursive ? unconnected.queryObjectRecursive(rootObject, this) : unconnected.queryObject(rootObject, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
QCOMPARE(q_obj->state(), QmlDebugQuery::Error);
delete q_obj;
+ delete unconnected;
q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
delete q_obj;
@@ -637,10 +643,11 @@ void tst_QmlDebug::queryExpressionResult()
QmlDebugExpressionQuery *q_expr;
- QmlEngineDebug unconnected(0);
- q_expr = unconnected.queryExpressionResult(objectId, expr, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_expr = unconnected->queryExpressionResult(objectId, expr, this);
QCOMPARE(q_expr->state(), QmlDebugQuery::Error);
delete q_expr;
+ delete unconnected;
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
@@ -801,9 +808,10 @@ class tst_QmlDebug_Factory : public QmlTestFactory
public:
QObject *createTest(QmlDebugTestData *data)
{
- QmlContext *c = new QmlContext(data->engine->rootContext());
+ tst_QmlDebug *test = new tst_QmlDebug(data);
+ QmlContext *c = new QmlContext(data->engine->rootContext(), test);
c->setObjectName("tst_QmlDebug_childContext");
- return new tst_QmlDebug(data);
+ return test;
}
};
diff --git a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
index 4e7bc27..9abc5a5 100644
--- a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
+++ b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
@@ -167,6 +167,7 @@ void tst_QmlDebugService::objectToString()
obj->setObjectName("Hello");
QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: Hello"));
+ delete obj;
}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
index da541c8..42d6da9 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
+++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
@@ -43,6 +43,7 @@
#include <qmlview.h>
#include <private/qmlgraphicsrectangle_p.h>
#include <qmlexpression.h>
+#include "../../../shared/util.h"
class tst_QmlGraphicsPositioners : public QObject
{
@@ -75,7 +76,6 @@ void tst_QmlGraphicsPositioners::test_horizontal()
QmlView *canvas = createView(SRCDIR "/data/horizontal.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -99,7 +99,6 @@ void tst_QmlGraphicsPositioners::test_horizontal_spacing()
QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -123,30 +122,31 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
canvas->execute();
- qApp->processEvents();
- //Note that they animate in
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
QCOMPARE(three->x(), -100.0);
- QTest::qWait(300);//Let the animation complete
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->x(), -100.0);//Not 'in' yet
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(three->y(), 0.0);
//Add 'two'
two->setOpacity(1.0);
@@ -154,9 +154,9 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
QTest::qWait(0);//Let the animation start
QCOMPARE(two->x(), -100.0);
QCOMPARE(three->x(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(three->x(), 100.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
}
void tst_QmlGraphicsPositioners::test_vertical()
@@ -164,7 +164,6 @@ void tst_QmlGraphicsPositioners::test_vertical()
QmlView *canvas = createView(SRCDIR "/data/vertical.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -188,7 +187,6 @@ void tst_QmlGraphicsPositioners::test_vertical_spacing()
QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -212,9 +210,7 @@ void tst_QmlGraphicsPositioners::test_vertical_animated()
QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
canvas->execute();
- qApp->processEvents();
- QTest::qWait(0);//Let the animation start
//Note that they animate in
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -228,25 +224,26 @@ void tst_QmlGraphicsPositioners::test_vertical_animated()
QVERIFY(three != 0);
QCOMPARE(three->y(), -100.0);
- QTest::qWait(300);//Let the animation complete
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), -100.0);//Not 'in' yet
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 50.0);
+ QTRY_COMPARE(three->x(), 0.0);
//Add 'two'
two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
+ QTRY_COMPARE(two->opacity(), 1.0);
QTest::qWait(0);//Let the animation start
QCOMPARE(two->y(), -100.0);
QCOMPARE(three->y(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->y(), 100.0);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
}
@@ -255,7 +252,6 @@ void tst_QmlGraphicsPositioners::test_grid()
QmlView *canvas = createView("data/grid.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -285,7 +281,6 @@ void tst_QmlGraphicsPositioners::test_grid_spacing()
QmlView *canvas = createView("data/grid-spacing.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -314,9 +309,7 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
{
QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml");
canvas->execute();
- qApp->processEvents();
- QTest::qWait(0);//Let the animation start
//Note that all animate in
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
@@ -343,19 +336,20 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QCOMPARE(five->x(), -100.0);
QCOMPARE(five->y(), -100.0);
- QTest::qWait(300);//Let the animation complete
-
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
- QCOMPARE(five->x(), 0.0);
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 0.0);
//Add 'two'
two->setOpacity(1.0);
@@ -371,17 +365,17 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QCOMPARE(four->y(), 0.0);
QCOMPARE(five->x(), 0.0);
QCOMPARE(five->y(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
}
@@ -390,7 +384,6 @@ void tst_QmlGraphicsPositioners::test_repeater()
QmlView *canvas = createView("data/repeater.qml");
canvas->execute();
- qApp->processEvents();
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
index 7a2e914..493db5b 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
@@ -11,6 +11,7 @@ Rectangle {
}
TextInput { id: input; focus: true
+ text: "Needs some text"
KeyNavigation.left: firstItem
KeyNavigation.right: lastItem
KeyNavigation.up: firstItem
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
index 673790d..0c81548 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import Qt 4.7
Item {
property var intInput: intInput
diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
index 906dbc2..b7ae4a2 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
+++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
@@ -508,6 +508,7 @@ void tst_qmlgraphicstextinput::inputMethodHints()
/*
TextInput element should only handle left/right keys until the cursor reaches
the extent of the text, then they should ignore the keys.
+
*/
void tst_qmlgraphicstextinput::navigation()
{
@@ -518,14 +519,24 @@ void tst_qmlgraphicstextinput::navigation()
QVERIFY(canvas->root() != 0);
- QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
QVERIFY(input != 0);
+ input->setCursorPosition(0);
QTRY_VERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->hasFocus() == true);
+ //QT-2944: If text is selected, then we should deselect first.
+ input->setCursorPosition(input->text().length());
+ input->setSelectionStart(0);
+ input->setSelectionEnd(input->text().length());
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->selectionStart() == input->selectionEnd());
+ QVERIFY(input->selectionStart() == input->text().length());
+ QVERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Left);
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
index 62ec67b..c4b4bb2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
@@ -1,4 +1,5 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
Test-Header: TestValue
MultiTest-Header: TestValue
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml
index bf31eca..e9535d5 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml
@@ -46,6 +46,7 @@ QtObject {
x.onreadystatechange = function() {
if (x.readyState == XMLHttpRequest.DONE) {
dataOK = (x.responseText == "QML Rocks!\n");
+ print("DATA:" + x.responseText);
}
}
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
index 964a7a8..2e29f56 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
@@ -1,2 +1,3 @@
HTTP/1.0 404 Document not found
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp
index aa0cd31..0010508 100644
--- a/tests/auto/declarative/shared/debugutil.cpp
+++ b/tests/auto/declarative/shared/debugutil.cpp
@@ -47,6 +47,8 @@
#include "debugutil_p.h"
+#include <iostream>
+
bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
QTimer timer;
@@ -117,21 +119,22 @@ void QmlDebugTestClient::messageReceived(const QByteArray &ba)
tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
- : m_ready(false), m_data(data), m_factory(factory)
+ : m_data(data), m_factory(factory)
{
}
void tst_QmlDebug_Thread::run()
{
- QTest::qWait(1000);
+ bool ok = false;
QmlDebugConnection conn;
conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
+ ok = conn.waitForConnected();
Q_ASSERT(ok);
- while (!m_ready)
- QTest::qWait(100);
+ QEventLoop loop;
+ connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit()));
+ loop.exec();
m_data->conn = &conn;
@@ -139,10 +142,10 @@ void tst_QmlDebug_Thread::run()
QObject *test = m_factory->createTest(m_data);
Q_ASSERT(test);
int code = QTest::qExec(test, QCoreApplication::arguments());
+ delete test;
emit testsFinished(code);
}
-
int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
{
qputenv("QML_DEBUG_SERVER_PORT", "3768");
@@ -152,7 +155,8 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
tst_QmlDebug_Thread thread(&data, factory);
QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
- thread.start();
+
+ QmlDebugService::notifyOnServerStart(&thread, "start");
QmlEngine engine; // blocks until client connects
@@ -165,7 +169,7 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
// start the test
data.engine = &engine;
- thread.m_ready = true;
+ emit data.engineCreated();
loop.exec();
thread.wait();
@@ -173,4 +177,3 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
return data.exitCode;
}
-
diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h
index 313d16c..6f23899 100644
--- a/tests/auto/declarative/shared/debugutil_p.h
+++ b/tests/auto/declarative/shared/debugutil_p.h
@@ -51,6 +51,15 @@
#include <private/qmldebugservice_p.h>
#include <private/qmlgraphicsitem_p.h>
+class QmlTestFactory;
+
+class QmlDebugTest
+{
+public:
+ static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+
+ static int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
+};
class QmlDebugTestData : public QObject
{
@@ -68,8 +77,14 @@ public:
QList<QmlGraphicsItem *> items;
+signals:
+ void engineCreated();
+
public slots:
void testsFinished(int code);
+
+private:
+ friend class QmlDebugTest;
};
@@ -82,14 +97,6 @@ public:
virtual QObject *createTest(QmlDebugTestData *data) = 0;
};
-
-namespace QmlDebugTest {
-
- bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
-
- int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
-}
-
class QmlDebugTestService : public QmlDebugService
{
Q_OBJECT
@@ -132,8 +139,6 @@ public:
void run();
- bool m_ready;
-
signals:
void testsFinished(int);
diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp
index 490fc95..5740925 100644
--- a/tests/auto/declarative/shared/testhttpserver.cpp
+++ b/tests/auto/declarative/shared/testhttpserver.cpp
@@ -190,13 +190,14 @@ void TestHTTPServer::disconnected()
--ii;
}
}
+ socket->disconnect();
socket->deleteLater();
}
void TestHTTPServer::readyRead()
{
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
- if (!socket) return;
+ if (!socket || socket->state() == QTcpSocket::ClosingState) return;
QByteArray ba = socket->readAll();
@@ -222,14 +223,14 @@ void TestHTTPServer::readyRead()
QByteArray data = ba.mid(ii);
qWarning() << "TestHTTPServer: Unexpected data" << data << "\nExpected: " << waitData;
m_hasFailed = true;
- socket->disconnect();
+ socket->disconnectFromHost();
return;
}
}
if (waitData.isEmpty()) {
socket->write(replyData);
- socket->disconnect();
+ socket->disconnectFromHost();
}
}
@@ -316,8 +317,8 @@ void TestHTTPServer::serveGET(QTcpSocket *socket, const QByteArray &data)
}
dataCache.remove(socket);
- if (close)
- socket->close();
+ if (close)
+ socket->disconnectFromHost();
}
}