diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-24 16:36:23 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-25 07:21:29 +0000 |
commit | cb80c055e7d8a242c529c9f72c9a9b8d87a90f31 (patch) | |
tree | 39ad3246eda83e0c505bcb8b807c92ee9e3130bb /tests | |
parent | 32810acaa191ba00be5aac5d771c23b87628292c (diff) |
Page: provide implicit size
Even though the control was designed to be used as full-screen page, it
can be sometimes useful to have non-fullscreen pages. In order to make
Page behave well in layouts, it must provide a suitable implicit size.
[ChangeLog][Controls][Page] Page has been made to calculate its
implicit size based on the implicit size of the header, content, and
footer plus paddings, and the implicit size of the background item.
Task-number: QTBUG-56709
Change-Id: I0f40897df6e54d7bde01a464e24f0398b12bc865
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_page.qml | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml index 3cd6b7b8..a1cdbf8e 100644 --- a/tests/auto/controls/data/tst_page.qml +++ b/tests/auto/controls/data/tst_page.qml @@ -56,6 +56,40 @@ TestCase { } Component { + id: oneChildPage + Page { + Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + + Component { + id: twoChildrenPage + Page { + Item { + implicitWidth: 100 + implicitHeight: 30 + } + Item { + implicitWidth: 200 + implicitHeight: 60 + } + } + } + + Component { + id: contentPage + Page { + contentItem: Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + + Component { id: toolBar ToolBar { } } @@ -71,6 +105,53 @@ TestCase { control.destroy() } + function test_empty() { + var control = page.createObject(testCase) + verify(control) + + verify(control.contentItem) + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + + control.destroy() + } + + function test_oneChild() { + var control = oneChildPage.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) + + control.destroy() + } + + function test_twoChildren() { + var control = twoChildrenPage.createObject(testCase) + verify(control) + + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + compare(control.implicitWidth, control.leftPadding + control.rightPadding) + compare(control.implicitHeight, control.topPadding + control.bottomPadding) + + control.destroy() + } + + function test_contentItem() { + var control = contentPage.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) + + control.destroy() + } + function test_layout() { var control = page.createObject(testCase, {width: 100, height: 100}) verify(control) @@ -124,6 +205,25 @@ TestCase { compare(control.contentItem.width, control.availableWidth) compare(control.contentItem.height, control.availableHeight) + control.contentItem.implicitWidth = 50 + control.contentItem.implicitHeight = 60 + compare(control.implicitWidth, control.contentItem.implicitWidth + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding) + + control.header.visible = true + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + + control.header.implicitHeight + control.spacing) + + control.footer.visible = true + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + + control.header.implicitHeight + control.footer.implicitHeight + 2 * control.spacing) + + control.header.implicitWidth = 150 + compare(control.implicitWidth, control.header.implicitWidth + control.leftPadding + control.rightPadding) + + control.footer.implicitWidth = 160 + compare(control.implicitWidth, control.footer.implicitWidth + control.leftPadding + control.rightPadding) + control.destroy() } } |