aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-02 10:29:39 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-02 11:24:25 +0000
commitfda44e6fed0062b8ef91d1cfdb10b1ffa6a3d730 (patch)
tree84136387e7fd07b16d9fdf54a64aa160f1bea79c /tests
parentda61768e9195593f3ad5b262b71e1b90c53fc681 (diff)
Make a plain AbstractButton calculate suitable implicit size
Just like commit 87b21a57 made Control do it, this applies the same logic to AbstractButton. The simple reasoning is that when customizing both the contentItem and the background, it is much better to use the AbstractButton type that does not have any default building blocks. Previously you would have to supply implicit size calculation as well, but this makes it much more convenient to use. [ChangeLog][Controls][AbstractButton] A plain AbstractButton now calculates its implicit size based on the implicit size of the content item plus paddings, and the implicit size of the background item. Change-Id: Ic380366b25940fbb9f28882c4622d58f4c042a07 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index c94653d9..ba5ee94c 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -55,6 +55,11 @@ TestCase {
AbstractButton {}
}
+ Component {
+ id: item
+ Item { }
+ }
+
function test_text() {
var control = button.createObject(testCase);
verify(control);
@@ -67,4 +72,35 @@ TestCase {
control.destroy();
}
+
+ function test_baseline() {
+ var control = button.createObject(testCase, {padding: 6})
+ verify(control)
+ compare(control.baselineOffset, 0)
+ control.contentItem = item.createObject(control, {baselineOffset: 12})
+ compare(control.baselineOffset, 18)
+ control.destroy()
+ }
+
+ function test_implicitSize() {
+ var control = button.createObject(testCase)
+ verify(control)
+
+ compare(control.implicitWidth, 0)
+ compare(control.implicitHeight, 0)
+
+ control.contentItem = item.createObject(control, {implicitWidth: 10, implicitHeight: 20})
+ compare(control.implicitWidth, 10)
+ compare(control.implicitHeight, 20)
+
+ control.background = item.createObject(control, {implicitWidth: 20, implicitHeight: 30})
+ compare(control.implicitWidth, 20)
+ compare(control.implicitHeight, 30)
+
+ control.padding = 100
+ compare(control.implicitWidth, 210)
+ compare(control.implicitHeight, 220)
+
+ control.destroy()
+ }
}