From 021c6064addd168017e0e9eff17639669e2f85d1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 12 Dec 2018 12:48:27 +0100 Subject: tst_QQuickStyle::availableStyles(): Ignore case when checking paths on Windows It is actually possible to get the test to fail in command line environments. Change-Id: I9e37e968bd259e3c7ad4acdb8bf289a64f199891 Reviewed-by: Mitch Curtis --- tests/auto/qquickstyle/tst_qquickstyle.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index 8d09a293..f5207a96 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -159,7 +159,11 @@ void tst_QQuickStyle::availableStyles() QQuickStyle::addStylePath(path); QStringList paths = QQuickStylePrivate::stylePaths(); +#ifndef Q_OS_WIN QVERIFY(paths.contains(path)); +#else + QVERIFY(paths.contains(path, Qt::CaseInsensitive)); +#endif const QStringList styles = QQuickStyle::availableStyles(); QVERIFY(!styles.isEmpty()); -- cgit v1.2.3 From b563bd583a50442b52e47f8c5f149aebafb385f2 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 14 Dec 2018 12:08:48 +0100 Subject: Fix TextField background not respecting control's width After 6858d4e9, the background of the Material style TextField does not respect the width of the control if the control is resized (e.g. due to being in a layout). - The first time resizeBackground() is called, !extra.isAllocated() returns true - that is, extra has not been allocated yet. - The if statement is executed and the background's width is set to the available width of the control (e.g. 120). - As a result of the background's width being set, its widthValid flag is set to true. This would previously be undone directly afterwards by setting widthValid flag to false. - In the case of the test case, the implicitWidth was already 120, so geometryChanged is not emitted. However, when the height of the background is set, this *does* cause itemGeometryChanged() to be called, which in turn does the following: extra.value().hasBackgroundWidth = p->widthValid; extra.value().hasBackgroundHeight = p->heightValid; resizeBackground(); So now all of the following checks evaluate to false: (!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) This prevents the background from being resized. This patch fixes the issue by unsetting the widthValid (and heightValid) flags of the background directly after setting its width. To be safe, it also only unsets it if we were the ones to set it. By doing this, the check mentioned above succeeds because p->widthValid and extra->hasBackgroundWidth are both now false. It also adds some extra safety into itemGeometryChanged() that ensures that extra.value().hasBackgroundWidth is only set if necessary, and therefore prevents the extra data from unnecessarily being allocated. This is not necessary for the fix, but feels like the right thing to do. Change-Id: I051e281718bd8a2a20c100767d929fb71497ce1b Fixes: QTBUG-71875 Reviewed-by: Richard Moe Gustavsen --- tests/auto/controls/data/tst_textfield.qml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index ee2d1a54..2ee1db41 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -51,6 +51,7 @@ import QtQuick 2.12 import QtTest 1.0 import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 TestCase { id: testCase @@ -633,4 +634,30 @@ TestCase { compare(control.background.height, 100) } + Component { + id: layoutComponent + + ColumnLayout { + anchors.fill: parent + + property alias textField: textField + + TextField { + id: textField + placeholderText: "Placeholder" + Layout.fillWidth: true + } + } + } + + function test_inLayout() { + var layout = createTemporaryObject(layoutComponent, testCase) + verify(layout) + + var control = layout.textField + verify(control) + + compare(control.width, control.parent.width) + compare(control.background.width, control.width) + } } -- cgit v1.2.3