diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-25 21:01:21 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-26 17:26:46 +0000 |
commit | f322d671c75886f1e456c7374b5391d8c94902cf (patch) | |
tree | a3798c9aebddccae125d3fa5491869512cbc0fcb /tests/auto/sanity | |
parent | 7c48f7cce6e59e3cf8d4b3ae173311bbf3624090 (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')
-rw-r--r-- | tests/auto/sanity/BLACKLIST | 14 | ||||
-rw-r--r-- | tests/auto/sanity/tst_sanity.cpp | 22 |
2 files changed, 15 insertions, 21 deletions
diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index 4f78cf40..f7cff87a 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -4,19 +4,5 @@ * [signalHandlers:material/TextField.qml] * -[anchors:material/Button.qml] -* -[anchors:material/CheckBox.qml] -* -[anchors:material/ItemDelegate.qml] -* -[anchors:material/RadioButton.qml] -* -[anchors:material/RangeSlider.qml] -* -[anchors:material/Slider.qml] -* -[anchors:material/Switch.qml] -* [attachedObjects:material/ItemDelegate.qml] * 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() |