aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpositioners
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickpositioners')
-rw-r--r--tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml12
-rw-r--r--tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml9
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp44
3 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml b/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml
new file mode 100644
index 0000000000..8da9fc270d
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.9
+import PositionerTest 1.0
+
+ImplicitGrid {
+ columns: 2
+ rows: 1
+
+ Text {
+ text: "Text"
+ width: parent.width
+ }
+}
diff --git a/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml b/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml
new file mode 100644
index 0000000000..25a287cf31
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.9
+import PositionerTest 1.0
+
+ImplicitRow {
+ Text {
+ text: "Text"
+ width: parent.width
+ }
+}
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 1b3939401a..4c4afb7a7b 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -98,6 +98,8 @@ private slots:
void test_attachedproperties();
void test_attachedproperties_data();
void test_attachedproperties_dynamic();
+ void test_useImplicitSize_oneItem_data();
+ void test_useImplicitSize_oneItem();
void populateTransitions_row();
void populateTransitions_row_data();
@@ -304,6 +306,8 @@ void tst_qquickpositioners::moveTransitions_flow_data()
tst_qquickpositioners::tst_qquickpositioners()
{
+ qmlRegisterType<QQuickImplicitRow>("PositionerTest", 1, 0, "ImplicitRow");
+ qmlRegisterType<QQuickImplicitGrid>("PositionerTest", 1, 0, "ImplicitGrid");
}
void tst_qquickpositioners::test_horizontal()
@@ -4004,6 +4008,46 @@ void tst_qquickpositioners::test_attachedproperties_dynamic()
}
+void tst_qquickpositioners::test_useImplicitSize_oneItem_data()
+{
+ QTest::addColumn<QString>("positionerType");
+
+ QTest::newRow("Grid") << "Grid";
+ QTest::newRow("Row") << "Row";
+}
+
+void tst_qquickpositioners::test_useImplicitSize_oneItem()
+{
+ QFETCH(QString, positionerType);
+
+ QQuickView view;
+ view.setSource(testFileUrl(QString::fromLatin1("implicit%1OneItem.qml").arg(positionerType)));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ QQuickItem *positioner = view.rootObject();
+ QVERIFY(positioner);
+ const qreal oldPositionerImplicitWidth = positioner->implicitWidth();
+
+ QQuickText *text = qobject_cast<QQuickText*>(positioner->childItems().first());
+ QVERIFY(text);
+ const qreal oldTextImplicitWidth = text->implicitWidth();
+ QCOMPARE(positioner->implicitWidth(), text->implicitWidth());
+
+ // Ensure that the implicit size of the positioner changes when the implicit size
+ // of one of its children changes.
+ text->setText(QLatin1String("Even More Text"));
+ const qreal textImplicitWidthIncrease = text->implicitWidth() - oldTextImplicitWidth;
+ QVERIFY(textImplicitWidthIncrease > 0);
+ QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease);
+
+ // Ensure that the implicit size of the positioner does not change when the
+ // explicit size of one of its children changes.
+ text->setWidth(10);
+ QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease);
+}
+
QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
{
QQuickView *window = new QQuickView(0);