diff options
Diffstat (limited to 'tests/auto/controls/data/tst_textarea.qml')
-rw-r--r-- | tests/auto/controls/data/tst_textarea.qml | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index e058ec19..de3e6854 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -70,13 +70,12 @@ TestCase { } function test_creation() { - var control = textArea.createObject(testCase) + var control = createTemporaryObject(textArea, testCase) verify(control) - control.destroy() } function test_implicitSize() { - var control = textArea.createObject(testCase) + var control = createTemporaryObject(textArea, testCase) var implicitWidthSpy = signalSpy.createObject(control, { target: control, signalName: "implicitWidthChanged"} ) var implicitHeightSpy = signalSpy.createObject(control, { target: control, signalName: "implicitHeightChanged"} ) @@ -86,18 +85,65 @@ TestCase { compare(control.implicitHeight, 200) compare(implicitWidthSpy.count, 1) compare(implicitHeightSpy.count, 1) + } - 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 = textArea.createObject(testCase) + function test_alignment(data) { + var control = createTemporaryObject(textArea, testCase, {text: data.text, placeholderText: data.placeholderText, horizontalAlignment: data.textAlignment}) - control.horizontalAlignment = TextArea.AlignRight - compare(control.horizontalAlignment, TextArea.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 = TextArea.AlignBottom @@ -106,8 +152,6 @@ TestCase { if (control.children[j].hasOwnProperty("verticalAlignment")) compare(control.children[j].verticalAlignment, Text.AlignBottom) // placeholder } - - control.destroy() } function test_font_explicit_attributes_data() { @@ -124,7 +168,7 @@ TestCase { } function test_font_explicit_attributes(data) { - var control = textArea.createObject(testCase) + var control = createTemporaryObject(textArea, testCase) verify(control) var child = textArea.createObject(control) @@ -149,12 +193,10 @@ TestCase { compare(child.font[data.tag], defaultValue) compare(childSpy.count, 0) - - control.destroy() } function test_flickable() { - var control = flickable.createObject(testCase, {text:"line0", selectByMouse: true}) + var control = createTemporaryObject(flickable, testCase, {text:"line0", selectByMouse: true}) verify(control) var textArea = control.TextArea.flickable @@ -190,8 +232,6 @@ TestCase { verify(above > 0 && above < center) mouseClick(textArea, control.width / 2, 0) compare(textArea.cursorPosition, center) // no change - - control.destroy() } function test_warning() { @@ -207,7 +247,7 @@ TestCase { } function test_hover(data) { - var control = textArea.createObject(testCase, {text: "TextArea", hoverEnabled: data.hoverEnabled}) + var control = createTemporaryObject(textArea, testCase, {text: "TextArea", hoverEnabled: data.hoverEnabled}) verify(control) compare(control.hovered, false) @@ -217,8 +257,6 @@ TestCase { mouseMove(control, -1, -1) compare(control.hovered, false) - - control.destroy() } function test_pressedReleased_data() { @@ -274,7 +312,7 @@ TestCase { } function test_pressedReleased(data) { - var mouseArea = mouseAreaComponent.createObject(testCase) + var mouseArea = createTemporaryObject(mouseAreaComponent, testCase) verify(mouseArea) var control = textArea.createObject(mouseArea, {text: "TextArea"}) verify(control) @@ -321,8 +359,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 { @@ -346,7 +382,7 @@ TestCase { } function test_ignorePressRelease() { - var mouseArea = mouseAreaComponent.createObject(testCase) + var mouseArea = createTemporaryObject(mouseAreaComponent, testCase) verify(mouseArea) var control = ignoreTextArea.createObject(mouseArea) verify(control) @@ -385,12 +421,10 @@ TestCase { compare(parentReleasedSpy.count, 1) control.onPressed.disconnect(checkEventAccepted) control.onReleased.disconnect(checkEventIgnored) - - mouseArea.destroy() } function test_multiClick() { - var control = textArea.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) + var control = createTemporaryObject(textArea, testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) verify(control) waitForRendering(control) @@ -404,7 +438,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() } } |