aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp16
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp39
-rw-r--r--tests/auto/quick/qquickapplication/tst_qquickapplication.cpp56
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp1
4 files changed, 87 insertions, 25 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index b75f069fab..94494df4c0 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -1759,6 +1759,22 @@ void tst_QJSEngine::stacktrace()
QJSValue result2 = eng.evaluate(script2, fileName);
QVERIFY(!result2.isError());
QVERIFY(result2.isString());
+
+ {
+ QString script3 = QString::fromLatin1(
+ "'use strict'\n"
+ "function throwUp() { throw new Error('up') }\n"
+ "function indirectlyThrow() { return throwUp() }\n"
+ "indirectlyThrow()\n"
+ );
+ QJSValue result3 = eng.evaluate(script3);
+ QVERIFY(result3.isError());
+ QJSValue stack = result3.property("stack");
+ QVERIFY(stack.isString());
+ QString stackTrace = stack.toString();
+ QVERIFY(!stackTrace.contains(QStringLiteral("indirectlyThrow")));
+ QVERIFY(stackTrace.contains(QStringLiteral("elide")));
+ }
}
void tst_QJSEngine::numberParsing_data()
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index e83dac48fb..7139a1c952 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -35,6 +35,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlpropertyvalueinterceptor_p.h>
+#include <private/qqmlengine_p.h>
#include <private/qhashedstring_p.h>
#include "../../shared/util.h"
@@ -64,6 +65,7 @@ private slots:
void unregisterCustomSingletonType();
void normalizeUrls();
+ void unregisterAttachedProperties();
};
class TestType : public QObject
@@ -533,6 +535,43 @@ void tst_qqmlmetatype::normalizeUrls()
QVERIFY(!QQmlMetaType::qmlType(url, /*includeNonFileImports=*/true).isValid());
}
+void tst_qqmlmetatype::unregisterAttachedProperties()
+{
+ qmlClearTypeRegistrations();
+
+ const QUrl dummy("qrc:///doesnotexist.qml");
+ {
+ QQmlEngine e;
+ QQmlComponent c(&e);
+ c.setData("import QtQuick 2.2\n Item { }", dummy);
+
+ const QQmlType attachedType = QQmlMetaType::qmlType("QtQuick/KeyNavigation", 2, 2);
+ QCOMPARE(attachedType.attachedPropertiesId(QQmlEnginePrivate::get(&e)),
+ attachedType.index());
+
+ QVERIFY(c.create());
+ }
+
+ qmlClearTypeRegistrations();
+ {
+ QQmlEngine e;
+ QQmlComponent c(&e);
+
+ // The extra import shuffles the type IDs around, so that we
+ // get a different ID for the attached properties. If the attached
+ // properties aren't properly cleared, this will crash.
+ c.setData("import QtQml.StateMachine 1.0 \n"
+ "import QtQuick 2.2 \n"
+ "Item { KeyNavigation.up: null }", dummy);
+
+ const QQmlType attachedType = QQmlMetaType::qmlType("QtQuick/KeyNavigation", 2, 2);
+ QCOMPARE(attachedType.attachedPropertiesId(QQmlEnginePrivate::get(&e)),
+ attachedType.index());
+
+ QVERIFY(c.create());
+ }
+}
+
QTEST_MAIN(tst_qqmlmetatype)
#include "tst_qqmlmetatype.moc"
diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
index 62027f59f4..3526eb98be 100644
--- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
+++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
@@ -88,31 +88,37 @@ void tst_qquickapplication::active()
QQuickWindow window;
item->setParentItem(window.contentItem());
- // not active
- QVERIFY(!item->property("active").toBool());
- QVERIFY(!item->property("active2").toBool());
-
- // active
- window.show();
- window.requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(&window));
- QCOMPARE(QGuiApplication::focusWindow(), &window);
- QVERIFY(item->property("active").toBool());
- QVERIFY(item->property("active2").toBool());
-
- QWindowSystemInterface::handleWindowActivated(nullptr);
-
-#ifdef Q_OS_OSX
- // OS X has the concept of "reactivation"
- QTRY_VERIFY(QGuiApplication::focusWindow() != &window);
- QVERIFY(item->property("active").toBool());
- QVERIFY(item->property("active2").toBool());
-#else
- // not active again
- QTRY_VERIFY(QGuiApplication::focusWindow() != &window);
- QVERIFY(!item->property("active").toBool());
- QVERIFY(!item->property("active2").toBool());
-#endif
+ // If the platform plugin has the ApplicationState capability, app activation originate from it
+ // as a result of a system event. We therefore have to simulate these events here.
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) {
+
+ // Flush pending events, in case the platform have already queued real application state events
+ QWindowSystemInterface::flushWindowSystemEvents();
+
+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
+ QWindowSystemInterface::flushWindowSystemEvents();
+ QVERIFY(item->property("active").toBool());
+ QVERIFY(item->property("active2").toBool());
+
+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
+ QWindowSystemInterface::flushWindowSystemEvents();
+ QVERIFY(!item->property("active").toBool());
+ QVERIFY(!item->property("active2").toBool());
+ } else {
+ // Otherwise, app activation is triggered by window activation.
+ window.show();
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QCOMPARE(QGuiApplication::focusWindow(), &window);
+ QVERIFY(item->property("active").toBool());
+ QVERIFY(item->property("active2").toBool());
+
+ // not active again
+ QWindowSystemInterface::handleWindowActivated(nullptr);
+ QTRY_VERIFY(QGuiApplication::focusWindow() != &window);
+ QVERIFY(!item->property("active").toBool());
+ QVERIFY(!item->property("active2").toBool());
+ }
}
void tst_qquickapplication::state()
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 8d3abb7ce3..bf38d2d926 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -1372,6 +1372,7 @@ void tst_QQuickPathView::package()
QSKIP("QTBUG-27170 view does not reliably receive polish without a running animation");
#endif
+ QQuickTest::qWaitForItemPolished(pathView);
QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem");
QVERIFY(item);
QVERIFY(item->scale() != 1.0);