summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/samegame/content/Dialog.qml1
-rwxr-xr-xdemos/declarative/samegame/content/samegame.js9
-rw-r--r--demos/declarative/samegame/samegame.qml16
-rw-r--r--src/declarative/debugger/qmldebugservice.cpp33
-rw-r--r--src/declarative/debugger/qmldebugservice_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput.cpp6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput_p.h2
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp4
-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
27 files changed, 205 insertions, 116 deletions
diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml
index f9a281a..5bd1123 100644
--- a/demos/declarative/samegame/content/Dialog.qml
+++ b/demos/declarative/samegame/content/Dialog.qml
@@ -11,6 +11,7 @@ Rectangle {
page.opacity = 1;
}
signal closed();
+ property Item text: myText
color: "white"; border.width: 1; width: myText.width + 20; height: myText.height + 40;
opacity: 0
opacity: Behavior {
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 0a42e88..c0f10bd 100755
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -158,7 +158,11 @@ function victoryCheck()
//Checks for game over
if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
timer = new Date() - timer;
+ //scoreName.show("You won! Please enter your name: ");
scoreName.show("You won! Please enter your name: ");
+ scoreName.initialWidth = scoreName.text.width + 20;
+ scoreName.width = scoreName.initialWidth;
+ scoreName.text.opacity = 0;//Just a spacer
//dialog.show("Game Over. Your score is " + gameCanvas.score);
}
}
@@ -218,8 +222,9 @@ function saveHighScore(name) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
tx.executeSql(dataStr, data);
- var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
- var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ //Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'+maxX+"x"+maxY+'" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for this grid size\n\n"
for(var i = 0; i < rs.rows.length; i++){
r += (i+1)+". " + rs.rows.item(i).name +' got '
+ rs.rows.item(i).score + ' points in '
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 626c76b..c2557ae 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -38,20 +38,30 @@ Rectangle {
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
Dialog {
id: scoreName; anchors.centerIn: parent; z: 22;
+ property int initialWidth: 0
+ width: Behavior{NumberAnimation{} enabled: initialWidth!=0}
Text {
id: spacer
- opacity: 0
- text: " You won! Please enter your name:"
+ anchors.left: scoreName.left
+ anchors.leftMargin: 20
+ anchors.verticalCenter: parent.verticalCenter
+ text: "You won! Please enter your name: "
}
TextInput {
id: editor
+ onTextChanged: {
+ var newWidth = editor.width + spacer.width + 40;
+ if((newWidth > scoreName.width && newWidth < screen.width)
+ || (scoreName.width > scoreName.initialWidth))
+ scoreName.width = newWidth;
+ }
onAccepted: {
if(scoreName.opacity==1&&editor.text!="")
saveHighScore(editor.text);
scoreName.forceClose();
}
anchors.verticalCenter: parent.verticalCenter
- width: 72; focus: true
+ focus: true
anchors.left: spacer.right
}
}
diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp
index 810fbed..2c9586f 100644
--- a/src/declarative/debugger/qmldebugservice.cpp
+++ b/src/declarative/debugger/qmldebugservice.cpp
@@ -61,9 +61,11 @@ class QmlDebugServer : public QObject
public:
static QmlDebugServer *instance();
void wait();
+ void registerForStartNotification(QObject *object, const char *receiver);
private Q_SLOTS:
void readyRead();
+ void registeredObjectDestroyed(QObject *object);
private:
friend class QmlDebugService;
@@ -83,6 +85,7 @@ public:
QPacketProtocol *protocol;
QHash<QString, QmlDebugService *> plugins;
QStringList enabledPlugins;
+ QList<QPair<QObject*, QByteArray> > notifyClients;
};
class QmlDebugServicePrivate : public QObjectPrivate
@@ -112,6 +115,14 @@ void QmlDebugServerPrivate::wait()
qWarning("QmlDebugServer: Waiting for connection on port %d...", port);
+ for (int i=0; i<notifyClients.count(); i++) {
+ if (!QMetaObject::invokeMethod(notifyClients[i].first, notifyClients[i].second)) {
+ qWarning() << "QmlDebugServer: unable to call method" << notifyClients[i].second
+ << "on object" << notifyClients[i].first << "to notify of debug server start";
+ }
+ }
+ notifyClients.clear();
+
if (!server.waitForNewConnection(-1)) {
qWarning("QmlDebugServer: Connection error");
return;
@@ -165,6 +176,23 @@ void QmlDebugServer::wait()
d->wait();
}
+void QmlDebugServer::registerForStartNotification(QObject *object, const char *methodName)
+{
+ Q_D(QmlDebugServer);
+ connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*)));
+ d->notifyClients.append(qMakePair(object, QByteArray(methodName)));
+}
+
+void QmlDebugServer::registeredObjectDestroyed(QObject *object)
+{
+ Q_D(QmlDebugServer);
+ QMutableListIterator<QPair<QObject*, QByteArray> > i(d->notifyClients);
+ while (i.hasNext()) {
+ if (i.next().first == object)
+ i.remove();
+ }
+}
+
QmlDebugServer::QmlDebugServer(int port)
: QObject(*(new QmlDebugServerPrivate))
{
@@ -367,6 +395,11 @@ void QmlDebugService::waitForClients()
QmlDebugServer::instance()->wait();
}
+void QmlDebugService::notifyOnServerStart(QObject *object, const char *receiver)
+{
+ QmlDebugServer::instance()->registerForStartNotification(object, receiver);
+}
+
void QmlDebugService::sendMessage(const QByteArray &message)
{
Q_D(QmlDebugService);
diff --git a/src/declarative/debugger/qmldebugservice_p.h b/src/declarative/debugger/qmldebugservice_p.h
index b406a3c..ec90d95 100644
--- a/src/declarative/debugger/qmldebugservice_p.h
+++ b/src/declarative/debugger/qmldebugservice_p.h
@@ -68,17 +68,19 @@ public:
static int idForObject(QObject *);
static QObject *objectForId(int);
-
static bool isDebuggingEnabled();
static QString objectToString(QObject *obj);
static void waitForClients();
+ static void notifyOnServerStart(QObject *object, const char *receiver);
+
protected:
virtual void enabledChanged(bool);
virtual void messageReceived(const QByteArray &);
private:
+ void registerForStartNotification(QObject *object, const char *methodName);
friend class QmlDebugServer;
};
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
index 127aec8..66d62f0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
@@ -127,9 +127,11 @@ void QmlGraphicsItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad);
QML_REGISTER_TYPE(Qt,4,6,PathView,QmlGraphicsPathView);
QML_REGISTER_TYPE(Qt,4,6,Pen,QmlGraphicsPen);
- QML_REGISTER_TYPE(Qt,4,6,QDoubleValidator,QDoubleValidator);
QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator);
- QML_REGISTER_TYPE(Qt,4,6,QRegExpValidator,QRegExpValidator);
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
+ QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator);
+ QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator);
+#endif
QML_REGISTER_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle);
QML_REGISTER_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater);
QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation);
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
index ea54351..6d9b7b1 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
@@ -646,10 +646,12 @@ void QmlGraphicsTextInput::focusChanged(bool hasFocus)
void QmlGraphicsTextInput::keyPressEvent(QKeyEvent* ev)
{
Q_D(QmlGraphicsTextInput);
- if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
+ if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
|| (d->control->cursor() == d->control->text().length()
- && ev->key() == Qt::Key_Right)){
+ && ev->key() == Qt::Key_Right))
+ && (d->lastSelectionStart == d->lastSelectionEnd)){
//ignore when moving off the end
+ //unless there is a selection, because then moving will do something (deselect)
ev->ignore();
}else{
d->control->processKeyEvent(ev);
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
index 4708381..a91e71a 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
@@ -222,8 +222,10 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsTextInput)
QML_DECLARE_TYPE(QValidator)
QML_DECLARE_TYPE(QIntValidator)
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
QML_DECLARE_TYPE(QDoubleValidator)
QML_DECLARE_TYPE(QRegExpValidator)
+#endif
QT_END_HEADER
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 319c4b0..0f5792f 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -413,11 +413,11 @@ QString QDesktopServices::storageLocation(StandardLocation type)
//return QDir::homePath(); break;
break;
case DataLocation:
- CEikonEnv::Static()->FsSession().PrivatePath(path);
+ qt_s60GetRFs().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
break;
case CacheLocation:
- CEikonEnv::Static()->FsSession().PrivatePath(path);
+ qt_s60GetRFs().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
path.Append(KCacheSubDir);
break;
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();
}
}