aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quickcontrols2/controls/data/tst_stackview.qml')
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_stackview.qml52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
index f2a3781fb1..901c9609a0 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
@@ -4,6 +4,7 @@
import QtQuick
import QtTest
import QtQuick.Controls
+import Qt.test.controls
TestCase {
id: testCase
@@ -1225,7 +1226,12 @@ TestCase {
Item {
objectName: "clearUponDestructionItem"
- Component.onDestruction: container.onDestructionCallback(stackView)
+ onParentChanged: {
+ // We don't actually do this on destruction because destruction is delayed.
+ // Rather, we do it when we get un-parented.
+ if (parent === null)
+ container.onDestructionCallback(stackView)
+ }
}
}
@@ -1544,4 +1550,48 @@ TestCase {
tryCompare(control, "busy", true)
tryCompare(control, "busy", false)
}
+
+ Component {
+ id: cppComponent
+
+ StackView {
+ id: stackView
+ anchors.fill: parent
+ initialItem: cppComponent
+
+ property Component cppComponent: ComponentCreator.createComponent("import QtQuick; Rectangle { color: \"navajowhite\" }")
+ }
+ }
+
+ // Test that a component created in C++ works with StackView.
+ function test_componentCreatedInCpp() {
+ let control = createTemporaryObject(cppComponent, testCase)
+ verify(control)
+ compare(control.currentItem.color, Qt.color("navajowhite"))
+
+ control.push(control.cppComponent, { color: "tomato" })
+ compare(control.currentItem.color, Qt.color("tomato"))
+ }
+
+ Component {
+ id: noProperties
+ Item {}
+ }
+
+ Component {
+ id: invalidProperties
+
+ StackView {
+ anchors.fill: parent
+ }
+ }
+
+ function test_invalidProperties() {
+ let control = createTemporaryObject(invalidProperties, testCase)
+ verify(control)
+ verify(control.empty)
+ ignoreWarning(/Cannot resolve property "unknownProperty.test"/)
+ control.push(noProperties, { "unknownProperty.test": "crashes" })
+ verify(!control.empty)
+ }
}