diff options
Diffstat (limited to 'tests/auto/controls/data/tst_container.qml')
-rw-r--r-- | tests/auto/controls/data/tst_container.qml | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml index 7c5efc1f..c5e74eeb 100644 --- a/tests/auto/controls/data/tst_container.qml +++ b/tests/auto/controls/data/tst_container.qml @@ -177,4 +177,46 @@ TestCase { compare(control.itemAt(2).objectName, "2") compare(control.itemAt(3).objectName, "3") } + + function test_removeTakeItem() { + var control = createTemporaryObject(container, testCase) + verify(control) + + var item1 = rectangle.createObject(control) + var item2 = rectangle.createObject(control) + var item3 = rectangle.createObject(control) + + item1.Component.onDestruction.connect(function() { item1 = null }) + item2.Component.onDestruction.connect(function() { item2 = null }) + item3.Component.onDestruction.connect(function() { item3 = null }) + + control.addItem(item1) + control.addItem(item2) + control.addItem(item3) + compare(control.count, 3) + + // takeItem(int) does not destroy + compare(control.takeItem(1), item2) + compare(control.count, 2) + wait(1) + verify(item2) + + // removeItem(Item) destroys + control.removeItem(item1) + compare(control.count, 1) + wait(1) + verify(!item1) + + // removeItem(null) must not call removeItem(0) + control.removeItem(null) + compare(control.count, 1) + wait(1) + verify(item3) + + // deprecated removeItem(int) does not destroy + control.removeItem(0) + compare(control.count, 0) + wait(1) + verify(item3) + } } |