aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklayouts
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@theqtcompany.com>2016-02-26 13:13:21 +0100
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2016-03-01 23:31:28 +0000
commita3144972af99a788f19fa84cba9d76948ae046b1 (patch)
tree9c136b293dd9d26de64143c29a95cf96e37106e0 /tests/auto/quick/qquicklayouts
parent83cb2069ead120e7777a13ef6b7c0a0b14052685 (diff)
Make test more data driven
Change-Id: Ia1c2d53c77da29337b4453046ddb3d526c7015e4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick/qquicklayouts')
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml64
1 files changed, 21 insertions, 43 deletions
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index 4b47b396a3..1e7575481a 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -689,40 +689,16 @@ Item {
id: test_distributeToPixelGrid_Component
RowLayout {
spacing: 0
- Rectangle {
- color: 'red'
- Layout.minimumWidth: 10
- Layout.preferredWidth: 50
- Layout.maximumWidth: 90
- Layout.fillWidth: true
- implicitHeight: 10
- }
- Rectangle {
- color: 'red'
- Layout.minimumWidth: 10
- Layout.preferredWidth: 20
- Layout.maximumWidth: 90
- Layout.fillWidth: true
- implicitHeight: 10
- }
- Rectangle {
- color: 'red'
- Layout.minimumWidth: 10
- Layout.preferredWidth: 70
- Layout.maximumWidth: 90
- Layout.fillWidth: true
- implicitHeight: 10
- }
}
}
function test_distributeToPixelGrid_data() {
return [
- { tag: "narrow", spacing: 0, width: 60 },
- { tag: "belowPreferred", spacing: 0, width: 130 },
- { tag: "belowPreferredWithSpacing", spacing: 10, width: 130 },
- { tag: "abovePreferred", spacing: 0, width: 150 },
- { tag: "stretchSomethingToMaximum", spacing: 0, width: 240,
+ { tag: "narrow", spacing: 0, width: 60, hints: [{pref: 50}, {pref: 20}, {pref: 70}] },
+ { tag: "belowPreferred", spacing: 0, width: 130, hints: [{pref: 50}, {pref: 20}, {pref: 70}]},
+ { tag: "belowPreferredWithSpacing", spacing: 10, width: 130, hints: [{pref: 50}, {pref: 20}, {pref: 70}]},
+ { tag: "abovePreferred", spacing: 0, width: 150, hints: [{pref: 50}, {pref: 20}, {pref: 70}]},
+ { tag: "stretchSomethingToMaximum", spacing: 0, width: 240, hints: [{pref: 50}, {pref: 20}, {pref: 70}],
expected: [90, 60, 90] },
{ tag: "minSizeHasFractions", spacing: 2, width: 31 + 4, hints: [{min: 10+1/3}, {min: 10+1/3}, {min: 10+1/3}],
/*expected: [11, 11, 11]*/ }, /* verify that nothing gets allocated a size smaller than its minimum */
@@ -740,25 +716,27 @@ Item {
layout.spacing = data.spacing
layout.width = data.width
layout.height = 10
- var kids = layout.children
- if (data.hasOwnProperty('hints')) {
- var hints = data.hints
- for (var i = 0; i < hints.length; ++i) {
- var h = hints[i]
- if (h.hasOwnProperty('min'))
- kids[i].Layout.minimumWidth = h.min
- if (h.hasOwnProperty('pref'))
- kids[i].Layout.preferredWidth = h.pref
- if (h.hasOwnProperty('max'))
- kids[i].Layout.maximumWidth = h.max
- }
+ var hints = data.hints
+ var i;
+ var n = hints.length
+ for (i = 0; i < n; ++i) {
+ var rect = layoutItem_Component.createObject(layout)
+ rect.Layout.fillWidth = true
+ var h = hints[i]
+ rect.Layout.minimumWidth = h.hasOwnProperty('min') ? h.min : 10
+ if (h.hasOwnProperty('pref'))
+ rect.Layout.preferredWidth = h.pref
+ rect.Layout.maximumWidth = h.hasOwnProperty('max') ? h.max : 90
}
+
+ var kids = layout.children
+
waitForRendering(layout)
- var sum = 2 * layout.spacing
+ var sum = (n - 1) * layout.spacing
// TEST
- for (var i = 0; i < kids.length; ++i) {
+ for (i = 0; i < n; ++i) {
compare(kids[i].x % 1, 0) // checks if position is a whole integer
// verify if the items are within the size constraints as specified
verify(kids[i].width >= kids[i].Layout.minimumWidth)