diff options
Diffstat (limited to 'tests')
32 files changed, 790 insertions, 77 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp index bca40e9acd..4a8025c254 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -124,7 +124,7 @@ void tst_QQmlDebugClient::state() QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable); // duplicate plugin name - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\" "); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\""); QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn); QCOMPARE(client2.state(), QQmlDebugClient::NotConnected); diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 1c1d84f37b..c50bb10035 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -164,7 +164,7 @@ void tst_QQmlDebugService::state() QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable); - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\" "); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\""); QQmlDebugTestService duplicate("tst_QQmlDebugService::state()"); QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected); } @@ -183,7 +183,7 @@ void tst_QQmlDebugService::sendMessage() QByteArray resp = client.waitForResponse(); QCOMPARE(resp, msg); - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\" "); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\""); QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()"); duplicate.sendMessage("msg"); } diff --git a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml index 7e85312692..cd68fb9b82 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml @@ -91,4 +91,15 @@ QtObject { testObjectWithAliasHandler.count++ return testObjectWithAliasHandler.testSuccess } + + signal signalWithClosureArgument(var f) + onSignalWithClosureArgument: f() + + function testSignalWithClosureArgument() { + var testSuccess = false + signalWithClosureArgument(function() { + testSuccess = true + }) + return testSuccess + } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c45750caac..b11ad2dd0e 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3910,7 +3910,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { QV4::Scope scope(v4); QV4::ScopedArrayObject scripts(scope, ctxt->importedScripts); QV4::ScopedValue qml(scope); - for (quint32 i = 0; i < scripts->arrayLength(); ++i) { + for (quint32 i = 0; i < scripts->getLength(); ++i) { QQmlContextData *scriptContext, *newContext; qml = scripts->getIndexed(i); @@ -6069,6 +6069,9 @@ void tst_qqmlecmascript::signalHandlers() QMetaObject::invokeMethod(o, "testAliasSignalHandler", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); + QMetaObject::invokeMethod(o, "testSignalWithClosureArgument", Q_RETURN_ARG(QVariant, result)); + QCOMPARE(result.toBool(), true); + delete o; } diff --git a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp index 44fbb0a982..c3d8a1502c 100644 --- a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp +++ b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp @@ -203,7 +203,7 @@ void tst_qqmlerror::debug() error.setLine(92); error.setColumn(13); - QTest::ignoreMessage(QtWarningMsg, "http://www.qt-project.org/main.qml:92:13: An Error "); + QTest::ignoreMessage(QtWarningMsg, "http://www.qt-project.org/main.qml:92:13: An Error"); qWarning() << error; } diff --git a/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp b/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp index 793da64734..2d7e0a8594 100644 --- a/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp +++ b/tests/auto/qml/qqmlglobal/tst_qqmlglobal.cpp @@ -63,7 +63,7 @@ void tst_qqmlglobal::initTestCase() void tst_qqmlglobal::colorProviderWarning() { - const QLatin1String expected("Warning: QQml_colorProvider: no color provider has been set! "); + const QLatin1String expected("Warning: QQml_colorProvider: no color provider has been set!"); QTest::ignoreMessage(QtWarningMsg, expected.data()); QQml_colorProvider(); } diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 0cd4360e67..9d62aa2984 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -500,7 +500,7 @@ void tst_qqmlinstruction::dump() << "8\t\tSTORE_INTEGER\t\t5\t9" << "9\t\tSTORE_BOOL\t\t6\ttrue" << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\"" - << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.qt-project.org\") " + << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.qt-project.org\")" << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\"" << "13\t\tSTORE_DATE\t\t10\t9" << "14\t\tSTORE_TIME\t\t11" diff --git a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp index d5e85f478d..143164841f 100644 --- a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp +++ b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp @@ -1725,11 +1725,11 @@ void tst_qqmllistcompositor::changeDebug() void tst_qqmllistcompositor::groupDebug() { - QTest::ignoreMessage(QtDebugMsg, "Default "); + QTest::ignoreMessage(QtDebugMsg, "Default"); qDebug() << C::Default; - QTest::ignoreMessage(QtDebugMsg, "Cache "); + QTest::ignoreMessage(QtDebugMsg, "Cache"); qDebug() << C::Cache; - QTest::ignoreMessage(QtDebugMsg, "Group3 "); + QTest::ignoreMessage(QtDebugMsg, "Group3"); qDebug() << Selection; } diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index d565ad557c..0eb38d92e6 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -117,6 +117,7 @@ private slots: void stringLocaleCompare_data(); void stringLocaleCompare(); + void localeAsCppProperty(); private: void addPropertyData(const QString &l); QVariant getProperty(QObject *obj, const QString &locale, const QString &property); @@ -1223,6 +1224,41 @@ void tst_qqmllocale::stringLocaleCompare() QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2)); } +class Calendar : public QObject +{ + Q_OBJECT + Q_PROPERTY(QLocale locale READ locale WRITE setLocale) +public: + Calendar() { + } + + QLocale locale() const { + return mLocale; + } + + void setLocale(const QLocale &locale) { + mLocale = locale; + } +private: + QLocale mLocale; +}; + +void tst_qqmllocale::localeAsCppProperty() +{ + QQmlComponent component(&engine); + qmlRegisterType<Calendar>("Test", 1, 0, "Calendar"); + component.setData("import QtQml 2.2\nimport Test 1.0\nCalendar { locale: Qt.locale('en_GB'); property var testLocale }", QUrl()); + QVERIFY(!component.isError()); + QTRY_VERIFY(component.isReady()); + + Calendar *item = qobject_cast<Calendar*>(component.create()); + QCOMPARE(item->property("locale").toLocale().name(), QLatin1String("en_GB")); + + QVariant localeVariant(QLocale("nb_NO")); + item->setProperty("testLocale", localeVariant); + QCOMPARE(item->property("testLocale").toLocale().name(), QLatin1String("nb_NO")); +} + class DateFormatter : public QObject { Q_OBJECT diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp index b1f83fcd6c..b0c7c5e81a 100644 --- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp +++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp @@ -329,11 +329,11 @@ void tst_QQmlMetaObject::method_data() << (QList<QByteArray>() << "int" << "bool" << "double") << (QList<QByteArray>() << "foo" << "bar" << "baz"); QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml" - << "testSignal(QVariant,QVariant)" + << "testSignal(QVariant,QJSValue)" << QMetaMethod::Signal << int(QMetaType::Void) << "void" - << (QList<int>() << QMetaType::QVariant << QMetaType::QVariant) - << (QList<QByteArray>() << "QVariant" << "QVariant") + << (QList<int>() << QMetaType::QVariant << qMetaTypeId<QJSValue>()) + << (QList<QByteArray>() << "QVariant" << "QJSValue") << (QList<QByteArray>() << "foo" << "bar"); QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml" << "testSignal(QColor,QDateTime,QUrl)" diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 62b64a3ef1..669ae7d5ea 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -123,21 +123,21 @@ void tst_QQmlPropertyMap::insert() //inserting property names same with existing method(signal, slot, method) names is not allowed //QQmlPropertyMap has an invokable keys() method - QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. "); + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("keys"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("keys"))); QVERIFY(map.value(QLatin1String("keys")).isNull()); //QQmlPropertyMap has a deleteLater() slot - QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. "); + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("deleteLater"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("deleteLater"))); QVERIFY(map.value(QLatin1String("deleteLater")).isNull()); //QQmlPropertyMap has an valueChanged() signal - QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. "); + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("valueChanged"), 1); QVERIFY(map.keys().count() == 2); QVERIFY(!map.contains(QLatin1String("valueChanged"))); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 7c0507dce3..5b8695f8f8 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -804,7 +804,7 @@ void tst_qqmlvaluetypes::font() // Test pixelSize and pointSize { QQmlComponent component(&engine, testFileUrl("font_write.3.qml")); - QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size."); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); @@ -814,7 +814,7 @@ void tst_qqmlvaluetypes::font() } { QQmlComponent component(&engine, testFileUrl("font_write.4.qml")); - QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size."); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 0ff378e86f..ec1b1de7c0 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -143,50 +143,6 @@ void tst_QQuickAccessible::commonTests() delete view; } - - -QString eventName(const int ev) -{ - switch (ev) { - case 0x0001: return "SoundPlayed"; - case 0x0002: return "Alert"; - case 0x0003: return "ForegroundChanged"; - case 0x0004: return "MenuStart"; - case 0x0005: return "MenuEnd"; - case 0x0006: return "PopupMenuStart"; - case 0x0007: return "PopupMenuEnd"; - case 0x000C: return "ContextHelpStart"; - case 0x000D: return "ContextHelpEnd"; - case 0x000E: return "DragDropStart"; - case 0x000F: return "DragDropEnd"; - case 0x0010: return "DialogStart"; - case 0x0011: return "DialogEnd"; - case 0x0012: return "ScrollingStart"; - case 0x0013: return "ScrollingEnd"; - case 0x0018: return "MenuCommand"; - case 0x8000: return "ObjectCreated"; - case 0x8001: return "ObjectDestroyed"; - case 0x8002: return "ObjectShow"; - case 0x8003: return "ObjectHide"; - case 0x8004: return "ObjectReorder"; - case 0x8005: return "Focus"; - case 0x8006: return "Selection"; - case 0x8007: return "SelectionAdd"; - case 0x8008: return "SelectionRemove"; - case 0x8009: return "SelectionWithin"; - case 0x800A: return "StateChanged"; - case 0x800B: return "LocationChanged"; - case 0x800C: return "NameChanged"; - case 0x800D: return "DescriptionChanged"; - case 0x800E: return "ValueChanged"; - case 0x800F: return "ParentChanged"; - case 0x80A0: return "HelpChanged"; - case 0x80B0: return "DefaultActionChanged"; - case 0x80C0: return "AcceleratorChanged"; - default: return "Unknown Event"; - } -} - void tst_QQuickAccessible::quickAttachedProperties() { { diff --git a/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml b/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml new file mode 100644 index 0000000000..9cf22dc7a1 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 400; height: 400 + + property alias animRunning: springAnim.running + + Rectangle { + objectName: "myRect" + color: "green" + width: 20; height: 20 + + property bool triggered: false + + onXChanged: { + if (!triggered && x > 50 && x < 80) { + triggered = true + x = x //set same value + } + } + + Behavior on x { + SpringAnimation { + id: springAnim + spring: 3 + damping: 0.2 + mass: .5 + } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml b/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml new file mode 100644 index 0000000000..db076bca9a --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/qtbug21549.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + + property int behaviorCount: 0 + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + ScriptAction { script: ++behaviorCount } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index c40abbd55f..5deda2d96b 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -81,6 +81,7 @@ private slots: void delayedRegistration(); void startOnCompleted(); void multipleChangesToValueType(); + void currentValue(); }; void tst_qquickbehaviors::simpleBehavior() @@ -495,6 +496,59 @@ void tst_qquickbehaviors::multipleChangesToValueType() QTRY_COMPARE(text->property("font").value<QFont>(), value); } +//QTBUG-21549 +void tst_qquickbehaviors::currentValue() +{ + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("qtbug21549.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + + QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect"); + QVERIFY(target); + + QCOMPARE(target->x(), qreal(0)); + + target->setProperty("x", 50); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(50)); + + target->setProperty("x", 50); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(50)); + + target->setX(100); + target->setProperty("x", 100); + QCOMPARE(item->property("behaviorCount").toInt(), 1); + QCOMPARE(target->x(), qreal(100)); + + delete item; + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("qtbug21549-2.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + + QQuickRectangle *target = item->findChild<QQuickRectangle*>("myRect"); + QVERIFY(target); + + QCOMPARE(target->x(), qreal(0)); + + target->setProperty("x", 100); + + // the spring animation should smoothly transition to the new value triggered + // in the QML (which should be between 50 and 80); + QTRY_COMPARE(item->property("animRunning").toBool(), true); + QTRY_COMPARE(item->property("animRunning").toBool(), false); + QVERIFY(target->x() > qreal(50) && target->x() < qreal(80)); + + delete item; + } +} + QTEST_MAIN(tst_qquickbehaviors) #include "tst_qquickbehaviors.moc" diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml index bc11d349fa..c658f35d1f 100644 --- a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml +++ b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml @@ -1,5 +1,6 @@ import QtQuick 2.0 import QtTest 1.0 +import QtQuick.Window 2.1 TestCase { id:testCase @@ -10,10 +11,16 @@ TestCase { function cleanupTestCase() { wait(100) //wait for a short while to make sure no leaked textures } + Window { + id: win + visible: true + } + function testData(type) { if (type === "2d") return [ { tag:"image threaded", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Threaded}}, + { tag:"image canvas invisible", properties:{visible: false, width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Threaded}}, // { tag:"image cooperative", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Cooperative}}, { tag:"image immediate", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Immediate}}, // { tag:"fbo cooperative", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Cooperative}}, @@ -24,7 +31,7 @@ TestCase { } function createCanvasObject(data) { - return component.createObject(testCase, data.properties); + return component.createObject(win, data.properties); } function comparePixel(ctx,x,y,r,g,b,a, d) diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index f13039ad95..b92f6354a5 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -180,11 +180,20 @@ CanvasTestCase { tryCompare(c, "availableChangedCount", 1); //scene graph could be available immediately //in this case, we force waiting a short while until the init paint finished - tryCompare(c, "paintedCount", 1); + if (c.visible) { + tryCompare(c, "paintedCount", 1); + } else { + tryCompare(c, "paintedCount", 0); + } ctx.fillRect(0, 0, c.width, c.height); c.toDataURL(); - tryCompare(c, "paintedCount", 2); - tryCompare(c, "paintCount", 1); + if (c.visible) { + tryCompare(c, "paintCount", 1); + tryCompare(c, "paintedCount", 2); + } else { + tryCompare(c, "paintCount", 0); + tryCompare(c, "paintedCount", 1); + } c.destroy(); } function test_loadImage(row) { diff --git a/tests/auto/quick/qquickgridview/data/displayMargin.qml b/tests/auto/quick/qquickgridview/data/displayMargin.qml new file mode 100644 index 0000000000..1086b8defd --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/displayMargin.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Jolla Ltd. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.3 + +Item { + width: 400; height: 400 + + GridView { + id: view + anchors.top: header.bottom + anchors.bottom: footer.top + width: parent.width + + cellWidth: 50 + cellHeight: 25 + + cacheBuffer: 0 + displayMarginBeginning: 60 + displayMarginEnd: 60 + + model: 200 + delegate: Rectangle { + objectName: "delegate" + width: 50 + height: 25 + color: index % 2 ? "steelblue" : "lightsteelblue" + Text { + anchors.centerIn: parent + text: index + } + } + } + + Rectangle { + id: header + width: parent.width; height: 60 + color: "#80FF0000" + } + + Rectangle { + id: footer + anchors.bottom: parent.bottom + width: parent.width; height: 60 + color: "#80FF0000" + } +} diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index f1adb7858f..2ee98c6c61 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -207,6 +207,8 @@ private slots: void moved_topToBottom_RtL_BtT(); void moved_topToBottom_RtL_BtT_data(); + void displayMargin(); + private: QList<int> toIntList(const QVariantList &list); void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes); @@ -6307,6 +6309,43 @@ void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QLi } } +void tst_QQuickGridView::displayMargin() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("displayMargin.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickGridView *gridview = window->rootObject()->findChild<QQuickGridView*>(); + QVERIFY(gridview != 0); + + QQuickItem *content = gridview->contentItem(); + QVERIFY(content != 0); + + QQuickItem *item0; + QQuickItem *item97; + + QVERIFY(item0 = findItem<QQuickItem>(content, "delegate", 0)); + QCOMPARE(delegateVisible(item0), true); + + // the 97th item should be within the end margin + QVERIFY(item97 = findItem<QQuickItem>(content, "delegate", 96)); + QCOMPARE(delegateVisible(item97), true); + + // GridView staggers item creation, so the 118th item should be outside the end margin. + QVERIFY(findItem<QQuickItem>(content, "delegate", 117) == 0); + + // the first delegate should still be within the begin margin + gridview->positionViewAtIndex(20, QQuickGridView::Beginning); + QCOMPARE(delegateVisible(item0), true); + + // the first delegate should now be outside the begin margin + gridview->positionViewAtIndex(36, QQuickGridView::Beginning); + QCOMPARE(delegateVisible(item0), false); + + delete window; +} + QTEST_MAIN(tst_QQuickGridView) #include "tst_qquickgridview.moc" diff --git a/tests/auto/quick/qquickitem/data/visualParentOwnership.qml b/tests/auto/quick/qquickitem/data/visualParentOwnership.qml new file mode 100644 index 0000000000..644d14ba43 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/visualParentOwnership.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + Component { + id: factory + Item {} + } + + property Item keepAliveProperty; + + function createItemWithoutParent() { + return factory.createObject(/*parent*/ null); + } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index ad3c4fc208..f4f2374183 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -49,6 +49,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QDebug> #include <QTimer> +#include <QQmlEngine> #include "../../shared/util.h" class TestItem : public QQuickItem @@ -167,6 +168,8 @@ private slots: void acceptedMouseButtons(); + void visualParentOwnership(); + private: enum PaintOrderOp { @@ -1754,6 +1757,68 @@ void tst_qquickitem::acceptedMouseButtons() QCOMPARE(item.releaseCount, 3); } +static void gc(QQmlEngine &engine) +{ + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + +void tst_qquickitem::visualParentOwnership() +{ + QQuickView view; + view.setSource(testFileUrl("visualParentOwnership.qml")); + + QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject()); + QVERIFY(root); + + QVariant newObject; + { + QVERIFY(QMetaObject::invokeMethod(root, "createItemWithoutParent", Q_RETURN_ARG(QVariant, newObject))); + QPointer<QQuickItem> newItem = qvariant_cast<QQuickItem*>(newObject); + QVERIFY(!newItem.isNull()); + + QVERIFY(!newItem->parent()); + QVERIFY(!newItem->parentItem()); + + newItem->setParentItem(root); + + gc(*view.engine()); + + QVERIFY(!newItem.isNull()); + newItem->setParentItem(0); + + gc(*view.engine()); + QVERIFY(newItem.isNull()); + } + { + QVERIFY(QMetaObject::invokeMethod(root, "createItemWithoutParent", Q_RETURN_ARG(QVariant, newObject))); + QPointer<QQuickItem> firstItem = qvariant_cast<QQuickItem*>(newObject); + QVERIFY(!firstItem.isNull()); + + firstItem->setParentItem(root); + + QVERIFY(QMetaObject::invokeMethod(root, "createItemWithoutParent", Q_RETURN_ARG(QVariant, newObject))); + QPointer<QQuickItem> secondItem = qvariant_cast<QQuickItem*>(newObject); + QVERIFY(!firstItem.isNull()); + + secondItem->setParentItem(firstItem); + + gc(*view.engine()); + + delete firstItem; + + root->setProperty("keepAliveProperty", newObject); + + gc(*view.engine()); + QVERIFY(!secondItem.isNull()); + + root->setProperty("keepAliveProperty", QVariant()); + + gc(*view.engine()); + QVERIFY(secondItem.isNull()); + } +} QTEST_MAIN(tst_qquickitem) diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 8a4ed5ae4c..64795f9ebe 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -1972,6 +1972,8 @@ void tst_QQuickItem::transforms_data() QTest::addColumn<QTransform>("transform"); QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") << QTransform(1,0,0,0,1,0,10,20,1); + QTest::newRow("matrix4x4") << QByteArray("Matrix4x4 { matrix: Qt.matrix4x4(1,0,0,10, 0,1,0,15, 0,0,1,0, 0,0,0,1) }") + << QTransform(1,0,0,0,1,0,10,15,1); QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") << QTransform(0,1,0,-1,0,0,0,0,1); QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") @@ -1985,7 +1987,7 @@ void tst_QQuickItem::transforms() QFETCH(QByteArray, qml); QFETCH(QTransform, transform); QQmlComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); + component.setData("import QtQuick 2.4\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); QCOMPARE(item->itemTransform(0,0), transform); diff --git a/tests/auto/quick/qquicklistview/data/displayMargin.qml b/tests/auto/quick/qquicklistview/data/displayMargin.qml new file mode 100644 index 0000000000..fde48bc5b9 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/displayMargin.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Jolla Ltd. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.3 + +Item { + width: 400; height: 400 + + ListView { + id: view + anchors.top: header.bottom + anchors.bottom: footer.top + width: parent.width + + cacheBuffer: 0 + displayMarginBeginning: 60 + displayMarginEnd: 60 + + model: 100 + delegate: Rectangle { + objectName: "delegate" + width: parent.width + height: 25 + color: index % 2 ? "steelblue" : "lightsteelblue" + Text { + anchors.centerIn: parent + text: index + } + } + } + + Rectangle { + id: header + width: parent.width; height: 60 + color: "#80FF0000" + } + + Rectangle { + id: footer + anchors.bottom: parent.bottom + width: parent.width; height: 60 + color: "#80FF0000" + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index a0045a244f..f741fec159 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -215,6 +215,7 @@ private slots: void testProxyModelChangedAfterMove(); void typedModel(); + void displayMargin(); void highlightItemGeometryChanges(); @@ -7039,6 +7040,43 @@ void tst_QQuickListView::typedModel() QCOMPARE(listview->count(), 0); } +void tst_QQuickListView::displayMargin() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("displayMargin.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>(); + QVERIFY(listview != 0); + + QQuickItem *content = listview->contentItem(); + QVERIFY(content != 0); + + QQuickItem *item0; + QQuickItem *item14; + + QVERIFY(item0 = findItem<QQuickItem>(content, "delegate", 0)); + QCOMPARE(delegateVisible(item0), true); + + // the 14th item should be within the end margin + QVERIFY(item14 = findItem<QQuickItem>(content, "delegate", 13)); + QCOMPARE(delegateVisible(item14), true); + + // the 15th item should be outside the end margin + QVERIFY(findItem<QQuickItem>(content, "delegate", 14) == 0); + + // the first delegate should still be within the begin margin + listview->positionViewAtIndex(3, QQuickListView::Beginning); + QCOMPARE(delegateVisible(item0), true); + + // the first delegate should now be outside the begin margin + listview->positionViewAtIndex(4, QQuickListView::Beginning); + QCOMPARE(delegateVisible(item0), false); + + delete window; +} + void tst_QQuickListView::highlightItemGeometryChanges() { QQmlEngine engine; diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp index 204a3ff019..1fed2ecda8 100644 --- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp +++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtTest/QSignalSpy> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> @@ -54,6 +55,7 @@ public: private slots: void gradient(); + void antialiasing(); private: QQmlEngine engine; @@ -87,6 +89,61 @@ void tst_qquickrectangle::gradient() delete rect; } +void tst_qquickrectangle::antialiasing() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Rectangle {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(object.data()); + QVERIFY(rect); + + QSignalSpy spy(rect, SIGNAL(antialiasingChanged(bool))); + + QCOMPARE(rect->antialiasing(), false); + + rect->setAntialiasing(true); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 1); + + rect->setAntialiasing(true); + QCOMPARE(spy.count(), 1); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 2); + + rect->setRadius(5); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 3); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 3); + + rect->setRadius(0); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 4); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 4); + + rect->setRadius(5); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 5); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 5); + + rect->setAntialiasing(false); + QCOMPARE(rect->antialiasing(), false); + QCOMPARE(spy.count(), 6); + + rect->resetAntialiasing(); + QCOMPARE(rect->antialiasing(), true); + QCOMPARE(spy.count(), 7); +} QTEST_MAIN(tst_qquickrectangle) diff --git a/tests/auto/quick/qquicktext/data/lineLayoutHAlign.qml b/tests/auto/quick/qquicktext/data/lineLayoutHAlign.qml new file mode 100644 index 0000000000..6349f7a644 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/lineLayoutHAlign.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: main + width: 200; height: 200 + + Text { + id: myText + objectName: "myText" + width: parent.width + font.family: "__Qt__Box__Engine__" + font.pixelSize: 14 + horizontalAlignment: Text.AlignHCenter + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit." + + onLineLaidOut: { + // do nothing + } + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 78e03be9c2..d241ac2d70 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -101,6 +101,7 @@ private slots: void color(); void smooth(); void renderType(); + void antialiasing(); // QQuickFontValueType void weight(); @@ -126,6 +127,7 @@ private slots: void clipRect(); void lineLaidOut(); void lineLaidOutRelayout(); + void lineLaidOutHAlign(); void imgTagsBaseUrl_data(); void imgTagsBaseUrl(); @@ -901,6 +903,8 @@ void tst_qquicktext::hAlignImplicitWidth() { // HCenter Align text->setHAlign(QQuickText::AlignHCenter); + text->setText("Reset"); // set dummy string to force relayout once original text is set again + text->setText("AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"); QImage image = view.grabWindow(); const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); @@ -911,6 +915,8 @@ void tst_qquicktext::hAlignImplicitWidth() { // Right Align text->setHAlign(QQuickText::AlignRight); + text->setText("Reset"); // set dummy string to force relayout once original text is set again + text->setText("AA\nBBBBBBB\nCCCCCCCCCCCCCCCC"); QImage image = view.grabWindow(); const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); @@ -1306,6 +1312,30 @@ void tst_qquicktext::renderType() QCOMPARE(spy.count(), 2); } +void tst_qquicktext::antialiasing() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Text {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickText *text = qobject_cast<QQuickText *>(object.data()); + QVERIFY(text); + + QSignalSpy spy(text, SIGNAL(antialiasingChanged(bool))); + + QCOMPARE(text->antialiasing(), true); + + text->setAntialiasing(false); + QCOMPARE(text->antialiasing(), false); + QCOMPARE(spy.count(), 1); + + text->setAntialiasing(false); + QCOMPARE(spy.count(), 1); + + text->resetAntialiasing(); + QCOMPARE(text->antialiasing(), true); + QCOMPARE(spy.count(), 2); +} + void tst_qquicktext::weight() { { @@ -2630,6 +2660,23 @@ void tst_qquicktext::lineLaidOutRelayout() delete window; } +void tst_qquicktext::lineLaidOutHAlign() +{ + QQuickView *window = createView(testFile("lineLayoutHAlign.qml")); + + QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText"); + QVERIFY(myText != 0); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); + QVERIFY(textPrivate != 0); + + QCOMPARE(textPrivate->layout.lineCount(), 1); + + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().x() < 0.0); + + delete window; +} + void tst_qquicktext::imgTagsBaseUrl_data() { QTest::addColumn<QUrl>("src"); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ff9554718b..8bf9d14a56 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2663,8 +2663,8 @@ void tst_qquicktextedit::delegateLoading_data() // import installed QTest::newRow("pass") << "cursorHttpTestPass.qml" << ""; - QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection "; - QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type "; + QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection"; + QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type"; } void tst_qquicktextedit::delegateLoading() diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index 02c00ff073..9b4fd2b32f 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -225,7 +225,7 @@ void tst_QQuickView::engine() QCOMPARE(view3->engine(), view4->engine()); delete view3; QVERIFY(!view4->engine()); - QTest::ignoreMessage(QtWarningMsg, "QQuickView: invalid qml engine. "); + QTest::ignoreMessage(QtWarningMsg, "QQuickView: invalid qml engine."); view4->setSource(QUrl()); QCOMPARE(view4->status(), QQuickView::Error); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 107d1d71f7..bdd70f6a6e 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -250,6 +250,18 @@ int TestTouchItem::mousePressNum = 0; int TestTouchItem::mouseMoveNum = 0; int TestTouchItem::mouseReleaseNum = 0; +class EventFilter : public QObject +{ +public: + bool eventFilter(QObject *watched, QEvent *event) { + Q_UNUSED(watched); + events.append(event->type()); + return false; + } + + QList<int> events; +}; + class ConstantUpdateItem : public QQuickItem { Q_OBJECT @@ -331,6 +343,10 @@ private slots: void crashWhenHoverItemDeleted(); + void qobjectEventFilter_touch(); + void qobjectEventFilter_key(); + void qobjectEventFilter_mouse(); + #ifndef QT_NO_CURSOR void cursor(); #endif @@ -923,6 +939,9 @@ void tst_qquickwindow::mouseFiltering() QTRY_COMPARE(middleItem->mousePressId, 1); QTRY_COMPARE(bottomItem->mousePressId, 2); QTRY_COMPARE(topItem->mousePressId, 3); + + // clean up mouse press state for the next tests + QTest::mouseRelease(window, Qt::LeftButton, 0, pos); } void tst_qquickwindow::qmlCreation() @@ -1560,6 +1579,84 @@ void tst_qquickwindow::crashWhenHoverItemDeleted() } } +// QTBUG-32004 +void tst_qquickwindow::qobjectEventFilter_touch() +{ + QQuickWindow window; + + window.resize(250, 250); + window.setPosition(100, 100); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + TestTouchItem *item = new TestTouchItem(window.contentItem()); + item->setSize(QSizeF(150, 150)); + + EventFilter eventFilter; + item->installEventFilter(&eventFilter); + + QPointF pos(10, 10); + + // press single point + QTest::touchEvent(&window, touchDevice).press(0, item->mapToScene(pos).toPoint(), &window); + + QCOMPARE(eventFilter.events.count(), 1); + QCOMPARE(eventFilter.events.first(), (int)QEvent::TouchBegin); +} + +// QTBUG-32004 +void tst_qquickwindow::qobjectEventFilter_key() +{ + QQuickWindow window; + + window.resize(250, 250); + window.setPosition(100, 100); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + TestTouchItem *item = new TestTouchItem(window.contentItem()); + item->setSize(QSizeF(150, 150)); + item->setFocus(true); + + EventFilter eventFilter; + item->installEventFilter(&eventFilter); + + QTest::keyPress(&window, Qt::Key_A); + + // NB: It may also receive some QKeyEvent(ShortcutOverride) which we're not interested in + QVERIFY(eventFilter.events.contains((int)QEvent::KeyPress)); + eventFilter.events.clear(); + + QTest::keyRelease(&window, Qt::Key_A); + + QVERIFY(eventFilter.events.contains((int)QEvent::KeyRelease)); +} + +// QTBUG-32004 +void tst_qquickwindow::qobjectEventFilter_mouse() +{ + QQuickWindow window; + + window.resize(250, 250); + window.setPosition(100, 100); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + TestTouchItem *item = new TestTouchItem(window.contentItem()); + item->setSize(QSizeF(150, 150)); + + EventFilter eventFilter; + item->installEventFilter(&eventFilter); + + QPoint point = item->mapToScene(QPointF(10, 10)).toPoint(); + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, point); + + QVERIFY(eventFilter.events.contains((int)QEvent::MouseButtonPress)); + + // clean up mouse press state for the next tests + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, point); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp index 7d1590e5f6..06338e09e2 100644 --- a/tests/auto/quick/rendernode/tst_rendernode.cpp +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -57,18 +57,18 @@ public: QImage runTest(const QString &fileName) { - QQuickView view; - view.setSource(testFileUrl(fileName)); + QQuickView view(&outerWindow); view.setResizeMode(QQuickView::SizeViewToRootObject); - const QRect screenGeometry = view.screen()->availableGeometry(); - const QSize size = view.size(); - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - view.setFramePosition(screenGeometry.center() - offset); - view.showNormal(); + view.setSource(testFileUrl(fileName)); + view.setVisible(true); QTest::qWaitForWindowExposed(&view); return view.grabWindow(); } + //It is important for platforms that only are able to show fullscreen windows + //to have a container for the window that is painted on. + QQuickWindow outerWindow; + private slots: void renderOrder(); void messUpState(); @@ -187,6 +187,8 @@ tst_rendernode::tst_rendernode() { qmlRegisterType<ClearItem>("Test", 1, 0, "ClearItem"); qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem"); + outerWindow.showNormal(); + outerWindow.setGeometry(0,0,400,400); } static bool fuzzyCompareColor(QRgb x, QRgb y, QByteArray *errorMessage) |