aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-02-01 20:43:29 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-02-01 20:43:30 +0100
commit6ba26317d0fc0573aca7638eda8bdb91e52d1ab3 (patch)
tree061ddc3d0977fc6364eb3275a3da4287fd1a7869 /tests
parentcd39a62bbd5c6e725547a696c297c46f929b3439 (diff)
parent835f8a90387c8d62e7ab262d23e3ab103aa6d133 (diff)
Merge dev into 5.9
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp4
-rw-r--r--tests/auto/qml/qml.pro2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp7
-rw-r--r--tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml4
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir1
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp29
-rw-r--r--tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml41
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml107
-rw-r--r--tests/auto/quick/qquicklayouts/qquicklayouts.pro3
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp3
-rw-r--r--tests/auto/quick/qquicktext/data/fontInfo.qml24
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp19
18 files changed, 275 insertions, 13 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index f25742fb14..1e80f1bf65 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -18,6 +18,4 @@ qtHaveModule(gui):qtConfig(opengl(es1|es2)?) {
# console applications not supported
uikit: SUBDIRS -= qmltest
-qmldevtools.CONFIG = host_build
-
installed_cmake.depends = cmake
diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
index 1791407934..ff295c5409 100644
--- a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
+++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
@@ -392,8 +392,10 @@ void tst_QPauseAnimationJob::multipleSequentialGroups()
#ifdef Q_OS_WIN
if (group.state() != QAbstractAnimationJob::Stopped)
QEXPECT_FAIL("", winTimerError, Abort);
-#endif
+ QCOMPARE(group.state(), QAbstractAnimationJob::Stopped);
+#else
QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped);
+#endif
#ifdef Q_OS_WIN
if (subgroup1.state() != QAbstractAnimationJob::Stopped)
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 68a2eace19..04e4b04114 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -73,7 +73,7 @@ qtHaveModule(widgets) {
SUBDIRS += $$PUBLICTESTS \
qqmlextensionplugin
SUBDIRS += $$METATYPETESTS
-!uikit:!winrt { # no QProcess on uikit/winrt
+!qtConfig(process) {
!contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger
SUBDIRS += qmllint qmlplugindump
}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
index 676593096c..54d29dfc94 100644
--- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
@@ -16,5 +16,11 @@ MyQmlObject
onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton)
- onQjsValueEmittingSignal: {}
+ property bool emittedQjsValueWasUndefined
+ property int emittedQjsValueAsInt
+
+ onQjsValueEmittingSignal: {
+ emittedQjsValueWasUndefined = value === undefined;
+ emittedQjsValueAsInt = value
+ }
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 8c0b0601fc..89dac33671 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -1412,7 +1412,6 @@ void tst_qqmlecmascript::signalParameterTypes()
QVERIFY(object != 0);
emit object->basicSignal();
- emit object->qjsValueEmittingSignal(QJSValue());
QCOMPARE(object->property("intProperty").toInt(), 10);
QCOMPARE(object->property("realProperty").toReal(), 19.2);
@@ -1421,6 +1420,12 @@ void tst_qqmlecmascript::signalParameterTypes()
QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
+ emit object->qjsValueEmittingSignal(QJSValue());
+ QVERIFY(object->property("emittedQjsValueWasUndefined").toBool());
+ emit object->qjsValueEmittingSignal(QJSValue(42));
+ QVERIFY(!object->property("emittedQjsValueWasUndefined").toBool());
+ QCOMPARE(object->property("emittedQjsValueAsInt").value<int>(), 42);
+
delete object;
}
diff --git a/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml
new file mode 100644
index 0000000000..5ffdc26096
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.6
+import "simpleimportByName"
+
+Item {
+ Component.onCompleted: {
+ console.warn(SimpleType)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml
new file mode 100644
index 0000000000..c446eae84c
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.6
+import "simpleimportByName" as ImportName
+
+Item {
+ Component.onCompleted: {
+ console.warn(ImportName.SimpleType)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml b/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml
new file mode 100644
index 0000000000..abe750db33
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.6
+
+Item {
+ Component.onCompleted: {
+ console.warn(Item)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml b/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml
new file mode 100644
index 0000000000..397d4f42f0
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.6 as Quick
+
+Quick.Item {
+ Quick.Component.onCompleted: {
+ console.warn(Quick.Item)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml b/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml
new file mode 100644
index 0000000000..4772dde8f0
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.6
+
+MouseArea {
+}
diff --git a/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir b/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir
new file mode 100644
index 0000000000..80df37d0e6
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir
@@ -0,0 +1 @@
+SimpleType 1.0 SimpleType.qml
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index f586f7d429..c0500afddd 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -257,6 +257,9 @@ private slots:
void defaultListProperty();
void namespacedPropertyTypes();
+ void qmlTypeCanBeResolvedByName_data();
+ void qmlTypeCanBeResolvedByName();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -4250,6 +4253,32 @@ void tst_qqmllanguage::namespacedPropertyTypes()
QVERIFY(!o.isNull());
}
+void tst_qqmllanguage::qmlTypeCanBeResolvedByName_data()
+{
+ QTest::addColumn<QUrl>("componentUrl");
+
+ // Built-in C++ types
+ QTest::newRow("C++ - Anonymous") << testFileUrl("quickTypeByName_anon.qml");
+ QTest::newRow("C++ - Named") << testFileUrl("quickTypeByName_named.qml");
+
+ // Composite types with a qmldir
+ QTest::newRow("QML - Anonymous - qmldir") << testFileUrl("compositeTypeByName_anon_qmldir.qml");
+ QTest::newRow("QML - Named - qmldir") << testFileUrl("compositeTypeByName_named_qmldir.qml");
+}
+
+void tst_qqmllanguage::qmlTypeCanBeResolvedByName()
+{
+ QFETCH(QUrl, componentUrl);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, componentUrl);
+ VERIFY_ERRORS(0);
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "[object Object]"); // a bit crude, but it will do
+
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml
index 022e98a202..a80814d6de 100644
--- a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml
+++ b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml
@@ -37,8 +37,9 @@ Item {
TestCase {
id: testCase
name: "item-grabber"
- when: imageOnDisk.ready && imageOnDiskSmall.ready && imageInCache.ready && imageInCacheSmall.ready
- function test_endresult() {
+ when: imageOnDisk.ready && imageOnDiskSmall.ready
+
+ function test_endresult_disk() {
var image = grabImage(root);
// imageOnDisk at (0, 0) - (100x100)
@@ -52,6 +53,40 @@ Item {
compare(imageOnDiskSmall.height, 50);
verify(image.pixel(100, 0) === Qt.rgba(1, 0, 0, 1));
verify(image.pixel(149, 49) === Qt.rgba(0, 0, 1, 1));
+ }
+
+ function test_endresult_cache_data() {
+ return [
+ { cache: true, sourceSize: Qt.size(-1, -1), fillMode: Image.Stretch },
+ { cache: true, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectFit },
+ { cache: true, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectCrop },
+ { cache: true, sourceSize: Qt.size(10, 10), fillMode: Image.Stretch },
+ { cache: true, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectFit },
+ { cache: true, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectCrop },
+ { cache: false, sourceSize: Qt.size(-1, -1), fillMode: Image.Stretch },
+ { cache: false, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectFit },
+ { cache: false, sourceSize: Qt.size(-1, -1), fillMode: Image.PreserveAspectCrop },
+ { cache: false, sourceSize: Qt.size(10, 10), fillMode: Image.Stretch },
+ { cache: false, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectFit },
+ { cache: false, sourceSize: Qt.size(10, 10), fillMode: Image.PreserveAspectCrop },
+ ];
+ }
+
+ function test_endresult_cache(data) {
+ imageInCache.cache = data.cache;
+ imageInCache.sourceSize = data.sourceSize;
+ imageInCache.fillMode = data.fillMode;
+ imageInCacheSmall.cache = data.cache;
+ imageInCacheSmall.sourceSize = data.sourceSize;
+ imageInCacheSmall.fillMode = data.fillMode;
+
+ box.grabToImage(imageInCache.handleGrab);
+ box.grabToImage(imageInCacheSmall.handleGrab, Qt.size(50, 50));
+
+ tryCompare(imageInCache, "ready", true);
+ tryCompare(imageInCacheSmall, "ready", true);
+
+ var image = grabImage(root);
// imageInCache at (0, 100) - 100x100
compare(imageInCache.width, 100);
@@ -72,8 +107,6 @@ Item {
onWindowShownChanged: {
box.grabToImage(imageOnDisk.handleGrab);
box.grabToImage(imageOnDiskSmall.handleGrab, Qt.size(50, 50));
- box.grabToImage(imageInCache.handleGrab);
- box.grabToImage(imageInCacheSmall.handleGrab, Qt.size(50, 50));
}
}
diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
new file mode 100644
index 0000000000..8234ac6ef7
--- /dev/null
+++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** 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:BSD$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 The Qt Company Ltd 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.2
+import QtTest 1.0
+import QtQuick.Layouts 1.3
+
+Item {
+ id: container
+ width: 200
+ height: 200
+ TestCase {
+ id: testCase
+ name: "Tests_StackLayout"
+ when: windowShown
+ width: 200
+ height: 200
+
+ Component {
+ id: layout_rearrange_Component
+
+ StackLayout {
+ width: 640
+ height: 480
+
+ property alias testRectangle: testRectangle
+
+ RowLayout {
+ spacing: 0
+
+ Rectangle {
+ Layout.preferredWidth: 100
+ Layout.preferredHeight: 100
+ }
+
+ Rectangle {
+ id: testRectangle
+ Layout.preferredWidth: 100
+ Layout.preferredHeight: 100
+ visible: false
+ }
+
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+
+ function test_rearrange()
+ {
+ var layout = layout_rearrange_Component.createObject(container)
+ compare(layout.testRectangle.x, 0)
+ layout.testRectangle.visible = true
+ tryCompare(layout.testRectangle, "x", 100)
+
+ layout.destroy()
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklayouts/qquicklayouts.pro b/tests/auto/quick/qquicklayouts/qquicklayouts.pro
index 9ed3e076be..5079d0a182 100644
--- a/tests/auto/quick/qquicklayouts/qquicklayouts.pro
+++ b/tests/auto/quick/qquicklayouts/qquicklayouts.pro
@@ -9,5 +9,6 @@ TESTDATA = data/*
OTHER_FILES += \
data/tst_rowlayout.qml \
- data/tst_gridlayout.qml
+ data/tst_gridlayout.qml \
+ data/tst_stacklayout.qml
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index 77af4796b6..3e7439f3e9 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -469,7 +469,7 @@ void tst_QQuickLoader::networkComponent()
// because in the synchronous case we're already done loading.
QTRY_COMPARE(component.status(), QQmlComponent::Ready);
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(component.create()));
QVERIFY(item);
QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->children().at(1));
@@ -481,7 +481,6 @@ void tst_QQuickLoader::networkComponent()
QCOMPARE(loader->status(), QQuickLoader::Ready);
QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1);
- delete loader;
}
void tst_QQuickLoader::failNetworkRequest()
diff --git a/tests/auto/quick/qquicktext/data/fontInfo.qml b/tests/auto/quick/qquicktext/data/fontInfo.qml
new file mode 100644
index 0000000000..25f924029f
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/fontInfo.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.9
+
+Item {
+ Text {
+ id: main
+ objectName: "main"
+ width: 500
+ height: 500
+ text: "Meaningless text"
+ font.pixelSize: 1000
+ fontSizeMode: Text.Fit
+ }
+
+ Text {
+ objectName: "copy"
+ text: main.text
+ width: main.width
+ height: main.height
+
+ font.family: main.fontInfo.family
+ font.pixelSize: main.fontInfo.pixelSize
+ }
+}
+
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 034ea4aec8..f741062d42 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -154,6 +154,8 @@ private slots:
void hAlignWidthDependsOnImplicitWidth_data();
void hAlignWidthDependsOnImplicitWidth();
+ void fontInfo();
+
private:
QStringList standard;
QStringList richText;
@@ -4253,6 +4255,23 @@ void tst_qquicktext::hAlignWidthDependsOnImplicitWidth()
QCOMPARE(numberOfNonWhitePixels(0, rectX - 1, image), 0);
}
+void tst_qquicktext::fontInfo()
+{
+ QQmlComponent component(&engine, testFile("fontInfo.qml"));
+
+ QScopedPointer<QObject> object(component.create());
+ QObject *root = object.data();
+
+ QQuickText *main = root->findChild<QQuickText *>("main");
+ QVERIFY(main);
+ QCOMPARE(main->font().pixelSize(), 1000);
+
+ QQuickText *copy = root->findChild<QQuickText *>("copy");
+ QVERIFY(copy);
+ QCOMPARE(copy->font().family(), QFontInfo(QFont()).family());
+ QVERIFY(copy->font().pixelSize() < 1000);
+}
+
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"