diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/sequenceSort.qml | 26 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/qqmlecmascript.pro | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.cpp | 41 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.h | 29 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 63 |
5 files changed, 90 insertions, 71 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml index b130408c18..74c7cda9a3 100644 --- a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml +++ b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml @@ -64,6 +64,16 @@ Item { var actual = msc.reals(realList); return checkResults(expected, actual, fn); } + function doIntVectorTest(intList, fn) { + var expected = createExpected(intList, fn); + var actual = msc.integerVector(intList); + return checkResults(expected, actual, fn); + } + function doRealVectorTest(realList, fn) { + var expected = createExpected(realList, fn); + var actual = msc.realVector(realList); + return checkResults(expected, actual, fn); + } function test_qtbug_25269(useCustomCompare) { return doStringTest( [ "one", "two", "three" ], null ); @@ -92,4 +102,20 @@ Item { var fn = useCustomCompare ? compareNumbers : null; return doRealTest( [ -3.4, 1, 10, 4.23, -30.1, 4.24, 4.21, -1, -1, 12, -100, 87.4, 101.3, -8.88888, 7.76, 10.10, 1.1, -1.1, -0, 11, 12.8, 0.001, -11, -0.75, 99999.99, 11.12, 32.3, 3.333333, 9.876 ], fn ); } + function test_number_vector_insertionSort(useCustomCompare) { + var fn = useCustomCompare ? compareNumbers : null; + return doIntVectorTest( [ 7, 3, 9, 1, 0, -1, 20, -11 ], fn ); + } + function test_number_vector_quickSort(useCustomCompare) { + var fn = useCustomCompare ? compareNumbers : null; + return doIntVectorTest( [ 7, 3, 37, 9, 1, 0, -1, 20, -11, -300, -87, 1, 3, -2, 100, 108, 96, 9, 99999, 12, 11, 11, 12, 11, 13, -13, 10, 10, 10, 8, 12 ], fn ); + } + function test_real_vector_insertionSort(useCustomCompare) { + var fn = useCustomCompare ? compareNumbers : null; + return doRealVectorTest( [ -3.4, 1, 10, 4.23, -30.1, 4.24, 4.21, -1, -1 ], fn ); + } + function test_real_vector_quickSort(useCustomCompare) { + var fn = useCustomCompare ? compareNumbers : null; + return doRealVectorTest( [ -3.4, 1, 10, 4.23, -30.1, 4.24, 4.21, -1, -1, 12, -100, 87.4, 101.3, -8.88888, 7.76, 10.10, 1.1, -1.1, -0, 11, 12.8, 0.001, -11, -0.75, 99999.99, 11.12, 32.3, 3.333333, 9.876 ], fn ); + } } diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro index 6f3f765aba..101181bba0 100644 --- a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro +++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro @@ -20,5 +20,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private network testlib qtHaveModule(widgets): QT += widgets - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index b9e088d64c..d9ddcd71a7 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** 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. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -300,6 +295,18 @@ public: { return v; } + Q_INVOKABLE QVector<int> integerVector(QVector<int> v) const + { + return v; + } + Q_INVOKABLE QVector<qreal> realVector(QVector<qreal> v) const + { + return v; + } + Q_INVOKABLE QVector<bool> boolVector(QVector<bool> v) const + { + return v; + } }; static MyInheritedQmlObject *theSingletonObject = 0; diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 4abf5fb167..d4d051443f 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** 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. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 08ebfbbbcf..29f81cd063 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** 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. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -4923,7 +4918,7 @@ void tst_qqmlecmascript::propertyVarImplicitOwnership() QCOMPARE(rootObject->property("rectCanary").toInt(), 5); QCOMPARE(childObject->property("textCanary").toInt(), 10); QMetaObject::invokeMethod(childObject, "constructQObject"); // creates a reference to a constructed QObject. - QWeakPointer<QObject> qobjectGuard(childObject->property("vp").value<QObject*>()); // get the pointer prior to processing deleteLater events. + QPointer<QObject> qobjectGuard(childObject->property("vp").value<QObject*>()); // get the pointer prior to processing deleteLater events. QVERIFY(!qobjectGuard.isNull()); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. QCoreApplication::processEvents(); @@ -4946,9 +4941,9 @@ void tst_qqmlecmascript::propertyVarReparent() QObject *rect = object->property("vp").value<QObject*>(); QObject *text = rect->findChild<QObject*>("textOne"); QObject *text2 = rect->findChild<QObject*>("textTwo"); - QWeakPointer<QObject> rectGuard(rect); - QWeakPointer<QObject> textGuard(text); - QWeakPointer<QObject> text2Guard(text2); + QPointer<QObject> rectGuard(rect); + QPointer<QObject> textGuard(text); + QPointer<QObject> text2Guard(text2); QVERIFY(!rectGuard.isNull()); QVERIFY(!textGuard.isNull()); QVERIFY(!text2Guard.isNull()); @@ -4957,7 +4952,7 @@ void tst_qqmlecmascript::propertyVarReparent() // now construct an image which we will reparent. QMetaObject::invokeMethod(text2, "constructQObject"); QObject *image = text2->property("vp").value<QObject*>(); - QWeakPointer<QObject> imageGuard(image); + QPointer<QObject> imageGuard(image); QVERIFY(!imageGuard.isNull()); QCOMPARE(image->property("imageCanary").toInt(), 13); // now reparent the "Image" object (currently, it has JS ownership) @@ -4988,9 +4983,9 @@ void tst_qqmlecmascript::propertyVarReparentNullContext() QObject *rect = object->property("vp").value<QObject*>(); QObject *text = rect->findChild<QObject*>("textOne"); QObject *text2 = rect->findChild<QObject*>("textTwo"); - QWeakPointer<QObject> rectGuard(rect); - QWeakPointer<QObject> textGuard(text); - QWeakPointer<QObject> text2Guard(text2); + QPointer<QObject> rectGuard(rect); + QPointer<QObject> textGuard(text); + QPointer<QObject> text2Guard(text2); QVERIFY(!rectGuard.isNull()); QVERIFY(!textGuard.isNull()); QVERIFY(!text2Guard.isNull()); @@ -4999,7 +4994,7 @@ void tst_qqmlecmascript::propertyVarReparentNullContext() // now construct an image which we will reparent. QMetaObject::invokeMethod(text2, "constructQObject"); QObject *image = text2->property("vp").value<QObject*>(); - QWeakPointer<QObject> imageGuard(image); + QPointer<QObject> imageGuard(image); QVERIFY(!imageGuard.isNull()); QCOMPARE(image->property("imageCanary").toInt(), 13); // now reparent the "Image" object (currently, it has JS ownership) @@ -5057,9 +5052,9 @@ void tst_qqmlecmascript::propertyVarCircular2() QVERIFY(rootObject != 0); QObject *childObject = rootObject->findChild<QObject*>("text"); QVERIFY(childObject != 0); - QWeakPointer<QObject> rootObjectTracker(rootObject); + QPointer<QObject> rootObjectTracker(rootObject); QVERIFY(!rootObjectTracker.isNull()); - QWeakPointer<QObject> childObjectTracker(childObject); + QPointer<QObject> childObjectTracker(childObject); QVERIFY(!childObjectTracker.isNull()); gc(engine); QCOMPARE(rootObject->property("rectCanary").toInt(), 5); @@ -6635,8 +6630,7 @@ void tst_qqmlecmascript::urlPropertyWithEncoding() MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); object->setStringProperty("http://qt-project.org"); - QUrl encoded; - encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); + const QUrl encoded = QUrl::fromEncoded("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); QCOMPARE(object->urlProperty(), encoded); QCOMPARE(object->value(), 0); // Interpreting URL as string yields canonicalised version QCOMPARE(object->property("result").toBool(), true); @@ -6654,8 +6648,7 @@ void tst_qqmlecmascript::urlListPropertyWithEncoding() MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3")); MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4")); QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0); - QUrl encoded; - encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); + const QUrl encoded = QUrl::fromEncoded("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << encoded)); QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << encoded)); QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << encoded << encoded)); @@ -7344,7 +7337,7 @@ void tst_qqmlecmascript::sequenceSort_data() QTest::newRow("qtbug_25269") << "test_qtbug_25269" << false; - const char *types[] = { "alphabet", "numbers", "reals" }; + const char *types[] = { "alphabet", "numbers", "reals", "number_vector", "real_vector" }; const char *sort[] = { "insertionSort", "quickSort" }; for (size_t t=0 ; t < sizeof(types)/sizeof(types[0]) ; ++t) { @@ -7354,7 +7347,7 @@ void tst_qqmlecmascript::sequenceSort_data() QString fnName = QLatin1String("test_") + testName; bool useComparer = c != 0; testName += useComparer ? QLatin1String("[custom]") : QLatin1String("[default]"); - QTest::newRow(testName.toAscii().constData()) << fnName << useComparer; + QTest::newRow(testName.toLatin1().constData()) << fnName << useComparer; } } } @@ -7373,7 +7366,7 @@ void tst_qqmlecmascript::sequenceSort() QVERIFY(object != 0); QVariant q; - QMetaObject::invokeMethod(object, function.toAscii().constData(), Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, useComparer)); + QMetaObject::invokeMethod(object, function.toLatin1().constData(), Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, useComparer)); QVERIFY(q.toBool()); delete object; |