diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmlcomponent/data/callingQmlContext.qml | 13 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 59 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcontext/data/qtbug_53431.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro | 1 | ||||
-rw-r--r-- | tests/auto/qmldevtools/compile/compile.pro | 2 | ||||
-rw-r--r-- | tests/auto/quick/examples/tst_examples.cpp | 12 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 30 | ||||
-rw-r--r-- | tests/auto/shared/imports.pri | 9 |
10 files changed, 119 insertions, 31 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/callingQmlContext.qml b/tests/auto/qml/qqmlcomponent/data/callingQmlContext.qml new file mode 100644 index 0000000000..8193d0f36c --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/callingQmlContext.qml @@ -0,0 +1,13 @@ +import QtQml 2.0 +import qqmlcomponenttest 1.0 +QtObject { + property Component factory + property QtObject incubatedObject + + Component.onCompleted: { + var incubatorState = factory.incubateObject(null, { value: 42 }) + incubatorState.onStatusChanged = function(status) { + incubatedObject = incubatorState.object + } + } +} diff --git a/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml b/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml new file mode 100644 index 0000000000..adf491c87e --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml @@ -0,0 +1,3 @@ +import qqmlcomponenttest 1.0 +CallingContextCheckingClass { +} diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index c1e51410c8..83bf783cf4 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -35,6 +35,7 @@ #include <QtQuick> #include <QtQuick/private/qquickrectangle_p.h> #include <QtQuick/private/qquickmousearea_p.h> +#include <private/qv8engine_p.h> #include <qcolor.h> #include "../../shared/util.h" #include "testhttpserver.h" @@ -111,6 +112,7 @@ private slots: void onDestructionCount(); void recursion(); void recursionContinuation(); + void callingContextForInitialProperties(); private: QQmlEngine engine; @@ -518,6 +520,63 @@ void tst_qqmlcomponent::recursionContinuation() QVERIFY(object->property("success").toBool()); } +class CallingContextCheckingClass : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) +public: + CallingContextCheckingClass() + : m_value(0) + {} + + int value() const { return m_value; } + void setValue(int v) { + scopeObject.clear(); + callingContextData.setContextData(0); + + m_value = v; + QJSEngine *jsEngine = qjsEngine(this); + if (!jsEngine) + return; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(jsEngine); + if (!v4) + return; + QV4::Scope scope(v4); + QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->qmlContext()); + if (!qmlContext) + return; + callingContextData = qmlContext->qmlContext(); + scopeObject = qmlContext->qmlScope(); + } + + int m_value; + QQmlGuardedContextData callingContextData; + QPointer<QObject> scopeObject; +}; + +void tst_qqmlcomponent::callingContextForInitialProperties() +{ + qmlRegisterType<CallingContextCheckingClass>("qqmlcomponenttest", 1, 0, "CallingContextCheckingClass"); + + QQmlComponent testFactory(&engine, testFileUrl("callingQmlContextComponent.qml")); + + QQmlComponent component(&engine, testFileUrl("callingQmlContext.qml")); + QScopedPointer<QObject> root(component.beginCreate(engine.rootContext())); + QVERIFY(!root.isNull()); + root->setProperty("factory", QVariant::fromValue(&testFactory)); + component.completeCreate(); + QTRY_VERIFY(qvariant_cast<QObject *>(root->property("incubatedObject"))); + QObject *o = qvariant_cast<QObject *>(root->property("incubatedObject")); + CallingContextCheckingClass *checker = qobject_cast<CallingContextCheckingClass*>(o); + QVERIFY(checker); + + QVERIFY(!checker->callingContextData.isNull()); + QVERIFY(checker->callingContextData->urlString().endsWith(QStringLiteral("callingQmlContext.qml"))); + + QVERIFY(!checker->scopeObject.isNull()); + QVERIFY(checker->scopeObject->metaObject()->indexOfProperty("incubatedObject") != -1); +} + QTEST_MAIN(tst_qqmlcomponent) #include "tst_qqmlcomponent.moc" diff --git a/tests/auto/qml/qqmlcontext/data/qtbug_53431.qml b/tests/auto/qml/qqmlcontext/data/qtbug_53431.qml new file mode 100644 index 0000000000..2ceee2bade --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/qtbug_53431.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +QtObject { + property int value: { + console.log("lookup in global object") + return 1 + } +} diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index edbf0869e8..e0cde6c86f 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -56,6 +56,7 @@ private slots: void refreshExpressions(); void refreshExpressionsCrash(); void refreshExpressionsRootContext(); + void skipExpressionRefresh_qtbug_53431(); void qtbug_22535(); void evalAfterInvalidate(); @@ -637,6 +638,19 @@ void tst_qqmlcontext::refreshExpressionsRootContext() delete o1; } +void tst_qqmlcontext::skipExpressionRefresh_qtbug_53431() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("qtbug_53431.qml")); + QScopedPointer<QObject> object(component.create(0)); + QVERIFY(!object.isNull()); + QCOMPARE(object->property("value").toInt(), 1); + object->setProperty("value", 10); + QCOMPARE(object->property("value").toInt(), 10); + engine.rootContext()->setContextProperty("randomContextProperty", 42); + QCOMPARE(object->property("value").toInt(), 10); +} + void tst_qqmlcontext::qtbug_22535() { QQmlEngine engine; diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro index 76544aa553..3eeb0008bd 100644 --- a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro @@ -6,7 +6,6 @@ DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType.2 QT += core-private gui-private qml-private -IMPORT_DIR = DESTDIR IMPORT_FILES = \ qmldir diff --git a/tests/auto/qmldevtools/compile/compile.pro b/tests/auto/qmldevtools/compile/compile.pro index 71d91c107d..54430eb668 100644 --- a/tests/auto/qmldevtools/compile/compile.pro +++ b/tests/auto/qmldevtools/compile/compile.pro @@ -5,7 +5,7 @@ force_bootstrap { !build_pass: CONFIG += release } else { QT = core - !build_pass:contains(QT_CONFIG, build_all): CONFIG += release + !build_pass:contains(QT_CONFIG, debug_and_release): CONFIG += release } QT += qmldevtools-private macx:CONFIG -= app_bundle diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 548b20a80a..233cb33631 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -74,15 +74,14 @@ private: tst_examples::tst_examples() { // Add files to exclude here - excludedFiles << "examples/quick/canvas/tiger/tiger.qml"; // QTBUG-26528 excludedFiles << "snippets/qml/listmodel/listmodel.qml"; //Just a ListModel, no root QQuickItem excludedFiles << "examples/quick/demos/photosurface/photosurface.qml"; // root item is Window rather than Item - // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/) + // Add directories you want excluded here excludedDirs << "shared"; //Not an example - excludedDirs << "quick/text/fonts"; // QTBUG-29004 excludedDirs << "snippets/qml/path"; //No root QQuickItem - excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir + excludedDirs << "examples/qml/qmlextensionplugins"; //Requires special import search path + excludedDirs << "examples/quick/tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir // These snippets are not expected to run on their own. excludedDirs << "snippets/qml/visualdatamodel_rootindex"; @@ -170,9 +169,8 @@ void tst_examples::namingConvention(const QDir &d) void tst_examples::namingConvention() { QStringList examplesLocations; - examplesLocations << QLibraryInfo::location(QLibraryInfo::ExamplesPath) + QLatin1String("/qtdeclarative"); - examplesLocations << QLibraryInfo::location(QLibraryInfo::ExamplesPath) + QLatin1String("/qtquick"); - examplesLocations << QLibraryInfo::location(QLibraryInfo::ExamplesPath) + QLatin1String("/qtqml"); + examplesLocations << QLibraryInfo::location(QLibraryInfo::ExamplesPath) + QLatin1String("/qml"); + examplesLocations << QLibraryInfo::location(QLibraryInfo::ExamplesPath) + QLatin1String("/quick"); foreach(const QString &examples, examplesLocations) { QDir d(examples); diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index f19a5ea167..fb8900649f 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -3420,16 +3420,15 @@ void tst_qquicktextinput::focusOnPress() QCOMPARE(textInputObject->hasFocus(), false); QCOMPARE(textInputObject->hasActiveFocus(), false); - QPoint centerPoint(window.width()/2, window.height()/2); Qt::KeyboardModifiers noModifiers = 0; - QTest::mousePress(&window, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&window, Qt::LeftButton, noModifiers); QGuiApplication::processEvents(); QCOMPARE(textInputObject->hasFocus(), true); QCOMPARE(textInputObject->hasActiveFocus(), true); QCOMPARE(focusSpy.count(), 1); QCOMPARE(activeFocusSpy.count(), 1); QCOMPARE(textInputObject->selectedText(), QString()); - QTest::mouseRelease(&window, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&window, Qt::LeftButton, noModifiers); textInputObject->setFocusOnPress(false); QCOMPARE(textInputObject->focusOnPress(), false); @@ -3443,13 +3442,13 @@ void tst_qquicktextinput::focusOnPress() // Wait for double click timeout to expire before clicking again. QTest::qWait(400); - QTest::mousePress(&window, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&window, Qt::LeftButton, noModifiers); QGuiApplication::processEvents(); QCOMPARE(textInputObject->hasFocus(), false); QCOMPARE(textInputObject->hasActiveFocus(), false); QCOMPARE(focusSpy.count(), 2); QCOMPARE(activeFocusSpy.count(), 2); - QTest::mouseRelease(&window, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&window, Qt::LeftButton, noModifiers); textInputObject->setFocusOnPress(true); QCOMPARE(textInputObject->focusOnPress(), true); @@ -3459,14 +3458,14 @@ void tst_qquicktextinput::focusOnPress() textInputObject->setProperty("selectOnFocus", true); QTest::qWait(400); - QTest::mousePress(&window, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&window, Qt::LeftButton, noModifiers); QGuiApplication::processEvents(); QCOMPARE(textInputObject->hasFocus(), true); QCOMPARE(textInputObject->hasActiveFocus(), true); QCOMPARE(focusSpy.count(), 3); QCOMPARE(activeFocusSpy.count(), 3); QCOMPARE(textInputObject->selectedText(), textInputObject->text()); - QTest::mouseRelease(&window, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&window, Qt::LeftButton, noModifiers); } void tst_qquicktextinput::openInputPanel() @@ -3490,23 +3489,22 @@ void tst_qquicktextinput::openInputPanel() QCOMPARE(qApp->inputMethod()->isVisible(), false); // input panel should open on focus - QPoint centerPoint(view.width()/2, view.height()/2); Qt::KeyboardModifiers noModifiers = 0; - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&view, Qt::LeftButton, noModifiers); QGuiApplication::processEvents(); QVERIFY(input->hasActiveFocus()); QCOMPARE(qApp->focusObject(), input); QCOMPARE(qApp->inputMethod()->isVisible(), true); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers); // input panel should be re-opened when pressing already focused TextInput qApp->inputMethod()->hide(); QCOMPARE(qApp->inputMethod()->isVisible(), false); QVERIFY(input->hasActiveFocus()); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&view, Qt::LeftButton, noModifiers); QGuiApplication::processEvents(); QCOMPARE(qApp->inputMethod()->isVisible(), true); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers); // input panel should stay visible if focus is lost to another text inputor QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged())); @@ -3529,8 +3527,8 @@ void tst_qquicktextinput::openInputPanel() input->setReadOnly(true); input->setFocus(true); QCOMPARE(qApp->inputMethod()->isVisible(), false); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&view, Qt::LeftButton, noModifiers); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers); QGuiApplication::processEvents(); QCOMPARE(qApp->inputMethod()->isVisible(), false); @@ -3539,8 +3537,8 @@ void tst_qquicktextinput::openInputPanel() input->setFocus(false); input->setFocus(true); QCOMPARE(qApp->inputMethod()->isVisible(), false); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mousePress(&view, Qt::LeftButton, noModifiers); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers); QCOMPARE(qApp->inputMethod()->isVisible(), false); } diff --git a/tests/auto/shared/imports.pri b/tests/auto/shared/imports.pri index 20e9bcb371..9cbf286386 100644 --- a/tests/auto/shared/imports.pri +++ b/tests/auto/shared/imports.pri @@ -1,7 +1,4 @@ -copyimportfiles.input = IMPORT_FILES -copyimportfiles.output = $$DESTDIR/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT} -copyimportfiles.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} -copyimportfiles.CONFIG += no_link_no_clean -copyimportfiles.variable_out = PRE_TARGETDEPS -QMAKE_EXTRA_COMPILERS += copyimportfiles +importfiles.files = $$IMPORT_FILES +importfiles.path = $$DESTDIR +COPIES += importfiles |