diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2013-03-13 13:55:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-15 09:21:20 +0100 |
commit | f153a5b1411e51ddaec7584e62ae1da8f68ff4cf (patch) | |
tree | 2be02839954ec5a59ad8d6668cfc4e599c93fb5e /tests/auto | |
parent | 002cbc549ea8501d116407c28edacdc054113fd0 (diff) | |
download | qtquickcontrols-f153a5b1411e51ddaec7584e62ae1da8f68ff4cf.tar.gz |
Add test for counting the number of geometry changes.
Change-Id: I47e0aa18a98864ab75a976dfd9b992b8a9f78911
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/controls/data/tst_rowlayout.qml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index af2f14e6..a590b916 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -191,7 +191,53 @@ Item { var row = Qt.createQmlObject(test_layoutStr, container, ''); compare(row.implicitWidth, 50 + 10 + 40); compare(row.implicitHeight, 6); + } + function test_countGeometryChanges() { + var test_layoutStr = + 'import QtQuick 2.0; \ + import QtQuick.Layouts 1.0; \ + ColumnLayout { \ + id : col; \ + property alias row: _row; \ + objectName: "col"; \ + anchors.fill: parent; \ + RowLayout { \ + id : _row; \ + property alias r1: _r1; \ + property alias r2: _r2; \ + objectName: "row"; \ + spacing: 0; \ + property int counter : 0; \ + onWidthChanged: { ++counter; } \ + Rectangle { \ + id: _r1; \ + color: "red"; \ + implicitWidth: 50; \ + implicitHeight: 20; \ + property int counter : 0; \ + onWidthChanged: { ++counter; } \ + Layout.horizontalSizePolicy: Layout.Expanding; \ + } \ + Rectangle { \ + id: _r2; \ + color: "green"; \ + implicitWidth: 50; \ + implicitHeight: 20; \ + property int counter : 0; \ + onWidthChanged: { ++counter; } \ + Layout.horizontalSizePolicy: Layout.Expanding; \ + } \ + } \ + } ' + var col = Qt.createQmlObject(test_layoutStr, container, ''); + compare(col.width, 200); + compare(col.row.width, 200); + compare(col.row.r1.width, 100); + compare(col.row.r2.width, 100); + compare(col.row.r1.counter, 1); + compare(col.row.r2.counter, 1); + verify(col.row.counter <= 2); } } } |