Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add autotest for v4 nested object bug.
Task-number: QTBUG-24606
Change-Id: I0909d60316f7213b21fc315e8a3d0a6124e84409
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
  • Loading branch information
Michael Brasser authored and Qt by Nokia committed Mar 9, 2012
1 parent 4eab198 commit 9ba6a3b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 5 additions & 0 deletions tests/auto/qml/v4/data/nestedObjectAccess2.qml
@@ -0,0 +1,5 @@
import Qt.v4 1.0

Result {
result: nested2.result
}
3 changes: 3 additions & 0 deletions tests/auto/qml/v4/testtypes.h
Expand Up @@ -59,6 +59,7 @@ class ResultObject : public QObject
Q_OBJECT
Q_PROPERTY(int result READ result WRITE setResult FINAL)
Q_PROPERTY(NestedObject *nested READ nested CONSTANT)
Q_PROPERTY(NestedObject *nested2 READ nested2 FINAL CONSTANT)
public:
ResultObject() : m_result(0), m_resultCounter(0) {}

Expand All @@ -69,12 +70,14 @@ class ResultObject : public QObject
void setResult(int result) { m_result = result; m_resultCounter++; }

NestedObject *nested() { return &m_nested; }
NestedObject *nested2() { return &m_nested2; }

private:
int m_result;
int m_resultCounter;

NestedObject m_nested;
NestedObject m_nested2;
};

void registerTypes();
Expand Down
31 changes: 24 additions & 7 deletions tests/auto/qml/v4/tst_v4.cpp
Expand Up @@ -225,17 +225,34 @@ void tst_v4::conditionalExpr()
// NestedObject::result.
void tst_v4::nestedObjectAccess()
{
QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml"));
{
QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml"));

QObject *o = component.create();
QVERIFY(o != 0);
QObject *o = component.create();
QVERIFY(o != 0);

ResultObject *ro = qobject_cast<ResultObject *>(o);
QVERIFY(ro != 0);
ResultObject *ro = qobject_cast<ResultObject *>(o);
QVERIFY(ro != 0);

QCOMPARE(ro->result(), 37);
QCOMPARE(ro->result(), 37);

delete o;
delete o;
}

{
QQmlComponent component(&engine, testFileUrl("nestedObjectAccess2.qml"));

QObject *o = component.create();
QVERIFY(o != 0);

ResultObject *ro = qobject_cast<ResultObject *>(o);
QVERIFY(ro != 0);

QEXPECT_FAIL("","QTBUG-24606", Continue);
QCOMPARE(ro->result(), 37);

delete o;
}
}

void tst_v4::subscriptionsInConditionalExpressions()
Expand Down

0 comments on commit 9ba6a3b

Please sign in to comment.