aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quicktest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quicktest')
-rw-r--r--tests/auto/quicktest/polish-qml/data/tst_polish.qml60
-rw-r--r--tests/auto/quicktest/polish-qml/polish-qml.pro12
-rw-r--r--tests/auto/quicktest/polish-qml/tst_polish-qml.cpp84
-rw-r--r--tests/auto/quicktest/polish/data/polish.qml32
-rw-r--r--tests/auto/quicktest/polish/polish.pro12
-rw-r--r--tests/auto/quicktest/polish/tst_polish.cpp88
-rw-r--r--tests/auto/quicktest/quicktest.pro1
7 files changed, 289 insertions, 0 deletions
diff --git a/tests/auto/quicktest/polish-qml/data/tst_polish.qml b/tests/auto/quicktest/polish-qml/data/tst_polish.qml
new file mode 100644
index 0000000000..d2d5972d43
--- /dev/null
+++ b/tests/auto/quicktest/polish-qml/data/tst_polish.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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: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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.13
+import QtTest 1.13
+
+import Test 1.0
+
+TestCase {
+ id: testCase
+ name: "polish-qml"
+ when: windowShown
+
+ Component {
+ id: customItemComponent
+ CustomItem {}
+ }
+
+ function test_polish()
+ {
+ var item = createTemporaryObject(customItemComponent, testCase)
+ verify(item)
+
+ item.polishMe()
+ verify(isPolishScheduled(item))
+ verify(item.isPolishScheduled())
+
+ verify(waitForItemPolished(item))
+ verify(item.wasUpdatePolishCalled())
+
+ // TODO: test failure conditions when https://bugreports.qt.io/browse/QTBUG-72351 is fixed
+// expectFail("", "Not a valid item")
+// isPolishScheduled(null)
+ }
+}
diff --git a/tests/auto/quicktest/polish-qml/polish-qml.pro b/tests/auto/quicktest/polish-qml/polish-qml.pro
new file mode 100644
index 0000000000..15b913ffe1
--- /dev/null
+++ b/tests/auto/quicktest/polish-qml/polish-qml.pro
@@ -0,0 +1,12 @@
+CONFIG += qmltestcase
+macos:CONFIG -= app_bundle
+TARGET = tst_polish-qml
+
+QT += testlib quick quick-private
+
+include (../../shared/util.pri)
+
+SOURCES += tst_polish-qml.cpp
+
+TESTDATA += \
+ $$PWD/data/*.qml
diff --git a/tests/auto/quicktest/polish-qml/tst_polish-qml.cpp b/tests/auto/quicktest/polish-qml/tst_polish-qml.cpp
new file mode 100644
index 0000000000..e525a8a5af
--- /dev/null
+++ b/tests/auto/quicktest/polish-qml/tst_polish-qml.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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: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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuickTest/quicktest.h>
+
+#include "../../shared/util.h"
+
+class CustomItem : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ CustomItem() {}
+
+ Q_INVOKABLE void polishMe() {
+ polish();
+ }
+
+ Q_INVOKABLE bool isPolishScheduled() const
+ {
+ return QQuickItemPrivate::get(this)->polishScheduled;
+ }
+
+ Q_INVOKABLE bool wasUpdatePolishCalled() const
+ {
+ return updatePolishCalled;
+ }
+
+ void updatePolish() override
+ {
+ updatePolishCalled = true;
+ }
+
+private:
+ bool updatePolishCalled = false;
+};
+
+class TestSetup : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestSetup() {}
+
+public slots:
+ void applicationAvailable()
+ {
+ qmlRegisterType<CustomItem>("Test", 1, 0, "CustomItem");
+ }
+};
+
+QUICK_TEST_MAIN_WITH_SETUP(polish-qml, TestSetup)
+
+#include "tst_polish-qml.moc"
diff --git a/tests/auto/quicktest/polish/data/polish.qml b/tests/auto/quicktest/polish/data/polish.qml
new file mode 100644
index 0000000000..0ab3afda2e
--- /dev/null
+++ b/tests/auto/quicktest/polish/data/polish.qml
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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: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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Test 1.0
+
+CustomItem {}
diff --git a/tests/auto/quicktest/polish/polish.pro b/tests/auto/quicktest/polish/polish.pro
new file mode 100644
index 0000000000..0dfb4bdf5e
--- /dev/null
+++ b/tests/auto/quicktest/polish/polish.pro
@@ -0,0 +1,12 @@
+CONFIG += qmltestcase
+macos:CONFIG -= app_bundle
+TARGET = tst_polish
+
+QT += testlib quick quick-private
+
+include (../../shared/util.pri)
+
+SOURCES += tst_polish.cpp
+
+TESTDATA += \
+ $$PWD/data/*.qml
diff --git a/tests/auto/quicktest/polish/tst_polish.cpp b/tests/auto/quicktest/polish/tst_polish.cpp
new file mode 100644
index 0000000000..3b96002cd2
--- /dev/null
+++ b/tests/auto/quicktest/polish/tst_polish.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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: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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickitem.h>
+#include <QQuickView>
+#include <QtQuickTest/quicktest.h>
+
+#include "../../shared/util.h"
+
+class CustomItem : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ CustomItem() {}
+
+ void updatePolish() override
+ {
+ updatePolishCalled = true;
+ }
+
+ bool updatePolishCalled = false;
+};
+
+class tst_Polish : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_Polish();
+
+private slots:
+ void testPolish();
+};
+
+tst_Polish::tst_Polish()
+{
+ qmlRegisterType<CustomItem>("Test", 1, 0, "CustomItem");
+}
+
+void tst_Polish::testPolish()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("polish.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ CustomItem *item = qobject_cast<CustomItem*>(view.rootObject());
+ QVERIFY(item);
+
+ item->polish();
+ QVERIFY(QQuickTest::qIsPolishScheduled(item));
+ QVERIFY(!item->updatePolishCalled);
+ QVERIFY(QQuickTest::qWaitForItemPolished(item));
+ QVERIFY(item->updatePolishCalled);
+}
+
+QTEST_MAIN(tst_Polish)
+
+#include "tst_polish.moc"
diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro
index 0e3f257e33..6d09f76c1d 100644
--- a/tests/auto/quicktest/quicktest.pro
+++ b/tests/auto/quicktest/quicktest.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = \
+ polish \
signalspy \
quicktestmainwithsetup \
testfiltering