diff options
Diffstat (limited to 'tests/auto/quick/qquickitem2/data')
19 files changed, 696 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem2/data/childrenProperty.qml b/tests/auto/quick/qquickitem2/data/childrenProperty.qml new file mode 100644 index 0000000000..85ddbc1446 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenProperty.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + property bool test1: root.children.length == 3 + property bool test2: root.children[0] == item1 + property bool test3: root.children[1] == item2 + property bool test4: root.children[2] == item3 + property bool test5: root.children[3] == null + + children: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] +} + diff --git a/tests/auto/quick/qquickitem2/data/childrenRect.qml b/tests/auto/quick/qquickitem2/data/childrenRect.qml new file mode 100644 index 0000000000..ebc57aefbe --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRect.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + property int childCount: 0; + + Item { + objectName: "testItem" + width: childrenRect.width + height: childrenRect.height + + Repeater { + id: repeater + model: childCount + delegate: Rectangle { + x: index*10 + y: index*20 + width: 10 + height: 20 + + color: "red" + } + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBug.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml new file mode 100644 index 0000000000..86a4f19c5c --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 200 + + Item { + objectName: "theItem" + anchors.centerIn: parent + width: childrenRect.width + height: childrenRect.height + Rectangle { + id: text1 + anchors.verticalCenter: parent.verticalCenter + width: 100; height: 100; color: "green" + } + Rectangle { + anchors.left: text1.right + anchors.verticalCenter: parent.verticalCenter + width: 100; height: 100; color: "green" + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml new file mode 100644 index 0000000000..6e80ed28af --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml @@ -0,0 +1,53 @@ +import QtQuick 2.0 + +Rectangle { + width:360; + height: 200 + + Item { + objectName: "theItem" + anchors.centerIn: parent + width: childrenRect.width + height: childrenRect.height + Rectangle { + id: header1 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + width: 100; height: 50 + color: "green" + } + Rectangle { + id: text1 + anchors.top: header1.bottom + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + width: 100; height: 50 + color: "blue" + } + } + + states: [ + State { + name: "row" + AnchorChanges { + target: header1 + anchors.horizontalCenter: undefined + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.top: undefined + } + AnchorChanges { + target: text1 + anchors.horizontalCenter: undefined + anchors.verticalCenter: parent.verticalCenter + anchors.top: undefined + anchors.left: header1.right + } + PropertyChanges { + target: text1 + anchors.leftMargin: 10 + anchors.topMargin: 0 + } + } + ] +} diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml new file mode 100644 index 0000000000..518e76509e --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 300 + + Rectangle { + height: childrenRect.height + + Repeater { + model: 1 + Rectangle { } + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/implicitsize.qml b/tests/auto/quick/qquickitem2/data/implicitsize.qml new file mode 100644 index 0000000000..cc6aaf7d60 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/implicitsize.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + implicitWidth: 200 + implicitHeight: 100 + + width: 80 + height: 60 + + function resetSize() { + width = undefined + height = undefined + } + + function changeImplicit() { + implicitWidth = 150 + implicitHeight = 80 + } +} diff --git a/tests/auto/quick/qquickitem2/data/keynavigationtest.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml new file mode 100644 index 0000000000..aacb621fb0 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml @@ -0,0 +1,87 @@ +import QtQuick 2.0 + +Grid { + columns: 2 + width: 100; height: 100 + function verify() { + if (item1.KeyNavigation.right != item2) + return false; + if (item1.KeyNavigation.down != item3) + return false; + if (item1.KeyNavigation.tab != item2) + return false; + if (item1.KeyNavigation.backtab != item4) + return false; + + if (item2.KeyNavigation.left != item1) + return false; + if (item2.KeyNavigation.down != item4) + return false; + if (item2.KeyNavigation.tab != item3) + return false; + if (item2.KeyNavigation.backtab != item1) + return false; + + if (item3.KeyNavigation.right != item4) + return false; + if (item3.KeyNavigation.up != item1) + return false; + if (item3.KeyNavigation.tab != item4) + return false; + if (item3.KeyNavigation.backtab != item2) + return false; + + if (item4.KeyNavigation.left != item3) + return false; + if (item4.KeyNavigation.up != item2) + return false; + if (item4.KeyNavigation.tab != item1) + return false; + if (item4.KeyNavigation.backtab != item3) + return false; + + return true; + } + + Rectangle { + id: item1 + objectName: "item1" + focus: true + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.right: item2 + KeyNavigation.down: item3 + KeyNavigation.tab: item2 + KeyNavigation.backtab: item4 + } + Rectangle { + id: item2 + objectName: "item2" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.left: item1 + KeyNavigation.down: item4 + KeyNavigation.tab: item3 + KeyNavigation.backtab: item1 + } + Rectangle { + id: item3 + objectName: "item3" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.right: item4 + KeyNavigation.up: item1 + KeyNavigation.tab: item4 + KeyNavigation.backtab: item2 + } + Rectangle { + id: item4 + objectName: "item4" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.left: item3 + KeyNavigation.up: item2 + KeyNavigation.tab: item1 + KeyNavigation.backtab: item3 + } +} diff --git a/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml new file mode 100644 index 0000000000..92d4ae23de --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 + +Grid { + columns: 2 + width: 100; height: 100 + function verify() { + if (item1.KeyNavigation.tab != item2) + return false; + if (item1.KeyNavigation.backtab != item4) + return false; + + if (item2.KeyNavigation.left != item1) + return false; + if (item2.KeyNavigation.down != item4) + return false; + if (item2.KeyNavigation.tab != item3) + return false; + if (item2.KeyNavigation.backtab != item1) + return false; + + if (item3.KeyNavigation.right != item4) + return false; + if (item3.KeyNavigation.up != item1) + return false; + if (item3.KeyNavigation.tab != item4) + return false; + if (item3.KeyNavigation.backtab != item2) + return false; + + return true; + } + + Rectangle { + id: item1 + objectName: "item1" + focus: true + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.tab: item2 + KeyNavigation.backtab: item4 + } + Rectangle { + id: item2 + objectName: "item2" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.left: item1 + KeyNavigation.down: item4 + KeyNavigation.tab: item3 + KeyNavigation.backtab: item1 + } + Rectangle { + id: item3 + objectName: "item3" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.right: item4 + KeyNavigation.up: item1 + KeyNavigation.tab: item4 + KeyNavigation.backtab: item2 + } + Rectangle { + id: item4 + objectName: "item4" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + } +} diff --git a/tests/auto/quick/qquickitem2/data/keysim.qml b/tests/auto/quick/qquickitem2/data/keysim.qml new file mode 100644 index 0000000000..7da8a47681 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keysim.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + focus: true + + Keys.forwardTo: [ item2 ] + + TextInput { + id: item2 + } +} diff --git a/tests/auto/quick/qquickitem2/data/keyspriority.qml b/tests/auto/quick/qquickitem2/data/keyspriority.qml new file mode 100644 index 0000000000..ae51aae776 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keyspriority.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import Test 1.0 + +KeyTestItem { + focus: true + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem + + property int priorityTest: Keys.priority +} diff --git a/tests/auto/quick/qquickitem2/data/keystest.qml b/tests/auto/quick/qquickitem2/data/keystest.qml new file mode 100644 index 0000000000..c70e0061f5 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keystest.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + focus: true + + property bool isEnabled: Keys.enabled + + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers) + Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) } + Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers) + Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers) + Keys.forwardTo: [ item2 ] + Keys.enabled: enableKeyHanding + + Item { + id: item2 + visible: forwardeeVisible + Keys.onPressed: keysTestObject.forwardedKey(event.key) + Keys.onReleased: keysTestObject.forwardedKey(event.key) + } +} diff --git a/tests/auto/quick/qquickitem2/data/layoutmirroring.qml b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml new file mode 100644 index 0000000000..036819740c --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +Item { + property bool childrenInherit: true + Item { + objectName: "mirrored1" + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: parent.childrenInherit + Item { + Item { + objectName: "notMirrored1" + LayoutMirroring.enabled: false + Item { + objectName: "inheritedMirror1" + } + } + Item { + objectName: "inheritedMirror2" + } + } + } + Item { + objectName: "mirrored2" + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: false + Item { + objectName: "notMirrored2" + } + } + Item { + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: true + Loader { + id: loader + } + } + states: State { + name: "newContent" + PropertyChanges { + target: loader + sourceComponent: component + } + } + Component { + id: component + Item { + objectName: "notMirrored3" + LayoutMirroring.enabled: false + Item { + objectName: "inheritedMirror3" + } + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml new file mode 100644 index 0000000000..7b979a54b3 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt 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.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root; objectName: "root" + width: 200; height: 200 + + Item { id: itemA; objectName: "itemA"; x: 50; y: 50 } + + Item { + x: 50; y: 50 + Item { id: itemB; objectName: "itemB"; x: 100; y: 100 } + } + + function mapAToB(x, y) { + var pos = itemA.mapToItem(itemB, x, y) + return Qt.point(pos.x, pos.y) + } + + function mapAFromB(x, y) { + var pos = itemA.mapFromItem(itemB, x, y) + return Qt.point(pos.x, pos.y) + } + + function mapAToNull(x, y) { + var pos = itemA.mapToItem(null, x, y) + return Qt.point(pos.x, pos.y) + } + + function mapAFromNull(x, y) { + var pos = itemA.mapFromItem(null, x, y) + return Qt.point(pos.x, pos.y) + } + + function checkMapAToInvalid(x, y) { + var pos = itemA.mapToItem(1122, x, y) + return pos == undefined; + } + + function checkMapAFromInvalid(x, y) { + var pos = itemA.mapFromItem(1122, x, y) + return pos == undefined; + } +} diff --git a/tests/auto/quick/qquickitem2/data/parentLoop.qml b/tests/auto/quick/qquickitem2/data/parentLoop.qml new file mode 100644 index 0000000000..7b6560fbf7 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/parentLoop.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + Item { + id: item1 + objectName: "item1" + + Item { + id: item2 + objectName: "item2" + } + } + Component.onCompleted: item1.parent = item2 +} diff --git a/tests/auto/quick/qquickitem2/data/propertychanges.qml b/tests/auto/quick/qquickitem2/data/propertychanges.qml new file mode 100644 index 0000000000..3fa5ea9c23 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/propertychanges.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + Item { + objectName: "item" + } + Item { + objectName: "parentItem" + } +} diff --git a/tests/auto/quick/qquickitem2/data/qtbug_16871.qml b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml new file mode 100644 index 0000000000..f1e7377730 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + children: [ 10 ] +} diff --git a/tests/auto/quick/qquickitem2/data/resourcesProperty.qml b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml new file mode 100644 index 0000000000..b8f18bb375 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Item { + id: root + + property bool test1 + property bool test2 + property bool test3 + property bool test4 + property bool test5 + + Component.onCompleted: { + test1 = (root.resources.length >= 3) + test2 = root.resources[0] == item1 + test3 = root.resources[1] == item2 + test4 = root.resources[2] == item3 + test5 = root.resources[10] == null + } + + resources: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] +} diff --git a/tests/auto/quick/qquickitem2/data/transformCrash.qml b/tests/auto/quick/qquickitem2/data/transformCrash.qml new file mode 100644 index 0000000000..284e85f0e0 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/transformCrash.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + id: wrapper + width: 200 + height: 200 + + QtObject { + id: object + } + + Component.onCompleted: wrapper.transform = object +} diff --git a/tests/auto/quick/qquickitem2/data/visiblechildren.qml b/tests/auto/quick/qquickitem2/data/visiblechildren.qml new file mode 100644 index 0000000000..e51eb3551b --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/visiblechildren.qml @@ -0,0 +1,143 @@ +import QtQuick 2.0 + +Item { + id: root + width: 400 + height: 300 + + Row { + id: row + Item { id: item1 + Item { id: item1_1; visible: true } + Item { id: item1_2; visible: true } + } + Item { id: item2 } + Item { id: item3 + Item { id: item3_1; visible: false } + Item { id: item3_2; visible: false } + } + Item { id: item4; visible: false + Item { id: item4_1 // implicitly invisible + Item { id: item4_1_1 } // implicitly invisible + Item { id: item4_1_2 } // implicitly invisible + } + } + } + + property int row_changeEventCalls: 0 + property int item1_changeEventCalls: 0 + property int item2_changeEventCalls: 0 + property int item3_changeEventCalls: 0 + property int item4_1_changeEventCalls: 0 + property int item4_1_1_changeEventCalls: 0 + Connections { target: row; onVisibleChildrenChanged: row_changeEventCalls++ } + Connections { target: item1; onVisibleChildrenChanged: item1_changeEventCalls++ } + Connections { target: item2; onVisibleChildrenChanged: item2_changeEventCalls++ } + Connections { target: item3; onVisibleChildrenChanged: item3_changeEventCalls++ } + Connections { target: item4_1; onVisibleChildrenChanged: item4_1_changeEventCalls++ } + Connections { target: item4_1_1; onVisibleChildrenChanged: item4_1_1_changeEventCalls++ } + + // Make sure there are three visible children and no signals fired yet + property bool test1_1: row.visibleChildren.length == 3 + property bool test1_2: row.visibleChildren[0] == item1 && row.visibleChildren[1] == item2 && row.visibleChildren[2] == item3 + property bool test1_3: row_changeEventCalls == 0 + property bool test1_4: item1_changeEventCalls == 0 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 + + // Next test + function hideFirstAndLastRowChild() { + item1.visible = false; + item3.visible = false; + } + + // Make sure row is signaled twice and item1 only once, and item3 not at all, and that item2 is the visible child + property bool test2_1: row.visibleChildren.length == 1 + property bool test2_2: row.visibleChildren[0] == item2 + property bool test2_3: row_changeEventCalls == 2 + property bool test2_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 + + // Next test + function showLastRowChildsLastChild() { + item3_2.visible = true; + } + + // Make sure item3_changeEventCalls is not signaled + property bool test3_1: row.visibleChildren.length == 1 + property bool test3_2: row.visibleChildren[0] == item2 + property bool test3_3: row_changeEventCalls == 2 + property bool test3_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 + + // Next test + function showLastRowChild() { + item3.visible = true; + } + + // Make sure row and item3 are signaled + property bool test4_1: row.visibleChildren.length == 2 + property bool test4_2: row.visibleChildren[0] == item2 && row.visibleChildren[1] == item3 + property bool test4_3: row_changeEventCalls == 3 + property bool test4_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 1 + + // Next test + function tryWriteToReadonlyVisibleChildren() { + var foo = fooComponent.createObject(root); + if (Qt.isQtObject(foo) && foo.children.length == 3 && foo.visibleChildren.length == 3) { + test5_1 = true; + } + + foo.visibleChildren.length = 10; // make sure this has no effect + test5_1 = (foo.visibleChildren.length == 3); + delete foo; + } + + Component { + id: fooComponent + Item { + children: [ Item {},Item {},Item {} ] + visibleChildren: [ Item {} ] + } + } + + // Make sure visibleChildren.length is 3 and stays that way + property bool test5_1: false + + // Next test + function reparentVisibleItem3() { + item3.parent = hiddenItem; // item3 has one visible children + } + + Item { id: hiddenItem; visible: false } + + property bool test6_1: row.visibleChildren.length == 1 && row_changeEventCalls == 4 + property bool test6_2: item3_changeEventCalls == 2 + property bool test6_3: item3.visible == false + + // Next test + + property bool test6_4: item4_1.visible == false && item4_1_changeEventCalls == 0 + + function reparentImlicitlyInvisibleItem4_1() { + item4_1.parent = visibleItem; + } + + Item { id: visibleItem; visible: true } + property int visibleItem_changeEventCalls: 0 + Connections { target: visibleItem; onVisibleChildrenChanged: visibleItem_changeEventCalls++ } + + + // Make sure that an item with implictly invisible children will be signaled when reparented to a visible parent + property bool test7_1: row.visibleChildren.length == 1 && row_changeEventCalls == 4 + property bool test7_2: item4_1.visible == true + property bool test7_3: item4_1_changeEventCalls == 1 + property bool test7_4: visibleItem_changeEventCalls == 1 + + + + // FINALLY make sure nothing has changes while we weren't paying attention + + property bool test8_1: row.visibleChildren.length == 1 && row.visibleChildren[0] == item2 && row_changeEventCalls == 4 + property bool test8_2: item1_changeEventCalls == 1 && item1.visible == false + property bool test8_3: item2_changeEventCalls == 0 && item2.visible == true + property bool test8_4: item3_changeEventCalls == 2 && item3.visible == false + property bool test8_5: item4_1_1_changeEventCalls == 0 && item4_1_1.visible == true + +} |