diff options
Diffstat (limited to 'tests/auto/controls/data/tst_textarea.qml')
-rw-r--r-- | tests/auto/controls/data/tst_textarea.qml | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index 269e11ec..bda0b3e3 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import Qt.labs.controls 1.0 +import QtQuick.Controls 2.0 TestCase { id: testCase @@ -56,6 +56,15 @@ TestCase { } Component { + id: flickable + Flickable { + width: 200 + height: 200 + TextArea.flickable: TextArea { } + } + } + + Component { id: signalSpy SignalSpy { } } @@ -68,10 +77,16 @@ TestCase { function test_implicitSize() { var control = textArea.createObject(testCase) + + var implicitWidthSpy = signalSpy.createObject(control, { target: control, signalName: "implicitWidthChanged"} ) + var implicitHeightSpy = signalSpy.createObject(control, { target: control, signalName: "implicitHeightChanged"} ) control.background.implicitWidth = 400 control.background.implicitHeight = 200 compare(control.implicitWidth, 400) compare(control.implicitHeight, 200) + compare(implicitWidthSpy.count, 1) + compare(implicitHeightSpy.count, 1) + control.destroy() } @@ -137,4 +152,69 @@ TestCase { control.destroy() } + + function test_flickable() { + var control = flickable.createObject(testCase, {text:"line0", selectByMouse: true}) + verify(control) + + var textArea = control.TextArea.flickable + verify(textArea) + + for (var i = 1; i <= 100; ++i) + textArea.text += "line\n" + i + + verify(textArea.contentWidth > 0) + verify(textArea.contentHeight > 200) + + compare(control.contentWidth, textArea.contentWidth + textArea.leftPadding + textArea.rightPadding) + compare(control.contentHeight, textArea.contentHeight + textArea.topPadding + textArea.bottomPadding) + + compare(textArea.cursorPosition, 0) + + var center = textArea.positionAt(control.width / 2, control.height / 2) + verify(center > 0) + mouseClick(textArea, control.width / 2, control.height / 2) + compare(textArea.cursorPosition, center) + + // click inside text area, but below flickable + var below = textArea.positionAt(control.width / 2, control.height + 1) + verify(below > center) + mouseClick(textArea, control.width / 2, control.height + 1) + compare(textArea.cursorPosition, center) // no change + + // scroll down + control.contentY = -(control.contentHeight - control.height) / 2 + + // click inside textarea, but above flickable + var above = textArea.positionAt(control.width / 2, textArea.topPadding) + verify(above > 0 && above < center) + mouseClick(textArea, control.width / 2, 0) + compare(textArea.cursorPosition, center) // no change + + control.destroy() + } + + function test_warning() { + ignoreWarning(Qt.resolvedUrl("tst_textarea.qml") + ":45:1: QML TestCase: TextArea must be attached to a Flickable") + testCase.TextArea.flickable = null + } + + function test_multiClick() { + var control = textArea.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) + verify(control) + + waitForRendering(control) + control.width = control.contentWidth + var rect = control.positionToRectangle(12) + + // double click -> select word + mouseDoubleClickSequence(control, rect.x + rect.width / 2, rect.y + rect.height / 2) + compare(control.selectedText, "Controls") + + // 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() + } } |