diff options
Diffstat (limited to 'tests/auto/qtquick2/qquickitem2')
21 files changed, 0 insertions, 2091 deletions
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml b/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml deleted file mode 100644 index 85ddbc1446..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml +++ /dev/null @@ -1,14 +0,0 @@ -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/qtquick2/qquickitem2/data/childrenRect.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml deleted file mode 100644 index ebc57aefbe..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml +++ /dev/null @@ -1,27 +0,0 @@ -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/qtquick2/qquickitem2/data/childrenRectBug.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml deleted file mode 100644 index 86a4f19c5c..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml +++ /dev/null @@ -1,23 +0,0 @@ -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/qtquick2/qquickitem2/data/childrenRectBug2.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml deleted file mode 100644 index 6e80ed28af..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml +++ /dev/null @@ -1,53 +0,0 @@ -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/qtquick2/qquickitem2/data/childrenRectBug3.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml deleted file mode 100644 index 518e76509e..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300 - height: 300 - - Rectangle { - height: childrenRect.height - - Repeater { - model: 1 - Rectangle { } - } - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml b/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml deleted file mode 100644 index cc6aaf7d60..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml +++ /dev/null @@ -1,19 +0,0 @@ -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/qtquick2/qquickitem2/data/keynavigationtest.qml b/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml deleted file mode 100644 index aacb621fb0..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml +++ /dev/null @@ -1,87 +0,0 @@ -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/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml b/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml deleted file mode 100644 index 92d4ae23de..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml +++ /dev/null @@ -1,68 +0,0 @@ -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/qtquick2/qquickitem2/data/keysim.qml b/tests/auto/qtquick2/qquickitem2/data/keysim.qml deleted file mode 100644 index 7da8a47681..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keysim.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - focus: true - - Keys.forwardTo: [ item2 ] - - TextInput { - id: item2 - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml b/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml deleted file mode 100644 index ae51aae776..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml +++ /dev/null @@ -1,11 +0,0 @@ -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/qtquick2/qquickitem2/data/keystest.qml b/tests/auto/qtquick2/qquickitem2/data/keystest.qml deleted file mode 100644 index c70e0061f5..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keystest.qml +++ /dev/null @@ -1,24 +0,0 @@ -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/qtquick2/qquickitem2/data/layoutmirroring.qml b/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml deleted file mode 100644 index 036819740c..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml +++ /dev/null @@ -1,54 +0,0 @@ -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/qtquick2/qquickitem2/data/mapCoordinates.qml b/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml deleted file mode 100644 index 7b979a54b3..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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/qtquick2/qquickitem2/data/parentLoop.qml b/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml deleted file mode 100644 index 7b6560fbf7..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml +++ /dev/null @@ -1,14 +0,0 @@ -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/qtquick2/qquickitem2/data/propertychanges.qml b/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml deleted file mode 100644 index 3fa5ea9c23..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Item { - Item { - objectName: "item" - } - Item { - objectName: "parentItem" - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml b/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml deleted file mode 100644 index f1e7377730..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - children: [ 10 ] -} diff --git a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml b/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml deleted file mode 100644 index b8f18bb375..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml +++ /dev/null @@ -1,21 +0,0 @@ -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/qtquick2/qquickitem2/data/transformCrash.qml b/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml deleted file mode 100644 index 284e85f0e0..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -Item { - id: wrapper - width: 200 - height: 200 - - QtObject { - id: object - } - - Component.onCompleted: wrapper.transform = object -} diff --git a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml b/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml deleted file mode 100644 index e51eb3551b..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml +++ /dev/null @@ -1,143 +0,0 @@ -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 - -} diff --git a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro b/tests/auto/qtquick2/qquickitem2/qquickitem2.pro deleted file mode 100644 index 44d3ba37c8..0000000000 --- a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickitem2 -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickitem.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib diff --git a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp deleted file mode 100644 index 9891b8718a..0000000000 --- a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp +++ /dev/null @@ -1,1380 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -#include <qtest.h> -#include <QtTest/QSignalSpy> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativecomponent.h> -#include <QtDeclarative/qdeclarativecontext.h> -#include <QtQuick/qquickview.h> -#include <QtGui/private/qinputmethod_p.h> -#include <QtQuick/private/qquickrectangle_p.h> -#include <QtQuick/private/qquicktextinput_p.h> -#include <private/qquickitem_p.h> -#include "../../shared/util.h" -#include "../shared/visualtestutil.h" -#include "../../shared/platforminputcontext.h" - -using namespace QQuickVisualTestUtil; - -class tst_QQuickItem : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickItem(); - -private slots: - void initTestCase(); - void cleanup(); - - void keys(); - void keysProcessingOrder(); - void keysim(); - void keyNavigation(); - void keyNavigation_RightToLeft(); - void keyNavigation_skipNotVisible(); - void keyNavigation_implicitSetting(); - void layoutMirroring(); - void layoutMirroringIllegalParent(); - void smooth(); - void clip(); - void mapCoordinates(); - void mapCoordinates_data(); - void propertyChanges(); - void transforms(); - void transforms_data(); - void childrenRect(); - void childrenRectBug(); - void childrenRectBug2(); - void childrenRectBug3(); - - void childrenProperty(); - void resourcesProperty(); - - void transformCrash(); - void implicitSize(); - void qtbug_16871(); - void visibleChildren(); - void parentLoop(); -private: - QDeclarativeEngine engine; -}; - -class KeysTestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) - -public: - KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} - - void reset() { - mKey = 0; - mText = QString(); - mModifiers = 0; - mForwardedKey = 0; - } - - bool processLast() const { return mLast; } - void setProcessLast(bool b) { - if (b != mLast) { - mLast = b; - emit processLastChanged(); - } - } - -public slots: - void keyPress(int key, QString text, int modifiers) { - mKey = key; - mText = text; - mModifiers = modifiers; - } - void keyRelease(int key, QString text, int modifiers) { - mKey = key; - mText = text; - mModifiers = modifiers; - } - void forwardedKey(int key) { - mForwardedKey = key; - } - -signals: - void processLastChanged(); - -public: - int mKey; - QString mText; - int mModifiers; - int mForwardedKey; - bool mLast; - -private: -}; - -class KeyTestItem : public QQuickItem -{ - Q_OBJECT -public: - KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {} - -protected: - void keyPressEvent(QKeyEvent *e) { - mKey = e->key(); - - if (e->key() == Qt::Key_A) - e->accept(); - else - e->ignore(); - } - - void keyReleaseEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_B) - e->accept(); - else - e->ignore(); - } - -public: - int mKey; -}; - -QML_DECLARE_TYPE(KeyTestItem); - - -tst_QQuickItem::tst_QQuickItem() -{ -} - -void tst_QQuickItem::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem"); -} - -void tst_QQuickItem::cleanup() -{ - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; -} - -void tst_QQuickItem::keys() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - KeysTestObject *testObject = new KeysTestObject; - canvas->rootContext()->setContextProperty("keysTestObject", testObject); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true)); - - canvas->setSource(testFileUrl("keystest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QVERIFY(canvas->rootObject()); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); - - QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::ShiftModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Return)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return)); - QCOMPARE(testObject->mText, QLatin1String("Return")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_0)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0)); - QCOMPARE(testObject->mText, QLatin1String("0")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_9)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9)); - QCOMPARE(testObject->mText, QLatin1String("9")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Tab)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab)); - QCOMPARE(testObject->mText, QLatin1String("Tab")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Backtab)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab)); - QCOMPARE(testObject->mText, QLatin1String("Backtab")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false)); - key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, 0); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(!key.isAccepted()); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Return)); - QVERIFY(key.isAccepted()); - - delete canvas; - delete testObject; -} - -void tst_QQuickItem::keysProcessingOrder() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - KeysTestObject *testObject = new KeysTestObject; - canvas->rootContext()->setContextProperty("keysTestObject", testObject); - - canvas->setSource(testFileUrl("keyspriority.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject()); - QVERIFY(testItem); - - QCOMPARE(testItem->property("priorityTest").toInt(), 0); - - QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - testObject->setProcessLast(true); - - QCOMPARE(testItem->property("priorityTest").toInt(), 1); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_B)); - QCOMPARE(testObject->mText, QLatin1String("B")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(key.isAccepted()); - - delete canvas; - delete testObject; -} - -void tst_QQuickItem::keysim() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keysim.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QVERIFY(canvas->rootObject()); - QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus()); - - QQuickTextInput *input = canvas->rootObject()->findChild<QQuickTextInput*>(); - QVERIFY(input); - - QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); - - QEXPECT_FAIL("", "QTBUG-24280", Continue); - QCOMPARE(input->text(), QLatin1String("Hello world!")); - - delete canvas; -} - -QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString) -{ - QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString))); - QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item); - return itemPrivate; -} - -QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property) -{ - QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString))); - return item->property(property); -} - -bool anchorsMirrored(QQuickItem *rootItem, const char * itemString) -{ - QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString))); - QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item); - return itemPrivate->anchors()->mirrored(); -} - -void tst_QQuickItem::layoutMirroring() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("layoutmirroring.qml")); - canvas->show(); - - QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(rootItem); - QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem); - QVERIFY(rootPrivate); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); - - QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true); - QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true); - QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false); - QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false); - QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true); - QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false); - - // load dynamic content using Loader that needs to inherit mirroring - rootItem->setProperty("state", "newContent"); - QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); - - // disable inheritance - rootItem->setProperty("childrenInherit", false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false); - - // re-enable inheritance - rootItem->setProperty("childrenInherit", true); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); - - // - // dynamic parenting - // - QQuickItem *parentItem1 = new QQuickItem(); - QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false; - QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true - QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror(); - - // inherit in constructor - QQuickItem *childItem1 = new QQuickItem(parentItem1); - QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true); - QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true); - - // inherit through a parent change - QQuickItem *childItem2 = new QQuickItem(); - QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false); - QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false); - childItem2->setParentItem(parentItem1); - QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true); - QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true); - - // stop inherting through a parent change - QQuickItem *parentItem2 = new QQuickItem(); - QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror(); - childItem2->setParentItem(parentItem2); - QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false); - QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false); - - delete parentItem1; - delete parentItem2; -} - -void tst_QQuickItem::layoutMirroringIllegalParent() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile("")); - QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items"); - QObject *object = component.create(); - QVERIFY(object != 0); -} - -void tst_QQuickItem::keyNavigation() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // down - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // up - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::keyNavigation_RightToLeft() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(rootItem); - QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem); - - rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true - rootItemPrivate->isMirrorImplicit = false; - rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true - rootItemPrivate->resolveLayoutMirror(); - - QEvent wa(QEvent::WindowActivate); - QGuiApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QGuiApplication::sendEvent(canvas, &fe); - - QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::keyNavigation_skipNotVisible() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Set item 2 to not visible - item = findItem<QQuickItem>(canvas->rootObject(), "item2"); - QVERIFY(item); - item->setVisible(false); - QVERIFY(!item->isVisible()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - //Set item 3 to not visible - item = findItem<QQuickItem>(canvas->rootObject(), "item3"); - QVERIFY(item); - item->setVisible(false); - QVERIFY(!item->isVisible()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::keyNavigation_implicitSetting() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest_implicit.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QEvent wa(QEvent::WindowActivate); - QGuiApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QGuiApplication::sendEvent(canvas, &fe); - - QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // down - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // move to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // up - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::smooth() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); - QSignalSpy spy(item, SIGNAL(smoothChanged(bool))); - - QVERIFY(item); - QVERIFY(!item->smooth()); - - item->setSmooth(true); - QVERIFY(item->smooth()); - QCOMPARE(spy.count(),1); - QList<QVariant> arguments = spy.first(); - QVERIFY(arguments.count() == 1); - QVERIFY(arguments.at(0).toBool() == true); - - item->setSmooth(true); - QCOMPARE(spy.count(),1); - - item->setSmooth(false); - QVERIFY(!item->smooth()); - QCOMPARE(spy.count(),2); - item->setSmooth(false); - QCOMPARE(spy.count(),2); - - delete item; -} - -void tst_QQuickItem::clip() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); - QSignalSpy spy(item, SIGNAL(clipChanged(bool))); - - QVERIFY(item); - QVERIFY(!item->clip()); - - item->setClip(true); - QVERIFY(item->clip()); - - QList<QVariant> arguments = spy.first(); - QVERIFY(arguments.count() == 1); - QVERIFY(arguments.at(0).toBool() == true); - - QCOMPARE(spy.count(),1); - item->setClip(true); - QCOMPARE(spy.count(),1); - - item->setClip(false); - QVERIFY(!item->clip()); - QCOMPARE(spy.count(),2); - item->setClip(false); - QCOMPARE(spy.count(),2); - - delete item; -} - -void tst_QQuickItem::mapCoordinates() -{ - QFETCH(int, x); - QFETCH(int, y); - - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(300, 300)); - canvas->setSource(testFileUrl("mapCoordinates.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(root != 0); - QQuickItem *a = findItem<QQuickItem>(canvas->rootObject(), "itemA"); - QVERIFY(a != 0); - QQuickItem *b = findItem<QQuickItem>(canvas->rootObject(), "itemB"); - QVERIFY(b != 0); - - QVariant result; - - QVERIFY(QMetaObject::invokeMethod(root, "mapAToB", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y))); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y))); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToScene(QPointF(x, y))); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y))); - - QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; - QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QVERIFY(result.toBool()); - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QVERIFY(result.toBool()); - - delete canvas; -} - -void tst_QQuickItem::mapCoordinates_data() -{ - QTest::addColumn<int>("x"); - QTest::addColumn<int>("y"); - - for (int i=-20; i<=20; i+=10) - QTest::newRow(QTest::toString(i)) << i << i; -} - -void tst_QQuickItem::transforms_data() -{ - QTest::addColumn<QByteArray>("qml"); - QTest::addColumn<QTransform>("transform"); - QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") - << QTransform(1,0,0,0,1,0,10,20,1); - QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") - << QTransform(0,1,0,-1,0,0,0,0,1); - QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") - << QTransform(1.5,0,0,0,-2,0,0,0,1); - QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]") - << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1); -} - -void tst_QQuickItem::transforms() -{ - QFETCH(QByteArray, qml); - QFETCH(QTransform, transform); - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); - QVERIFY(item); - QCOMPARE(item->itemTransform(0,0), transform); -} - -void tst_QQuickItem::childrenProperty() -{ - QDeclarativeComponent component(&engine, testFileUrl("childrenProperty.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - delete o; -} - -void tst_QQuickItem::resourcesProperty() -{ - QDeclarativeComponent component(&engine, testFileUrl("resourcesProperty.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - delete o; -} - -void tst_QQuickItem::propertyChanges() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(300, 300)); - canvas->setSource(testFileUrl("propertychanges.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item"); - QQuickItem *parentItem = findItem<QQuickItem>(canvas->rootObject(), "parentItem"); - - QVERIFY(item); - QVERIFY(parentItem); - - QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *))); - QSignalSpy widthSpy(item, SIGNAL(widthChanged())); - QSignalSpy heightSpy(item, SIGNAL(heightChanged())); - QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); - QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); - QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); - QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); - QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged())); - QSignalSpy xSpy(item, SIGNAL(xChanged())); - QSignalSpy ySpy(item, SIGNAL(yChanged())); - - item->setParentItem(parentItem); - item->setWidth(100.0); - item->setHeight(200.0); - item->setFocus(true); - item->setBaselineOffset(10.0); - - QCOMPARE(item->parentItem(), parentItem); - QCOMPARE(parentSpy.count(),1); - QList<QVariant> parentArguments = parentSpy.first(); - QVERIFY(parentArguments.count() == 1); - QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0))); - QCOMPARE(childrenChangedSpy.count(),1); - - item->setParentItem(parentItem); - QCOMPARE(childrenChangedSpy.count(),1); - - QCOMPARE(item->width(), 100.0); - QCOMPARE(widthSpy.count(),1); - - QCOMPARE(item->height(), 200.0); - QCOMPARE(heightSpy.count(),1); - - QCOMPARE(item->baselineOffset(), 10.0); - QCOMPARE(baselineOffsetSpy.count(),1); - QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first(); - QVERIFY(baselineOffsetArguments.count() == 1); - QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal()); - - QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0)); - QCOMPARE(childrenRectSpy.count(),1); - QList<QVariant> childrenRectArguments = childrenRectSpy.at(0); - QVERIFY(childrenRectArguments.count() == 1); - QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); - - QCOMPARE(item->hasActiveFocus(), true); - QCOMPARE(focusSpy.count(),1); - QList<QVariant> focusArguments = focusSpy.first(); - QVERIFY(focusArguments.count() == 1); - QCOMPARE(focusArguments.at(0).toBool(), true); - - QCOMPARE(parentItem->hasActiveFocus(), false); - QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(wantsFocusSpy.count(),0); - - item->setX(10.0); - QCOMPARE(item->x(), 10.0); - QCOMPARE(xSpy.count(), 1); - - item->setY(10.0); - QCOMPARE(item->y(), 10.0); - QCOMPARE(ySpy.count(), 1); - - delete canvas; -} - -void tst_QQuickItem::childrenRect() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("childrenRect.qml")); - canvas->setBaseSize(QSize(240,320)); - canvas->show(); - - QQuickItem *o = canvas->rootObject(); - QQuickItem *item = o->findChild<QQuickItem*>("testItem"); - QCOMPARE(item->width(), qreal(0)); - QCOMPARE(item->height(), qreal(0)); - - o->setProperty("childCount", 1); - QCOMPARE(item->width(), qreal(10)); - QCOMPARE(item->height(), qreal(20)); - - o->setProperty("childCount", 5); - QCOMPARE(item->width(), qreal(50)); - QCOMPARE(item->height(), qreal(100)); - - o->setProperty("childCount", 0); - QCOMPARE(item->width(), qreal(0)); - QCOMPARE(item->height(), qreal(0)); - - delete o; - delete canvas; -} - -// QTBUG-11383 -void tst_QQuickItem::childrenRectBug() -{ - QQuickView *canvas = new QQuickView(0); - - QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - - canvas->setSource(testFileUrl("childrenRectBug.qml")); - canvas->show(); - - QQuickItem *o = canvas->rootObject(); - QQuickItem *item = o->findChild<QQuickItem*>("theItem"); - QCOMPARE(item->width(), qreal(200)); - QCOMPARE(item->height(), qreal(100)); - QCOMPARE(item->x(), qreal(100)); - - delete canvas; -} - -// QTBUG-11465 -void tst_QQuickItem::childrenRectBug2() -{ - QQuickView *canvas = new QQuickView(0); - - QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\""; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - - QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - - canvas->setSource(testFileUrl("childrenRectBug2.qml")); - canvas->show(); - - QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject()); - QVERIFY(rect); - QQuickItem *item = rect->findChild<QQuickItem*>("theItem"); - QCOMPARE(item->width(), qreal(100)); - QCOMPARE(item->height(), qreal(110)); - QCOMPARE(item->x(), qreal(130)); - - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - rectPrivate->setState("row"); - QCOMPARE(item->width(), qreal(210)); - QCOMPARE(item->height(), qreal(50)); - QCOMPARE(item->x(), qreal(75)); - - delete canvas; -} - -// QTBUG-12722 -void tst_QQuickItem::childrenRectBug3() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("childrenRectBug3.qml")); - canvas->show(); - - //don't crash on delete - delete canvas; -} - -// QTBUG-13893 -void tst_QQuickItem::transformCrash() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("transformCrash.qml")); - canvas->show(); - - delete canvas; -} - -void tst_QQuickItem::implicitSize() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("implicitsize.qml")); - canvas->show(); - - QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(item); - QCOMPARE(item->width(), qreal(80)); - QCOMPARE(item->height(), qreal(60)); - - QCOMPARE(item->implicitWidth(), qreal(200)); - QCOMPARE(item->implicitHeight(), qreal(100)); - - QMetaObject::invokeMethod(item, "resetSize"); - - QCOMPARE(item->width(), qreal(200)); - QCOMPARE(item->height(), qreal(100)); - - QMetaObject::invokeMethod(item, "changeImplicit"); - - QCOMPARE(item->implicitWidth(), qreal(150)); - QCOMPARE(item->implicitHeight(), qreal(80)); - QCOMPARE(item->width(), qreal(150)); - QCOMPARE(item->height(), qreal(80)); - - delete canvas; -} - -void tst_QQuickItem::qtbug_16871() -{ - QDeclarativeComponent component(&engine, testFileUrl("qtbug_16871.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - delete o; -} - - -void tst_QQuickItem::visibleChildren() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("visiblechildren.qml")); - canvas->show(); - - QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(root); - - QCOMPARE(root->property("test1_1").toBool(), true); - QCOMPARE(root->property("test1_2").toBool(), true); - QCOMPARE(root->property("test1_3").toBool(), true); - QCOMPARE(root->property("test1_4").toBool(), true); - - QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild"); - QCOMPARE(root->property("test2_1").toBool(), true); - QCOMPARE(root->property("test2_2").toBool(), true); - QCOMPARE(root->property("test2_3").toBool(), true); - QCOMPARE(root->property("test2_4").toBool(), true); - - QMetaObject::invokeMethod(root, "showLastRowChildsLastChild"); - QCOMPARE(root->property("test3_1").toBool(), true); - QCOMPARE(root->property("test3_2").toBool(), true); - QCOMPARE(root->property("test3_3").toBool(), true); - QCOMPARE(root->property("test3_4").toBool(), true); - - QMetaObject::invokeMethod(root, "showLastRowChild"); - QCOMPARE(root->property("test4_1").toBool(), true); - QCOMPARE(root->property("test4_2").toBool(), true); - QCOMPARE(root->property("test4_3").toBool(), true); - QCOMPARE(root->property("test4_4").toBool(), true); - - QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren"); - QCOMPARE(root->property("test5_1").toBool(), true); - - QMetaObject::invokeMethod(root, "reparentVisibleItem3"); - QCOMPARE(root->property("test6_1").toBool(), true); - QCOMPARE(root->property("test6_2").toBool(), true); - QCOMPARE(root->property("test6_3").toBool(), true); - QCOMPARE(root->property("test6_4").toBool(), true); - - QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1"); - QCOMPARE(root->property("test7_1").toBool(), true); - QCOMPARE(root->property("test7_2").toBool(), true); - QCOMPARE(root->property("test7_3").toBool(), true); - QCOMPARE(root->property("test7_4").toBool(), true); - - // FINALLY TEST THAT EVERYTHING IS AS EXPECTED - QCOMPARE(root->property("test8_1").toBool(), true); - QCOMPARE(root->property("test8_2").toBool(), true); - QCOMPARE(root->property("test8_3").toBool(), true); - QCOMPARE(root->property("test8_4").toBool(), true); - QCOMPARE(root->property("test8_5").toBool(), true); - - delete canvas; -} - -void tst_QQuickItem::parentLoop() -{ - QQuickView *canvas = new QQuickView(0); - - QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree."); - canvas->setSource(testFileUrl("parentLoop.qml")); - - QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(root); - - QQuickItem *item1 = root->findChild<QQuickItem*>("item1"); - QVERIFY(item1); - QCOMPARE(item1->parentItem(), root); - - QQuickItem *item2 = root->findChild<QQuickItem*>("item2"); - QVERIFY(item2); - QCOMPARE(item2->parentItem(), item1); - - delete canvas; -} - -QTEST_MAIN(tst_QQuickItem) - -#include "tst_qquickitem.moc" |