diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-09 01:00:06 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-03-09 10:54:36 +0100 |
commit | f65c0e7190c4f2ebcadc963cf0647c71de26f3bb (patch) | |
tree | 9e6525274d9aa01d4fff9e059dc5b428cbf2f447 /tests/auto | |
parent | 433f5be47b8245e955bad5a4d3cfcc38354ce62a (diff) | |
parent | d51d5ff3c187821929cf7b765e037423bcc90466 (diff) |
Merge "Merge remote-tracking branch 'origin/5.15' into dev"
Diffstat (limited to 'tests/auto')
16 files changed, 147 insertions, 22 deletions
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index b019ff4535..f636e527c3 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -325,7 +325,8 @@ void tst_qqmlapplicationengine::failureToLoadTriggersWarningSignal() auto url = testFileUrl("invalid.qml"); qRegisterMetaType<QList<QQmlError>>(); QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlApplicationEngine failed to load component"); - QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(url.toString() + QLatin1Char('*'))); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, + QRegularExpression(QRegularExpression::escape(url.toString()) + QLatin1Char('*'))); QQmlApplicationEngine test; QSignalSpy warningObserver(&test, &QQmlApplicationEngine::warnings); test.load(url); diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index db79adac6c..627347df06 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -63,10 +63,10 @@ namespace { for (const QQmlJS::DiagnosticMessage &e : errors) { QString errorString = QLatin1String("qmldir"); - if (e.line > 0) { - errorString += QLatin1Char(':') + QString::number(e.line); - if (e.column > 0) - errorString += QLatin1Char(':') + QString::number(e.column); + if (e.loc.startLine > 0) { + errorString += QLatin1Char(':') + QString::number(e.loc.startLine); + if (e.loc.startColumn > 0) + errorString += QLatin1Char(':') + QString::number(e.loc.startColumn); } errorString += QLatin1String(": ") + e.message; diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 61dc393998..fea5c836e3 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7304,7 +7304,7 @@ void tst_qqmlecmascript::forInLoop() QMetaObject::invokeMethod(object, "listProperty"); - QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts); + QStringList r = object->property("listResult").toString().split("|", Qt::SkipEmptyParts); QCOMPARE(r.size(), 3); QCOMPARE(r[0],QLatin1String("0=obj1")); QCOMPARE(r[1],QLatin1String("1=obj2")); diff --git a/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml new file mode 100644 index 0000000000..3b37c29b18 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml @@ -0,0 +1,5 @@ +import StaticTest 1.0 + +MyStaticSecondNamespacedType { + list: [ MyStaticNamespacedType {} ] +} diff --git a/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml new file mode 100644 index 0000000000..2778baadb9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml @@ -0,0 +1,6 @@ +import StaticTest 1.0 + +MyStaticNamespacedType { + myEnum: MyStaticNamespace.Key5 + property int intProperty: MyStaticNamespace.MyOtherNSEnum.OtherKey2 +} diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro index 724a27320c..6c54525544 100644 --- a/tests/auto/qml/qqmllanguage/qqmllanguage.pro +++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro @@ -1,4 +1,7 @@ -CONFIG += testcase +CONFIG += testcase qmltypes +QML_IMPORT_NAME = StaticTest +QML_IMPORT_VERSION = 1.0 + TARGET = tst_qqmllanguage macx:CONFIG -= app_bundle diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 148179cb9c..8852bf7af9 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -750,6 +750,47 @@ private: bool m_ownRWObj; }; +namespace MyStaticNamespace { + Q_NAMESPACE + QML_ELEMENT + + enum MyNSEnum { + Key1 = 1, + Key2, + Key5 = 5 + }; + Q_ENUM_NS(MyNSEnum); + + enum class MyOtherNSEnum { + OtherKey1 = 1, + OtherKey2 + }; + Q_ENUM_NS(MyOtherNSEnum); + + + class MyNamespacedType : public QObject + { + Q_OBJECT + Q_PROPERTY(MyStaticNamespace::MyNSEnum myEnum MEMBER m_myEnum) + QML_NAMED_ELEMENT(MyStaticNamespacedType) + MyStaticNamespace::MyNSEnum m_myEnum = MyNSEnum::Key1; + }; + + class MySecondNamespacedType : public QObject + { + Q_OBJECT + Q_PROPERTY(QQmlListProperty<MyStaticNamespace::MyNamespacedType> list READ list) + QML_NAMED_ELEMENT(MyStaticSecondNamespacedType) + public: + QQmlListProperty<MyNamespacedType> list() + { + return QQmlListProperty<MyNamespacedType>(this, &m_list); + } + + private: + QList<MyNamespacedType *> m_list; + }; +} namespace MyNamespace { Q_NAMESPACE diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 9440fcaad4..7e053a027d 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -1859,21 +1859,30 @@ void tst_qqmllanguage::valueTypes() void tst_qqmllanguage::cppnamespace() { - { - QQmlComponent component(&engine, testFileUrl("cppnamespace.qml")); + QScopedPointer<QObject> object; + + auto create = [&](const char *file) { + QQmlComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(0); - QScopedPointer<QObject> object(component.create()); + object.reset(component.create()); QVERIFY(object != nullptr); + }; - QCOMPARE(object->property("intProperty").toInt(), (int)MyNamespace::MyOtherNSEnum::OtherKey2); - } + auto createAndCheck = [&](const char *file) { + create(file); + return !QTest::currentTestFailed(); + }; - { - QQmlComponent component(&engine, testFileUrl("cppnamespace.2.qml")); - VERIFY_ERRORS(0); - QScopedPointer<QObject> object(component.create()); - QVERIFY(object != nullptr); - } + QVERIFY(createAndCheck("cppnamespace.qml")); + QCOMPARE(object->property("intProperty").toInt(), + (int)MyNamespace::MyOtherNSEnum::OtherKey2); + + QVERIFY(createAndCheck("cppstaticnamespace.qml")); + QCOMPARE(object->property("intProperty").toInt(), + (int)MyStaticNamespace::MyOtherNSEnum::OtherKey2); + + QVERIFY(createAndCheck("cppnamespace.2.qml")); + QVERIFY(createAndCheck("cppstaticnamespace.2.qml")); } void tst_qqmllanguage::aliasProperties() diff --git a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml index 59af114379..1d3420e186 100644 --- a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml +++ b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml @@ -1,4 +1,5 @@ import QtQuick 2.0 +import QtQml.WorkerScript 2.15 WorkerScript { id: worker diff --git a/tests/auto/quick/qquickitem/data/hellotr_la.qm b/tests/auto/quick/qquickitem/data/hellotr_la.qm Binary files differnew file mode 100644 index 0000000000..25c0aad583 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/hellotr_la.qm diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index ac8c599cc9..137162099f 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -43,6 +43,7 @@ #include "../../shared/util.h" #include "../shared/viewtestutil.h" #include <QSignalSpy> +#include <QTranslator> #ifdef TEST_QTBUG_60123 #include <QWidget> @@ -73,6 +74,7 @@ public: ulong timestamp; QPoint lastWheelEventPos; QPoint lastWheelEventGlobalPos; + int languageChangeEventCount = 0; protected: virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } @@ -89,6 +91,12 @@ protected: lastWheelEventPos = event->position().toPoint(); lastWheelEventGlobalPos = event->globalPosition().toPoint(); } + bool event(QEvent *e) override + { + if (e->type() == QEvent::LanguageChange) + languageChangeEventCount++; + return QQuickItem::event(e); + } }; class TestWindow: public QQuickWindow @@ -201,6 +209,7 @@ private slots: #endif void setParentCalledInOnWindowChanged(); + void receivesLanguageChangeEvent(); private: @@ -2158,6 +2167,32 @@ void tst_qquickitem::setParentCalledInOnWindowChanged() QVERIFY(ensureFocus(&view)); // should not crash } +void tst_qquickitem::receivesLanguageChangeEvent() +{ + QQuickWindow window; + window.setFramePosition(QPoint(100, 100)); + window.resize(200, 200); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QScopedPointer<TestItem> child1(new TestItem); + child1->setObjectName(QStringLiteral("child1")); + child1->setSize(QSizeF(200, 100)); + child1->setParentItem(window.contentItem()); + + QScopedPointer<TestItem> child2(new TestItem); + child2->setObjectName(QStringLiteral("child2")); + child2->setSize(QSizeF(50, 50)); + child2->setParentItem(child1.data()); + + QTranslator t; + QVERIFY(t.load("hellotr_la.qm", dataDirectory())); + QVERIFY(QCoreApplication::installTranslator(&t)); + + QTRY_COMPARE(child1->languageChangeEventCount, 1); + QCOMPARE(child2->languageChangeEventCount, 1); +} + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml new file mode 100644 index 0000000000..042f408753 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.14 + +Item { + width: 400 + height: 200 + Item { + objectName: "hiddenChild" + focus: true + activeFocusOnTab: true + visible: false + } +} diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index a1b4a70217..45ecbfde11 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -64,6 +64,7 @@ private slots: void activeFocusOnTab8(); void activeFocusOnTab9(); void activeFocusOnTab10(); + void activeFocusOnTab_infiniteLoop_data(); void activeFocusOnTab_infiniteLoop(); void nextItemInFocusChain(); @@ -1027,12 +1028,20 @@ void tst_QQuickItem::activeFocusOnTab10() delete window; } +void tst_QQuickItem::activeFocusOnTab_infiniteLoop_data() +{ + QTest::addColumn<QUrl>("source"); + QTest::newRow("infiniteLoop") << testFileUrl("activeFocusOnTab_infiniteLoop.qml"); // QTBUG-68271 + QTest::newRow("infiniteLoop2") << testFileUrl("activeFocusOnTab_infiniteLoop2.qml");// QTBUG-81510 +} + void tst_QQuickItem::activeFocusOnTab_infiniteLoop() { - // see QTBUG-68271 + QFETCH(QUrl, source); + // create a window where the currently focused item is not visible QScopedPointer<QQuickView>window(new QQuickView()); - window->setSource(testFileUrl("activeFocusOnTab_infiniteLoop.qml")); + window->setSource(source); window->show(); auto *hiddenChild = findItem<QQuickItem>(window->rootObject(), "hiddenChild"); QVERIFY(hiddenChild); @@ -1041,6 +1050,8 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop() auto *item = hiddenChild->nextItemInFocusChain(); // focus is moved to the root object since there is no other candidate QCOMPARE(item, window->rootObject()); + item = hiddenChild->nextItemInFocusChain(false); + QCOMPARE(item, window->rootObject()); } void tst_QQuickItem::nextItemInFocusChain() diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index b141e235d5..49b68a8473 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -9867,6 +9867,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() window->resize(640, 480); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QVERIFY(window->rootObject() != nullptr); QQuickListView *listView = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listView != nullptr); diff --git a/tests/auto/shared/qqmljsastdumper.cpp b/tests/auto/shared/qqmljsastdumper.cpp index bc21d8d4e5..1292be8d5b 100644 --- a/tests/auto/shared/qqmljsastdumper.cpp +++ b/tests/auto/shared/qqmljsastdumper.cpp @@ -216,7 +216,7 @@ QString AstDumper::qs(const QStringRef &s) { return qs(s.toString()); } -QString AstDumper::loc(const AST::SourceLocation &s) { +QString AstDumper::loc(const SourceLocation &s) { if (noLocations() || !s.isValid()) return QLatin1String("\"\""); else { diff --git a/tests/auto/shared/qqmljsastdumper.h b/tests/auto/shared/qqmljsastdumper.h index d8d19e351d..5e46e516f0 100644 --- a/tests/auto/shared/qqmljsastdumper.h +++ b/tests/auto/shared/qqmljsastdumper.h @@ -91,7 +91,7 @@ public: QString qs(const char *s); QString qs(const QStringRef &s); - QString loc(const AST::SourceLocation &s); + QString loc(const SourceLocation &s); QString boolStr(bool v); |