aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-11-06 20:32:26 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-11-06 20:32:26 +0100
commit501d45012f746d843e0144c78202297a577758bc (patch)
tree5c2b125327d49e3495b5f47995d93fb4215acbb4 /tests/auto
parent9e1b044afa994cdd77fd256cea78cd144e804d76 (diff)
parent442843db6f5dce6b594448d43b380c9b884a7c91 (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/quickcontrols2/qquickchecklabel.cpp src/quickcontrols2/qquickchecklabel_p.h src/quickcontrols2/qquickmnemoniclabel_p.h src/quicktemplates2/qquickbuttongroup_p.h src/quicktemplates2/qquickspinbox.cpp src/quicktemplates2/qquickswipedelegate.cpp Change-Id: I1278b78dcaf25be5698f34751193b83dc951eb3c
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml4
-rw-r--r--tests/auto/controls/data/tst_container.qml30
-rw-r--r--tests/auto/controls/data/tst_pageindicator.qml36
-rw-r--r--tests/auto/controls/data/tst_scrollbar.qml4
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml5
-rw-r--r--tests/auto/controls/data/tst_textfield.qml15
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml31
-rw-r--r--tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml14
-rw-r--r--tests/auto/qquickdrawer/BLACKLIST14
-rw-r--r--tests/auto/qquickiconimage/data/imageProvider.qml9
-rw-r--r--tests/auto/qquickiconimage/tst_qquickiconimage.cpp39
-rw-r--r--tests/auto/qquickpopup/BLACKLIST10
-rw-r--r--tests/auto/sanity/tst_sanity.cpp13
-rw-r--r--tests/auto/snippets/tst_snippets.cpp8
14 files changed, 177 insertions, 55 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index f4a89367..f71a3725 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -410,7 +410,7 @@ TestCase {
verify(control)
control.text = "&Hello"
- compare(control.text, "Hello") // ### TODO: visualize mnemonics
+ compare(control.text, "&Hello")
var clickSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
verify(clickSpy.valid)
@@ -427,7 +427,7 @@ TestCase {
compare(clickSpy.count, 2)
control.text = "Te&st"
- compare(control.text, "Test") // ### TODO: visualize mnemonics
+ compare(control.text, "Te&st")
keyClick(Qt.Key_H, Qt.AltModifier)
compare(clickSpy.count, 2)
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml
index 94f22ad2..c5e74eeb 100644
--- a/tests/auto/controls/data/tst_container.qml
+++ b/tests/auto/controls/data/tst_container.qml
@@ -128,7 +128,7 @@ TestCase {
}
Component {
- id: repeaterContainer
+ id: repeaterContainer1
Container {
id: container
Item { objectName: "0" }
@@ -143,9 +143,33 @@ TestCase {
}
}
+ Component {
+ id: repeaterContainer2
+ Container {
+ id: container
+ contentItem: Item {
+ Repeater {
+ model: container.contentModel
+ }
+ Rectangle { objectName: "extra" }
+ }
+ Rectangle { objectName: "0" }
+ Rectangle { objectName: "1" }
+ Rectangle { objectName: "2" }
+ Rectangle { objectName: "3" }
+ }
+ }
+
+ function test_repeater_data() {
+ return [
+ { tag: "1", component: repeaterContainer1 },
+ { tag: "2", component: repeaterContainer2 }
+ ]
+ }
+
// don't crash (QTBUG-61310)
- function test_repeater() {
- var control = createTemporaryObject(repeaterContainer)
+ function test_repeater(data) {
+ var control = createTemporaryObject(data.component)
verify(control)
compare(control.itemAt(0).objectName, "0")
diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml
index f3151882..dc411e45 100644
--- a/tests/auto/controls/data/tst_pageindicator.qml
+++ b/tests/auto/controls/data/tst_pageindicator.qml
@@ -122,18 +122,30 @@ TestCase {
// test also clicking outside delegates => the nearest should be selected
for (var i = 0; i < control.count; ++i) {
var child = control.contentItem.children[i]
- for (var x = -2; x <= child.width + 2; ++x) {
- for (var y = -2; y <= child.height + 2; ++y) {
- control.currentIndex = -1
- compare(control.currentIndex, -1)
-
- var pos = control.mapFromItem(child, x, y)
- if (data.touch)
- touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit()
- else
- mouseClick(control, pos.x, pos.y, Qt.LeftButton)
- compare(control.currentIndex, i)
- }
+
+ var points = [
+ Qt.point(child.width / 2, -2), // top
+ Qt.point(-2, child.height / 2), // left
+ Qt.point(child.width + 2, child.height / 2), // right
+ Qt.point(child.width / 2, child.height + 2), // bottom
+
+ Qt.point(-2, -2), // top-left
+ Qt.point(child.width + 2, -2), // top-right
+ Qt.point(-2, child.height + 2), // bottom-left
+ Qt.point(child.width + 2, child.height + 2), // bottom-right
+ ]
+
+ for (var j = 0; j < points.length; ++j) {
+ control.currentIndex = -1
+ compare(control.currentIndex, -1)
+
+ var point = points[j]
+ var pos = control.mapFromItem(child, x, y)
+ if (data.touch)
+ touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit()
+ else
+ mouseClick(control, pos.x, pos.y, Qt.LeftButton)
+ compare(control.currentIndex, i)
}
}
}
diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml
index a8d33cea..90fe9468 100644
--- a/tests/auto/controls/data/tst_scrollbar.qml
+++ b/tests/auto/controls/data/tst_scrollbar.qml
@@ -704,7 +704,7 @@ TestCase {
}
function test_overshoot() {
- var container = flickable.createObject(testCase)
+ var container = createTemporaryObject(flickable, testCase)
verify(container)
waitForRendering(container)
@@ -733,8 +733,6 @@ TestCase {
horizontal.position = 0.8
compare(horizontal.contentItem.x, horizontal.leftPadding + 0.8 * horizontal.availableWidth)
compare(horizontal.contentItem.width, 0.2 * horizontal.availableWidth)
-
- container.destroy()
}
function test_orientation() {
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index a1d1b7ba..9568da1a 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -367,6 +367,9 @@ TestCase {
var control = createTemporaryObject(spinBox, testCase)
verify(control)
+ var valueModifiedSpy = signalSpy.createObject(control, {target: control, signalName: "valueModified"})
+ verify(valueModifiedSpy.valid)
+
control.contentItem.forceActiveFocus()
compare(control.contentItem.activeFocus, true)
@@ -375,6 +378,7 @@ TestCase {
keyClick(Qt.Key_5)
keyClick(Qt.Key_Return)
compare(control.value, 0)
+ compare(valueModifiedSpy.count, 0)
control.editable = true
compare(control.editable, true)
@@ -382,6 +386,7 @@ TestCase {
keyClick(Qt.Key_5)
keyClick(Qt.Key_Return)
compare(control.value, 5)
+ compare(valueModifiedSpy.count, 1)
}
function test_wheel_data() {
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml
index 6a40f053..0fee7363 100644
--- a/tests/auto/controls/data/tst_textfield.qml
+++ b/tests/auto/controls/data/tst_textfield.qml
@@ -420,4 +420,19 @@ TestCase {
mouseClick(control, rect.x + rect.width / 2, rect.y + rect.height / 2)
compare(control.selectedText, "Qt Quick Controls 2 TextArea")
}
+
+ // QTBUG-64048
+ function test_rightClick() {
+ var control = createTemporaryObject(textField, testCase, {text: "TextField", selectByMouse: true})
+ verify(control)
+
+ control.selectAll()
+ compare(control.selectedText, "TextField")
+
+ mouseClick(control, control.width / 2, control.height / 2, Qt.RightButton)
+ compare(control.selectedText, "TextField")
+
+ mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton | Qt.RightButton)
+ compare(control.selectedText, "")
+ }
}
diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml
index bd46fabd..e7cc6787 100644
--- a/tests/auto/controls/data/tst_tooltip.qml
+++ b/tests/auto/controls/data/tst_tooltip.qml
@@ -298,4 +298,35 @@ TestCase {
keyPress(Qt.Key_A)
compare(shortcutActivatedSpy.count, 1)
}
+
+ Component {
+ id: hoverComponent
+ MouseArea {
+ id: hoverArea
+ property alias tooltip: tooltip
+ hoverEnabled: true
+ width: testCase.width
+ height: testCase.height
+ ToolTip {
+ id: tooltip
+ x: 10; y: 10
+ width: 10; height: 10
+ visible: hoverArea.containsMouse
+ }
+ }
+ }
+
+ // QTBUG-63644
+ function test_hover() {
+ var root = createTemporaryObject(hoverComponent, testCase)
+ verify(root)
+
+ var tooltip = root.tooltip
+ verify(tooltip)
+
+ for (var pos = 0; pos <= 25; pos += 5) {
+ mouseMove(root, pos, pos)
+ verify(tooltip.visible)
+ }
+ }
}
diff --git a/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml
index 3589439e..a992e0be 100644
--- a/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml
+++ b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml
@@ -1,12 +1,22 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: https://www.qt.io/licensing/
**
** 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:
+** 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
diff --git a/tests/auto/qquickdrawer/BLACKLIST b/tests/auto/qquickdrawer/BLACKLIST
deleted file mode 100644
index b302c76b..00000000
--- a/tests/auto/qquickdrawer/BLACKLIST
+++ /dev/null
@@ -1,14 +0,0 @@
-# See qtbase/src/testlib/qtestblacklist.cpp for format
-
-# https://bugreports.qt.io/browse/QTBUG-62628
-[multiple]
-*
-
-[touch]
-*
-
-[multiTouch]
-*
-
-[grabber]
-*
diff --git a/tests/auto/qquickiconimage/data/imageProvider.qml b/tests/auto/qquickiconimage/data/imageProvider.qml
new file mode 100644
index 00000000..0d7d3033
--- /dev/null
+++ b/tests/auto/qquickiconimage/data/imageProvider.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.10
+import QtQuick.Controls 2.3
+import QtQuick.Controls.impl 2.3
+import QtQuick.Templates 2.3 as T
+
+IconLabel {
+ icon.color: "transparent"
+ icon.source: "image://provider/red"
+}
diff --git a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp
index 4e4afb13..77b860a2 100644
--- a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp
+++ b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp
@@ -35,6 +35,7 @@
#include <QtQml/qqmlfileselector.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickimageprovider.h>
#include <QtQuick/qquickitemgrabresult.h>
#include <QtQuick/private/qquickimage_p.h>
#include <QtQuickControls2/private/qquickiconimage_p.h>
@@ -67,6 +68,7 @@ private slots:
void svgSourceBindingSourceSize();
void color();
void fileSelectors();
+ void imageProvider();
private:
void setTheme();
@@ -480,6 +482,43 @@ void tst_qquickiconimage::fileSelectors()
QCOMPARE(iconImageWindowGrab.pixelColor(iconImageWindowGrab.width() / 2, iconImageWindowGrab.height() / 2), QColor(Qt::blue));
}
+class TestImageProvider : public QQuickImageProvider
+{
+public:
+ TestImageProvider() : QQuickImageProvider(QQuickImageProvider::Pixmap) { }
+
+ QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
+ {
+ QSize defaultSize(32, 32);
+ if (size)
+ *size = defaultSize;
+
+ QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : defaultSize.width(),
+ requestedSize.height() > 0 ? requestedSize.height() : defaultSize.height());
+ pixmap.fill(QColor(id).rgba());
+ return pixmap;
+ }
+};
+
+// don't crash (QTBUG-63959)
+void tst_qquickiconimage::imageProvider()
+{
+ QQuickView view;
+ view.engine()->addImageProvider("provider", new TestImageProvider);
+ view.setSource(testFileUrl("imageProvider.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQuickIconImage *iconImage = qobject_cast<QQuickIconImage*>(view.rootObject()->findChild<QQuickIconImage *>());
+ QVERIFY(iconImage);
+
+ QImage image = grabItemToImage(iconImage);
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.pixelColor(image.width() / 2, image.height() / 2), QColor(Qt::red));
+}
+
int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
diff --git a/tests/auto/qquickpopup/BLACKLIST b/tests/auto/qquickpopup/BLACKLIST
deleted file mode 100644
index 47795a8b..00000000
--- a/tests/auto/qquickpopup/BLACKLIST
+++ /dev/null
@@ -1,10 +0,0 @@
-[overlay]
-# QTBUG-62668
-*
-
-[closePolicy]
-# QTBUG-62668
-*
-
-
-
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp
index 25e118e3..f6e1c78b 100644
--- a/tests/auto/sanity/tst_sanity.cpp
+++ b/tests/auto/sanity/tst_sanity.cpp
@@ -139,7 +139,7 @@ private:
void tst_Sanity::initTestCase()
{
QDirIterator it(QQC2_IMPORT_PATH, QStringList() << "*.qml" << "*.js", QDir::Files, QDirIterator::Subdirectories);
- const QStringList excludeDirs = QStringList() << QStringLiteral("snippets") << QStringLiteral("designer");
+ const QStringList excludeDirs = QStringList() << QStringLiteral("snippets") << QStringLiteral("designer") << QStringLiteral("Sketch");
while (it.hasNext()) {
it.next();
QFileInfo info = it.fileInfo();
@@ -280,9 +280,12 @@ static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QSt
if (QFile::exists(filePath)) {
QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
break;
- } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) {
- QTest::newRow(qPrintable(name)) << QUrl(filePath);
- break;
+ } else {
+ filePath = QQmlFile::urlToLocalFileOrQrc(filePath);
+ if (!filePath.isEmpty() && QFile::exists(filePath)) {
+ QTest::newRow(qPrintable(name)) << QUrl(filePath);
+ break;
+ }
}
}
}
@@ -313,7 +316,7 @@ void tst_Sanity::attachedObjects_data()
{
QTest::addColumn<QUrl>("url");
addTestRows(&engine, "calendar", "Qt/labs/calendar");
- addTestRows(&engine, "controls", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
+ addTestRows(&engine, "controls", "QtQuick/Controls.2");
addTestRows(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
addTestRows(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
addTestRows(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
diff --git a/tests/auto/snippets/tst_snippets.cpp b/tests/auto/snippets/tst_snippets.cpp
index 852c98e9..107759ce 100644
--- a/tests/auto/snippets/tst_snippets.cpp
+++ b/tests/auto/snippets/tst_snippets.cpp
@@ -103,8 +103,8 @@ void tst_Snippets::verify()
QUrl url = QUrl::fromLocalFile(input);
component.loadUrl(url);
- QObject *root = component.create();
- QVERIFY(root);
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(!root.isNull(), qPrintable(component.errorString()));
QCOMPARE(component.status(), QQmlComponent::Ready);
QVERIFY(component.errors().isEmpty());
@@ -132,10 +132,10 @@ void tst_Snippets::verify()
output.insert(index, "-" + applicationStyle.toLower());
}
- QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root.data());
if (!window) {
QQuickView *view = new QQuickView;
- view->setContent(url, &component, root);
+ view->setContent(url, &component, root.data());
window = view;
}