aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-29 15:58:07 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-30 08:31:24 +0000
commitb4ce31415baba84ca82aec68f4480b3e6ac89b90 (patch)
tree6984bb3adc85564e7f7ac8ed5c80861a392323b1 /tests
parent7433cc2f91d1aba045ab4920d6732c85d2ee33b9 (diff)
TabBar: fix mixing of fixed and implicitly resized tabs
Don't calculate the implicit item width based on the total width of the whole control, but based on the available width that is left after subtracting the items that have an explicit width and won't be resized. Change-Id: Iae18dd9c9756b6f2afa143baab7d2501ce9d4697 Task-number: QTBUG-56265 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_tabbar.qml26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml
index b46f7f00..351db999 100644
--- a/tests/auto/controls/data/tst_tabbar.qml
+++ b/tests/auto/controls/data/tst_tabbar.qml
@@ -504,17 +504,31 @@ TestCase {
control.destroy()
}
- function test_layout() {
- var control = tabBar.createObject(testCase, {spacing: 0, width: 200})
+ function test_layout_data() {
+ return [
+ { tag: "spacing:0", spacing: 0 },
+ { tag: "spacing:1", spacing: 1 },
+ { tag: "spacing:10", spacing: 10 },
+ ]
+ }
+
+ function test_layout(data) {
+ var control = tabBar.createObject(testCase, {spacing: data.spacing, width: 200})
- var tab1 = tabButton.createObject(control)
+ var tab1 = tabButton.createObject(control, {text: "First"})
control.addItem(tab1)
tryCompare(tab1, "width", control.width)
- var tab2 = tabButton.createObject(control)
+ var tab2 = tabButton.createObject(control, {text: "Second"})
control.addItem(tab2)
- tryCompare(tab1, "width", control.width / 2)
- tryCompare(tab2, "width", control.width / 2)
+ tryCompare(tab1, "width", (control.width - data.spacing) / 2)
+ compare(tab2.width, (control.width - data.spacing) / 2)
+
+ var tab3 = tabButton.createObject(control, {width: 50, text: "Third"})
+ control.addItem(tab3)
+ tryCompare(tab1, "width", (control.width - 2 * data.spacing - 50) / 2)
+ compare(tab2.width, (control.width - 2 * data.spacing - 50) / 2)
+ compare(tab3.width, 50)
control.destroy()
}