From 5e9af2b3e008b9076b30523028008659ac13c3a6 Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Wed, 13 Jan 2010 15:05:53 +0100 Subject: [PATCH] Take builtin properties into account for QML lookup tests. --- .../qmleditor/lookup/data/localIdLookup.qml | 62 +++++++++---------- .../qmleditor/lookup/data/localRootLookup.qml | 2 +- .../lookup/data/localScriptMethodLookup.qml | 26 ++++---- .../auto/qml/qmleditor/lookup/tst_lookup.cpp | 36 +++++++---- 4 files changed, 70 insertions(+), 56 deletions(-) diff --git a/tests/auto/qml/qmleditor/lookup/data/localIdLookup.qml b/tests/auto/qml/qmleditor/lookup/data/localIdLookup.qml index 3e30313aab5..fd04eee4abb 100644 --- a/tests/auto/qml/qmleditor/lookup/data/localIdLookup.qml +++ b/tests/auto/qml/qmleditor/lookup/data/localIdLookup.qml @@ -1,45 +1,45 @@ import Qt 4.6 -// Try to look up root, parentItem, foo, child and childChild +// Try to look up x, y, z, opacity and visible // in all symbol contexts. It should always get the right item. Item { - id: root + id: x Script { - function root() {} - function parentItem() {} - function foo() {} - function child() {} - function childChild() {} + function x() {} + function y() {} + function z() {} + function opacity() {} + function visible() {} } - property var root: "wrong"; - property var parentItem: "wrong"; - property var foo: "wrong"; - property var child: "wrong"; - property var childChild: "wrong"; + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; + property var opacity: "wrong"; + property var visible: "wrong"; Item { - id: parentItem - property var root: "wrong"; - property var parentItem: "wrong"; - property var foo: "wrong"; - property var child: "wrong"; - property var childChild: "wrong"; + id: y + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; + property var opacity: "wrong"; + property var visible: "wrong"; Item { - id: foo - property var root: "wrong"; - property var parentItem: "wrong"; - property var foo: "wrong"; - property var child: "wrong"; - property var childChild: "wrong"; + id: z + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; + property var opacity: "wrong"; + property var visible: "wrong"; Item { - id: child - property var root: "wrong"; - property var parentItem: "wrong"; - property var foo: "wrong"; - property var child: "wrong"; - property var childChild: "wrong"; + id: opacity + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; + property var opacity: "wrong"; + property var visible: "wrong"; Item { - id: childChild + id: visible } } } diff --git a/tests/auto/qml/qmleditor/lookup/data/localRootLookup.qml b/tests/auto/qml/qmleditor/lookup/data/localRootLookup.qml index c7bf847cbdd..bc512720ee0 100644 --- a/tests/auto/qml/qmleditor/lookup/data/localRootLookup.qml +++ b/tests/auto/qml/qmleditor/lookup/data/localRootLookup.qml @@ -3,7 +3,7 @@ import Qt 4.6 // Try to look up prop in child. // It should get the root's prop. -Item { +Rectangle { id: theRoot property var prop Item { diff --git a/tests/auto/qml/qmleditor/lookup/data/localScriptMethodLookup.qml b/tests/auto/qml/qmleditor/lookup/data/localScriptMethodLookup.qml index 0d2004df7d2..a4e535a9ae4 100644 --- a/tests/auto/qml/qmleditor/lookup/data/localScriptMethodLookup.qml +++ b/tests/auto/qml/qmleditor/lookup/data/localScriptMethodLookup.qml @@ -1,32 +1,32 @@ import Qt 4.6 -// Try to look up rootFunc, parentFunc, childFunc +// Try to look up x, y, z // in all symbol contexts. It should always get the function. Item { id: theRoot Script { - function rootFunc() {} + function x() {} } - property var rootFunc: "wrong"; - property var parentFunc: "wrong"; - property var childFunc: "wrong"; + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; Item { id: theParent Script { - function parentFunc() {} + function y() {} } - property var rootFunc: "wrong"; - property var parentFunc: "wrong"; - property var childFunc: "wrong"; + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; Item { id: theChild Script { - function childFunc() {} + function z() {} } - property var rootFunc: "wrong"; - property var parentFunc: "wrong"; - property var childFunc: "wrong"; + property var x: "wrong"; + property var y: "wrong"; + property var z: "wrong"; } } } \ No newline at end of file diff --git a/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp b/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp index 9e869cd38f6..516294bb0d7 100644 --- a/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp +++ b/tests/auto/qml/qmleditor/lookup/tst_lookup.cpp @@ -178,11 +178,11 @@ void tst_Lookup::localIdLookup() QVERIFY(doc->isParsedCorrectly()); QStringList symbolNames; - symbolNames.append("root"); - symbolNames.append("parentItem"); - symbolNames.append("foo"); - symbolNames.append("child"); - symbolNames.append("childChild"); + symbolNames.append("x"); + symbolNames.append("y"); + symbolNames.append("z"); + symbolNames.append("opacity"); + symbolNames.append("visible"); // check symbol existence foreach (const QString &symbolName, symbolNames) { @@ -215,9 +215,9 @@ void tst_Lookup::localScriptMethodLookup() symbolNames.append("theChild"); QStringList functionNames; - functionNames.append("rootFunc"); - functionNames.append("parentFunc"); - functionNames.append("childFunc"); + functionNames.append("x"); + functionNames.append("y"); + functionNames.append("z"); // check symbol existence foreach (const QString &symbolName, symbolNames) { @@ -232,7 +232,8 @@ void tst_Lookup::localScriptMethodLookup() foreach (const QString &functionName, functionNames) { QmlSymbol *symbol = context.resolve(functionName); - QVERIFY(symbol && !symbol->isProperty()); + QVERIFY(symbol); + QVERIFY(!symbol->isProperty()); // verify that it's a function } } @@ -262,10 +263,16 @@ void tst_Lookup::localScopeLookup() scopes.push_back(doc->ids()[contextSymbolName]); QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem()); - QmlSymbol *symbol = context.resolve("prop"); + QmlSymbol *symbol; + symbol = context.resolve("prop"); QVERIFY(symbol); QVERIFY(symbol->isPropertyDefinitionSymbol()); QVERIFY(doc->ids()[contextSymbolName]->members().contains(symbol)); + + symbol = context.resolve("x"); + QVERIFY(symbol); + QVERIFY(symbol->isProperty()); + QVERIFY(doc->ids()[contextSymbolName]->members().contains(symbol)); } } @@ -292,10 +299,17 @@ void tst_Lookup::localRootLookup() // try lookup QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem()); - QmlSymbol *symbol = context.resolve("prop"); + + QmlSymbol *symbol; + symbol = context.resolve("prop"); QVERIFY(symbol); QVERIFY(symbol->isPropertyDefinitionSymbol()); QVERIFY(doc->ids()[symbolNames[0]]->members().contains(symbol)); + + symbol = context.resolve("color"); + QVERIFY(symbol); + QVERIFY(symbol->isProperty()); + QVERIFY(doc->ids()[symbolNames[0]]->members().contains(symbol)); } QTEST_APPLESS_MAIN(tst_Lookup) -- GitLab