aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <[email protected]>2024-03-06 16:00:24 +0800
committerMitch Curtis <[email protected]>2024-03-07 09:32:12 +0800
commitcb7eb152204e206539f307a9556eea43c589f026 (patch)
treeb51e55f2d63c5b6d49da81631f5d592009640970 /tests
parent8726722886454be0fd531ce7f28ad3bdec12cab1 (diff)
Material: fix floating placeholder text x position
Don't set it to control.leftPadding, because we don't want it to change if the user changes leftPadding. Fixes: QTBUG-120149 Pick-to: 6.5 6.6 6.7 Change-Id: I67bbc22192fef386fe088398b67d3eb0a10421ba Reviewed-by: Oliver Eftevaag <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt9
-rw-r--r--tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml32
-rw-r--r--tests/manual/quickcontrols/material/pages/TextAreaPage.qml32
-rw-r--r--tests/manual/quickcontrols/material/pages/TextFieldPage.qml32
4 files changed, 101 insertions, 4 deletions
diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt b/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt
index b5acd374d4..0fe3fe7b9a 100644
--- a/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt
+++ b/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt
@@ -41,7 +41,8 @@ qt_internal_add_resource(tst_qquickmaterialstyle "qmake_immediate"
${qmake_immediate_resource_files}
)
-
-#### Keys ignored in scope 1:.:.:qquickmaterialstyle.pro:<TRUE>:
-# OTHER_FILES = "$$PWD/data/*.qml"
-# TEMPLATE = "app"
+# Make the QML files available to Creator's locator.
+target_sources(tst_qquickmaterialstyle
+ PRIVATE
+ ${test_data}
+)
diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
index 6d7fbffa64..c824ede3c3 100644
--- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
@@ -1040,6 +1040,38 @@ TestCase {
}
}
+ function test_outlinedPlaceholderTextPosWithPadding_data() {
+ return [
+ { tag: "TextField, leftPadding=0", component: textFieldComponent, leftPadding: 0 },
+ { tag: "TextField, rightPadding=0", component: textFieldComponent, rightPadding: 0 },
+ { tag: "TextField, leftPadding=20", component: textFieldComponent, leftPadding: 20 },
+ { tag: "TextField, rightPadding=20", component: textFieldComponent, rightPadding: 20 },
+ { tag: "TextArea, leftPadding=0", component: textAreaComponent, leftPadding: 0 },
+ { tag: "TextArea, rightPadding=0", component: textAreaComponent, rightPadding: 0 },
+ { tag: "TextArea, leftPadding=20", component: textAreaComponent, leftPadding: 20 },
+ { tag: "TextArea, rightPadding=20", component: textAreaComponent, rightPadding: 20 },
+ ]
+ }
+
+ function test_outlinedPlaceholderTextPosWithPadding(data) {
+ let control = createTemporaryObject(data.component, testCase, {
+ text: "Text",
+ placeholderText: "Enter text..."
+ })
+ verify(control)
+
+ // Work around QTBUG-99231.
+ if (data.leftPadding !== undefined)
+ control.leftPadding = data.leftPadding
+ if (data.rightPadding !== undefined)
+ control.rightPadding = data.rightPadding
+
+ let placeholderTextItem = control.children[0]
+ verify(placeholderTextItem as MaterialImpl.FloatingPlaceholderText)
+ // This is the default value returned by textFieldHorizontalPadding when using a non-dense variant.
+ compare(placeholderTextItem.x, 16)
+ }
+
Component {
id: flickableTextAreaComponent
diff --git a/tests/manual/quickcontrols/material/pages/TextAreaPage.qml b/tests/manual/quickcontrols/material/pages/TextAreaPage.qml
index ef92ffd589..9de28d1118 100644
--- a/tests/manual/quickcontrols/material/pages/TextAreaPage.qml
+++ b/tests/manual/quickcontrols/material/pages/TextAreaPage.qml
@@ -91,6 +91,38 @@ Page {
Material.containerStyle: layout.containerStyle
}
+ TextArea {
+ text: "0 leftPadding"
+ placeholderText: "placeholderText"
+ leftPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
+ TextArea {
+ text: "0 rightPadding"
+ placeholderText: "placeholderText"
+ rightPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
+ TextArea {
+ text: "0 topPadding"
+ placeholderText: "placeholderText"
+ topPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
+ TextArea {
+ text: "0 bottomPadding"
+ placeholderText: "placeholderText"
+ bottomPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
Flickable {
width: 200
height: 100
diff --git a/tests/manual/quickcontrols/material/pages/TextFieldPage.qml b/tests/manual/quickcontrols/material/pages/TextFieldPage.qml
index 63c89f0f9c..9aeef4b5c2 100644
--- a/tests/manual/quickcontrols/material/pages/TextFieldPage.qml
+++ b/tests/manual/quickcontrols/material/pages/TextFieldPage.qml
@@ -59,6 +59,38 @@ Page {
Material.containerStyle: layout.containerStyle
}
+
+ TextField {
+ text: "0 leftPadding"
+ placeholderText: "placeholderText"
+ leftPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
+ TextField {
+ text: "0 rightPadding"
+ placeholderText: "placeholderText"
+ rightPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
+ TextField {
+ text: "0 topPadding"
+ placeholderText: "placeholderText"
+ topPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
+
+ TextField {
+ text: "0 bottomPadding"
+ placeholderText: "placeholderText"
+ bottomPadding: 0
+
+ Material.containerStyle: layout.containerStyle
+ }
}
ColumnLayout {