summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-17 05:38:19 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-17 05:38:19 (GMT)
commitd4f2c30ba3ab70a3f40fb7699a6924c1155c83d3 (patch)
tree295b45bd4d125c58fd5bc34784c02f848feb3bda
parent9a5dd525723363dc4230595c85f4406f27d5c0f2 (diff)
parentf2cb8e0ec8b34044b41e3a2389edbd45f1828b8f (diff)
downloadQt-d4f2c30ba3ab70a3f40fb7699a6924c1155c83d3.zip
Qt-d4f2c30ba3ab70a3f40fb7699a6924c1155c83d3.tar.gz
Qt-d4f2c30ba3ab70a3f40fb7699a6924c1155c83d3.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/util/qmllistaccessor.cpp128
-rw-r--r--src/declarative/util/qmllistaccessor_p.h5
-rw-r--r--tests/auto/declarative/anchors/data/anchors.qml18
-rw-r--r--tests/auto/declarative/anchors/data/illegal1.qml12
-rw-r--r--tests/auto/declarative/anchors/data/illegal2.qml13
-rw-r--r--tests/auto/declarative/anchors/data/illegal3.qml12
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp96
-rw-r--r--tests/auto/declarative/debugger/debugger.pro5
-rw-r--r--tests/auto/declarative/debugger/debugutil.cpp173
-rw-r--r--tests/auto/declarative/debugger/debugutil_p.h142
-rw-r--r--tests/auto/declarative/declarative.pro7
-rw-r--r--tests/auto/declarative/qmldebug/qmldebug.pro (renamed from tests/auto/declarative/debugger/qmldebug/qmldebug.pro)4
-rw-r--r--tests/auto/declarative/qmldebug/tst_qmldebug.cpp (renamed from tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp)2
-rw-r--r--tests/auto/declarative/qmldebugclient/qmldebugclient.pro (renamed from tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro)4
-rw-r--r--tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp (renamed from tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp)2
-rw-r--r--tests/auto/declarative/qmldebugservice/qmldebugservice.pro (renamed from tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro)4
-rw-r--r--tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp (renamed from tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp)2
-rw-r--r--tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro (renamed from tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro)4
-rw-r--r--tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp (renamed from tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp)2
-rw-r--r--tests/auto/declarative/states/data/anchorChanges3.qml29
-rw-r--r--tests/auto/declarative/states/tst_states.cpp28
21 files changed, 292 insertions, 400 deletions
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp
index 2c01081..910f2a5 100644
--- a/src/declarative/util/qmllistaccessor.cpp
+++ b/src/declarative/util/qmllistaccessor.cpp
@@ -149,6 +149,134 @@ QVariant QmlListAccessor::at(int idx) const
return QVariant();
}
+void QmlListAccessor::append(const QVariant &value)
+{
+ switch(m_type) {
+ case Invalid:
+ break;
+ case StringList:
+ {
+ const QString &str = value.toString();
+ qvariant_cast<QStringList>(d).append(str);
+ break;
+ }
+ case VariantList:
+ {
+ qvariant_cast<QVariantList>(d).append(value);
+ break;
+ }
+ case QmlList:
+ {
+ QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
+ li->append(const_cast<void *>(value.constData())); //XXX
+ break;
+ }
+ case QList:
+ QmlMetaType::append(d, value);
+ break;
+ case Instance:
+ case Integer:
+ //do nothing
+ break;
+ }
+}
+
+void QmlListAccessor::insert(int index, const QVariant &value)
+{
+ switch(m_type) {
+ case Invalid:
+ break;
+ case StringList:
+ {
+ const QString &str = value.toString();
+ qvariant_cast<QStringList>(d).insert(index, str);
+ break;
+ }
+ case VariantList:
+ {
+ qvariant_cast<QVariantList>(d).insert(index, value);
+ break;
+ }
+ case QmlList:
+ {
+ QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
+ li->insert(index, const_cast<void *>(value.constData())); //XXX
+ break;
+ }
+ case QList:
+ //XXX needs implementation
+ qWarning() << "insert function not yet implemented for QLists";
+ break;
+ case Instance:
+ //XXX do nothing?
+ if (index == 0)
+ setList(value);
+ break;
+ case Integer:
+ break;
+ }
+}
+
+void QmlListAccessor::removeAt(int index)
+{
+ switch(m_type) {
+ case Invalid:
+ break;
+ case StringList:
+ qvariant_cast<QStringList>(d).removeAt(index);
+ break;
+ case VariantList:
+ qvariant_cast<QVariantList>(d).removeAt(index);
+ break;
+ case QmlList:
+ {
+ QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
+ li->removeAt(index);
+ break;
+ }
+ case QList:
+ //XXX needs implementation
+ qWarning() << "removeAt function not yet implemented for QLists";
+ break;
+ case Instance:
+ //XXX do nothing?
+ if (index == 0)
+ setList(QVariant());
+ break;
+ case Integer:
+ break;
+ }
+}
+
+void QmlListAccessor::clear()
+{
+ switch(m_type) {
+ case Invalid:
+ break;
+ case StringList:
+ qvariant_cast<QStringList>(d).clear();
+ break;
+ case VariantList:
+ qvariant_cast<QVariantList>(d).clear();
+ break;
+ case QmlList:
+ {
+ QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
+ li->clear();
+ break;
+ }
+ case QList:
+ QmlMetaType::clear(d);
+ break;
+ case Instance:
+ //XXX what should we do here?
+ setList(QVariant());
+ break;
+ case Integer:
+ d = 0;
+ }
+}
+
bool QmlListAccessor::isValid() const
{
return m_type != Invalid;
diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h
index 7b34d75..2697606 100644
--- a/src/declarative/util/qmllistaccessor_p.h
+++ b/src/declarative/util/qmllistaccessor_p.h
@@ -65,6 +65,11 @@ public:
int count() const;
QVariant at(int) const;
+ virtual void append(const QVariant &);
+ virtual void insert(int, const QVariant &);
+ virtual void removeAt(int);
+ virtual void clear();
+
enum Type { Invalid, StringList, VariantList, QmlList, QList, Instance, Integer };
Type type() const { return m_type; }
diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml
index b880762..b64d0b0 100644
--- a/tests/auto/declarative/anchors/data/anchors.qml
+++ b/tests/auto/declarative/anchors/data/anchors.qml
@@ -130,6 +130,24 @@ Rectangle {
anchors.bottom: masterRect.bottom
anchors.bottomMargin: 5
}
+ Rectangle {
+ id: rect24; objectName: "rect24"
+ width: 10; height: 10
+ anchors.horizontalCenter: masterRect.left
+ anchors.horizontalCenterOffset: width/2
+ }
+ Rectangle {
+ id: rect25; objectName: "rect25"
+ width: 10; height: 10
+ anchors.verticalCenter: rect12.top
+ anchors.verticalCenterOffset: height/2
+ }
+ Rectangle {
+ id: rect26; objectName: "rect26"
+ width: 10; height: 10
+ anchors.baseline: masterRect.top
+ anchors.baselineOffset: height/2
+ }
Text {
id: text1; objectName: "text1"
y: 200;
diff --git a/tests/auto/declarative/anchors/data/illegal1.qml b/tests/auto/declarative/anchors/data/illegal1.qml
deleted file mode 100644
index 53af443..0000000
--- a/tests/auto/declarative/anchors/data/illegal1.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- id: rect
- width: 120; height: 200; color: "white"
- Rectangle { id: theRect; width: 100; height: 100 }
- Rectangle {
- anchors.left: theRect.left
- anchors.right: theRect.right
- anchors.horizontalCenter: theRect.horizontalCenter
- }
-}
diff --git a/tests/auto/declarative/anchors/data/illegal2.qml b/tests/auto/declarative/anchors/data/illegal2.qml
deleted file mode 100644
index 978be52..0000000
--- a/tests/auto/declarative/anchors/data/illegal2.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- id: rect
- width: 120; height: 200; color: "white"
- Text { id: text1; text: "Hello" }
- Text {
- id: text2;
- anchors.baseline: text1.baseline;
- anchors.top: text1.top;
- text: "World"
- }
-}
diff --git a/tests/auto/declarative/anchors/data/illegal3.qml b/tests/auto/declarative/anchors/data/illegal3.qml
deleted file mode 100644
index 065ceb5..0000000
--- a/tests/auto/declarative/anchors/data/illegal3.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- id: rect
- width: 120; height: 200; color: "white"
- Item {
- Rectangle { id: theRect; width: 100; height: 100 }
- }
- Rectangle {
- anchors.left: theRect.left
- }
-}
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index 34c1e01..22f8327 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -60,6 +60,7 @@ private slots:
void basicAnchors();
void loops();
void illegalSets();
+ void illegalSets_data();
void reset();
void nullItem();
void crash1();
@@ -143,6 +144,11 @@ void tst_anchors::basicAnchors()
QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->width(), 86.0);
QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->height(), 10.0);
+ // offsets
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0);
+
//baseline
QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text1"));
QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text2"));
@@ -185,44 +191,71 @@ void tst_anchors::loops()
void tst_anchors::illegalSets()
{
- {
- QmlView *view = new QmlView;
+ QFETCH(QString, qml);
+ QFETCH(QString, warning);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QmlEngine engine;
+ QmlComponent component(&engine, QByteArray("import Qt 4.6\n" + qml.toUtf8()), QUrl("file://"));
+ if (!component.isReady())
+ qWarning() << "Test errors:" << component.errors();
+ QVERIFY(component.isReady());
+ QObject *o = component.create();
+ delete o;
+}
- view->setUrl(QUrl("file://" SRCDIR "/data/illegal1.qml"));
+void tst_anchors::illegalSets_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("warning");
- QString expect = "QML QmlGraphicsRectangle (" + view->url().toString() + ":7:5" + ") Can't specify left, right, and hcenter anchors.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- qApp->processEvents();
+ QTest::newRow("H - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
+ << "QML QmlGraphicsRectangle (file::2:23) Can't specify left, right, and hcenter anchors.";
- delete view;
- }
+ QTest::newRow("H - anchor to V")
+ << "Rectangle { Rectangle { anchors.left: parent.top } }"
+ << "QML QmlGraphicsRectangle (file::2:13) Can't anchor a horizontal edge to a vertical edge.";
- {
- QmlView *view = new QmlView;
+ QTest::newRow("H - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.left: rect.left } }"
+ << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling.";
- view->setUrl(QUrl("file://" SRCDIR "/data/illegal2.qml"));
+ QTest::newRow("H - anchor to self")
+ << "Rectangle { id: rect; anchors.left: rect.left }"
+ << "QML QmlGraphicsRectangle (file::2:1) Can't anchor item to self.";
- QString expect = "QML QmlGraphicsText (" + view->url().toString() + ":7:5" + ") Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- //qApp->processEvents();
- delete view;
- }
+ QTest::newRow("V - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
+ << "QML QmlGraphicsRectangle (file::2:23) Can't specify top, bottom, and vcenter anchors.";
- {
- QmlView *view = new QmlView;
+ QTest::newRow("V - too many anchors with baseline")
+ << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
+ << "QML QmlGraphicsText (file::2:47) Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors.";
- view->setUrl(QUrl("file://" SRCDIR "/data/illegal3.qml"));
+ QTest::newRow("V - anchor to H")
+ << "Rectangle { Rectangle { anchors.top: parent.left } }"
+ << "QML QmlGraphicsRectangle (file::2:13) Can't anchor a vertical edge to a horizontal edge.";
- QString expect = "QML QmlGraphicsRectangle (" + view->url().toString() + ":9:5" + ") Can't anchor to an item that isn't a parent or sibling.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- //qApp->processEvents();
+ QTest::newRow("V - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.top: rect.top } }"
+ << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling.";
- delete view;
- }
+ QTest::newRow("V - anchor to self")
+ << "Rectangle { id: rect; anchors.top: rect.top }"
+ << "QML QmlGraphicsRectangle (file::2:1) Can't anchor item to self.";
+
+
+ QTest::newRow("centerIn - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
+ << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling.";
+
+
+ QTest::newRow("fill - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
+ << "QML QmlGraphicsRectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling.";
}
void tst_anchors::reset()
@@ -243,10 +276,17 @@ void tst_anchors::reset()
void tst_anchors::nullItem()
{
QmlGraphicsAnchorLine anchor;
+ QmlGraphicsItem *item;
QTest::ignoreMessage(QtWarningMsg, "QML QmlGraphicsItem (unknown location) Can't anchor to a null item.");
- QmlGraphicsItem *item = new QmlGraphicsItem;
+ item = new QmlGraphicsItem;
+ item->anchors()->setLeft(anchor);
+ delete item;
+
+ QTest::ignoreMessage(QtWarningMsg, "QML QmlGraphicsItem (unknown location) Can't anchor to a null item.");
+ item = new QmlGraphicsItem;
item->anchors()->setBottom(anchor);
+ delete item;
}
void tst_anchors::crash1()
diff --git a/tests/auto/declarative/debugger/debugger.pro b/tests/auto/declarative/debugger/debugger.pro
deleted file mode 100644
index a341ca9..0000000
--- a/tests/auto/declarative/debugger/debugger.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += qmldebug \
- qmldebugclient \
- qmldebugservice \
- qpacketprotocol
diff --git a/tests/auto/declarative/debugger/debugutil.cpp b/tests/auto/declarative/debugger/debugutil.cpp
deleted file mode 100644
index 7008529..0000000
--- a/tests/auto/declarative/debugger/debugutil.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QSignalSpy>
-#include <QEventLoop>
-#include <QTimer>
-
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-
-#include "debugutil_p.h"
-
-bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
- QEventLoop loop;
- QTimer timer;
- QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- QObject::connect(receiver, member, &loop, SLOT(quit()));
- timer.start(timeout);
- loop.exec();
- return timer.isActive();
-}
-
-
-QmlDebugTestData::QmlDebugTestData(QEventLoop *el)
- : exitCode(-1), loop(el)
-{
-}
-
-QmlDebugTestData::~QmlDebugTestData()
-{
- qDeleteAll(items);
-}
-
-void QmlDebugTestData::testsFinished(int code)
-{
- exitCode = code;
- loop->quit();
-}
-
-
-
-QmlDebugTestService::QmlDebugTestService(const QString &s, QObject *parent)
- : QmlDebugService(s, parent), enabled(false)
-{
-}
-
-void QmlDebugTestService::messageReceived(const QByteArray &ba)
-{
- sendMessage(ba);
-}
-
-void QmlDebugTestService::enabledChanged(bool e)
-{
- emit enabledStateChanged();
- enabled = e;
-}
-
-
-QmlDebugTestClient::QmlDebugTestClient(const QString &s, QmlDebugConnection *c)
- : QmlDebugClient(s, c)
-{
-}
-
-QByteArray QmlDebugTestClient::waitForResponse()
-{
- QSignalSpy spy(this, SIGNAL(serverMessage(QByteArray)));
- QmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
- if (spy.count() == 0) {
- qWarning() << "tst_QmlDebugClient: no response from server!";
- return QByteArray();
- }
- return spy.at(0).at(0).value<QByteArray>();
-}
-
-void QmlDebugTestClient::messageReceived(const QByteArray &ba)
-{
- emit serverMessage(ba);
-}
-
-
-tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
- : m_ready(false), m_data(data), m_factory(factory)
-{
-}
-
-void tst_QmlDebug_Thread::run()
-{
- QTest::qWait(1000);
-
- QmlDebugConnection conn;
- conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
- Q_ASSERT(ok);
-
- while (!m_ready)
- QTest::qWait(100);
-
- m_data->conn = &conn;
-
- Q_ASSERT(m_factory);
- QObject *test = m_factory->createTest(m_data);
- Q_ASSERT(test);
- int code = QTest::qExec(test);
- emit testsFinished(code);
-}
-
-
-int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
-{
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
-
- QEventLoop loop;
- QmlDebugTestData data(&loop);
-
- tst_QmlDebug_Thread thread(&data, factory);
- QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
- thread.start();
-
- QmlEngine engine; // blocks until client connects
-
- foreach (const QByteArray &code, qml) {
- QmlComponent c(&engine, code, QUrl("file://"));
- Q_ASSERT(c.isReady()); // fails if bad syntax
- data.items << qobject_cast<QmlGraphicsItem*>(c.create());
- }
-
- // start the test
- data.engine = &engine;
- thread.m_ready = true;
-
- loop.exec();
-
- return data.exitCode;
-}
-
-
diff --git a/tests/auto/declarative/debugger/debugutil_p.h b/tests/auto/declarative/debugger/debugutil_p.h
deleted file mode 100644
index 665aeda..0000000
--- a/tests/auto/declarative/debugger/debugutil_p.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QSignalSpy>
-#include <QEventLoop>
-#include <QPointer>
-#include <QTimer>
-#include <QThread>
-#include <QTest>
-
-#include <QtDeclarative/qmlengine.h>
-
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-#include <private/qmlgraphicsitem_p.h>
-
-
-class QmlDebugTestData : public QObject
-{
- Q_OBJECT
-public:
- QmlDebugTestData(QEventLoop *el);
-
- ~QmlDebugTestData();
-
- QmlEngine *engine;
- QmlDebugConnection *conn;
-
- int exitCode;
- QEventLoop *loop;
-
- QList<QmlGraphicsItem *> items;
-
-public slots:
- void testsFinished(int code);
-};
-
-
-class QmlTestFactory
-{
-public:
- QmlTestFactory() {}
- virtual ~QmlTestFactory() {}
-
- 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
-public:
- QmlDebugTestService(const QString &s, QObject *parent = 0);
- bool enabled;
-
-signals:
- void enabledStateChanged();
-
-protected:
- virtual void messageReceived(const QByteArray &ba);
-
- virtual void enabledChanged(bool e);
-};
-
-class QmlDebugTestClient : public QmlDebugClient
-{
- Q_OBJECT
-public:
- QmlDebugTestClient(const QString &s, QmlDebugConnection *c);
-
- QByteArray waitForResponse();
-
-signals:
- void serverMessage(const QByteArray &);
-
-protected:
- virtual void messageReceived(const QByteArray &ba);
-};
-
-class tst_QmlDebug_Thread : public QThread
-{
- Q_OBJECT
-public:
- tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory);
-
- void run();
-
- bool m_ready;
-
-signals:
- void testsFinished(int);
-
-private:
- QmlDebugTestData *m_data;
- QmlTestFactory *m_factory;
-};
-
-
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index ec83411..cc8660f 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -2,10 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += \
anchors \ # Cover
animatedimage \ # Cover
- animations \ # Cover
- behaviors \ # Cover
datetimeformatter \ # Cover
- debugger \ # Cover
examples \
graphicswidgets \ # Cover
layouts \ # Cover
@@ -16,6 +13,9 @@ SUBDIRS += \
qmlbinding \ # Cover
qmlconnection \ # Cover
qmlcontext \ # Cover
+ qmldebug \ # Cover
+ qmldebugclient \ # Cover
+ qmldebugservice \ # Cover
qmldom \ # Cover
qmleasefollow \ # Cover
qmlecmascript \ # Cover
@@ -51,6 +51,7 @@ SUBDIRS += \
qmlsystempalette \ # Cover
qmltimer \ # Cover
qmlxmllistmodel \ # Cover
+ qpacketprotocol \ # Cover
repeater \ # Cover
sql \ # Cover
states \ # Cover
diff --git a/tests/auto/declarative/debugger/qmldebug/qmldebug.pro b/tests/auto/declarative/qmldebug/qmldebug.pro
index 0af30e1..f79829d 100644
--- a/tests/auto/declarative/debugger/qmldebug/qmldebug.pro
+++ b/tests/auto/declarative/qmldebug/qmldebug.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debugutil_p.h
+HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qmldebug.cpp \
- ../debugutil.cpp
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
index 70404f6..6916cc9 100644
--- a/tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp
+++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
@@ -59,7 +59,7 @@
#include <private/qmldebugservice_p.h>
#include <private/qmlgraphicsrectangle_p.h>
-#include "../debugutil_p.h"
+#include "../shared/debugutil_p.h"
Q_DECLARE_METATYPE(QmlDebugWatch::State)
diff --git a/tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro b/tests/auto/declarative/qmldebugclient/qmldebugclient.pro
index c0aa7b2..36aa818 100644
--- a/tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro
+++ b/tests/auto/declarative/qmldebugclient/qmldebugclient.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debugutil_p.h
+HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qmldebugclient.cpp \
- ../debugutil.cpp
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp b/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp
index 6c4a1a3..8325731 100644
--- a/tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp
+++ b/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp
@@ -52,7 +52,7 @@
#include <private/qmldebugclient_p.h>
#include <private/qmldebugservice_p.h>
-#include "../debugutil_p.h"
+#include "../shared/debugutil_p.h"
class tst_QmlDebugClient : public QObject
{
diff --git a/tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro b/tests/auto/declarative/qmldebugservice/qmldebugservice.pro
index cce277a..9995f1f 100644
--- a/tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro
+++ b/tests/auto/declarative/qmldebugservice/qmldebugservice.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debugutil_p.h
+HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qmldebugservice.cpp \
- ../debugutil.cpp
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
index 0c02929..625d1f5 100644
--- a/tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp
+++ b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
@@ -52,7 +52,7 @@
#include <private/qmldebugclient_p.h>
#include <private/qmldebugservice_p.h>
-#include "../debugutil_p.h"
+#include "../shared/debugutil_p.h"
class tst_QmlDebugService : public QObject
{
diff --git a/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro
index 800e5e0..f42cecc 100644
--- a/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro
+++ b/tests/auto/declarative/qpacketprotocol/qpacketprotocol.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debugutil_p.h
+HEADERS += ../shared/debugutil_p.h
SOURCES += tst_qpacketprotocol.cpp \
- ../debugutil.cpp
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
index 36b6317..b54f133 100644
--- a/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
+++ b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -48,7 +48,7 @@
#include <private/qpacketprotocol_p.h>
-#include "../debugutil_p.h"
+#include "../shared/debugutil_p.h"
class tst_QPacketProtocol : public QObject
{
diff --git a/tests/auto/declarative/states/data/anchorChanges3.qml b/tests/auto/declarative/states/data/anchorChanges3.qml
new file mode 100644
index 0000000..8a74595
--- /dev/null
+++ b/tests/auto/declarative/states/data/anchorChanges3.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+ width: 200; height: 200
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ color: "green";
+ anchors.left: parent.left
+ anchors.right: rightGuideline.left
+ anchors.top: topGuideline.top
+ anchors.bottom: container.bottom
+ }
+ Item { id: leftGuideline; x: 10 }
+ Item { id: rightGuideline; x: 150 }
+ Item { id: topGuideline; y: 10 }
+ Item { id: bottomGuideline; y: 150 }
+ states: State {
+ name: "reanchored"
+ AnchorChanges {
+ target: myRect;
+ left: leftGuideline.left
+ right: container.right
+ top: container.top
+ bottom: bottomGuideline.bottom
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
index 0e0a72a..1588d4c 100644
--- a/tests/auto/declarative/states/tst_states.cpp
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -488,6 +488,8 @@ void tst_states::anchorChanges()
rect->setState("");
QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
}
{
@@ -499,10 +501,36 @@ void tst_states::anchorChanges()
QVERIFY(innerRect != 0);
rect->setState("right");
+ QEXPECT_FAIL("", "QTBUG-5338", Continue);
QCOMPARE(innerRect->x(), qreal(150));
rect->setState("");
QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(innerRect->x(), qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ QCOMPARE(innerRect->width(), qreal(190));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ QCOMPARE(innerRect->width(), qreal(150));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
}
}