aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/sanity/tst_sanity.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-25 21:01:21 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-26 17:26:46 +0000
commitf322d671c75886f1e456c7374b5391d8c94902cf (patch)
treea3798c9aebddccae125d3fa5491869512cbc0fcb /tests/auto/sanity/tst_sanity.cpp
parent7c48f7cce6e59e3cf8d4b3ae173311bbf3624090 (diff)
Fix tst_Sanity::anchors()
Validate with a AST::Visitor that there are no local anchors -bindings in controls. Other QQuickAnchors instances (in QtGraphicalEffects) are now allowed. Change-Id: Ie862f193860eef7a90b6ac0c8e6c930e5cdd8245 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/sanity/tst_sanity.cpp')
-rw-r--r--tests/auto/sanity/tst_sanity.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp
index 6c2e94d8..bc114d62 100644
--- a/tests/auto/sanity/tst_sanity.cpp
+++ b/tests/auto/sanity/tst_sanity.cpp
@@ -222,18 +222,26 @@ void tst_Sanity::signalHandlers_data()
QTest::newRow(qPrintable(it.key())) << it.key() << it.value();
}
+class AnchorValidator : public BaseValidator
+{
+protected:
+ virtual bool visit(QQmlJS::AST::UiScriptBinding *node)
+ {
+ QQmlJS::AST::UiQualifiedId* id = node->qualifiedId;
+ if (id && id->name == QStringLiteral("anchors"))
+ addError("anchors are not allowed", node);
+ return true;
+ }
+};
+
void tst_Sanity::anchors()
{
QFETCH(QString, control);
QFETCH(QString, filePath);
- QQmlComponent component(&engine);
- component.loadUrl(QUrl::fromLocalFile(filePath));
-
- QScopedPointer<QObject> object(component.create());
- QVERIFY(object.data());
- foreach (QObject *object, *qt_qobjects)
- QVERIFY2(!object->inherits("QQuickAnchors"), "Anchors are not allowed");
+ AnchorValidator validator;
+ if (!validator.validate(filePath))
+ QFAIL(qPrintable(validator.errors()));
}
void tst_Sanity::anchors_data()