aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_abstractbutton.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2017-12-20 16:36:39 +0100
committerMitch Curtis <mitch.curtis@qt.io>2017-12-22 12:59:46 +0000
commit146bc9517c56feda4eba34282d3cc53bd47b6267 (patch)
treedd84bbabd42e16db89e8e2af2d6becab136b05b3 /tests/auto/controls/data/tst_abstractbutton.qml
parentb12371c4bbc6035ad0ea60f2bc8a5ca4d48610ad (diff)
Make AbstractButton's text win over action's when both are specified
The idea is that you share a generic Action in different places in the UI, and then you override things locally in specific controls. This patch enforces that by changing QQuickAbstractButton::text() to return the Button's text if explicitly set (or there isn't an Action), or the action's text if one is set. Change-Id: Iae422abca35c9598f73ba7a1d3f1387c36037ec0 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_abstractbutton.qml')
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index ea381a32..508cfd43 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -227,6 +227,9 @@ TestCase {
compare(control.checked, true)
compare(control.enabled, false)
+ var textSpy = signalSpy.createObject(control, { target: control, signalName: "textChanged" })
+ verify(textSpy.valid)
+
// changes via action
control.action.text = "Action"
control.action.icon.name = "action"
@@ -240,6 +243,7 @@ TestCase {
compare(control.checkable, false) // propagates
compare(control.checked, false) // propagates
compare(control.enabled, true) // propagates
+ compare(textSpy.count, 1)
// changes via button
control.text = "Button"
@@ -260,6 +264,27 @@ TestCase {
compare(control.action.checkable, true) // propagates
compare(control.action.checked, true) // propagates
compare(control.action.enabled, true) // does NOT propagate
+ compare(textSpy.count, 2)
+
+ // remove the action so that only the button's text is left
+ control.action = null
+ compare(control.text, "Button")
+ compare(textSpy.count, 2)
+
+ // setting an action while button has text shouldn't cause a change in the button's effective text
+ var secondAction = createTemporaryObject(action, testCase)
+ verify(secondAction)
+ secondAction.text = "SecondAction"
+ control.action = secondAction
+ compare(control.text, "Button")
+ compare(textSpy.count, 2)
+
+ // test setting an action with empty text
+ var thirdAction = createTemporaryObject(action, testCase)
+ verify(thirdAction)
+ control.action = thirdAction
+ compare(control.text, "Button")
+ compare(textSpy.count, 2)
}
Component {
@@ -400,6 +425,7 @@ TestCase {
keyClick(Qt.Key_H, Qt.AltModifier)
compare(clickSpy.count, 4)
+ control.text = undefined
control.action = action.createObject(control, {text: "&Action"})
var actionSpy = signalSpy.createObject(control, {target: control.action, signalName: "triggered"})