diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-05-13 04:31:32 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-05-13 04:31:32 (GMT) |
commit | 203b5edc04143edce0335c5e62de409c64df4c07 (patch) | |
tree | f71a1148267a082b712628ab3219b7a155c8570f /tests/auto | |
parent | f6d9a717946422d910ec9e680197617eb706410c (diff) | |
parent | f69e465e15930ef02dceba7175eed6f3f1df070e (diff) | |
download | Qt-203b5edc04143edce0335c5e62de409c64df4c07.zip Qt-203b5edc04143edce0335c5e62de409c64df4c07.tar.gz Qt-203b5edc04143edce0335c5e62de409c64df4c07.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Make TextEdit word selection more natural.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml | 8 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 36 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml new file mode 100644 index 0000000..af23f6d --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml @@ -0,0 +1,8 @@ +import QtQuick 1.1 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRS\nTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextInput.SelectWords +} diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 7bbef21..f8af433 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -119,6 +119,7 @@ private slots: void moveCursorSelectionSequence(); void mouseSelection_data(); void mouseSelection(); + void multilineMouseSelection(); void deferEnableSelectByMouse_data(); void deferEnableSelectByMouse(); void deferDisableSelectByMouse_data(); @@ -1364,6 +1365,41 @@ void tst_qdeclarativetextedit::mouseSelection() delete canvas; } +void tst_qdeclarativetextedit::multilineMouseSelection() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml"); + + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QVERIFY(canvas->rootObject() != 0); + QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag from x1,y1 to x2,y1 + int x1 = 10; + int x2 = textEditObject->width() - 10; + int y1 = textEditObject->height() / 4; + int y2 = textEditObject->height() * 3 / 4; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y1))); + QMouseEvent mv1(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y1)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv1); + QString str1 = textEditObject->selectedText(); + QVERIFY(str1.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform) + + // drag-and-release from x2,y1 to x2,y2 + QMouseEvent mv2(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y2)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv2); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y2))); + QString str2 = textEditObject->selectedText(); + QVERIFY(str1 != str2); + QVERIFY(str2.length() > 3); + + delete canvas; +} + void tst_qdeclarativetextedit::deferEnableSelectByMouse_data() { QTest::addColumn<QString>("qmlfile"); |