summaryrefslogtreecommitdiff
path: root/tests/auto/controls/data/tst_applicationwindow.qml
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-10-15 17:39:13 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-14 23:53:20 +0100
commitd16f084b267140b4a901e437c3facebbdf08d89f (patch)
tree708ec90c92fa525981ce46930ca5bad44c9501df /tests/auto/controls/data/tst_applicationwindow.qml
parent1618e1938275afd6dcf3225aa1f933eb568d13d2 (diff)
downloadqtquickcontrols-d16f084b267140b4a901e437c3facebbdf08d89f.tar.gz
Expose contentArea as contentItem in ApplicationWindow
This will intentionally shadow the QQuickWindow::contentItem This enables users of ApplicationWindow to correctly set the {min,max}imumHeight for the contents of the ApplicationWindow (excluding menubar, toolbar and statusbar). With this information at hand, the ApplicationWindow can easily deduct the correct total size of its {min,max}imumHeight *including* the menubar, toolbar and statusbar. Previously, it was for instance not possible to set an exact minimumHeight because it didn't take the toolbar, statusbar or menubar into consideration One small disadvantage is that the contentItem.minimumWidth cannot be autocompleted. qmlplugindump does not inspect the members of ContentItem. Task-number: QTBUG-32443 Change-Id: I9903e7d4b5e6db7bd7c3c46351a2bb5578f67a57 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'tests/auto/controls/data/tst_applicationwindow.qml')
-rw-r--r--tests/auto/controls/data/tst_applicationwindow.qml73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml
index e424cc2d..590231f4 100644
--- a/tests/auto/controls/data/tst_applicationwindow.qml
+++ b/tests/auto/controls/data/tst_applicationwindow.qml
@@ -94,5 +94,78 @@ TestCase {
verify(contentArea.height < oldHeight)
window.destroy()
}
+
+
+ function test_defaultContentItemConstraints_data() {
+ return [
+ { tag: "height",
+ input: {height: 100},
+ expected: {implicitHeight: 100} },
+ { tag: "height_y",
+ input: {height: 100, y: 10},
+ expected: {implicitHeight: 110} },
+ { tag: "height_implicitHeight_anchorsFill",
+ input: {height: 100, implicitHeight: 10, anchorsFill: true},
+ expected: {implicitHeight: 10} },
+ { tag: "height_implicitHeight_anchorsFill_margins",
+ input: {height: 100, implicitHeight: 10, anchorsFill: true, anchors_margins: 20},
+ expected: {implicitHeight: 50} },
+ { tag: "height_anchorsFill_margins",
+ input: {height: 100, anchorsFill: true, anchors_margins: 20},
+ expected: {implicitHeight: 40} },
+ { tag: "anchorsFill_margins", //Rectangle { anchors.fill: parent; anchors.margins: 20 }
+ input: {anchorsFill: true, anchors_margins: 20},
+ expected: {implicitHeight: 40} },
+ { tag: "anchorsFill_margins0", //Rectangle { anchors.fill: parent; anchors.margins: 0 }
+ input: {anchorsFill: true, anchors_margins: 0},
+ expected: {implicitHeight: 0} },
+ { tag: "minimum_implicit_maximum_anchorsFill",
+ input: {anchorsFill: true, Layout_minimumHeight: 10, implicitHeight: 100, Layout_maximumHeight: 150},
+ expected: {minimumHeight: 10, implicitHeight: 100, maximumHeight: 150} },
+ { tag: "minimum_implicit_maximum_anchorsFill_margins",
+ input: {anchorsFill: true, anchors_margins: 20, Layout_minimumHeight: 10, implicitHeight: 100, Layout_maximumHeight: 150},
+ expected: {minimumHeight: 50, implicitHeight: 140, maximumHeight: 190} },
+ { tag: "minimum_height_maximum_anchorsFill",
+ input: {anchorsFill: true, Layout_minimumHeight: 0, height: 100, Layout_maximumHeight: 150},
+ expected: {minimumHeight: 0, implicitHeight: 0, maximumHeight: 150} },
+ ];
+ }
+ function test_defaultContentItemConstraints(data) {
+ var input = data.input
+ var expected = data.expected
+
+ var str = ''
+ // serialize....
+ for (var varName in input) {
+ var realName = varName.replace('_', '.')
+ // anchorsFill is special...
+ if (realName === 'anchorsFill') {
+ str += 'anchors.fill:parent;'
+ } else if (input[varName] !== undefined) {
+ // serialize the other properties...
+ str += realName + ':' + input[varName] +';'
+ }
+ }
+
+ var test_control = 'import QtQuick 2.1; \
+ import QtQuick.Controls 1.1; \
+ import QtQuick.Layouts 1.1; \
+ ApplicationWindow { \
+ id: window; \
+ Rectangle { \
+ id: rect; \
+ color: \'red\'; \
+ ' + str + '\
+ } \
+ } '
+
+ var window = Qt.createQmlObject(test_control, container, '')
+ wait(0)
+
+ for (var propName in expected) {
+ compare(window.contentItem[propName], expected[propName])
+ }
+ }
+
}
}