aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-01 19:18:31 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-03 09:35:49 +0000
commita108298bb9529dd1ad4b195849f3c1e12daa82bf (patch)
tree73510314439ab8c13764d1ed906b7e9154d53d15 /tests
parent92aa5333846081b294fc332e64f7e49b329edf92 (diff)
Add AbstractButton::autoExclusive
This feature is adopted from QtWidgets' QAbstractButton. It's no longer necessary to create an ExclusiveGroup to manage a simple list of radio buttons: Column { RadioButton { text: "Option 1" } RadioButton { text: "Option 2" } } Change-Id: Ib4cb718c3b3034c9c956b2f23db4b06b00547b8e Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_radiobutton.qml68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml
index d76a8c38..2df3542d 100644
--- a/tests/auto/controls/data/tst_radiobutton.qml
+++ b/tests/auto/controls/data/tst_radiobutton.qml
@@ -225,4 +225,72 @@ TestCase {
container.destroy()
}
+
+ Component {
+ id: radioButtonGroup
+ Column {
+ // auto-exclusive buttons behave as if they were in their own exclusive group
+ RadioButton { }
+ RadioButton { }
+
+ // explicitly grouped buttons are only exclusive with each other, not with
+ // auto-exclusive buttons, and the autoExclusive property is ignored
+ ExclusiveGroup { id: eg }
+ RadioButton { ExclusiveGroup.group: eg }
+ RadioButton { ExclusiveGroup.group: eg; autoExclusive: false }
+
+ // non-exclusive buttons don't affect the others
+ RadioButton { autoExclusive: false }
+ RadioButton { autoExclusive: false }
+ }
+ }
+
+ function test_autoExclusive() {
+ var container = radioButtonGroup.createObject(testCase)
+ compare(container.children.length, 6)
+
+ var checkStates = [false, false, false, false, false, false]
+ for (var i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[0].checked = true
+ checkStates[0] = true
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[1].checked = true
+ checkStates[0] = false
+ checkStates[1] = true
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[2].checked = true
+ checkStates[2] = true
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[3].checked = true
+ checkStates[2] = false
+ checkStates[3] = true
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[4].checked = true
+ checkStates[4] = true
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[5].checked = true
+ checkStates[5] = true
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.children[0].checked = true
+ checkStates[0] = true
+ checkStates[1] = false
+ for (i = 0; i < 6; ++i)
+ compare(container.children[i].checked, checkStates[i])
+
+ container.destroy()
+ }
}