From dad6794dbf6caa932329718418a06e24f29af850 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether <jan-arve.saether@digia.com> Date: Mon, 22 Apr 2013 10:54:43 +0200 Subject: [PATCH] Add test for dynamic adding and removing layout items Change-Id: I7a92428e910435f0ecd63577cb12d5ce5b7653bc Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com> --- tests/auto/controls/data/tst_rowlayout.qml | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index 42ffc09c7..d142a5965 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -251,6 +251,73 @@ Item { col.destroy() } + Component { + id: layoutItem_Component + Rectangle { + implicitWidth: 20 + implicitHeight: 20 + } + } + + Component { + id: columnLayoutItem_Component + ColumnLayout { + } + } + + Component { + id: layout_addAndRemoveItems_Component + RowLayout { + spacing: 0 + } + } + + function test_addAndRemoveItems() + { + var layout = layout_addAndRemoveItems_Component.createObject(container) + compare(layout.implicitWidth, 0) + compare(layout.implicitHeight, 0) + + var rect0 = layoutItem_Component.createObject(layout) + compare(layout.implicitWidth, 20) + compare(layout.implicitHeight, 20) + + var rect1 = layoutItem_Component.createObject(layout) + rect1.Layout.preferredWidth = 30; + rect1.Layout.preferredHeight = 30; + compare(layout.implicitWidth, 50) + compare(layout.implicitHeight, 30) + + var col = columnLayoutItem_Component.createObject(layout) + var rect2 = layoutItem_Component.createObject(col) + rect2.Layout.fillHeight = true + var rect3 = layoutItem_Component.createObject(col) + rect3.Layout.fillHeight = true + + compare(layout.implicitWidth, 70) + compare(layout.implicitHeight, 30) + + rect3.destroy() + wait(0) // this will hopefully effectuate the destruction of the object + + col.destroy() + wait(0) + compare(layout.implicitWidth, 50) + compare(layout.implicitHeight, 30) + + rect0.destroy() + wait(0) + compare(layout.implicitWidth, 30) + compare(layout.implicitHeight, 30) + + rect1.destroy() + wait(0) + compare(layout.implicitWidth, 0) + compare(layout.implicitHeight, 0) + + layout.destroy() + } + Component { id: layout_alignment_Component RowLayout { -- GitLab