aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-08-26 12:46:42 +0200
committerMitch Curtis <mitch.curtis@qt.io>2016-09-02 08:23:49 +0000
commit58326f2bc3bceafc0054e790832e0a77db340606 (patch)
tree596cd37c11aab8077980e7e6db9f65e200e1bf82 /tests
parent67f67f2cc6de160ddea4aa76afc56e86415ed99b (diff)
StackView: add removed() attached signal
This provides an opportunity for users to destroy items that StackView doesn't, like objects that are pushed as Items. [ChangeLog][Controls][StackView] Added StackView.removed() attached signal to provide a way to delete items that StackView won't. Task-number: QTBUG-55405 Change-Id: I59096efaf1a95d36451fbf1f46b8f68ee96c20de Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_stackview.qml54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml
index 2de0fb98..4de8bed0 100644
--- a/tests/auto/controls/data/tst_stackview.qml
+++ b/tests/auto/controls/data/tst_stackview.qml
@@ -680,6 +680,60 @@ TestCase {
}
Component {
+ id: removeComponent
+
+ Item {
+ objectName: "removeItem"
+ StackView.onRemoved: destroy()
+ }
+ }
+
+ function test_destroyOnRemoved() {
+ var control = stackView.createObject(testCase, { initialItem: component })
+ verify(control)
+
+ var item = removeComponent.createObject(control)
+ verify(item)
+
+ var removedSpy = signalSpy.createObject(control, { target: item.StackView, signalName: "removed" })
+ verify(removedSpy)
+ verify(removedSpy.valid)
+
+ var destructionSpy = signalSpy.createObject(control, { target: item.Component, signalName: "destruction" })
+ verify(destructionSpy)
+ verify(destructionSpy.valid)
+
+ // push-pop
+ control.push(item, StackView.Immediate)
+ compare(control.currentItem, item)
+ control.pop(StackView.Transition)
+ item = null
+ tryCompare(removedSpy, "count", 1)
+ tryCompare(destructionSpy, "count", 1)
+ compare(control.busy, false)
+
+ item = removeComponent.createObject(control)
+ verify(item)
+
+ removedSpy.target = item.StackView
+ verify(removedSpy.valid)
+
+ destructionSpy.target = item.Component
+ verify(destructionSpy.valid)
+
+ // push-replace
+ control.push(item, StackView.Immediate)
+ compare(control.currentItem, item)
+ control.replace(component, StackView.Transition)
+ item = null
+ tryCompare(removedSpy, "count", 2)
+ tryCompare(destructionSpy, "count", 2)
+ compare(control.busy, false)
+
+ control.destroy()
+ }
+
+ Component {
id: attachedItem
Item {
property int index: StackView.index