diff options
Diffstat (limited to 'tests')
20 files changed, 384 insertions, 17 deletions
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 2ca3e42991..b61eca730f 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -25,7 +25,8 @@ PUBLICTESTS += \ qtqmlmodules \ qquickfolderlistmodel \ qqmlapplicationengine \ - qqmlsettings + qqmlsettings \ + qqmlstatemachine PRIVATETESTS += \ animation \ diff --git a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp index 81215f7a18..4f1c9ae53e 100644 --- a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp +++ b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp @@ -165,6 +165,7 @@ private slots: void readProperty(); void propertyChange(); void disconnectOnDestroy(); + void lotsOfBindings(); private: void createObjects(); @@ -312,6 +313,39 @@ void tst_qqmlnotifier::disconnectOnDestroy() exportedObject->verifyReceiverCount(); } +class TestObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int a READ a NOTIFY aChanged) + +public: + int a() const { return 0; } + +signals: + void aChanged(); +}; + +void tst_qqmlnotifier::lotsOfBindings() +{ + TestObject o; + QQmlEngine *e = new QQmlEngine; + + e->rootContext()->setContextProperty(QStringLiteral("test"), &o); + + QList<QQmlComponent *> components; + for (int i = 0; i < 20000; ++i) { + QQmlComponent *component = new QQmlComponent(e); + component->setData("import QtQuick 2.0; Item { width: test.a; }", QUrl()); + component->create(e->rootContext()); + components.append(component); + } + + o.aChanged(); + + qDeleteAll(components); + delete e; +} + QTEST_MAIN(tst_qqmlnotifier) #include "tst_qqmlnotifier.moc" diff --git a/tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml b/tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml new file mode 100644 index 0000000000..253d61d1da --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + readonly property var r_var: 1; + readonly property int r_int: 1; + property var w_var: 1; + property int w_int: 1; +} diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 1d6c2d87ff..d6b1c86b88 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -146,6 +146,7 @@ private slots: void warnOnInvalidBinding(); void registeredCompositeTypeProperty(); void deeplyNestedObject(); + void readOnlyDynamicProperties(); void copy(); private: @@ -2039,6 +2040,20 @@ void tst_qqmlproperty::deeplyNestedObject() QCOMPARE(p.read(), QVariant(14)); } +void tst_qqmlproperty::readOnlyDynamicProperties() +{ + QQmlComponent comp(&engine, testFileUrl("readonlyPrimitiveVsVar.qml")); + QObject *obj = comp.create(); + QVERIFY(obj != 0); + + QVERIFY(!obj->metaObject()->property(obj->metaObject()->indexOfProperty("r_var")).isWritable()); + QVERIFY(!obj->metaObject()->property(obj->metaObject()->indexOfProperty("r_int")).isWritable()); + QVERIFY(obj->metaObject()->property(obj->metaObject()->indexOfProperty("w_var")).isWritable()); + QVERIFY(obj->metaObject()->property(obj->metaObject()->indexOfProperty("w_int")).isWritable()); + + delete obj; +} + void tst_qqmlproperty::initTestCase() { QQmlDataTest::initTestCase(); diff --git a/tests/auto/qml/qqmlstatemachine/data/cppsignal.qml b/tests/auto/qml/qqmlstatemachine/data/cppsignal.qml new file mode 100644 index 0000000000..3d06d823e2 --- /dev/null +++ b/tests/auto/qml/qqmlstatemachine/data/cppsignal.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Ford Motor Company +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml 2.0 + +import QtQml.StateMachine 1.0 + +import CppObjectEnum 1.0 + +StateMachine { + id: stateMachine + initialState: state0 + + State { + id: state0 + SignalTransition { + targetState: state1 + signal: _cppObject.mySignal + // signalState is mySignal's parameter + guard: signalState === CppObject.State1 + } + } + + State { + id: state1 + SignalTransition { + targetState: state2 + signal: _cppObject.mySignal + // signalState is mySignal's parameter + guard: signalState === CppObject.State2 + } + onEntered: _cppObject.objectState = CppObject.State1 + } + + FinalState { + id: state2 + onEntered: _cppObject.objectState = CppObject.State2 + } + Component.onCompleted: stateMachine.running = true +} diff --git a/tests/auto/qml/qqmlstatemachine/qqmlstatemachine.pro b/tests/auto/qml/qqmlstatemachine/qqmlstatemachine.pro new file mode 100644 index 0000000000..002af1d707 --- /dev/null +++ b/tests/auto/qml/qqmlstatemachine/qqmlstatemachine.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TARGET = tst_qqmlstatemachine +osx:CONFIG -= app_bundle + +SOURCES += tst_qqmlstatemachine.cpp + +include (../../shared/util.pri) + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private gui testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp b/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp new file mode 100644 index 0000000000..0d36b66e3f --- /dev/null +++ b/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Ford Motor Company +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QQmlComponent> +#include <QQmlContext> +#include <QQmlEngine> +#include <QTest> +#include "../../shared/util.h" + +class tst_qqmlstatemachine : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlstatemachine(); + +private slots: + void tst_cppObjectSignal(); +}; + + +class CppObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(ObjectState objectState READ objectState WRITE setObjectState NOTIFY objectStateChanged) + Q_ENUMS(ObjectState) +public: + enum ObjectState { + State0, + State1, + State2 + }; + +public: + CppObject() + : QObject() + , m_objectState(State0) + {} + + ObjectState objectState() const { return m_objectState; } + void setObjectState(ObjectState objectState) { m_objectState = objectState; emit objectStateChanged();} + +signals: + void objectStateChanged(); + void mySignal(int signalState); + +private: + ObjectState m_objectState; +}; + +tst_qqmlstatemachine::tst_qqmlstatemachine() +{ + QVERIFY(-1 != qmlRegisterUncreatableType<CppObject>("CppObjectEnum", 1, 0, "CppObject", QString())); +} + +void tst_qqmlstatemachine::tst_cppObjectSignal() +{ + CppObject cppObject; + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("cppsignal.qml")); + QVERIFY(!component.isError()); + + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("_cppObject", &cppObject); + QScopedPointer<QObject> rootObject(component.create()); + QVERIFY(rootObject != 0); + + // wait for state machine to start + QTRY_VERIFY(rootObject->property("running").toBool()); + + // emit signal from cpp + emit cppObject.mySignal(CppObject::State1); + + // check if the signal was propagated + QTRY_COMPARE(cppObject.objectState(), CppObject::State1); + + // emit signal from cpp + emit cppObject.mySignal(CppObject::State2); + + // check if the signal was propagated + QTRY_COMPARE(cppObject.objectState(), CppObject::State2); + + // wait for state machine to finish + QTRY_VERIFY(!rootObject->property("running").toBool()); +} + + +QTEST_MAIN(tst_qqmlstatemachine) + +#include "tst_qqmlstatemachine.moc" diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro index 6543aa1b2b..3d821fc13d 100644 --- a/tests/auto/quick/examples/examples.pro +++ b/tests/auto/quick/examples/examples.pro @@ -10,3 +10,5 @@ CONFIG += parallel_test #temporary QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +!qtHaveModule(xmlpatterns): DEFINES += QT_NO_XMLPATTERNS + diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 175955d663..90c78ec942 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -104,7 +104,9 @@ tst_examples::tst_examples() excludedDirs << "demos/twitter"; excludedDirs << "demos/flickr"; excludedDirs << "demos/photoviewer"; - excludedDirs << "snippets/qml/xmlrole.qml"; + excludedFiles << "snippets/qml/xmlrole.qml"; + excludedFiles << "particles/itemparticle/particleview.qml"; + excludedFiles << "views/visualdatamodel/slideshow.qml"; #endif } diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp index b49ce34951..c49f01d5a7 100644 --- a/tests/auto/quick/nodes/tst_nodestest.cpp +++ b/tests/auto/quick/nodes/tst_nodestest.cpp @@ -283,7 +283,7 @@ void NodesTest::textureNodeTextureOwnership() QVERIFY(!texture.isNull()); } - { // Check that it is deleted when we so desire + { // Check that it is deleted on destruction when we so desire QPointer<QSGTexture> texture(new QSGPlainTexture()); QSGSimpleTextureNode *tn = new QSGSimpleTextureNode(); @@ -294,6 +294,25 @@ void NodesTest::textureNodeTextureOwnership() delete tn; QVERIFY(texture.isNull()); } + + { // Check that it is deleted on update when we so desire + QPointer<QSGTexture> oldTexture(new QSGPlainTexture()); + QPointer<QSGTexture> newTexture(new QSGPlainTexture()); + + QSGSimpleTextureNode *tn = new QSGSimpleTextureNode(); + tn->setOwnsTexture(true); + QVERIFY(tn->ownsTexture()); + + tn->setTexture(oldTexture); + QVERIFY(!oldTexture.isNull()); + QVERIFY(!newTexture.isNull()); + + tn->setTexture(newTexture); + QVERIFY(oldTexture.isNull()); + QVERIFY(!newTexture.isNull()); + + delete tn; + } } void NodesTest::textureNodeRect() diff --git a/tests/auto/quick/qquickanimationcontroller/data/tst_parallelanimation.qml b/tests/auto/quick/qquickanimationcontroller/data/tst_parallelanimation.qml index 87cba880af..cd0f95bc7a 100644 --- a/tests/auto/quick/qquickanimationcontroller/data/tst_parallelanimation.qml +++ b/tests/auto/quick/qquickanimationcontroller/data/tst_parallelanimation.qml @@ -24,7 +24,7 @@ Rectangle { name:"AnimationController" when:windowShown function test_parallelAnimation_data() { - //FIXME:the commented lines fail on MAC OS X + //FIXME:the commented lines fail on OS X return [ {tag:"0.1",progress:0.1, x:5, y:10, color:"#e50019", width:14, height:14}, //{tag:"0.2",progress:0.2, x:10, y:20, color:"#cb0033", width:18, height:18}, diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index 5960e53557..93f85107a7 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -677,5 +677,27 @@ CanvasTestCase { waitForRendering(implicitlySizedItem); comparePixel(implicitlySizedItem.canvas.context, xCenter, yCenter, 0, 0, 0, 255); } + + Component { + id: simpleTextureNodeUsageComponent + + Canvas { + id: canvas + anchors.fill: parent + + onPaint: { + var ctx = canvas.getContext("2d"); + ctx.clearRect(0, 0, 200, 200); + } + } + } + + function test_simpleTextureNodeUsage() { + var canvas = simpleTextureNodeUsageComponent.createObject(container); + verify(canvas); + wait(0); + // Shouldn't crash. + canvas.requestPaint(); + } } } diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp index 95e495a74e..4678f5fbb9 100644 --- a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp +++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp @@ -153,6 +153,8 @@ void tst_qquickstyledtext::textOutput_data() QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)) << false; QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList() << false; QTest::newRow("tag mix") << "<f6>ds<b></img><pro>gfh</b><w><w>ghj</stron><ql><sl><pl>dfg</j6><img><bol><r><prp>dfg<bkj></b><up><string>ewrq</al><bl>jklhj<zl>" << "dsgfhghjdfgdfgewrqjklhj" << (FormatList() << Format(Format::Bold, 2, 3)) << false; + QTest::newRow("named html entities") << "> < & " " << QLatin1String("> < & \" ") + QChar(QChar::Nbsp) << FormatList() << false; + QTest::newRow("invalid html entities") << "a &hello & a &goodbye;" << "a &hello & a " << FormatList() << false; } void tst_qquickstyledtext::textOutput() diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 9682070162..079f73ae34 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -2419,7 +2419,7 @@ void tst_qquicktextinput::navigation() simulateKey(&window, Qt::Key_Left); QVERIFY(input->hasActiveFocus()); - // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). + // Up and Down should NOT do Home/End, even on OS X (QTBUG-10438). input->setCursorPosition(2); QCOMPARE(input->cursorPosition(),2); simulateKey(&window, Qt::Key_Up); diff --git a/tests/auto/quick/qquickwindow/BLACKLIST b/tests/auto/quick/qquickwindow/BLACKLIST deleted file mode 100644 index 8a19a679a3..0000000000 --- a/tests/auto/quick/qquickwindow/BLACKLIST +++ /dev/null @@ -1,4 +0,0 @@ -[cursor] -* -[testWindowVisibilityOrder] -osx diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 2c7a3c933b..e1ea068a62 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1753,14 +1753,6 @@ void tst_qquickwindow::testWindowVisibilityOrder() QTest::qWaitForWindowExposed(window5); QVERIFY(window4->isVisible()); QVERIFY(window5->isVisible()); - window4->hide(); - window5->hide(); - - window3->hide(); - QTRY_COMPARE(window2, QGuiApplication::focusWindow()); - - window2->hide(); - QTRY_COMPARE(window1.data(), QGuiApplication::focusWindow()); } void tst_qquickwindow::blockClosing() diff --git a/tests/manual/scenegraph_lancelot/data/text/textedit_cyrillic_selected.qml b/tests/manual/scenegraph_lancelot/data/text/textedit_cyrillic_selected.qml new file mode 100644 index 0000000000..849e4b8597 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/textedit_cyrillic_selected.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + TextEdit { + id: textEdit + text: "и в у" + anchors.centerIn: parent + Component.onCompleted: textEdit.select(2, 3) + font.pixelSize: 14 + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/textedit_cyrillic_selected_all.qml b/tests/manual/scenegraph_lancelot/data/text/textedit_cyrillic_selected_all.qml new file mode 100644 index 0000000000..9580f28e29 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/textedit_cyrillic_selected_all.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + TextEdit { + id: textEdit + text: "и в у" + anchors.centerIn: parent + Component.onCompleted: textEdit.selectAll() + font.pixelSize: 14 + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/textedit_table_selected.qml b/tests/manual/scenegraph_lancelot/data/text/textedit_table_selected.qml new file mode 100644 index 0000000000..749c37904e --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/textedit_table_selected.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + TextEdit { + id: textEdit + anchors.centerIn: parent + verticalAlignment: Text.AlignBottom + font.family: "Arial" + font.pixelSize: 16 + textFormat: Text.RichText + Component.onCompleted: textEdit.selectAll() + text: + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + + "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + + "<body >\n" + + "<table >\n" + + "<tr >\n" + + "<td >\n" + + "Cell 1\n" + + "</td>\n" + + "</tr>\n" + + "<tr >\n" + + "<td >\n" + + "Cell 2\n" + + "</td>\n" + + "</tr>\n" + + "<tr >\n" + + "<td >\n" + + "Cell 3\n" + + "</td>\n" + + "</tr>\n" + + "</table>\n" + + "</body>\n" + + "</html>\n" + + } +} diff --git a/tests/manual/v4/typedarrays.js b/tests/manual/v4/typedarrays.js index d7a863e573..d52fd6bab0 100644 --- a/tests/manual/v4/typedarrays.js +++ b/tests/manual/v4/typedarrays.js @@ -67,6 +67,15 @@ function assertArrayEquals(a, b) assertEquals(a[i], b[i]) } +function TestIsViewFalse() { + assertTrue(!ArrayBuffer.isView()); + assertTrue(!ArrayBuffer.isView(42)); + assertTrue(!ArrayBuffer.isView('foo')); + assertTrue(!ArrayBuffer.isView(new ArrayBuffer())); +} + +TestIsViewFalse(); + function TestByteLength(param, expectedByteLength) { var ab = new ArrayBuffer(param); assertSame(expectedByteLength, ab.byteLength); |