summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-09-23 07:31:22 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-09-23 07:31:22 (GMT)
commitc646730ca4ef1795973d578a95413ab4c4671a93 (patch)
tree3365cb2cb8df8c0178913c4dd9ea922365df8330
parent857f3f1466cb4ba57eca2d39d5515e2655a8c617 (diff)
parent04cf065afd6d0f5025cad58984ee4bad8e43bf76 (diff)
downloadQt-c646730ca4ef1795973d578a95413ab4c4671a93.zip
Qt-c646730ca4ef1795973d578a95413ab4c4671a93.tar.gz
Qt-c646730ca4ef1795973d578a95413ab4c4671a93.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rwxr-xr-xconfigure.exebin2038784 -> 1413120 bytes
-rw-r--r--demos/declarative/contacts/contacts.qml4
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml4
-rw-r--r--examples/declarative/listview/highlight.qml4
-rw-r--r--src/declarative/fx/qfxrepeater.cpp26
-rw-r--r--src/declarative/fx/qfxtextedit.cpp3
-rw-r--r--src/declarative/qml/qmlengine.cpp3
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp18
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h6
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp6
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp49
-rw-r--r--tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml6
-rw-r--r--tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml8
-rw-r--r--tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml11
-rw-r--r--tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml7
-rw-r--r--tests/auto/declarative/qmlecmascript/data/enums.2.qml8
-rw-r--r--tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml5
-rw-r--r--tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml14
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp104
-rw-r--r--tests/auto/declarative/repeater/data/repeater.qml6
-rw-r--r--tests/auto/declarative/repeater/repeater.pro1
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp30
22 files changed, 267 insertions, 56 deletions
diff --git a/configure.exe b/configure.exe
index 2c5b717..2cc5c01 100755
--- a/configure.exe
+++ b/configure.exe
Binary files differ
diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml
index 278eeb3..2b0d983 100644
--- a/demos/declarative/contacts/contacts.qml
+++ b/demos/declarative/contacts/contacts.qml
@@ -224,7 +224,7 @@ Rectangle {
}
}
]
- autoHighlight: true
+ highlightFollowsCurrentItem: true
focus: false
}
FocusScope {
@@ -291,7 +291,7 @@ Rectangle {
]
}
focus: contacts.mode != 'new'
- forwardTo: { contacts.mode == "list" ? [searchBarWrapper, contactListView] : [contactListView]}
+ Keys.forwardTo: { contacts.mode == "list" ? [searchBarWrapper, contactListView] : [contactListView]}
states: [
State {
name: "editNewState"
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml
index 7d73900..9d63e69 100644
--- a/examples/declarative/aspectratio/face_fit_animated.qml
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -17,8 +17,8 @@ Rectangle {
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
scale: SpringFollow {
- source: Math.max(Math.min(Image.parent.width/Image.width*1.333,Image.parent.height/Image.height),
- Math.min(Image.parent.width/Image.width,Image.parent.height/Image.height*1.333))
+ source: Math.max(Math.min(Face.parent.width/Face.width*1.333,Face.parent.height/Face.height),
+ Math.min(Face.parent.width/Face.width,Face.parent.height/Face.height*1.333))
spring: 1
damping: 0.05
}
diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
index cb92ad9..b6db453 100644
--- a/examples/declarative/listview/highlight.qml
+++ b/examples/declarative/listview/highlight.qml
@@ -37,7 +37,7 @@ Rectangle {
]
}
}
- // Specify a highlight with custom movement. Note that autoHighlight
+ // Specify a highlight with custom movement. Note that highlightFollowsCurrentItem
// is set to false in the ListView so that we can control how the
// highlight moves to the current item.
Component {
@@ -51,7 +51,7 @@ Rectangle {
id: List1
width: 200; height: parent.height
model: MyPetsModel; delegate: PetDelegate
- highlight: PetHighlight; autoHighlight: false
+ highlight: PetHighlight; highlightFollowsCurrentItem: false
focus: true
}
}
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 84804ce..5ef7b10 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -282,14 +282,26 @@ void QFxRepeater::regenerate()
if (!d->model || !d->model->count() || !d->model->isValid() || !parentItem() || !isComponentComplete())
return;
- if (d->model) {
- for (int ii = 0; ii < count(); ++ii) {
- QFxItem *item = d->model->item(ii);
- if (item) {
- item->setParent(parentItem());
- d->deletables << item;
- }
+ //In order to do the insertion like the examples, we have to be at the
+ //same point in the childItems() list. Temporary measure until we think of something better
+ int pos = parentItem()->childItems().indexOf(this);
+ Q_ASSERT(pos != -1);
+ QList<QGraphicsItem*> otherChildren;
+ for (int ii = pos+1; ii < parentItem()->childItems().count(); ii++){
+ QGraphicsItem* otherChild = parentItem()->childItems()[ii];
+ otherChildren << otherChild;
+ otherChild->setParentItem(0);
+ }
+
+ for (int ii = 0; ii < count(); ++ii) {
+ QFxItem *item = d->model->item(ii);
+ if (item) {
+ item->setParent(parentItem());
+ d->deletables << item;
}
}
+
+ foreach(QGraphicsItem* other, otherChildren)
+ other->setParentItem(parentItem());
}
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index f7b92a4..ce06348 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -1051,7 +1051,8 @@ void QFxTextEdit::updateSize()
if(d->cursor)
cursorWidth = d->cursor->width();
newWidth += cursorWidth;
- newWidth += 3;// ### Need a better way of ensuring cursor is in width
+ if(!d->document->isEmpty())
+ newWidth += 3;// ### Need a better way of accounting for space between char and cursor
setImplicitWidth(newWidth);
setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height());
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index a58b35e..72603ed 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1255,7 +1255,8 @@ QmlTypeNameScriptClass::queryProperty(const QScriptValue &scriptObject,
} else {
// Must be an attached property
this->object = qmlAttachedPropertiesObjectById(bridge.type->index(), bridge.object);
- Q_ASSERT(this->object);
+ if (!this->object)
+ return 0;
return ep->queryObject(strName, id, this->object);
}
}
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 91769d3..efc4a2b 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -119,6 +119,7 @@ QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject)
QmlMetaProperty::QmlMetaProperty()
: d(new QmlMetaPropertyPrivate)
{
+ d->q = this;
}
/*!
@@ -134,7 +135,9 @@ QmlMetaProperty::~QmlMetaProperty()
default property, an invalid QmlMetaProperty will be created.
*/
QmlMetaProperty::QmlMetaProperty(QObject *obj)
+: d(new QmlMetaPropertyPrivate)
{
+ d->q = this;
d->initDefault(obj);
}
@@ -146,6 +149,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj)
QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt)
: d(new QmlMetaPropertyPrivate)
{
+ d->q = this;
d->context = ctxt;
d->initDefault(obj);
}
@@ -175,6 +179,7 @@ void QmlMetaPropertyPrivate::initDefault(QObject *obj)
QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt)
: d(new QmlMetaPropertyPrivate)
{
+ d->q = this;
d->context = ctxt;
d->object = obj;
d->type = Property;
@@ -191,6 +196,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt)
QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name)
: d(new QmlMetaPropertyPrivate)
{
+ d->q = this;
d->initProperty(obj, name);
}
@@ -201,6 +207,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name)
QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *ctxt)
: d(new QmlMetaPropertyPrivate)
{
+ d->q = this;
d->context = ctxt;
d->initProperty(obj, name);
}
@@ -276,6 +283,7 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other)
: d(new QmlMetaPropertyPrivate(*other.d))
{
+ d->q = this;
}
/*!
@@ -560,9 +568,10 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const
if (!isProperty() || (type() & Attached) || !d->object)
return 0;
- QmlDeclarativeData *data = QmlDeclarativeData::get(d->object, true);
+ QmlDeclarativeData *data =
+ QmlDeclarativeData::get(d->object, 0 != newBinding);
- if (data->hasBindingBit(d->coreIdx)) {
+ if (data && data->hasBindingBit(d->coreIdx)) {
QmlAbstractBinding *binding = data->bindings;
while (binding) {
// ### This wont work for value types
@@ -584,7 +593,6 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const
return 0;
}
-
/*!
Returns the expression associated with this signal property, or 0 if no
signal expression exists.
@@ -743,6 +751,10 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value,
int writeBackIdx = -1;
bool deleteWriteBack = false;
+ // Remove any existing bindings on this property
+ if (source != QmlMetaProperty::Binding)
+ delete q->setBinding(0);
+
if (type & QmlMetaProperty::ValueTypeProperty) {
QmlEnginePrivate *ep = context?static_cast<QmlEnginePrivate *>(QObjectPrivate::get(context->engine())):0;
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
index f2d0039..1ccf913 100644
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ b/src/declarative/qml/qmlmetaproperty_p.h
@@ -85,16 +85,18 @@ class QmlMetaPropertyPrivate
{
public:
QmlMetaPropertyPrivate()
- : context(0), coreIdx(-1), valueTypeIdx(-1), valueTypeId(0),
+ : q(0), context(0), coreIdx(-1), valueTypeIdx(-1), valueTypeId(0),
type(QmlMetaProperty::Invalid), attachedFunc(-1),
object(0), propType(-1), category(QmlMetaProperty::Unknown) {}
QmlMetaPropertyPrivate(const QmlMetaPropertyPrivate &other)
- : name(other.name), signal(other.signal), context(other.context),
+ : q(0), name(other.name), signal(other.signal), context(other.context),
coreIdx(other.coreIdx), valueTypeIdx(other.valueTypeIdx),
valueTypeId(other.valueTypeId), type(other.type),
attachedFunc(other.attachedFunc), object(other.object),
propType(other.propType), category(other.category) {}
+ QmlMetaProperty *q;
+
QString name;
QMetaMethod signal;
QmlContext *context;
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index ffbb09b..e38e0e7 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -130,7 +130,7 @@ void tst_qfxtextedit::width()
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 0.);
+ QCOMPARE(textEditObject->width(), 1.);//+1 for cursor
}
for (int i = 0; i < standard.size(); i++)
@@ -144,7 +144,7 @@ void tst_qfxtextedit::width()
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(metricWidth));
+ QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character.
}
for (int i = 0; i < richText.size(); i++)
@@ -160,7 +160,7 @@ void tst_qfxtextedit::width()
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(documentWidth));
+ QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3));
}
}
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
index 13a301d..bd0b9c3 100644
--- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -93,7 +93,7 @@ void tst_qfxtextinput::width()
{
QFont f;
QFontMetrics fm(f);
- int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ int metricWidth = fm.width(standard.at(i));
QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
@@ -268,43 +268,36 @@ void tst_qfxtextinput::selection()
void tst_qfxtextinput::maxLength()
{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
-
- QVERIFY(canvas->root() != 0);
-
- QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
-
- QVERIFY(input != 0);
- //TODO: Me
+ QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QVERIFY(textinputObject->text().isEmpty());
+ foreach(const QString &str, standard){
+ QVERIFY(textinputObject->text().length() <= 10);
+ textinputObject->setText(str);
+ QVERIFY(textinputObject->text().length() <= 10);
+ }
+ //TODO: Simulated keypress input adding 11 chars at a time
}
void tst_qfxtextinput::masks()
{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
-
- QVERIFY(canvas->root() != 0);
-
- QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
- QVERIFY(input != 0);
//TODO: Me
}
void tst_qfxtextinput::validators()
{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
-
- QVERIFY(canvas->root() != 0);
-
- QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
- QVERIFY(input != 0);
//TODO: Me
}
@@ -336,7 +329,7 @@ void tst_qfxtextinput::navigation()
void tst_qfxtextinput::cursorDelegate()
{
- //TODO:Get the QFxTextInput test passing first
+ //TODO:Get the QFxTextEdit test passing first
}
void tst_qfxtextinput::simulateKey(QmlView *view, int key)
diff --git a/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml
new file mode 100644
index 0000000..b4a702b
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int c1: 0
+ property int c2: c1
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml
new file mode 100644
index 0000000..13c5ae5
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml
@@ -0,0 +1,8 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int c1: 0
+ property int c2: c1
+
+ onBasicSignal: c2 = 13
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml
new file mode 100644
index 0000000..d205526
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property alias c1: MyConstants.c1
+ property alias c2: MyConstants.c2
+
+ objectProperty: ConstantsOverrideBindings {
+ id: MyConstants
+ c2: 10
+ }
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml
new file mode 100644
index 0000000..ca9d1d8
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml
@@ -0,0 +1,7 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int c1: 0
+ property int c2: c1
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/enums.2.qml b/tests/auto/declarative/qmlecmascript/data/enums.2.qml
new file mode 100644
index 0000000..bdc672f
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/enums.2.qml
@@ -0,0 +1,8 @@
+import Qt.test 1.0
+import Qt.test 1.0 as Namespace
+
+MyQmlObject {
+ property int a: MyQmlObject.EnumValue10
+ property int b: Namespace.MyQmlObject.EnumValue10
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml b/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml
new file mode 100644
index 0000000..f9585db
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml
@@ -0,0 +1,5 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ stringProperty: MyQmlContainer.prop
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml
new file mode 100644
index 0000000..49ada1f
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml
@@ -0,0 +1,14 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property alias c1: MyConstants.c1
+ property alias c2: MyConstants.c2
+ property int c3: 0
+
+ objectProperty: ConstantsOverrideBindings {
+ id: MyConstants
+ c2: c3
+ }
+
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 40e4fff..7e6d83b 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -46,6 +46,9 @@ private slots:
void extensionObjects();
void enums();
void valueTypeFunctions();
+ void constantsOverrideBindings();
+ void outerBindingOverridesInnerBinding();
+ void nonExistantAttachedObject();
private:
QmlEngine engine;
@@ -376,6 +379,8 @@ void tst_qmlecmascript::extensionObjects()
void tst_qmlecmascript::enums()
{
+ // Existant enums
+ {
QmlComponent component(&engine, TEST_FILE("enums.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -390,6 +395,15 @@ void tst_qmlecmascript::enums()
QCOMPARE(object->property("h").toInt(), 3);
QCOMPARE(object->property("i").toInt(), 19);
QCOMPARE(object->property("j").toInt(), 19);
+ }
+ // Non-existant enums
+ {
+ QmlComponent component(&engine, TEST_FILE("enums.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 0);
+ }
}
void tst_qmlecmascript::valueTypeFunctions()
@@ -401,6 +415,96 @@ void tst_qmlecmascript::valueTypeFunctions()
QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
}
+/*
+Tests that writing a constant to a property with a binding on it disables the
+binding.
+*/
+void tst_qmlecmascript::constantsOverrideBindings()
+{
+ // From ECMAScript
+ {
+ QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(8));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ }
+
+ // During construction
+ {
+ QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ }
+
+ // From C++
+ {
+ QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ object->setProperty("c2", QVariant(13));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(7));
+ QCOMPARE(object->property("c1").toInt(), 7);
+ QCOMPARE(object->property("c2").toInt(), 13);
+ }
+}
+
+/*
+Tests that assigning a binding to a property that already has a binding causes
+the original binding to be disabled.
+*/
+void tst_qmlecmascript::outerBindingOverridesInnerBinding()
+{
+ QmlComponent component(&engine, TEST_FILE("outerBindingOverridesInnerBinding.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c3", QVariant(8));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 8);
+ QCOMPARE(object->property("c3").toInt(), 8);
+}
+
+/*
+Access a non-existant attached object.
+
+Tests for a regression where this used to crash.
+*/
+void tst_qmlecmascript::nonExistantAttachedObject()
+{
+ QmlComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
QTEST_MAIN(tst_qmlecmascript)
diff --git a/tests/auto/declarative/repeater/data/repeater.qml b/tests/auto/declarative/repeater/data/repeater.qml
index 57ba9dc..7d83230 100644
--- a/tests/auto/declarative/repeater/data/repeater.qml
+++ b/tests/auto/declarative/repeater/data/repeater.qml
@@ -6,6 +6,9 @@ Rectangle {
width: 240
height: 320
color: "white"
+ Text {
+ text: "Zero"
+ }
Repeater {
id: repeater
objectName: "repeater"
@@ -19,4 +22,7 @@ Rectangle {
}
}
}
+ Text {
+ text: "Last"
+ }
}
diff --git a/tests/auto/declarative/repeater/repeater.pro b/tests/auto/declarative/repeater/repeater.pro
index 0ecd7ee..1d30b7b 100644
--- a/tests/auto/declarative/repeater/repeater.pro
+++ b/tests/auto/declarative/repeater/repeater.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
SOURCES += tst_repeater.cpp
+macx:CONFIG -= app_bundle
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index 5fce70e..1bb746b 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -24,6 +24,11 @@ tst_QFxRepeater::tst_QFxRepeater()
{
}
+/*
+The Repeater element creates children at its own position in its parent's
+stacking order. In this test we insert a repeater between two other Text
+elements to test this.
+*/
void tst_QFxRepeater::stringList()
{
QmlView *canvas = createView(SRCDIR "/data/repeater.qml");
@@ -46,12 +51,27 @@ void tst_QFxRepeater::stringList()
QFxItem *container = findItem<QFxItem>(canvas->root(), "container");
QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), data.count() + 1);
+ QCOMPARE(container->childItems().count(), data.count() + 3);
+
+ for (int i = 0; i < container->childItems().count(); ++i) {
+
+ if (i == 0) {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Zero"));
+ } else if (i == 1) {
+ // The repeater itself
+ continue;
+ } else if (i == container->childItems().count() - 1) {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Last"));
+ } else {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-2));
+ }
- for (int i = 1; i < container->childItems().count(); ++i) {
- QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
}
delete canvas;