summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-05-12 07:42:52 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-05-12 07:42:52 (GMT)
commit731a2f16578ead0f75f2752e757b138376b2f872 (patch)
tree2b6f9746771992f97cbdb5cf5af8f35ac6928b26 /tests
parent37475bcc4aef3f08c5917f22c7f0f427e4214b91 (diff)
parentb4c589868f278aa9a58ab9afa727dbf0a9442e22 (diff)
downloadQt-731a2f16578ead0f75f2752e757b138376b2f872.zip
Qt-731a2f16578ead0f75f2752e757b138376b2f872.tar.gz
Qt-731a2f16578ead0f75f2752e757b138376b2f872.tar.bz2
Merge remote branch 'mainline/4.7' into 4.7
Conflicts: src/declarative/qml/qdeclarativeengine.cpp tools/qdoc3/htmlgenerator.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp22
-rw-r--r--tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml52
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml1
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp53
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp21
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml16
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp90
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/eval.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/function.qml19
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml13
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml13
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp111
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml27
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp28
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h4
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml9
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro (renamed from tests/auto/declarative/graphicswidgets/graphicswidgets.pro)4
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp115
-rw-r--r--tests/auto/declarative/qdeclarativelayouts/data/layouts.qml31
-rw-r--r--tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro10
-rw-r--r--tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp147
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml1
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/NoResize.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml1
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml1
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml1
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml1
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp67
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml28
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp46
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml38
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp100
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/darker.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/lighter.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp26
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/objlist.qml2
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp19
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml24
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml14
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp277
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml12
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp17
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml12
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp19
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml22
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml21
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml10
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml9
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml14
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml8
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml10
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml9
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h30
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp148
-rw-r--r--tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/data/orientation.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro11
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp108
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml16
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp99
-rw-r--r--tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml4
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml4
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp15
-rw-r--r--tests/benchmarks/declarative/compilation/compilation.pro11
-rw-r--r--tests/benchmarks/declarative/compilation/data/BoomBlock.qml65
-rw-r--r--tests/benchmarks/declarative/compilation/tst_compilation.cpp (renamed from tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp)46
82 files changed, 1813 insertions, 537 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 9b3b3d0..a9b069c 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -1,7 +1,6 @@
TEMPLATE = subdirs
SUBDIRS += \
examples \
- graphicswidgets \ # Cover
parserstress \ # Cover
qmetaobjectbuilder \ # Cover
qdeclarativeanimations \ # Cover
@@ -29,7 +28,6 @@ SUBDIRS += \
qdeclarativeitem \ # Cover
qdeclarativelistview \ # Cover
qdeclarativeloader \ # Cover
- qdeclarativelayouts \ # Cover
qdeclarativemousearea \ # Cover
qdeclarativeparticles \ # Cover
qdeclarativepathview \ # Cover
@@ -65,6 +63,7 @@ SUBDIRS += \
qdeclarativestyledtext \ # Cover
qdeclarativesqldatabase \ # Cover
qdeclarativevisualdatamodel \ # Cover
+ qdeclarativeviewer \ # Cover
qmlvisual # Cover
contains(QT_CONFIG, webkit) {
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 16b0cbe..3759cb5 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -80,14 +80,7 @@ tst_examples::tst_examples()
// Add directories you want excluded here
- excludedDirs << "examples/declarative/extending";
- excludedDirs << "examples/declarative/tutorials/extending";
- excludedDirs << "examples/declarative/plugins";
- excludedDirs << "examples/declarative/proxywidgets";
- excludedDirs << "examples/declarative/gestures";
-
- excludedDirs << "examples/declarative/imageprovider";
- excludedDirs << "demos/declarative/minehunt";
+ excludedDirs << "doc/src/snippets/declarative/graphicswidgets";
#ifdef QT_NO_WEBKIT
excludedDirs << "examples/declarative/webview";
@@ -157,11 +150,14 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
QStringList rv;
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
- foreach (const QString &file, files) {
- if (file.at(0).isLower()) {
- rv << d.absoluteFilePath(file);
+ QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files);
+ if (cppfiles.isEmpty()) {
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ if (file.at(0).isLower()) {
+ rv << d.absoluteFilePath(file);
+ }
}
}
diff --git a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
deleted file mode 100644
index d6cf4de..0000000
--- a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-import Qt 4.7
-import Qt.widgets 4.7
-
-QGraphicsWidget {
- geometry: "20,0,600x400"
- layout: QGraphicsLinearLayout {
- orientation: Qt.Horizontal
- QGraphicsWidget {
- layout: QGraphicsLinearLayout {
- spacing: 10; orientation: Qt.Vertical
- LayoutItem {
- QGraphicsLinearLayout.stretchFactor: 1
- QGraphicsLinearLayout.spacing: 1
- objectName: "left"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent }
- }
- LayoutItem {
- QGraphicsLinearLayout.stretchFactor: 10
- QGraphicsLinearLayout.spacing: 10
- objectName: "left"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { objectName: "yellowRect"; color: "blue"; anchors.fill: parent }
- }
- }
- }
- QGraphicsWidget {
- layout: QGraphicsLinearLayout {
- spacing: 10; orientation: Qt.Horizontal; contentsMargin: 10
- LayoutItem {
- objectName: "left"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { objectName: "yellowRect"; color: "red"; anchors.fill: parent }
- }
- LayoutItem {
- objectName: "left"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { objectName: "yellowRect"; color: "green"; anchors.fill: parent }
- }
- }
- }
- }
-}
-
diff --git a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml b/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml
index 91973a3..d430c2c 100644
--- a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml
@@ -1,5 +1,4 @@
import Qt 4.7
-import Qt.widgets 4.7
Rectangle {
color: "white"
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
index dff62c7..e169fa2 100644
--- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -48,6 +48,7 @@
#include <private/qdeclarativerectangle_p.h>
#include <private/qdeclarativetext_p.h>
#include <QtDeclarative/private/qdeclarativeanchors_p_p.h>
+#include <QtDeclarative/private/qdeclarativeitem_p.h>
Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor)
Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine)
@@ -376,15 +377,16 @@ void tst_qdeclarativeanchors::reset()
anchor.anchorLine = anchorLine;
QDeclarativeItem *item = new QDeclarativeItem;
+ QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
- const QMetaObject *meta = item->anchors()->metaObject();
+ const QMetaObject *meta = itemPrivate->anchors()->metaObject();
QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
- QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true);
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
- QVERIFY(p.reset(item->anchors()));
- QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false);
+ QVERIFY(p.reset(itemPrivate->anchors()));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
delete item;
delete baseItem;
@@ -410,18 +412,19 @@ void tst_qdeclarativeanchors::resetConvenience()
{
QDeclarativeItem *baseItem = new QDeclarativeItem;
QDeclarativeItem *item = new QDeclarativeItem;
+ QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
//fill
- item->anchors()->setFill(baseItem);
- QVERIFY(item->anchors()->fill() == baseItem);
- item->anchors()->resetFill();
- QVERIFY(item->anchors()->fill() == 0);
+ itemPrivate->anchors()->setFill(baseItem);
+ QVERIFY(itemPrivate->anchors()->fill() == baseItem);
+ itemPrivate->anchors()->resetFill();
+ QVERIFY(itemPrivate->anchors()->fill() == 0);
//centerIn
- item->anchors()->setCenterIn(baseItem);
- QVERIFY(item->anchors()->centerIn() == baseItem);
- item->anchors()->resetCenterIn();
- QVERIFY(item->anchors()->centerIn() == 0);
+ itemPrivate->anchors()->setCenterIn(baseItem);
+ QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
+ itemPrivate->anchors()->resetCenterIn();
+ QVERIFY(itemPrivate->anchors()->centerIn() == 0);
delete item;
delete baseItem;
@@ -433,12 +436,13 @@ void tst_qdeclarativeanchors::nullItem()
QDeclarativeAnchorLine anchor;
QDeclarativeItem *item = new QDeclarativeItem;
+ QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
- const QMetaObject *meta = item->anchors()->metaObject();
+ const QMetaObject *meta = itemPrivate->anchors()->metaObject();
QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item.");
- QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
delete item;
}
@@ -486,15 +490,16 @@ void tst_qdeclarativeanchors::fill()
qApp->processEvents();
QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler"));
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QCOMPARE(rect->x(), 0.0 + 10.0);
QCOMPARE(rect->y(), 0.0 + 30.0);
QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
//Alter Offsets (tests QTBUG-6631)
- rect->anchors()->setLeftMargin(20.0);
- rect->anchors()->setRightMargin(0.0);
- rect->anchors()->setBottomMargin(0.0);
- rect->anchors()->setTopMargin(10.0);
+ rectPrivate->anchors()->setLeftMargin(20.0);
+ rectPrivate->anchors()->setRightMargin(0.0);
+ rectPrivate->anchors()->setBottomMargin(0.0);
+ rectPrivate->anchors()->setTopMargin(10.0);
QCOMPARE(rect->x(), 0.0 + 20.0);
QCOMPARE(rect->y(), 0.0 + 10.0);
QCOMPARE(rect->width(), 200.0 - 20.0);
@@ -509,11 +514,12 @@ void tst_qdeclarativeanchors::centerIn()
qApp->processEvents();
QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("centered"));
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QCOMPARE(rect->x(), 75.0 + 10);
QCOMPARE(rect->y(), 75.0 + 30);
//Alter Offsets (tests QTBUG-6631)
- rect->anchors()->setHorizontalCenterOffset(-20.0);
- rect->anchors()->setVerticalCenterOffset(-10.0);
+ rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
QCOMPARE(rect->x(), 75.0 - 20.0);
QCOMPARE(rect->y(), 75.0 - 10.0);
@@ -526,13 +532,14 @@ void tst_qdeclarativeanchors::margins()
qApp->processEvents();
QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler"));
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 6.0);
QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
- rect->anchors()->setTopMargin(0.0);
- rect->anchors()->setMargins(20.0);
+ rectPrivate->anchors()->setTopMargin(0.0);
+ rectPrivate->anchors()->setMargins(20.0);
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 20.0);
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index e217e34..ed7e506 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -44,6 +44,7 @@
#include <QtDeclarative/qdeclarativeview.h>
#include <private/qdeclarativerectangle_p.h>
#include <private/qdeclarativeanimation_p.h>
+#include <private/qdeclarativeitem_p.h>
#include <QVariantAnimation>
#include <QEasingCurve>
@@ -324,7 +325,7 @@ void tst_qdeclarativeanimations::badTypes()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QVERIFY(rect);
- rect->setState("state1");
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
QTest::qWait(1000 + 50);
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
QVERIFY(myRect);
@@ -366,7 +367,7 @@ void tst_qdeclarativeanimations::mixedTypes()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QVERIFY(rect);
- rect->setState("state1");
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
QTest::qWait(500);
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
QVERIFY(myRect);
@@ -382,7 +383,7 @@ void tst_qdeclarativeanimations::mixedTypes()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QVERIFY(rect);
- rect->setState("state1");
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
QTest::qWait(500);
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
QVERIFY(myRect);
@@ -468,7 +469,7 @@ void tst_qdeclarativeanimations::propertiesTransition()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QVERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
QVERIFY(myRect);
QTest::qWait(waitDuration);
@@ -483,7 +484,7 @@ void tst_qdeclarativeanimations::propertiesTransition()
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
QVERIFY(myRect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QCOMPARE(myRect->x(),qreal(200));
QCOMPARE(myRect->y(),qreal(100));
QTest::qWait(waitDuration);
@@ -498,7 +499,7 @@ void tst_qdeclarativeanimations::propertiesTransition()
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
QVERIFY(myRect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QCOMPARE(myRect->x(),qreal(200));
QCOMPARE(myRect->y(),qreal(100));
}
@@ -511,7 +512,7 @@ void tst_qdeclarativeanimations::propertiesTransition()
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
QVERIFY(myRect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QCOMPARE(myRect->x(),qreal(100));
QTest::qWait(waitDuration);
QTIMED_COMPARE(myRect->x(),qreal(200));
@@ -525,7 +526,7 @@ void tst_qdeclarativeanimations::propertiesTransition()
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
QVERIFY(myRect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QCOMPARE(myRect->x(),qreal(100));
QTest::qWait(waitDuration);
QTIMED_COMPARE(myRect->x(),qreal(200));
@@ -539,7 +540,7 @@ void tst_qdeclarativeanimations::propertiesTransition()
QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
QVERIFY(myRect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QCOMPARE(myRect->x(),qreal(100));
QTest::qWait(waitDuration);
QTIMED_COMPARE(myRect->x(),qreal(100));
@@ -709,7 +710,7 @@ void tst_qdeclarativeanimations::rotation()
QDeclarativeRectangle *rr3 = rect->findChild<QDeclarativeRectangle*>("rr3");
QDeclarativeRectangle *rr4 = rect->findChild<QDeclarativeRectangle*>("rr4");
- rect->setState("state1");
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
QTest::qWait(800);
qreal r1 = rr->rotation();
qreal r2 = rr2->rotation();
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml
new file mode 100644
index 0000000..1911cc4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml
@@ -0,0 +1,16 @@
+import Qt 4.7
+
+Rectangle {
+ width: 800;
+ height: 480;
+
+ Text { id:theText; text: "hello world" }
+
+ Rectangle {
+ objectName: "innerRect"
+ color: "red"
+ x: theText.width
+ Behavior on x { NumberAnimation {} }
+ width: 100; height: 100
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index ee9e282..1dc4b53 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -43,8 +43,10 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetext_p.h>
#include <private/qdeclarativebehavior_p.h>
#include <private/qdeclarativeanimation_p.h>
+#include <private/qdeclarativeitem_p.h>
#include "../../../shared/util.h"
class tst_qdeclarativebehaviors : public QObject
@@ -80,7 +82,7 @@ void tst_qdeclarativebehaviors::simpleBehavior()
QTRY_VERIFY(rect);
QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
@@ -128,7 +130,7 @@ void tst_qdeclarativebehaviors::loop()
QTRY_VERIFY(rect);
//don't crash
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
delete rect;
}
@@ -140,7 +142,7 @@ void tst_qdeclarativebehaviors::colorBehavior()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QTRY_VERIFY(rect);
- rect->setState("red");
+ QDeclarativeItemPrivate::get(rect)->setState("red");
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color() != QColor("red"));
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color() != QColor("green"));
//i.e. the behavior has been triggered
@@ -155,7 +157,7 @@ void tst_qdeclarativebehaviors::parentBehavior()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QTRY_VERIFY(rect);
- rect->setState("reparented");
+ QDeclarativeItemPrivate::get(rect)->setState("reparented");
QTRY_VERIFY(rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem() != rect->findChild<QDeclarativeItem*>("NewParent"));
QTRY_VERIFY(rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem() == rect->findChild<QDeclarativeItem*>("NewParent"));
@@ -169,7 +171,7 @@ void tst_qdeclarativebehaviors::replaceBinding()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QTRY_VERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
QTRY_VERIFY(innerRect);
QTRY_VERIFY(innerRect->x() > 0);
@@ -181,7 +183,7 @@ void tst_qdeclarativebehaviors::replaceBinding()
rect->setProperty("movedx", 210);
QTRY_COMPARE(innerRect->x(), (qreal)210);
- rect->setState("");
+ QDeclarativeItemPrivate::get(rect)->setState("");
QTRY_VERIFY(innerRect->x() > 10);
QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
QTRY_COMPARE(innerRect->x(), (qreal)10);
@@ -201,7 +203,7 @@ void tst_qdeclarativebehaviors::group()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QTRY_VERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
//QTest::qWait(200);
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
@@ -216,7 +218,7 @@ void tst_qdeclarativebehaviors::group()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QTRY_VERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
@@ -230,11 +232,11 @@ void tst_qdeclarativebehaviors::emptyBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QTRY_COMPARE(x, qreal(200)); //should change immediately
+ QCOMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -244,9 +246,9 @@ void tst_qdeclarativebehaviors::explicitSelection()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200);
//i.e. the behavior has been triggered
@@ -259,11 +261,11 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QTRY_COMPARE(x, qreal(200)); //should change immediately
+ QCOMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -275,10 +277,9 @@ void tst_qdeclarativebehaviors::reassignedAnimation()
QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_COMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
- qobject_cast<QDeclarativeBehavior*>(
- rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation())->duration(), 200);
+ QVERIFY(rect);
+ QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
+ rect->findChild<QDeclarativeBehavior*>("MyBehavior")->animation())->duration(), 200);
delete rect;
}
@@ -288,12 +289,12 @@ void tst_qdeclarativebehaviors::disabled()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_COMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
+ QVERIFY(rect);
+ QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
- rect->setState("moved");
+ QDeclarativeItemPrivate::get(rect)->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QTRY_COMPARE(x, qreal(200)); //should change immediately
+ QCOMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -307,28 +308,47 @@ void tst_qdeclarativebehaviors::dontStart()
QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QTRY_VERIFY(myAnim && myAnim->qtAnimation());
- QTRY_VERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
delete rect;
}
void tst_qdeclarativebehaviors::startup()
{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
- QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
- QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
- QTRY_VERIFY(innerRect);
+ QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
+ QVERIFY(innerRect);
- QTRY_COMPARE(innerRect->x(), qreal(100)); //should be set immediately
+ QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
- delete rect;
+ delete rect;
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QDeclarativeText *text = rect->findChild<QDeclarativeText*>();
+ QVERIFY(text);
+
+ QCOMPARE(innerRect->x(), text->width()); //should be set immediately
+
+ delete rect;
+ }
}
QTEST_MAIN(tst_qdeclarativebehaviors)
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml
new file mode 100644
index 0000000..764d5ab
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml
@@ -0,0 +1,8 @@
+import Qt 4.7
+
+Item {
+ id: screen
+
+ Connections { target: screen; onNotFooBar1: {} ignoreUnknownSignals: true }
+ Connections { objectName: "connections"; onNotFooBar2: {} ignoreUnknownSignals: true }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml
new file mode 100644
index 0000000..09e7812
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Item {
+ id: screen
+
+ Connections { objectName: "connections"; target: null; onNotFooBar: {} }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml
new file mode 100644
index 0000000..478503d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Item {
+ id: screen
+
+ Connections { objectName: "connections"; onFooBar: {} }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml
new file mode 100644
index 0000000..d4e8d7e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Item {
+ id: screen
+
+ Connections { objectName: "connections"; target: screen; onFooBar: {} }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
index 0efae3b..00e97ca 100644
--- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
+++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
@@ -59,6 +59,8 @@ private slots:
void connection();
void trimming();
void targetChanged();
+ void unknownSignals_data();
+ void unknownSignals();
private:
QDeclarativeEngine engine;
@@ -156,6 +158,41 @@ void tst_qdeclarativeconnection::targetChanged()
delete item;
}
+void tst_qdeclarativeconnection::unknownSignals_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
+ QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
+ QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error
+ QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error
+}
+
+void tst_qdeclarativeconnection::unknownSignals()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, error);
+
+ QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file);
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
+ } else {
+ // QTest has no way to insist no message (i.e. fail)
+ }
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, url);
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
+ QVERIFY(item != 0);
+
+ // check that connection is created (they are all runtime errors)
+ QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections");
+ QVERIFY(connections);
+
+ delete item;
+}
+
QTEST_MAIN(tst_qdeclarativeconnection)
#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
index a951827..6c19566 100644
--- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -419,10 +419,8 @@ void tst_qdeclarativedom::loadSyntaxErrors()
void tst_qdeclarativedom::loadRemoteErrors()
{
QByteArray qml = "import Qt 4.7\n"
+ "import \"http://localhost/exampleQmlScript.js\" as Script\n"
"Item {\n"
- " Script {\n"
- " source: \"http://localhost/exampleQmlScript.js\""
- " }\n"
"}";
QDeclarativeDomDocument document;
QVERIFY(false == document.load(&engine, qml));
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
index 72b59ae..2337e44 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
@@ -19,7 +19,7 @@ QtObject {
myObject.deleteOnSet = 1;
- test3 = myObject.value == undefined;
- test4 = obj.value == undefined;
+ test3 = myObject == null
+ test4 = obj == null
}
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
index 3047e9b..7b132e1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
@@ -11,7 +11,7 @@ MyQmlObject{
function createTwo()
{
var component = Qt.createComponent('dynamicCreation.helper.qml');
- obj.objectProperty = component.createObject();
+ obj.objectProperty = component.createObject(obj);
}
function createThree()
@@ -22,6 +22,6 @@ MyQmlObject{
function dontCrash()
{
var component = Qt.createComponent('file-doesnt-exist.qml');
- obj.objectProperty = component.createObject();
+ obj.objectProperty = component.createObject(obj);
}
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
new file mode 100644
index 0000000..bc2df98
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
@@ -0,0 +1,23 @@
+import Qt 4.7
+
+QtObject {
+ property bool test1: false;
+ property bool test2: false;
+ property bool test3: false;
+ property bool test4: false;
+ property bool test5: false;
+
+
+ property int a: 7
+ property int b: 8
+
+ Component.onCompleted: {
+ var b = 9;
+
+ test1 = (eval("a") == 7);
+ test2 = (eval("b") == 9);
+ test3 = (eval("c") == undefined);
+ test4 = (eval("console") == console);
+ test5 = (eval("Qt") == Qt);
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
new file mode 100644
index 0000000..b435f58
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
@@ -0,0 +1,19 @@
+import Qt 4.7
+
+QtObject {
+ property bool test1: false;
+ property bool test2: false;
+ property bool test3: false;
+
+ Component.onCompleted: {
+ var a = 10;
+
+ var func1 = new Function("a", "return a + 7");
+ var func2 = new Function("a", "return Qt.atob(a)");
+ var func3 = new Function("return a");
+
+ test1 = (func1(4) == 11);
+ test2 = (func2("Hello World!") == Qt.atob("Hello World!"));
+ test3 = (func3() == undefined);
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml
new file mode 100644
index 0000000..09540f1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml
@@ -0,0 +1,5 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property variant a: function myFunction() { return 2; }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml
new file mode 100644
index 0000000..948b39c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml
@@ -0,0 +1,13 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property variant a
+ property bool runTest: false
+ onRunTestChanged: {
+ function myFunction() {
+ console.log("hello world");
+ }
+ a = myFunction;
+ }
+
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml
new file mode 100644
index 0000000..b6d31d5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml
@@ -0,0 +1,13 @@
+import Qt 4.7
+
+QtObject {
+ id: root
+ property QtObject object: QtObject {
+ id: nested
+ property QtObject nestedObject
+ }
+
+ Component.onCompleted: {
+ nested.nestedObject = root;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml
new file mode 100644
index 0000000..a36b4c0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+QtObject {
+ id: root
+
+ property variant a: 10
+ property int x: 10
+ property int test: a.x
+
+ Component.onCompleted: {
+ a = 11;
+ a = root;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 491a736..8c9290f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -142,8 +142,12 @@ private slots:
void libraryScriptAssert();
void variantsAssignedUndefined();
void qtbug_9792();
+ void qtcreatorbug_1289();
void noSpuriousWarningsAtShutdown();
void canAssignNullToQObject();
+ void functionAssignment();
+ void eval();
+ void function();
void callQtInvokables();
private:
@@ -1100,7 +1104,7 @@ void tst_qdeclarativeecmascript::exceptionClearsOnReeval()
QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml"));
QString url = component.url().toString();
- QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object.";
+ QString warning = url + ":4: TypeError: Result of expression 'objectProperty' [null] is not an object.";
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
@@ -1149,6 +1153,7 @@ static void transientErrorsMsgHandler(QtMsgType, const char *)
// Check that transient binding errors are not displayed
void tst_qdeclarativeecmascript::transientErrors()
{
+ {
QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.qml"));
transientErrorsMsgCount = 0;
@@ -1160,6 +1165,22 @@ void tst_qdeclarativeecmascript::transientErrors()
qInstallMsgHandler(old);
QCOMPARE(transientErrorsMsgCount, 0);
+ }
+
+ // One binding erroring multiple times, but then resolving
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.2.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+ }
}
// Check that errors during shutdown are minimized
@@ -2188,6 +2209,27 @@ void tst_qdeclarativeecmascript::qtbug_9792()
delete object;
}
+// Verifies that QDeclarativeGuard<>s used in the vmemetaobject are cleaned correctly
+void tst_qdeclarativeecmascript::qtcreatorbug_1289()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("qtcreatorbug_1289.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(o->property("object"));
+ QVERIFY(nested != 0);
+
+ QVERIFY(qvariant_cast<QObject *>(nested->property("nestedObject")) == o);
+
+ delete nested;
+ nested = qvariant_cast<QObject *>(o->property("object"));
+ QVERIFY(nested == 0);
+
+ // If the bug is present, the next line will crash
+ delete o;
+}
+
// Test that we shut down without stupid warnings
void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown()
{
@@ -2252,6 +2294,73 @@ void tst_qdeclarativeecmascript::canAssignNullToQObject()
}
}
+void tst_qdeclarativeecmascript::functionAssignment()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.1.qml"));
+
+ QString url = component.url().toString();
+ QString warning = url + ":4: Unable to assign a function to a property.";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(!o->property("a").isValid());
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.2.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(!o->property("a").isValid());
+
+ QString url = component.url().toString();
+ QString warning = url + ":10: Error: Cannot assign a function to a property.";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ o->setProperty("runTest", true);
+
+ QVERIFY(!o->property("a").isValid());
+
+ delete o;
+ }
+}
+
+void tst_qdeclarativeecmascript::eval()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("eval.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+
+ delete o;
+}
+
+void tst_qdeclarativeecmascript::function()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("function.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+
+ delete o;
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml
new file mode 100644
index 0000000..f351b53
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml
@@ -0,0 +1,27 @@
+import Qt 4.7
+
+Rectangle {
+ width: 400
+ height: 400
+
+ property int childCount: 0;
+
+ Item {
+ objectName: "testItem"
+ width: childrenRect.width
+ height: childrenRect.height
+
+ Repeater {
+ id: repeater
+ model: childCount
+ delegate: Rectangle {
+ x: index*10
+ y: index*20
+ width: 10
+ height: 20
+
+ color: "red"
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index d2c328e..e0ca746 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -63,6 +63,7 @@ private slots:
void propertyChanges();
void transforms();
void transforms_data();
+ void childrenRect();
void childrenProperty();
void resourcesProperty();
@@ -537,6 +538,33 @@ void tst_QDeclarativeItem::propertyChanges()
delete canvas;
}
+void tst_QDeclarativeItem::childrenRect()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRect.qml"));
+ canvas->show();
+
+ QGraphicsObject *o = canvas->rootObject();
+ QDeclarativeItem *item = o->findChild<QDeclarativeItem*>("testItem");
+ QCOMPARE(item->width(), qreal(0));
+ QCOMPARE(item->height(), qreal(0));
+
+ o->setProperty("childCount", 1);
+ QCOMPARE(item->width(), qreal(10));
+ QCOMPARE(item->height(), qreal(20));
+
+ o->setProperty("childCount", 5);
+ QCOMPARE(item->width(), qreal(50));
+ QCOMPARE(item->height(), qreal(100));
+
+ o->setProperty("childCount", 0);
+ QCOMPARE(item->width(), qreal(0));
+ QCOMPARE(item->height(), qreal(0));
+
+ delete o;
+}
+
template<typename T>
T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName)
{
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index 89f99c8..acbe219 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -99,7 +99,7 @@ private:
int m_value2;
};
-class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParserStatus
+class MyQmlObject : public QObject, public MyInterface
{
Q_OBJECT
Q_PROPERTY(int value READ value WRITE setValue FINAL)
@@ -113,7 +113,7 @@ class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParse
Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
- Q_INTERFACES(MyInterface QDeclarativeParserStatus)
+ Q_INTERFACES(MyInterface)
public:
MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
diff --git a/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml b/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml
new file mode 100644
index 0000000..ee881a2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml
@@ -0,0 +1,9 @@
+import Qt 4.7
+
+LayoutItem {//Sized by the layout
+ id: resizable
+ objectName: "resizable"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "200x200"
+}
diff --git a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro
index b77b430..eeb784d 100644
--- a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro
+++ b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro
@@ -2,9 +2,7 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative gui
macx:CONFIG -= app_bundle
-SOURCES += tst_graphicswidgets.cpp
+SOURCES += tst_qdeclarativelayoutitem.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
new file mode 100644
index 0000000..2207635
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 <QtTest/QtTest>
+#include <qdeclarativecomponent.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativeitem.h>
+#include <private/qdeclarativelayoutitem_p.h>
+#include <qgraphicsview.h>
+#include <qgraphicsscene.h>
+#include <qgraphicswidget.h>
+#include <qgraphicslinearlayout.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativelayoutitem : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativelayoutitem();
+
+private slots:
+ void test_resizing();
+};
+
+tst_qdeclarativelayoutitem::tst_qdeclarativelayoutitem()
+{
+}
+
+void tst_qdeclarativelayoutitem::test_resizing()
+{
+ //Create Layout (must be done in C++)
+ QGraphicsView view;
+ QGraphicsScene scene;
+ QGraphicsWidget *widget = new QGraphicsWidget();
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
+ widget->setLayout(layout);
+ scene.addItem(widget);
+ view.setScene(&scene);
+ //Add the QML snippet into the layout
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl(SRCDIR "/data/layoutItem.qml"));
+ QDeclarativeLayoutItem* obj = static_cast<QDeclarativeLayoutItem*>(c.create());
+ layout->addItem(obj);
+ layout->setContentsMargins(0,0,0,0);
+ widget->setContentsMargins(0,0,0,0);
+ view.show();
+
+ QVERIFY(obj!= 0);
+
+ widget->setGeometry(QRectF(0,0, 400,400));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+
+ widget->setGeometry(QRectF(0,0, 300,300));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+
+ widget->setGeometry(QRectF(0,0, 200,200));
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 200.0);
+
+ widget->setGeometry(QRectF(0,0, 100,100));
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 100.0);
+
+ widget->setGeometry(QRectF(0,0, 40,40));
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 100.0);
+
+ widget->setGeometry(QRectF(0,0, 412,112));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 112.0);
+}
+
+
+QTEST_MAIN(tst_qdeclarativelayoutitem)
+
+#include "tst_qdeclarativelayoutitem.moc"
diff --git a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml
deleted file mode 100644
index 0538738..0000000
--- a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml
+++ /dev/null
@@ -1,31 +0,0 @@
-import Qt 4.7
-import Qt.widgets 4.7
-
-Item {
- id: resizable
- width:300
- height:300
- QGraphicsWidget {
- x : resizable.x
- y : resizable.y
- width : resizable.width
- height : resizable.height
- layout: QGraphicsLinearLayout {
- spacing: 0
- LayoutItem {
- objectName: "left"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent }
- }
- LayoutItem {
- objectName: "right"
- minimumSize: "100x100"
- maximumSize: "400x400"
- preferredSize: "200x200"
- Rectangle { objectName: "greenRect"; color: "green"; anchors.fill: parent }
- }
- }
- }
-}
diff --git a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro
deleted file mode 100644
index a2065f4..0000000
--- a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qdeclarativelayouts.cpp
-macx:CONFIG -= app_bundle
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
diff --git a/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp
deleted file mode 100644
index 412c3b7..0000000
--- a/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 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 <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qdeclarativeview.h>
-#include <private/qdeclarativelayoutitem_p.h>
-#include <qdeclarativeexpression.h>
-#include <QStyle>
-
-class tst_QDeclarativeLayouts : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativeLayouts();
-
-private slots:
- void test_qml();//GraphicsLayout set up in Qml
- void test_cpp();//GraphicsLayout set up in C++
-
-private:
- QDeclarativeView *createView(const QString &filename);
-};
-
-tst_QDeclarativeLayouts::tst_QDeclarativeLayouts()
-{
-}
-
-void tst_QDeclarativeLayouts::test_qml()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/layouts.qml");
-
- qApp->processEvents();
- QDeclarativeLayoutItem *left = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("left"));
- QVERIFY(left != 0);
-
- QDeclarativeLayoutItem *right = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("right"));
- QVERIFY(right != 0);
-
- qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
- qreal r = QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin);
- qreal t = QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin);
- qreal b = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
- QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins.");
- qreal gvMargin = l;
-
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
-
- //Preferred Size
- rootItem->setWidth(300 + 2*gvMargin);
- rootItem->setHeight(300 + 2*gvMargin);
-
- QCOMPARE(left->x(), gvMargin);
- QCOMPARE(left->y(), gvMargin);
- QCOMPARE(left->width(), 100.0);
- QCOMPARE(left->height(), 300.0);
-
- QCOMPARE(right->x(), 100.0 + gvMargin);
- QCOMPARE(right->y(), 0.0 + gvMargin);
- QCOMPARE(right->width(), 200.0);
- QCOMPARE(right->height(), 300.0);
-
- //Minimum Size
- rootItem->setWidth(10+2*gvMargin);
- rootItem->setHeight(10+2*gvMargin);
-
- QCOMPARE(left->x(), gvMargin);
- QCOMPARE(left->width(), 100.0);
- QCOMPARE(left->height(), 100.0);
-
- QCOMPARE(right->x(), 100.0 + gvMargin);
- QCOMPARE(right->width(), 100.0);
- QCOMPARE(right->height(), 100.0);
-
- //Between preferred and Maximum Size
- /*Note that if set to maximum size (or above) GraphicsLinearLayout behavior
- is to shrink them down to preferred size. So the exact maximum size can't
- be used*/
- rootItem->setWidth(670 + 2*gvMargin);
- rootItem->setHeight(300 + 2*gvMargin);
-
- QCOMPARE(left->x(), gvMargin);
- QCOMPARE(left->width(), 270.0);
- QCOMPARE(left->height(), 300.0);
-
- QCOMPARE(right->x(), 270.0 + gvMargin);
- QCOMPARE(right->width(), 400.0);
- QCOMPARE(right->height(), 300.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativeLayouts::test_cpp()
-{
- //TODO: This test!
-}
-
-QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-
-QTEST_MAIN(tst_QDeclarativeLayouts)
-
-#include "tst_qdeclarativelayouts.moc"
diff --git a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
index 9bb0b37..3b851c1 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
@@ -1,5 +1,4 @@
import Qt 4.7
-import Qt.widgets 4.6
QGraphicsWidget {
size: "250x250"
diff --git a/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
index 6aa3d2f..72cd3b9 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
@@ -1,7 +1,8 @@
import Qt 4.7
-Loader {
- resizeMode: "NoResize"
+Item {
width: 200; height: 80
- source: "Rect120x60.qml"
+ Loader {
+ source: "Rect120x60.qml"
+ }
}
diff --git a/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
index 9322141..0cff506 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
@@ -1,8 +1,9 @@
import Qt 4.7
-Loader {
- resizeMode: Loader.NoResize
- source: "GraphicsWidget250x250.qml"
+Item {
width: 200
- height: 80
+ height: 80
+ Loader {
+ source: "GraphicsWidget250x250.qml"
+ }
}
diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
index 0cfb4df..81610ad 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
@@ -1,7 +1,6 @@
import Qt 4.7
Loader {
- resizeMode: Loader.SizeItemToLoader
width: 200
height: 80
source: "GraphicsWidget250x250.qml"
diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
index b588c9d..a801a42 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
@@ -1,6 +1,5 @@
import Qt 4.7
Loader {
- resizeMode: Loader.SizeLoaderToItem
source: "GraphicsWidget250x250.qml"
}
diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
index 93be6f1..77aa8d9 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
@@ -1,6 +1,5 @@
import Qt 4.7
Loader {
- resizeMode: "SizeLoaderToItem"
source: "Rect120x60.qml"
}
diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
index 04b46fb..0098927 100644
--- a/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
@@ -1,7 +1,6 @@
import Qt 4.7
Loader {
- resizeMode: "SizeItemToLoader"
width: 200; height: 80
source: "Rect120x60.qml"
}
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index 7cdadb4..b56ff13 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -270,7 +270,6 @@ void tst_QDeclarativeLoader::sizeLoaderToItem()
QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem);
QCOMPARE(loader->width(), 120.0);
QCOMPARE(loader->height(), 60.0);
@@ -282,20 +281,28 @@ void tst_QDeclarativeLoader::sizeLoaderToItem()
QCOMPARE(loader->width(), 150.0);
QCOMPARE(loader->height(), 45.0);
+ // Check explicit width
+ loader->setWidth(200.0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(rect->width(), 200.0);
+ rect->setWidth(100.0); // when rect changes ...
+ QCOMPARE(rect->width(), 100.0); // ... it changes
+ QCOMPARE(loader->width(), 200.0); // ... but loader stays the same
+
+ // Check explicit height
+ loader->setHeight(200.0);
+ QCOMPARE(loader->height(), 200.0);
+ QCOMPARE(rect->height(), 200.0);
+ rect->setHeight(100.0); // when rect changes ...
+ QCOMPARE(rect->height(), 100.0); // ... it changes
+ QCOMPARE(loader->height(), 200.0); // ... but loader stays the same
+
// Switch mode
- loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader);
loader->setWidth(180);
loader->setHeight(30);
QCOMPARE(rect->width(), 180.0);
QCOMPARE(rect->height(), 30.0);
- // notify
- QSignalSpy spy(loader, SIGNAL(resizeModeChanged()));
- loader->setResizeMode(QDeclarativeLoader::NoResize);
- QCOMPARE(spy.count(),1);
- loader->setResizeMode(QDeclarativeLoader::NoResize);
- QCOMPARE(spy.count(),1);
-
delete loader;
}
@@ -304,7 +311,6 @@ void tst_QDeclarativeLoader::sizeItemToLoader()
QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader);
QCOMPARE(loader->width(), 200.0);
QCOMPARE(loader->height(), 80.0);
@@ -320,7 +326,8 @@ void tst_QDeclarativeLoader::sizeItemToLoader()
QCOMPARE(rect->height(), 30.0);
// Switch mode
- loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem);
+ loader->resetWidth(); // reset explicit size
+ loader->resetHeight();
rect->setWidth(160);
rect->setHeight(45);
QCOMPARE(loader->width(), 160.0);
@@ -332,17 +339,12 @@ void tst_QDeclarativeLoader::sizeItemToLoader()
void tst_QDeclarativeLoader::noResize()
{
QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml"));
- QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 120.0);
- QCOMPARE(rect->height(), 60.0);
+ QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item != 0);
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 80.0);
- delete loader;
+ delete item;
}
void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget()
@@ -353,7 +355,6 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget()
scene.addItem(loader);
QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem);
QCOMPARE(loader->width(), 250.0);
QCOMPARE(loader->height(), 250.0);
@@ -365,7 +366,6 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget()
QCOMPARE(loader->height(), 45.0);
// Switch mode
- loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader);
loader->setWidth(180);
loader->setHeight(30);
QCOMPARE(widget->size().width(), 180.0);
@@ -382,7 +382,6 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader()
scene.addItem(loader);
QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader);
QCOMPARE(loader->width(), 200.0);
QCOMPARE(loader->height(), 80.0);
@@ -398,7 +397,8 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader()
QCOMPARE(widget->size().height(), 30.0);
// Switch mode
- loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem);
+ loader->resetWidth(); // reset explicit size
+ loader->resetHeight();
widget->resize(QSizeF(160,45));
QCOMPARE(loader->width(), 160.0);
QCOMPARE(loader->height(), 45.0);
@@ -409,20 +409,15 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader()
void tst_QDeclarativeLoader::noResizeGraphicsWidget()
{
QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml"));
- QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
+ scene.addItem(item);
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- QCOMPARE(widget->size().width(), 250.0);
- QCOMPARE(widget->size().height(), 250.0);
+ QVERIFY(item != 0);
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 80.0);
- delete loader;
+ delete item;
}
void tst_QDeclarativeLoader::networkRequestUrl()
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
index 36efe13..76e86c9 100644
--- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
+++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
@@ -88,7 +88,10 @@ QML_DECLARE_TYPE(TestType);
class ParserStatusTestType : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
+ void classBegin(){}
+ void componentComplete(){}
Q_CLASSINFO("DefaultProperty", "foo") // Missing default property
+ Q_INTERFACES(QDeclarativeParserStatus)
};
QML_DECLARE_TYPE(ParserStatusTestType);
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml b/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml
new file mode 100644
index 0000000..c01e938
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml
@@ -0,0 +1,28 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ color: "#ffffff"
+ width: 320; height: 240
+ property bool mr1_pressed: false
+ property bool mr1_released: false
+ property bool mr1_canceled: false
+ property bool mr2_pressed: false
+ property bool mr2_released: false
+ property bool mr2_canceled: false
+
+ MouseArea {
+ id: mouseRegion1
+ anchors.fill: parent
+ onPressed: { root.mr1_pressed = true }
+ onReleased: { root.mr1_released = true }
+ onCanceled: { root.mr1_canceled = true }
+ }
+ MouseArea {
+ id: mouseRegion2
+ width: 120; height: 120
+ onPressed: { root.mr2_pressed = true; mouse.accepted = false }
+ onReleased: { root.mr2_released = true }
+ onCanceled: { root.mr2_canceled = true }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index eb4aa12..ff3bf45 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -56,6 +56,8 @@ private slots:
void updateMouseAreaPosOnClick();
void updateMouseAreaPosOnResize();
void noOnClickedWithPressAndHold();
+ void onMousePressRejected();
+
private:
QDeclarativeView *createView();
};
@@ -320,7 +322,7 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold()
QTest::qWait(1000);
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMousePress);
+ QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
releaseEvent.setScenePos(QPointF(100, 100));
releaseEvent.setButton(Qt::LeftButton);
releaseEvent.setButtons(Qt::LeftButton);
@@ -330,6 +332,48 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold()
QVERIFY(canvas->rootObject()->property("held").toBool());
}
+void tst_QDeclarativeMouseArea::onMousePressRejected()
+{
+ QDeclarativeView *canvas = createView();
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rejectEvent.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool());
+
+ QGraphicsScene *scene = canvas->scene();
+ QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
+ pressEvent.setScenePos(QPointF(100, 100));
+ pressEvent.setButton(Qt::LeftButton);
+ pressEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &pressEvent);
+
+ QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+ QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool());
+
+ QTest::qWait(200);
+
+ QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
+ releaseEvent.setScenePos(QPointF(100, 100));
+ releaseEvent.setButton(Qt::LeftButton);
+ releaseEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &releaseEvent);
+
+ QVERIFY(canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+}
+
QTEST_MAIN(tst_QDeclarativeMouseArea)
#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml b/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml
new file mode 100644
index 0000000..ce0f0c9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml
@@ -0,0 +1,38 @@
+import Qt 4.7
+
+Rectangle {
+ width: 800
+ height: 480
+ color: "black"
+ resources: [
+ ListModel {
+ id: appModel
+ ListElement { color: "green" }
+ },
+ Component {
+ id: appDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ color: "green"
+ width: 100
+ height: 100
+ }
+ }
+ ]
+ PathView {
+ id: pathView
+ objectName: "pathView"
+ model: appModel
+ anchors.fill: parent
+
+ transformOrigin: "Top"
+ delegate: appDelegate
+ path: Path {
+ objectName: "path"
+ startX: pathView.width / 2 // startX: 400 <- this works as expected
+ startY: 300
+ PathLine { x: 400; y: 120 }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 0e3a74d..c32e9cc 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -77,6 +77,7 @@ private slots:
void pathChanges();
void componentChanges();
void modelChanges();
+ void pathUpdateOnStartChanged();
private:
@@ -672,6 +673,28 @@ void tst_QDeclarativePathView::modelChanges()
delete canvas;
}
+void tst_QDeclarativePathView::pathUpdateOnStartChanged()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdateOnStartChanged.qml"));
+
+ QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView");
+ QVERIFY(pathView);
+
+ QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path");
+ QVERIFY(path);
+ QCOMPARE(path->startX(), 400.0);
+ QCOMPARE(path->startY(), 300.0);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
+ QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
index b4ac0e1..7a23773 100644
--- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
#include <private/qlistmodelinterface_p.h>
#include <qdeclarativeview.h>
+#include <qdeclarativeengine.h>
#include <private/qdeclarativerectangle_p.h>
#include <private/qdeclarativepositioners_p.h>
#include <private/qdeclarativetransition_p.h>
@@ -69,6 +70,7 @@ private slots:
void test_repeater();
void test_flow();
void test_flow_resize();
+ void test_conflictinganchors();
private:
QDeclarativeView *createView(const QString &filename);
};
@@ -100,6 +102,8 @@ void tst_QDeclarativePositioners::test_horizontal()
QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
QCOMPARE(row->width(), 110.0);
QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_horizontal_spacing()
@@ -125,6 +129,8 @@ void tst_QDeclarativePositioners::test_horizontal_spacing()
QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
QCOMPARE(row->width(), 130.0);
QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_horizontal_animated()
@@ -175,6 +181,8 @@ void tst_QDeclarativePositioners::test_horizontal_animated()
QTRY_COMPARE(two->x(), 50.0);
QTRY_COMPARE(three->x(), 100.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_vertical()
@@ -201,6 +209,8 @@ void tst_QDeclarativePositioners::test_vertical()
QVERIFY(column);
QCOMPARE(column->height(), 80.0);
QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_vertical_spacing()
@@ -226,6 +236,8 @@ void tst_QDeclarativePositioners::test_vertical_spacing()
QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
QCOMPARE(column->height(), 100.0);
QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_vertical_animated()
@@ -273,6 +285,7 @@ void tst_QDeclarativePositioners::test_vertical_animated()
QTRY_COMPARE(two->y(), 50.0);
QTRY_COMPARE(three->y(), 100.0);
+ delete canvas;
}
void tst_QDeclarativePositioners::test_grid()
@@ -304,6 +317,8 @@ void tst_QDeclarativePositioners::test_grid()
QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
QCOMPARE(grid->width(), 120.0);
QCOMPARE(grid->height(), 100.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_grid_topToBottom()
@@ -335,6 +350,8 @@ void tst_QDeclarativePositioners::test_grid_topToBottom()
QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 120.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_grid_spacing()
@@ -366,6 +383,8 @@ void tst_QDeclarativePositioners::test_grid_spacing()
QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
QCOMPARE(grid->width(), 128.0);
QCOMPARE(grid->height(), 104.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_grid_animated()
@@ -446,6 +465,7 @@ void tst_QDeclarativePositioners::test_grid_animated()
QTRY_COMPARE(five->x(), 50.0);
QTRY_COMPARE(five->y(), 50.0);
+ delete canvas;
}
void tst_QDeclarativePositioners::test_grid_zero_columns()
@@ -477,6 +497,8 @@ void tst_QDeclarativePositioners::test_grid_zero_columns()
QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
QCOMPARE(grid->width(), 170.0);
QCOMPARE(grid->height(), 60.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_propertychanges()
@@ -534,6 +556,8 @@ void tst_QDeclarativePositioners::test_propertychanges()
grid->setRows(2);
QCOMPARE(columnsSpy.count(),2);
QCOMPARE(rowsSpy.count(),2);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_repeater()
@@ -555,6 +579,8 @@ void tst_QDeclarativePositioners::test_repeater()
QCOMPARE(two->y(), 0.0);
QCOMPARE(three->x(), 100.0);
QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_flow()
@@ -587,6 +613,8 @@ void tst_QDeclarativePositioners::test_flow()
QVERIFY(flow);
QCOMPARE(flow->width(), 90.0);
QCOMPARE(flow->height(), 120.0);
+
+ delete canvas;
}
void tst_QDeclarativePositioners::test_flow_resize()
@@ -618,6 +646,78 @@ void tst_QDeclarativePositioners::test_flow_resize()
QCOMPARE(four->y(), 50.0);
QCOMPARE(five->x(), 50.0);
QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+QString warningMessage;
+
+void interceptWarnings(QtMsgType type, const char *msg)
+{
+ Q_UNUSED( type );
+ warningMessage = msg;
+}
+
+void tst_QDeclarativePositioners::test_conflictinganchors()
+{
+ qInstallMsgHandler(interceptWarnings);
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+
+ component.setData("import Qt 4.7\nColumn { Item {} }", QUrl::fromLocalFile(""));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+
+ component.setData("import Qt 4.7\nRow { Item {} }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+
+ component.setData("import Qt 4.7\nGrid { Item {} }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+
+ component.setData("import Qt 4.7\nFlow { Item {} }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+
+ component.setData("import Qt 4.7\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom or verticalCenter anchors for items inside Column"));
+ warningMessage.clear();
+
+ component.setData("import Qt 4.7\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+
+ component.setData("import Qt 4.7\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right or horizontalCenter anchors for items inside Row"));
+ warningMessage.clear();
+
+ component.setData("import Qt 4.7\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+
+ component.setData("import Qt 4.7\nGrid { Item { anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid"));
+ warningMessage.clear();
+
+ component.setData("import Qt 4.7\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
}
QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
diff --git a/tests/auto/declarative/qdeclarativeqt/data/darker.qml b/tests/auto/declarative/qdeclarativeqt/data/darker.qml
index f6333fe..738095d 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/darker.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/darker.qml
@@ -3,9 +3,10 @@ import Qt 4.7
QtObject {
property variant test1: Qt.darker(Qt.rgba(1, 0.8, 0.3))
property variant test2: Qt.darker()
- property variant test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10)
+ property variant test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8)
property variant test4: Qt.darker("red");
property variant test5: Qt.darker("perfectred"); // Non-existant color
property variant test6: Qt.darker(10);
+ property variant test7: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8, 10)
}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml b/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml
new file mode 100644
index 0000000..e66c7be
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+QtObject {
+ property variant test1: Qt.fontFamilies(10)
+ property variant test2: Qt.fontFamilies();
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
index 6c0053ba..ddaf78d 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
@@ -3,8 +3,9 @@ import Qt 4.7
QtObject {
property variant test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3))
property variant test2: Qt.lighter()
- property variant test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10)
+ property variant test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8)
property variant test4: Qt.lighter("red");
property variant test5: Qt.lighter("perfectred"); // Non-existant color
property variant test6: Qt.lighter(10);
+ property variant test7: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8, 5)
}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 7cbd8db..5095be8 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -42,6 +42,7 @@
#include <qtest.h>
#include <QDebug>
#include <QDeclarativeEngine>
+#include <QFontDatabase>
#include <QFileInfo>
#include <QDeclarativeComponent>
#include <QDesktopServices>
@@ -76,6 +77,7 @@ private slots:
void isQtObject();
void btoa();
void atob();
+ void fontFamilies();
private:
QDeclarativeEngine engine;
@@ -232,7 +234,7 @@ void tst_qdeclarativeqt::lighter()
QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));
QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
- QString warning2 = component.url().toString() + ":6: Error: Qt.lighter(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -241,7 +243,7 @@ void tst_qdeclarativeqt::lighter()
QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
@@ -254,7 +256,7 @@ void tst_qdeclarativeqt::darker()
QDeclarativeComponent component(&engine, TEST_FILE("darker.qml"));
QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
- QString warning2 = component.url().toString() + ":6: Error: Qt.darker(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -263,7 +265,7 @@ void tst_qdeclarativeqt::darker()
QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
@@ -483,6 +485,22 @@ void tst_qdeclarativeqt::atob()
delete object;
}
+void tst_qdeclarativeqt::fontFamilies()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("fontFamilies.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QFontDatabase database;
+ QCOMPARE(object->property("test2"), QVariant::fromValue(database.families()));
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeqt)
#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
index 17c5d8d..e1bd2e2 100644
--- a/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
@@ -14,7 +14,7 @@ Rectangle {
property int instantiated: 0
Component {
Item{
- Component.onCompleted: {if(index!=model.idx) repeater.errors += 1; repeater.instantiated++}
+ Component.onCompleted: {if(index!=modelData.idx) repeater.errors += 1; repeater.instantiated++}
}
}
}
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
index 8be7d80..e6b2fdd 100644
--- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -185,15 +185,24 @@ void tst_QDeclarativeRepeater::numberModel()
delete canvas;
}
+class MyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int idx READ idx CONSTANT)
+public:
+ MyObject(int i) : QObject(), m_idx(i) {}
+
+ int idx() const { return m_idx; }
+
+ int m_idx;
+};
+
void tst_QDeclarativeRepeater::objectList()
{
QDeclarativeView *canvas = createView();
-
QObjectList data;
- for(int i=0; i<100; i++){
- data << new QObject();
- data.back()->setProperty("idx", i);
- }
+ for(int i=0; i<100; i++)
+ data << new MyObject(i);
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testData", QVariant::fromValue(data));
diff --git a/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml
new file mode 100644
index 0000000..2215ee4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml
@@ -0,0 +1,24 @@
+import Qt 4.7
+
+Rectangle {
+ id: myRect
+ width: 400
+ height: 400
+
+ states: [
+ State {
+ name: "state1"
+ PropertyChanges {
+ target: myRect
+ onHeightChanged: console.log("Hello World")
+ color: "green"
+ }
+ },
+ State {
+ name: "state2"; extend: "state1"
+ PropertyChanges {
+ target: myRect
+ color: "red"
+ }
+ }]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml
new file mode 100644
index 0000000..a70840c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+Rectangle {
+ id: theRect
+ property bool triggerState: false
+ property string stateString: ""
+ states: State {
+ when: triggerState
+ PropertyChanges {
+ target: theRect
+ stateString: "inState"
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index a016fa7..ea074a4 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -47,6 +47,7 @@
#include <private/qdeclarativetext_p.h>
#include <private/qdeclarativepropertychanges_p.h>
#include <private/qdeclarativestategroup_p.h>
+#include <private/qdeclarativeitem_p.h>
class MyRect : public QDeclarativeRectangle
@@ -86,6 +87,7 @@ private slots:
void basicBinding();
void signalOverride();
void signalOverrideCrash();
+ void signalOverrideCrash2();
void parentChange();
void parentChangeErrors();
void anchorChanges();
@@ -109,6 +111,7 @@ private slots:
void illegalObjectCreation();
void whenOrdering();
void urlResolution();
+ void unnamedWhen();
};
void tst_qdeclarativestates::initTestCase()
@@ -128,63 +131,66 @@ void tst_qdeclarativestates::basicChanges()
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
}
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
}
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),1);
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->border()->width(),1);
- rect->setState("bordered");
+ rectPrivate->setState("bordered");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),2);
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),1);
//### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
- rect->setState("bordered");
+ rectPrivate->setState("bordered");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),2);
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->border()->width(),1);
@@ -220,32 +226,33 @@ void tst_qdeclarativestates::basicExtension()
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),1);
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->border()->width(),1);
- rect->setState("bordered");
+ rectPrivate->setState("bordered");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->border()->width(),2);
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->border()->width(),1);
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),1);
- rect->setState("bordered");
+ rectPrivate->setState("bordered");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->border()->width(),2);
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->border()->width(),1);
}
@@ -253,26 +260,27 @@ void tst_qdeclarativestates::basicExtension()
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
}
}
@@ -284,77 +292,80 @@ void tst_qdeclarativestates::basicBinding()
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
rect->setProperty("sourceColor", QColor("green"));
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
rect->setProperty("sourceColor", QColor("yellow"));
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("yellow"));
}
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
rect->setProperty("sourceColor", QColor("green"));
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("green"));
rect->setProperty("sourceColor", QColor("yellow"));
QCOMPARE(rect->color(),QColor("yellow"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("yellow"));
}
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
rect->setProperty("sourceColor", QColor("green"));
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
rect->setProperty("sourceColor", QColor("red"));
QCOMPARE(rect->color(),QColor("blue"));
rect->setProperty("sourceColor2", QColor("yellow"));
QCOMPARE(rect->color(),QColor("yellow"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
rect->setProperty("sourceColor2", QColor("green"));
QCOMPARE(rect->color(),QColor("red"));
@@ -365,27 +376,28 @@ void tst_qdeclarativestates::basicBinding()
{
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QVERIFY(rect != 0);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
rect->setProperty("sourceColor", QColor("yellow"));
QCOMPARE(rect->color(),QColor("yellow"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
rect->setProperty("sourceColor", QColor("purple"));
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("purple"));
- rect->setState("green");
+ rectPrivate->setState("green");
QCOMPARE(rect->color(),QColor("green"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
}
}
@@ -403,7 +415,7 @@ void tst_qdeclarativestates::signalOverride()
rect->doSomething();
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("green");
+ QDeclarativeItemPrivate::get(rect)->setState("green");
rect->doSomething();
QCOMPARE(rect->color(),QColor("green"));
}
@@ -418,8 +430,7 @@ void tst_qdeclarativestates::signalOverride()
QCOMPARE(rect->color(),QColor("blue"));
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("extendedRect"));
-
- innerRect->setState("green");
+ QDeclarativeItemPrivate::get(innerRect)->setState("green");
rect->doSomething();
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(innerRect->color(),QColor("green"));
@@ -435,10 +446,25 @@ void tst_qdeclarativestates::signalOverrideCrash()
MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
QVERIFY(rect != 0);
- rect->setState("overridden");
+ QDeclarativeItemPrivate::get(rect)->setState("overridden");
rect->doSomething();
}
+void tst_qdeclarativestates::signalOverrideCrash2()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
+ QDeclarativeItemPrivate::get(rect)->setState("state2");
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
+
+ delete rect;
+}
+
void tst_qdeclarativestates::parentChange()
{
QDeclarativeEngine engine;
@@ -463,7 +489,7 @@ void tst_qdeclarativestates::parentChange()
QCOMPARE(pChange->parent(), nParent);
- rect->setState("reparented");
+ QDeclarativeItemPrivate::get(rect)->setState("reparented");
QCOMPARE(innerRect->rotation(), qreal(0));
QCOMPARE(innerRect->scale(), qreal(1));
QCOMPARE(innerRect->x(), qreal(-133));
@@ -474,11 +500,11 @@ void tst_qdeclarativestates::parentChange()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- rect->setState("reparented");
+ rectPrivate->setState("reparented");
QCOMPARE(innerRect->rotation(), qreal(15));
QCOMPARE(innerRect->scale(), qreal(.5));
QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
@@ -489,17 +515,17 @@ void tst_qdeclarativestates::parentChange()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- rect->setState("reparented");
+ rectPrivate->setState("reparented");
QCOMPARE(innerRect->rotation(), qreal(-37));
QCOMPARE(innerRect->scale(), qreal(.25));
QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(innerRect->rotation(), qreal(0));
QCOMPARE(innerRect->scale(), qreal(1));
QCOMPARE(innerRect->x(), qreal(5));
@@ -521,7 +547,7 @@ void tst_qdeclarativestates::parentChangeErrors()
QVERIFY(innerRect != 0);
QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale");
- rect->setState("reparented");
+ QDeclarativeItemPrivate::get(rect)->setState("reparented");
QCOMPARE(innerRect->rotation(), qreal(0));
QCOMPARE(innerRect->scale(), qreal(1));
QCOMPARE(innerRect->x(), qreal(5));
@@ -537,7 +563,7 @@ void tst_qdeclarativestates::parentChangeErrors()
QVERIFY(innerRect != 0);
QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform");
- rect->setState("reparented");
+ QDeclarativeItemPrivate::get(rect)->setState("reparented");
QCOMPARE(innerRect->rotation(), qreal(0));
QCOMPARE(innerRect->scale(), qreal(1));
QCOMPARE(innerRect->x(), qreal(5));
@@ -552,6 +578,7 @@ void tst_qdeclarativestates::anchorChanges()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
@@ -564,14 +591,14 @@ void tst_qdeclarativestates::anchorChanges()
QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
- rect->setState("right");
+ rectPrivate->setState("right");
QCOMPARE(innerRect->x(), qreal(150));
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->object()->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item);
- QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(innerRect->x(), qreal(5));
delete rect;
@@ -584,14 +611,15 @@ void tst_qdeclarativestates::anchorChanges2()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- rect->setState("right");
+ rectPrivate->setState("right");
QCOMPARE(innerRect->x(), qreal(150));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(innerRect->x(), qreal(5));
delete rect;
@@ -604,6 +632,7 @@ void tst_qdeclarativestates::anchorChanges3()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
@@ -622,23 +651,23 @@ void tst_qdeclarativestates::anchorChanges3()
QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
- rect->setState("reanchored");
+ rectPrivate->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->object()->anchors()->left().item, leftGuideline->left().item);
- QCOMPARE(aChanges->object()->anchors()->left().anchorLine, leftGuideline->left().anchorLine);
- QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item);
- QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine);
- QCOMPARE(aChanges->object()->anchors()->top().item, rect->top().item);
- QCOMPARE(aChanges->object()->anchors()->top().anchorLine, rect->top().anchorLine);
- QCOMPARE(aChanges->object()->anchors()->bottom().item, bottomGuideline->bottom().item);
- QCOMPARE(aChanges->object()->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine);
QCOMPARE(innerRect->x(), qreal(10));
QCOMPARE(innerRect->y(), qreal(0));
QCOMPARE(innerRect->width(), qreal(190));
QCOMPARE(innerRect->height(), qreal(150));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(innerRect->x(), qreal(0));
QCOMPARE(innerRect->y(), qreal(10));
QCOMPARE(innerRect->width(), qreal(150));
@@ -672,12 +701,12 @@ void tst_qdeclarativestates::anchorChanges4()
QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
- rect->setState("reanchored");
+ QDeclarativeItemPrivate::get(rect)->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(aChanges->object()->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->object()->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->object()->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item);
- QCOMPARE(aChanges->object()->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item);
+ QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine);
delete rect;
}
@@ -707,7 +736,7 @@ void tst_qdeclarativestates::anchorChanges5()
QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
- rect->setState("reanchored");
+ QDeclarativeItemPrivate::get(rect)->setState("reanchored");
QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
//QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
//QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
@@ -726,7 +755,7 @@ void tst_qdeclarativestates::anchorChangesCrash()
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
- rect->setState("reanchored");
+ QDeclarativeItemPrivate::get(rect)->setState("reanchored");
delete rect;
}
@@ -739,13 +768,13 @@ void tst_qdeclarativestates::script()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
}
}
@@ -757,13 +786,13 @@ void tst_qdeclarativestates::restoreEntryValues()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("blue"));
}
@@ -774,7 +803,7 @@ void tst_qdeclarativestates::explicitChanges()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QDeclarativeListReference list(rect, "states");
QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
QVERIFY(state != 0);
@@ -786,18 +815,18 @@ void tst_qdeclarativestates::explicitChanges()
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
rect->setProperty("sourceColor", QColor("green"));
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
rect->setProperty("sourceColor", QColor("yellow"));
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("yellow"));
}
@@ -812,7 +841,7 @@ void tst_qdeclarativestates::propertyErrors()
QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\"");
- rect->setState("blue");
+ QDeclarativeItemPrivate::get(rect)->setState("blue");
}
void tst_qdeclarativestates::incorrectRestoreBug()
@@ -822,22 +851,22 @@ void tst_qdeclarativestates::incorrectRestoreBug()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QCOMPARE(rect->color(),QColor("red"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
// make sure if we change the base state value, we then restore to it correctly
rect->setColor(QColor("green"));
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("green"));
}
@@ -865,12 +894,12 @@ void tst_qdeclarativestates::deletingChange()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
- rect->setState("blue");
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("blue"));
QCOMPARE(rect->radius(),qreal(5));
- rect->setState("");
+ rectPrivate->setState("");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->radius(),qreal(0));
@@ -883,7 +912,7 @@ void tst_qdeclarativestates::deletingChange()
qmlExecuteDeferred(state);
QCOMPARE(state->operationCount(), 1);
- rect->setState("blue");
+ rectPrivate->setState("blue");
QCOMPARE(rect->color(),QColor("red"));
QCOMPARE(rect->radius(),qreal(5));
@@ -928,11 +957,11 @@ void tst_qdeclarativestates::tempState()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QTest::ignoreMessage(QtDebugMsg, "entering placed");
QTest::ignoreMessage(QtDebugMsg, "entering idle");
- rect->setState("placed");
- QCOMPARE(rect->state(), QLatin1String("idle"));
+ rectPrivate->setState("placed");
+ QCOMPARE(rectPrivate->state(), QLatin1String("idle"));
}
void tst_qdeclarativestates::illegalTempState()
@@ -942,10 +971,10 @@ void tst_qdeclarativestates::illegalTempState()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition.");
- rect->setState("placed");
- QCOMPARE(rect->state(), QLatin1String("placed"));
+ rectPrivate->setState("placed");
+ QCOMPARE(rectPrivate->state(), QLatin1String("placed"));
}
void tst_qdeclarativestates::nonExistantProperty()
@@ -955,10 +984,10 @@ void tst_qdeclarativestates::nonExistantProperty()
QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
-
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- rect->setState("blue");
- QCOMPARE(rect->state(), QLatin1String("blue"));
+ rectPrivate->setState("blue");
+ QCOMPARE(rectPrivate->state(), QLatin1String("blue"));
}
void tst_qdeclarativestates::reset()
@@ -974,7 +1003,7 @@ void tst_qdeclarativestates::reset()
QCOMPARE(text->width(), qreal(40.));
QVERIFY(text->width() < text->height());
- rect->setState("state1");
+ QDeclarativeItemPrivate::get(rect)->setState("state1");
QVERIFY(text->width() > 41);
QVERIFY(text->width() > text->height());
@@ -1000,19 +1029,20 @@ void tst_qdeclarativestates::whenOrdering()
QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml");
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QCOMPARE(rect->state(), QLatin1String(""));
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
rect->setProperty("condition2", true);
- QCOMPARE(rect->state(), QLatin1String("state2"));
+ QCOMPARE(rectPrivate->state(), QLatin1String("state2"));
rect->setProperty("condition1", true);
- QCOMPARE(rect->state(), QLatin1String("state1"));
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
rect->setProperty("condition2", false);
- QCOMPARE(rect->state(), QLatin1String("state1"));
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
rect->setProperty("condition2", true);
- QCOMPARE(rect->state(), QLatin1String("state1"));
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
rect->setProperty("condition1", false);
rect->setProperty("condition2", false);
- QCOMPARE(rect->state(), QLatin1String(""));
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
}
void tst_qdeclarativestates::urlResolution()
@@ -1029,13 +1059,32 @@ void tst_qdeclarativestates::urlResolution()
QDeclarativeImage *image3 = rect->findChild<QDeclarativeImage*>("image3");
QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
- myType->setState("SetImageState");
+ QDeclarativeItemPrivate::get(myType)->setState("SetImageState");
QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png");
QCOMPARE(image1->source(), resolved);
QCOMPARE(image2->source(), resolved);
QCOMPARE(image3->source(), resolved);
}
+void tst_qdeclarativestates::unnamedWhen()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+ rect->setProperty("triggerState", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
+ rect->setProperty("triggerState", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml b/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml
new file mode 100644
index 0000000..b39ba5b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml
@@ -0,0 +1,12 @@
+import Qt 4.7
+
+Item {
+ width: 400; height: 500;
+ property int bindingWidth: text.width
+ property int bindingHeight: text.height
+
+ TextInput {
+ id: text
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 3307b7c..b92024f 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -84,7 +84,7 @@ private slots:
void navigation();
void readOnly();
void sendRequestSoftwareInputPanelEvent();
-
+ void geometrySignals();
private:
void simulateKey(QDeclarativeView *, int key);
QDeclarativeView *createView(const QString &filename);
@@ -202,7 +202,7 @@ void tst_qdeclarativetextedit::width()
QFont f;
QFontMetricsF fm(f);
qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = floor(metricWidth);
+ metricWidth = ceil(metricWidth);
QString componentStr = "import Qt 4.7\nTextEdit { text: \"" + standard.at(i) + "\" }";
QDeclarativeComponent texteditComponent(&engine);
@@ -219,7 +219,7 @@ void tst_qdeclarativetextedit::width()
document.setHtml(richText.at(i));
document.setDocumentMargin(0);
- int documentWidth = document.idealWidth();
+ int documentWidth = ceil(document.idealWidth());
QString componentStr = "import Qt 4.7\nTextEdit { text: \"" + richText.at(i) + "\" }";
QDeclarativeComponent texteditComponent(&engine);
@@ -808,6 +808,17 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
QApplication::processEvents();
QCOMPARE(ic.softwareInputPanelEventReceived, true);
}
+
+void tst_qdeclarativetextedit::geometrySignals()
+{
+ QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml");
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("bindingWidth").toInt(), 400);
+ QCOMPARE(o->property("bindingHeight").toInt(), 500);
+ delete o;
+}
+
QTEST_MAIN(tst_qdeclarativetextedit)
#include "tst_qdeclarativetextedit.moc"
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml b/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml
new file mode 100644
index 0000000..a9b50fe
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml
@@ -0,0 +1,12 @@
+import Qt 4.7
+
+Item {
+ width: 400; height: 500;
+ property int bindingWidth: text.width
+ property int bindingHeight: text.height
+
+ TextEdit {
+ id: text
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 83ebe6c..c00390d 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -76,6 +76,7 @@ private slots:
void focusOutClearSelection();
void echoMode();
+ void geometrySignals();
private:
void simulateKey(QDeclarativeView *, int key);
QDeclarativeView *createView(const QString &filename);
@@ -575,6 +576,14 @@ void tst_qdeclarativetextinput::navigation()
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == true);
+ // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
+ input->setCursorPosition(2);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(canvas, Qt::Key_Up);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(canvas, Qt::Key_Down);
+ QCOMPARE(input->cursorPosition(),2);
+
delete canvas;
}
@@ -805,6 +814,16 @@ void tst_qdeclarativetextinput::focusOutClearSelection()
QTRY_COMPARE(input.selectedText(), QLatin1String(""));
}
+void tst_qdeclarativetextinput::geometrySignals()
+{
+ QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml");
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("bindingWidth").toInt(), 400);
+ QCOMPARE(o->property("bindingHeight").toInt(), 500);
+ delete o;
+}
+
QTEST_MAIN(tst_qdeclarativetextinput)
#include "tst_qdeclarativetextinput.moc"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml
new file mode 100644
index 0000000..6c4a682
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml
@@ -0,0 +1,22 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_m11: matrix.m11
+ property real v_m12: matrix.m12
+ property real v_m13: matrix.m13
+ property real v_m14: matrix.m14
+ property real v_m21: matrix.m21
+ property real v_m22: matrix.m22
+ property real v_m23: matrix.m23
+ property real v_m24: matrix.m24
+ property real v_m31: matrix.m31
+ property real v_m32: matrix.m32
+ property real v_m33: matrix.m33
+ property real v_m34: matrix.m34
+ property real v_m41: matrix.m41
+ property real v_m42: matrix.m42
+ property real v_m43: matrix.m43
+ property real v_m44: matrix.m44
+ property variant copy: matrix
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml
new file mode 100644
index 0000000..2a9f154
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml
@@ -0,0 +1,21 @@
+import Test 1.0
+
+MyTypeObject {
+ matrix.m11: if (true) 11
+ matrix.m12: if (true) 12
+ matrix.m13: if (true) 13
+ matrix.m14: if (true) 14
+ matrix.m21: if (true) 21
+ matrix.m22: if (true) 22
+ matrix.m23: if (true) 23
+ matrix.m24: if (true) 24
+ matrix.m31: if (true) 31
+ matrix.m32: if (true) 32
+ matrix.m33: if (true) 33
+ matrix.m34: if (true) 34
+ matrix.m41: if (true) 41
+ matrix.m42: if (true) 42
+ matrix.m43: if (true) 43
+ matrix.m44: if (true) 44
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml
new file mode 100644
index 0000000..d1a21dc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_scalar: quaternion.scalar
+ property real v_x: quaternion.x
+ property real v_y: quaternion.y
+ property real v_z: quaternion.z
+ property variant copy: quaternion
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml
new file mode 100644
index 0000000..0c3e5af
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ quaternion.scalar: if (true) 88.5
+ quaternion.x: if (true) -0.3
+ quaternion.y: if (true) -12.9
+ quaternion.z: if (true) 907.4
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml
new file mode 100644
index 0000000..e4715ab
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+QtObject {
+ property int x;
+ property int y;
+ property int z;
+
+ Component.onCompleted: {
+ var vec3 = Qt.vector3d(1, 2, 3);
+ x = vec3.x;
+ y = vec3.y;
+ z = vec3.z;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml
new file mode 100644
index 0000000..fc315f7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector2.x
+ property real v_y: vector2.y
+ property variant copy: vector2
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml
new file mode 100644
index 0000000..f0e35ff
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ vector2.x: if (true) -0.3
+ vector2.y: if (true) -12.9
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml
new file mode 100644
index 0000000..f9d5d60
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector4.x
+ property real v_y: vector4.y
+ property real v_z: vector4.z
+ property real v_w: vector4.w
+ property variant copy: vector4
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml
new file mode 100644
index 0000000..5486981
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ vector4.x: if (true) -0.3
+ vector4.y: if (true) -12.9
+ vector4.z: if (true) 907.4
+ vector4.w: if (true) 88.5
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
index 8a9b981..1da9990 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
@@ -48,7 +48,11 @@
#include <QSizeF>
#include <QRect>
#include <QRectF>
+#include <QVector2D>
#include <QVector3D>
+#include <QVector4D>
+#include <QQuaternion>
+#include <QMatrix4x4>
#include <QFont>
#include <qdeclarative.h>
#include <QDeclarativePropertyValueSource>
@@ -66,7 +70,11 @@ class MyTypeObject : public QObject
Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
+ Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
+ Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
+ Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
+ Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
public:
@@ -77,7 +85,11 @@ public:
m_sizef(0.1, 100923.2),
m_rect(2, 3, 109, 102),
m_rectf(103.8, 99.2, 88.1, 77.6),
- m_vector(23.88, 3.1, 4.3)
+ m_vector2(32.88, 1.3),
+ m_vector(23.88, 3.1, 4.3),
+ m_vector4(54.2, 23.88, 3.1, 4.3),
+ m_quaternion(4.3, 54.2, 23.88, 3.1),
+ m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
{
m_font.setFamily("Arial");
m_font.setBold(true);
@@ -116,10 +128,26 @@ public:
QRectF rectf() const { return m_rectf; }
void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
+ QVector2D m_vector2;
+ QVector2D vector2() const { return m_vector2; }
+ void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
+
QVector3D m_vector;
QVector3D vector() const { return m_vector; }
void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
+ QVector4D m_vector4;
+ QVector4D vector4() const { return m_vector4; }
+ void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
+
+ QQuaternion m_quaternion;
+ QQuaternion quaternion() const { return m_quaternion; }
+ void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
+
+ QMatrix4x4 m_matrix;
+ QMatrix4x4 matrix() const { return m_matrix; }
+ void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
+
QFont m_font;
QFont font() const { return m_font; }
void setFont(const QFont &v) { m_font = v; emit changed(); }
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index b733b10..95b9baa 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -62,7 +62,11 @@ private slots:
void sizereadonly();
void rect();
void rectf();
+ void vector2d();
void vector3d();
+ void vector4d();
+ void quaternion();
+ void matrix4x4();
void font();
void bindingAssignment();
@@ -80,6 +84,7 @@ private slots:
void enums();
void conflictingBindings();
void returnValues();
+ void varAssignment();
private:
QDeclarativeEngine engine;
@@ -293,6 +298,31 @@ void tst_qdeclarativevaluetypes::rectf()
}
}
+void tst_qdeclarativevaluetypes::vector2d()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector2d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector2d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9));
+
+ delete object;
+ }
+}
+
void tst_qdeclarativevaluetypes::vector3d()
{
{
@@ -319,6 +349,106 @@ void tst_qdeclarativevaluetypes::vector3d()
}
}
+void tst_qdeclarativevaluetypes::vector4d()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector4d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector4d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::quaternion()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("quaternion_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3);
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("quaternion_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::matrix4x4()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_m11").toDouble(), (float)1);
+ QCOMPARE((float)object->property("v_m12").toDouble(), (float)2);
+ QCOMPARE((float)object->property("v_m13").toDouble(), (float)3);
+ QCOMPARE((float)object->property("v_m14").toDouble(), (float)4);
+ QCOMPARE((float)object->property("v_m21").toDouble(), (float)5);
+ QCOMPARE((float)object->property("v_m22").toDouble(), (float)6);
+ QCOMPARE((float)object->property("v_m23").toDouble(), (float)7);
+ QCOMPARE((float)object->property("v_m24").toDouble(), (float)8);
+ QCOMPARE((float)object->property("v_m31").toDouble(), (float)9);
+ QCOMPARE((float)object->property("v_m32").toDouble(), (float)10);
+ QCOMPARE((float)object->property("v_m33").toDouble(), (float)11);
+ QCOMPARE((float)object->property("v_m34").toDouble(), (float)12);
+ QCOMPARE((float)object->property("v_m41").toDouble(), (float)13);
+ QCOMPARE((float)object->property("v_m42").toDouble(), (float)14);
+ QCOMPARE((float)object->property("v_m43").toDouble(), (float)15);
+ QCOMPARE((float)object->property("v_m44").toDouble(), (float)16);
+ QCOMPARE(object->property("copy"),
+ QVariant(QMatrix4x4(1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14,
+ 21, 22, 23, 24,
+ 31, 32, 33, 34,
+ 41, 42, 43, 44));
+
+ delete object;
+ }
+}
+
void tst_qdeclarativevaluetypes::font()
{
{
@@ -665,7 +795,12 @@ void tst_qdeclarativevaluetypes::cppClasses()
CPP_TEST(QDeclarativeSizeFValueType, QSizeF(-100.7, 18.2));
CPP_TEST(QDeclarativeRectValueType, QRect(13, 39, 10928, 88));
CPP_TEST(QDeclarativeRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
+ CPP_TEST(QDeclarativeVector2DValueType, QVector2D(19.7, 1002));
CPP_TEST(QDeclarativeVector3DValueType, QVector3D(18.2, 19.7, 1002));
+ CPP_TEST(QDeclarativeVector4DValueType, QVector4D(18.2, 19.7, 1002, 54));
+ CPP_TEST(QDeclarativeQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54));
+ CPP_TEST(QDeclarativeMatrix4x4ValueType,
+ QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
CPP_TEST(QDeclarativeFontValueType, QFont("Helvetica"));
}
@@ -777,6 +912,19 @@ void tst_qdeclarativevaluetypes::returnValues()
delete object;
}
+void tst_qdeclarativevaluetypes::varAssignment()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("varAssignment.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("x").toInt(), 1);
+ QCOMPARE(object->property("y").toInt(), 2);
+ QCOMPARE(object->property("z").toInt(), 3);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativevaluetypes)
#include "tst_qdeclarativevaluetypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
index 1ed51c1..dd2f46e 100644
--- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
+++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
@@ -147,7 +147,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem()
declarativeItem->setHeight(80);
QCOMPARE(canvas->width(), 80);
QCOMPARE(canvas->height(), 100);
- QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(QSize(declarativeItem->width(), declarativeItem->height()), canvas->sizeHint());
QCOMPARE(sceneResizedSpy2.count(), 2);
// size update from view
@@ -230,7 +230,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget()
canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
graphicsWidget->resize(QSizeF(60,80));
QCOMPARE(canvas->size(), QSize(80,100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(QSize(graphicsWidget->size().width(), graphicsWidget->size().height()), canvas->sizeHint());
QCOMPARE(sceneResizedSpy2.count(), 2);
// size update from view
diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml
new file mode 100644
index 0000000..687fac6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml
@@ -0,0 +1,10 @@
+import Qt 4.7
+Rectangle {
+ color: "black"
+ width: (runtime.orientation == Orientation.Landscape) ? 300 : 200
+ height: (runtime.orientation == Orientation.Landscape) ? 200 : 300
+ Text {
+ text: runtime.orientation == Orientation.Landscape ? "Landscape" : "Portrait"
+ color: "white"
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro
new file mode 100644
index 0000000..dc10f5b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+include(../../../../tools/qml/qml.pri)
+
+SOURCES += tst_qdeclarativeviewer.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
new file mode 100644
index 0000000..9429dc9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+#include "qmlruntime.h"
+
+class tst_QDeclarativeViewer : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeViewer();
+
+private slots:
+ void orientation();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_QDeclarativeViewer::tst_QDeclarativeViewer()
+{
+}
+
+void tst_QDeclarativeViewer::orientation()
+{
+ QWidget window;
+ QDeclarativeViewer *viewer = new QDeclarativeViewer(&window);
+ QVERIFY(viewer);
+ viewer->open(SRCDIR "/data/orientation.qml");
+ QVERIFY(viewer->view());
+ QVERIFY(viewer->menuBar());
+ QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
+ QVERIFY(rootItem);
+ window.show();
+
+ QCOMPARE(rootItem->width(), 200.0);
+ QCOMPARE(rootItem->height(), 300.0);
+ QCOMPARE(viewer->view()->size(), QSize(200, 300));
+ QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
+ QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), viewer->sizeHint());
+
+ viewer->toggleOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(rootItem->width(), 300.0);
+ QCOMPARE(rootItem->height(), 200.0);
+ QCOMPARE(viewer->view()->size(), QSize(300, 200));
+ QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200));
+ QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), viewer->sizeHint());
+
+ viewer->toggleOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(rootItem->width(), 200.0);
+ QCOMPARE(rootItem->height(), 300.0);
+ QCOMPARE(viewer->view()->size(), QSize(200, 300));
+ QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
+ QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), viewer->sizeHint());
+}
+
+QTEST_MAIN(tst_QDeclarativeViewer)
+
+#include "tst_qdeclarativeviewer.moc"
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml
new file mode 100644
index 0000000..f5198c9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml
@@ -0,0 +1,16 @@
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ color: model.modelData.color
+ Text { objectName: "name"; text: name }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 7de15a3..c238ef9 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -44,6 +44,10 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativelistview_p.h>
+#include <private/qdeclarativetext_p.h>
#include <private/qdeclarativevisualitemmodel_p.h>
#include <private/qdeclarativevaluetype_p.h>
#include <math.h>
@@ -74,9 +78,50 @@ public:
private slots:
void rootIndex();
+ void objectListModel();
private:
QDeclarativeEngine engine;
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName, int index);
+};
+
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
+
+public:
+ DataObject(QObject *parent=0) : QObject(parent) {}
+ DataObject(const QString &name, const QString &color, QObject *parent=0)
+ : QObject(parent), m_name(name), m_color(color) { }
+
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) {
+ if (name != m_name) {
+ m_name = name;
+ emit nameChanged();
+ }
+ }
+
+ QString color() const { return m_color; }
+ void setColor(const QString &color) {
+ if (color != m_color) {
+ m_color = color;
+ emit colorChanged();
+ }
+ }
+
+signals:
+ void nameChanged();
+ void colorChanged();
+
+private:
+ QString m_name;
+ QString m_color;
};
tst_qdeclarativevisualdatamodel::tst_qdeclarativevisualdatamodel()
@@ -105,6 +150,60 @@ void tst_qdeclarativevisualdatamodel::rootIndex()
delete obj;
}
+void tst_qdeclarativevisualdatamodel::objectListModel()
+{
+ QDeclarativeView view;
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/objectlist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "name", 0);
+ QCOMPARE(name->text(), QString("Item 1"));
+
+ dataList[0]->setProperty("name", QLatin1String("Changed"));
+ QCOMPARE(name->text(), QString("Changed"));
+}
+
+template<typename T>
+T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeExpression e(qmlContext(item), "index", item);
+ if (e.evaluate().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
QTEST_MAIN(tst_qdeclarativevisualdatamodel)
diff --git a/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml b/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml
index d82c6df..cc9a639 100644
--- a/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml
+++ b/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml
@@ -16,7 +16,7 @@ Rectangle {
id: img
source: "pics/qtlogo.png"
x: 60-width/2
- y: 100
+ y: 200-img.height
SequentialAnimation on y {
loops: Animation.Infinite
NumberAnimation {
@@ -24,7 +24,7 @@ Rectangle {
easing.type: "InOutQuad"
}
NumberAnimation {
- to: 100
+ to: 200-img.height
easing.type: "OutBounce"
duration: 2000
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml
index a0b787f..e223f5e 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml
@@ -25,7 +25,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
onPressed: blue.color = "lightsteelblue"
- onReleased: blue.color = "steelblue"
+ onCanceled: blue.color = "steelblue"
}
}
Rectangle {
@@ -36,7 +36,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
onEntered: { red.color = "darkred"; tooltip.opacity = 1 }
- onExited: { red.color = "red"; tooltip.opacity = 0 }
+ onCanceled: { red.color = "red"; tooltip.opacity = 0 }
}
Rectangle {
id: tooltip
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index d5f63d3..6cea834 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3436,6 +3436,21 @@ void tst_QGraphicsProxyWidget::inputMethod()
qApp->sendEvent(proxy, &event);
QCOMPARE(lineEdit->inputMethodEvents, i);
}
+
+ scene.clear();
+ QGraphicsView view(&scene);
+ QWidget *w = new QWidget;
+ w->setLayout(new QVBoxLayout(w));
+ QLineEdit *lineEdit = new QLineEdit;
+ lineEdit->setEchoMode(QLineEdit::Password);
+ w->layout()->addWidget(lineEdit);
+ lineEdit->setAttribute(Qt::WA_InputMethodEnabled, true);
+ QGraphicsProxyWidget *proxy = scene.addWidget(w);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod));
+ lineEdit->setFocus();
+ QVERIFY((proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod));
}
void tst_QGraphicsProxyWidget::clickFocus()
diff --git a/tests/benchmarks/declarative/compilation/compilation.pro b/tests/benchmarks/declarative/compilation/compilation.pro
new file mode 100644
index 0000000..32f4aba
--- /dev/null
+++ b/tests/benchmarks/declarative/compilation/compilation.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_compilation
+QT += declarative
+macx:CONFIG -= app_bundle
+
+CONFIG += release
+
+SOURCES += tst_compilation.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml
new file mode 100644
index 0000000..47f43c2
--- /dev/null
+++ b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml
@@ -0,0 +1,65 @@
+import Qt 4.7
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property int targetX: 0
+ property int targetY: 0
+
+ SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if(type == 0){
+ "pics/redStar.png";
+ } else if (type == 1) {
+ "pics/blueStar.png";
+ } else {
+ "pics/greenStar.png";
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
index f1a71d5..5694d5b 100644
--- a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
+++ b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
@@ -38,37 +38,53 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QFile>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtGui/qgraphicswidget.h>
-class tst_graphicswidgets : public QObject
+#ifdef Q_OS_SYMBIAN
+// In Symbian OS test data is located in applications private dir
+// Application private dir is default serach path for files, so SRCDIR can be set to empty
+#define SRCDIR ""
+#endif
+class tst_compilation : public QObject
{
Q_OBJECT
public:
- tst_graphicswidgets();
+ tst_compilation();
private slots:
- void widgets();
+ void boomblock();
+
+private:
+ QDeclarativeEngine engine;
};
-tst_graphicswidgets::tst_graphicswidgets()
+tst_compilation::tst_compilation()
{
}
-void tst_graphicswidgets::widgets()
+inline QUrl TEST_FILE(const QString &filename)
{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml"));
- QGraphicsWidget *obj = qobject_cast<QGraphicsWidget*>(c.create());
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_compilation::boomblock()
+{
+ QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QByteArray data = f.readAll();
- QVERIFY(obj != 0);
- delete obj;
+ QBENCHMARK {
+ QDeclarativeComponent c(&engine);
+ c.setData(data, QUrl());
+// QVERIFY(c.isReady());
+ }
}
-QTEST_MAIN(tst_graphicswidgets)
+QTEST_MAIN(tst_compilation)
-#include "tst_graphicswidgets.moc"
+#include "tst_compilation.moc"