aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qmltest')
-rw-r--r--tests/auto/qmltest/BLACKLIST5
-rw-r--r--tests/auto/qmltest/objectmodel/tst_objectmodel.qml100
-rw-r--r--tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml71
-rw-r--r--tests/auto/qmltest/selftests/tst_grabImage.qml58
-rw-r--r--tests/auto/qmltest/selftests/tst_selftests.qml26
-rw-r--r--tests/auto/qmltest/textedit/tst_textedit_editingfinished.qml89
-rw-r--r--tests/auto/qmltest/window/tst_clickwindow.qml84
7 files changed, 433 insertions, 0 deletions
diff --git a/tests/auto/qmltest/BLACKLIST b/tests/auto/qmltest/BLACKLIST
new file mode 100644
index 0000000000..cd8b1181e0
--- /dev/null
+++ b/tests/auto/qmltest/BLACKLIST
@@ -0,0 +1,5 @@
+# Blacklist for testing
+[SelfTests::test_blacklisted_fail]
+*
+[SelfTests::test_blacklistWithData:test2]
+*
diff --git a/tests/auto/qmltest/objectmodel/tst_objectmodel.qml b/tests/auto/qmltest/objectmodel/tst_objectmodel.qml
new file mode 100644
index 0000000000..e8205a1486
--- /dev/null
+++ b/tests/auto/qmltest/objectmodel/tst_objectmodel.qml
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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:
+**
+** "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 QtQml 2.1
+import QtQml.Models 2.3
+import QtTest 1.1
+
+TestCase {
+ name: "ObjectModel"
+
+ ObjectModel {
+ id: model
+ QtObject { id: static0 }
+ QtObject { id: static1 }
+ QtObject { id: static2 }
+ }
+
+ Component { id: object; QtObject { } }
+
+ function test_attached_index() {
+ compare(model.count, 3)
+ compare(static0.ObjectModel.index, 0)
+ compare(static1.ObjectModel.index, 1)
+ compare(static2.ObjectModel.index, 2)
+
+ var dynamic0 = object.createObject(model, {objectName: "dynamic0"})
+ compare(dynamic0.ObjectModel.index, -1)
+ model.append(dynamic0) // -> [static0, static1, static2, dynamic0]
+ compare(model.count, 4)
+ for (var i = 0; i < model.count; ++i)
+ compare(model.get(i).ObjectModel.index, i)
+
+ var dynamic1 = object.createObject(model, {objectName: "dynamic1"})
+ compare(dynamic1.ObjectModel.index, -1)
+ model.insert(0, dynamic1) // -> [dynamic1, static0, static1, static2, dynamic0]
+ compare(model.count, 5)
+ for (i = 0; i < model.count; ++i)
+ compare(model.get(i).ObjectModel.index, i)
+
+ model.move(1, 3) // -> [dynamic1, static1, static2, static0, dynamic0]
+ compare(model.count, 5)
+ for (i = 0; i < model.count; ++i)
+ compare(model.get(i).ObjectModel.index, i)
+
+ model.move(4, 0) // -> [dynamic0, dynamic1, static1, static2, static0]
+ compare(model.count, 5)
+ for (i = 0; i < model.count; ++i)
+ compare(model.get(i).ObjectModel.index, i)
+
+ model.remove(1) // -> [dynamic0, static1, static2, static0]
+ compare(model.count, 4)
+ compare(dynamic1.ObjectModel.index, -1)
+ for (i = 0; i < model.count; ++i)
+ compare(model.get(i).ObjectModel.index, i)
+
+ model.clear()
+ compare(static0.ObjectModel.index, -1)
+ compare(static1.ObjectModel.index, -1)
+ compare(static2.ObjectModel.index, -1)
+ compare(dynamic0.ObjectModel.index, -1)
+ compare(dynamic1.ObjectModel.index, -1)
+ }
+}
diff --git a/tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml b/tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml
new file mode 100644
index 0000000000..9de9a621f6
--- /dev/null
+++ b/tests/auto/qmltest/qtbug46798/tst_qtbug46798.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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:
+**
+** "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 QtQml.Models 2.3
+import QtTest 1.1
+
+Item {
+ id: top
+
+ ListView {
+ id: listViewWithObjectModel // QTBUG-46798
+ anchors.fill: parent
+ model: ObjectModel {
+ id: objectModel
+ Rectangle { width: 160; height: 160; color: "red" }
+ Rectangle { width: 160; height: 160; color: "green" }
+ Rectangle { width: 160; height: 160; color: "blue" }
+ }
+ }
+
+ TestCase {
+ name: "QTBUG-46798"
+ when: windowShown
+
+ function test_bug46798() {
+ var item = objectModel.get(0)
+ if (item) {
+ objectModel.remove(0)
+ item.destroy()
+ }
+ }
+ }
+}
diff --git a/tests/auto/qmltest/selftests/tst_grabImage.qml b/tests/auto/qmltest/selftests/tst_grabImage.qml
new file mode 100644
index 0000000000..7a758ae8fc
--- /dev/null
+++ b/tests/auto/qmltest/selftests/tst_grabImage.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite 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 QtQuick 2.0
+import QtTest 1.1
+
+TestCase {
+ id: testCase
+ name: "tst_grabImage"
+ when: windowShown
+
+ function test_equals() {
+ var rect = Qt.createQmlObject("import QtQuick 2.0; Rectangle { color: 'red'; width: 10; height: 10; }", testCase);
+ verify(rect);
+ var oldImage = grabImage(rect);
+ rect.width += 10;
+ var newImage = grabImage(rect);
+ verify(!newImage.equals(oldImage));
+
+ oldImage = grabImage(rect);
+ // Don't change anything...
+ newImage = grabImage(rect);
+ verify(newImage.equals(oldImage));
+
+ verify(!newImage.equals(null));
+ verify(!newImage.equals(undefined));
+ }
+}
diff --git a/tests/auto/qmltest/selftests/tst_selftests.qml b/tests/auto/qmltest/selftests/tst_selftests.qml
index 0d09f9536a..a372107e26 100644
--- a/tests/auto/qmltest/selftests/tst_selftests.qml
+++ b/tests/auto/qmltest/selftests/tst_selftests.qml
@@ -278,4 +278,30 @@ TestCase {
}
verify(caught)
}
+
+ function test_blacklisted_fail()
+ {
+ verify(false)
+ }
+
+ function test_blacklistWithData_data() {
+ return [
+ {
+ tag: "test1",
+ success: true
+ },
+ {
+ tag: "test2",
+ success: false
+ },
+ {
+ tag: "test3",
+ success: true
+ }
+ ]
+ }
+
+ function test_blacklistWithData(row) {
+ verify(row.success)
+ }
}
diff --git a/tests/auto/qmltest/textedit/tst_textedit_editingfinished.qml b/tests/auto/qmltest/textedit/tst_textedit_editingfinished.qml
new file mode 100644
index 0000000000..c9eadde373
--- /dev/null
+++ b/tests/auto/qmltest/textedit/tst_textedit_editingfinished.qml
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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:
+**
+** "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.6
+import QtTest 1.1
+
+Row {
+ width: 100
+ height: 50
+ spacing: 10
+
+ property alias control1: _control1
+ property alias control2: _control2
+ TextEdit {
+ id: _control1
+ text: 'A'
+ property bool myeditingfinished: false
+ onEditingFinished: myeditingfinished = true
+ activeFocusOnTab: true
+ }
+ TextEdit {
+ id: _control2
+ text: 'B'
+ property bool myeditingfinished: false
+ onEditingFinished: myeditingfinished = true
+ activeFocusOnTab: true
+ }
+
+ TestCase {
+ name: "TextEdit_editingFinished"
+ when: windowShown
+
+ function test_editingFinished() {
+ control1.forceActiveFocus()
+ verify(control1.activeFocus)
+ verify(!control2.activeFocus)
+
+ verify(control1.myeditingfinished === false)
+ verify(control2.myeditingfinished === false)
+
+ keyClick(Qt.Key_Backtab)
+ verify(!control1.activeFocus)
+ verify(control2.activeFocus)
+ verify(control1.myeditingfinished === true)
+
+ keyClick(Qt.Key_Backtab)
+ verify(control1.activeFocus)
+ verify(!control2.activeFocus)
+ verify(control2.myeditingfinished === true)
+ }
+ }
+}
diff --git a/tests/auto/qmltest/window/tst_clickwindow.qml b/tests/auto/qmltest/window/tst_clickwindow.qml
new file mode 100644
index 0000000000..bbe091990c
--- /dev/null
+++ b/tests/auto/qmltest/window/tst_clickwindow.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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:
+**
+** "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.0
+import QtQuick.Window 2.0
+import QtTest 1.1
+
+Item {
+ width: height
+ height: 40
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+
+ property bool everClicked: false
+
+ onClicked: everClicked = true;
+ }
+
+ Window {
+ id: ma2Window
+ width: height
+ height: 40
+ MouseArea {
+ id: ma2
+ anchors.fill: parent
+
+ property bool everClicked: false
+
+ onClicked: everClicked = true;
+ }
+
+ Component.onCompleted: ma2Window.show();
+ }
+
+ TestCase {
+ name: "ClickWindow"
+ when: windowShown
+
+ function test_clickBothWindows() {
+ mouseClick(ma, 20, 20);
+ verify(ma.everClicked);
+ mouseClick(ma2, 20, 20);
+ verify(ma2.everClicked);
+ }
+ }
+}