diff options
Diffstat (limited to 'tests/auto/controls/data/tst_textfield.qml')
-rw-r--r-- | tests/auto/controls/data/tst_textfield.qml | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index 4847dffe..a6686a13 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -61,13 +61,12 @@ TestCase { } function test_creation() { - var control = textField.createObject(testCase) + var control = createTemporaryObject(textField, testCase) verify(control) - control.destroy() } function test_implicitSize() { - var control = textField.createObject(testCase) + var control = createTemporaryObject(textField, testCase) verify(control.implicitWidth > control.leftPadding + control.rightPadding) var implicitWidthSpy = signalSpy.createObject(control, { target: control, signalName: "implicitWidthChanged"} ) @@ -97,18 +96,65 @@ TestCase { compare(control.implicitHeight, control.contentHeight + control.topPadding + control.bottomPadding) compare(implicitWidthSpy.count, 4) compare(implicitHeightSpy.count, 2) + } - control.destroy() + function test_alignment_data() { + return [ + { tag: "empty", text: "", placeholderText: "", textAlignment: undefined, placeholderAlignment: Qt.AlignLeft }, + { tag: "empty,left", text: "", placeholderText: "", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "empty,center", text: "", placeholderText: "", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "empty,right", text: "", placeholderText: "", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "empty,ltr", text: "", placeholderText: "Search", textAlignment: undefined, placeholderAlignment: Qt.AlignLeft }, + { tag: "empty,ltr,left", text: "", placeholderText: "Search", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "empty,ltr,center", text: "", placeholderText: "Search", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "empty,ltr,right", text: "", placeholderText: "Search", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "empty,rtl", text: "", placeholderText: "بحث", textAlignment: undefined, placeholderAlignment: Qt.AlignRight }, + { tag: "empty,rtl,left", text: "", placeholderText: "بحث", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "empty,rtl,center", text: "", placeholderText: "بحث", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "empty,rtl,right", text: "", placeholderText: "بحث", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "ltr,empty", text: "Text", placeholderText: "", textAlignment: undefined, placeholderAlignment: Qt.AlignLeft }, + { tag: "ltr,empty,left", text: "Text", placeholderText: "", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "ltr,empty,center", text: "Text", placeholderText: "", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "ltr,empty,right", text: "Text", placeholderText: "", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "ltr,ltr", text: "Text", placeholderText: "Search", textAlignment: undefined, placeholderAlignment: Qt.AlignLeft }, + { tag: "ltr,ltr,left", text: "Text", placeholderText: "Search", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "ltr,ltr,center", text: "Text", placeholderText: "Search", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "ltr,ltr,right", text: "Text", placeholderText: "Search", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "ltr,rtl", text: "Text", placeholderText: "بحث", textAlignment: undefined, placeholderAlignment: Qt.AlignRight }, + { tag: "ltr,rtl,left", text: "Text", placeholderText: "بحث", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "ltr,rtl,center", text: "Text", placeholderText: "بحث", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "ltr,rtl,right", text: "Text", placeholderText: "بحث", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "rtl,empty", text: "نص", placeholderText: "", textAlignment: undefined, placeholderAlignment: Qt.AlignLeft }, + { tag: "rtl,empty,left", text: "نص", placeholderText: "", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "rtl,empty,center", text: "نص", placeholderText: "", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "rtl,empty,right", text: "نص", placeholderText: "", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "rtl,ltr", text: "نص", placeholderText: "Search", textAlignment: undefined, placeholderAlignment: Qt.AlignLeft }, + { tag: "rtl,ltr,left", text: "نص", placeholderText: "Search", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "rtl,ltr,center", text: "نص", placeholderText: "Search", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "rtl,ltr,right", text: "نص", placeholderText: "Search", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + + { tag: "rtl,rtl", text: "نص", placeholderText: "بحث", textAlignment: undefined, placeholderAlignment: Qt.AlignRight }, + { tag: "rtl,rtl,left", text: "نص", placeholderText: "بحث", textAlignment: Qt.AlignLeft, placeholderAlignment: Qt.AlignLeft }, + { tag: "rtl,rtl,center", text: "نص", placeholderText: "بحث", textAlignment: Qt.AlignHCenter, placeholderAlignment: Qt.AlignHCenter }, + { tag: "rtl,rtl,right", text: "نص", placeholderText: "بحث", textAlignment: Qt.AlignRight, placeholderAlignment: Qt.AlignRight }, + ] } - function test_alignment() { - var control = textField.createObject(testCase) + function test_alignment(data) { + var control = createTemporaryObject(textField, testCase, {text: data.text, placeholderText: data.placeholderText, horizontalAlignment: data.textAlignment}) - control.horizontalAlignment = TextField.AlignRight - compare(control.horizontalAlignment, TextField.AlignRight) + if (data.textAlignment !== undefined) + compare(control.horizontalAlignment, data.textAlignment) for (var i = 0; i < control.children.length; ++i) { if (control.children[i].hasOwnProperty("horizontalAlignment")) - compare(control.children[i].horizontalAlignment, Text.AlignRight) // placeholder + compare(control.children[i].effectiveHorizontalAlignment, data.placeholderAlignment) // placeholder } control.verticalAlignment = TextField.AlignBottom @@ -117,8 +163,6 @@ TestCase { if (control.children[j].hasOwnProperty("verticalAlignment")) compare(control.children[j].verticalAlignment, Text.AlignBottom) // placeholder } - - control.destroy() } function test_font_explicit_attributes_data() { @@ -135,7 +179,7 @@ TestCase { } function test_font_explicit_attributes(data) { - var control = textField.createObject(testCase) + var control = createTemporaryObject(textField, testCase) verify(control) var child = textField.createObject(control) @@ -160,8 +204,6 @@ TestCase { compare(child.font[data.tag], defaultValue) compare(childSpy.count, 0) - - control.destroy() } function test_hover_data() { @@ -172,7 +214,7 @@ TestCase { } function test_hover(data) { - var control = textField.createObject(testCase, {hoverEnabled: data.hoverEnabled}) + var control = createTemporaryObject(textField, testCase, {hoverEnabled: data.hoverEnabled}) verify(control) compare(control.hovered, false) @@ -182,8 +224,6 @@ TestCase { mouseMove(control, -1, -1) compare(control.hovered, false) - - control.destroy() } function test_pressedReleased_data() { @@ -239,7 +279,7 @@ TestCase { } function test_pressedReleased(data) { - var mouseArea = mouseAreaComponent.createObject(testCase) + var mouseArea = createTemporaryObject(mouseAreaComponent, testCase) verify(mouseArea) var control = textField.createObject(mouseArea) verify(control) @@ -286,8 +326,6 @@ TestCase { mouseRelease(control, data.x, data.y, data.button) compare(controlReleasedSpy.count, data.controlReleaseEvent ? 1 : 0) compare(parentReleasedSpy.count, data.parentReleaseEvent ? 1 : 0) - - mouseArea.destroy() } Component { @@ -311,7 +349,7 @@ TestCase { } function test_ignorePressRelease() { - var mouseArea = mouseAreaComponent.createObject(testCase) + var mouseArea = createTemporaryObject(mouseAreaComponent, testCase) verify(mouseArea) var control = ignoreTextField.createObject(mouseArea) verify(control) @@ -350,12 +388,10 @@ TestCase { compare(parentReleasedSpy.count, 1) control.onPressed.disconnect(checkEventAccepted) control.onReleased.disconnect(checkEventIgnored) - - mouseArea.destroy() } function test_multiClick() { - var control = textField.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) + var control = createTemporaryObject(textField, testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) verify(control) waitForRendering(control) @@ -369,7 +405,5 @@ TestCase { // tripple click -> select whole line mouseClick(control, rect.x + rect.width / 2, rect.y + rect.height / 2) compare(control.selectedText, "Qt Quick Controls 2 TextArea") - - control.destroy() } } |