Commit 5e9af2b3 authored by Christian Kamm's avatar Christian Kamm
Browse files

Take builtin properties into account for QML lookup tests.

parent e83c2e40
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
}
}
}
......
......@@ -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 {
......
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
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment