From ba1491488e02dfb4de734b4f2755c4899db0a815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Tue, 1 Mar 2016 12:31:28 +0100 Subject: Add more tests for pixel snapping of sizes Task-number: QTBUG-41216 Change-Id: I4456709ec5c4e61183fb4056a5f6d6bd9bd863d5 Reviewed-by: Paul Olav Tvete --- .../quick/qquicklayouts/data/tst_rowlayout.qml | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml index 64a54830f9..33b8fd0e4e 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml @@ -706,6 +706,33 @@ Item { /*expected: [90, 90, 90]*/ }, /* verify that nothing gets allocated a size larger than its maximum */ { tag: "fixedSizeHasFractions", spacing: 2, width: 31 + 4, hints: [{min: 10+1/3, max: 10+1/3}, {min: 10+1/3, max: 10+1/3}, {min: 10+1/3, max: 10+1/3}], /*expected: [11, 11, 11]*/ }, /* verify that nothing gets allocated a size smaller than its minimum */ + { tag: "481", spacing: 0, width: 481, + hints: [{min:0, pref:0, max:999}, {min:0, pref:0, max: 999}, {min: 0, pref: 0, max:0}], + expected: [241, 240, 0] }, + { tag: "theend", spacing: 1, width: 18, + hints: [{min: 10, pref: 10, max:10}, {min:3, pref:3.33}, {min:2, pref:2.33}], + expected: [10, 4, 2] }, + { tag: "theend2", spacing: 1, width: 18, + hints: [{min: 10, pref: 10, max:10}, {min:3, pref:3.33}, {min:2.33, pref:2.33}], + expected: [10, 3, 3] }, + { tag: "43", spacing: 0, width: 43, + hints: [{min: 10, pref: 10, max:10}, {min:10, pref:30.33}, {min:2.33, pref:2.33}], + expected: [10, 30, 3] }, + { tag: "40", spacing: 0, width: 40, + hints: [{min: 10, pref: 10, max:10}, {min:10, pref:30.33}, {min:2.33, pref:2.33}], + expected: [10, 27, 3] }, + { tag: "roundingAccumulates1", spacing: 0, width: 50, + hints: [{pref: 10, max:30.3}, + {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, + {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, + {pref: 10, max:30.3}], + expected: [10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 10] }, + { tag: "roundingAccumulates2", spacing: 0, width: 60, + hints: [{pref: 20, max:30.3}, + {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, + {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, {min:2.3, pref:2.3}, + {pref: 20, max:30.3}], + expected: [15, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 15] }, ]; } @@ -738,6 +765,10 @@ Item { // TEST for (i = 0; i < n; ++i) { compare(kids[i].x % 1, 0) // checks if position is a whole integer + // check if width is a whole integer (unless there are constraints preventing it from stretching) + verify(kids[i].width % 1 == 0 + || Math.floor(kids[i].Layout.maximumWidth) < kids[i].width + || layout.width < layout.Layout.maximumWidth + 1) // verify if the items are within the size constraints as specified verify(kids[i].width >= kids[i].Layout.minimumWidth) verify(kids[i].width <= kids[i].Layout.maximumWidth) -- cgit v1.2.3