diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-01-28 05:58:37 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-02-01 00:00:30 (GMT) |
commit | ba63becc13221ca6538fb40c790275465dd47703 (patch) | |
tree | 46d27e12faee710564866b2779343f7ac5791209 /tests/auto/declarative/qdeclarativetextedit | |
parent | 2b337d8cbe8e6646ec78b3acaad50ce108d33dc0 (diff) | |
download | Qt-ba63becc13221ca6538fb40c790275465dd47703.zip Qt-ba63becc13221ca6538fb40c790275465dd47703.tar.gz Qt-ba63becc13221ca6538fb40c790275465dd47703.tar.bz2 |
Add a mouseSelectionMode property to TextEdit and TextInput.
Adds an option to do per word selection when selectByMouse is true.
Also changes the selection behavior so that the first word selected
remains selected when the direction of the selection changes which
is more consistent with other implementations including the existing
per word selection in QTextEdit.
Task-number: QTBUG-16283
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextedit')
4 files changed, 314 insertions, 58 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_characters.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_characters.qml new file mode 100644 index 0000000..5784e19 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_characters.qml @@ -0,0 +1,8 @@ +import QtQuick 1.1 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextEdit.SelectCharacters +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_default.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_default.qml new file mode 100644 index 0000000..1e5f4aa --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_default.qml @@ -0,0 +1,7 @@ +import QtQuick 1.1 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_words.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_words.qml new file mode 100644 index 0000000..4b25f2f --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_words.qml @@ -0,0 +1,8 @@ +import QtQuick 1.1 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextEdit.SelectWords +} diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 1364337..b82aca8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -112,8 +112,12 @@ private slots: void selection(); void moveCursorSelection_data(); void moveCursorSelection(); + void moveCursorSelectionSequence_data(); + void moveCursorSelectionSequence(); void mouseSelection_data(); void mouseSelection(); + void mouseSelectionMode_data(); + void mouseSelectionMode(); void dragMouseSelection(); void inputMethodHints(); @@ -786,91 +790,113 @@ void tst_qdeclarativetextedit::moveCursorSelection_data() QTest::newRow("jum()ped|characters") << standard[0] << 23 << 23 << QDeclarativeTextEdit::SelectCharacters << 23 << 23 << true; - QTest::newRow("(t)he|words") + QTest::newRow("<(t)he>|words") << standard[0] << 0 << 1 << QDeclarativeTextEdit::SelectWords << 0 << 3 << true; - QTest::newRow("do(g)|words") + QTest::newRow("<do(g)>|words") << standard[0] << 43 << 44 << QDeclarativeTextEdit::SelectWords << 41 << 44 << true; - QTest::newRow("jum(p)ed|words") + QTest::newRow("<jum(p)ed>|words") << standard[0] << 23 << 24 << QDeclarativeTextEdit::SelectWords << 20 << 26 << true; - QTest::newRow("jumped( )over|words") - << standard[0] << 26 << 27 << QDeclarativeTextEdit::SelectWords << 27 << 27 << false; - QTest::newRow("jumped( )over|words,reversed") - << standard[0] << 27 << 26 << QDeclarativeTextEdit::SelectWords << 26 << 26 << false; - QTest::newRow("(the )|words") - << standard[0] << 0 << 4 << QDeclarativeTextEdit::SelectWords << 0 << 3 << true; - QTest::newRow("( dog)|words") - << standard[0] << 40 << 44 << QDeclarativeTextEdit::SelectWords << 41 << 44 << true; - QTest::newRow("( jumped )|words") - << standard[0] << 19 << 27 << QDeclarativeTextEdit::SelectWords << 20 << 26 << true; - QTest::newRow("th(e qu)ick|words") + QTest::newRow("<jumped( )>over|words") + << standard[0] << 26 << 27 << QDeclarativeTextEdit::SelectWords << 20 << 27 << false; + QTest::newRow("jumped<( )over>|words,reversed") + << standard[0] << 27 << 26 << QDeclarativeTextEdit::SelectWords << 26 << 31 << false; + QTest::newRow("<(the )>quick|words") + << standard[0] << 0 << 4 << QDeclarativeTextEdit::SelectWords << 0 << 4 << false; + QTest::newRow("<(the )quick>|words,reversed") + << standard[0] << 4 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 9 << false; + QTest::newRow("<lazy( dog)>|words") + << standard[0] << 40 << 44 << QDeclarativeTextEdit::SelectWords << 36 << 44 << false; + QTest::newRow("lazy<( dog)>|words,reversed") + << standard[0] << 44 << 40 << QDeclarativeTextEdit::SelectWords << 40 << 44 << false; + QTest::newRow("<fox( jumped )>over|words") + << standard[0] << 19 << 27 << QDeclarativeTextEdit::SelectWords << 16 << 27 << false; + QTest::newRow("fox<( jumped )over>|words,reversed") + << standard[0] << 27 << 19 << QDeclarativeTextEdit::SelectWords << 19 << 31 << false; + QTest::newRow("<th(e qu)ick>|words") << standard[0] << 2 << 6 << QDeclarativeTextEdit::SelectWords << 0 << 9 << true; - QTest::newRow("la(zy d)og|words") + QTest::newRow("<la(zy d)og|words>") << standard[0] << 38 << 42 << QDeclarativeTextEdit::SelectWords << 36 << 44 << true; - QTest::newRow("jum(ped ov)er|words") + QTest::newRow("<jum(ped ov)er>|words") << standard[0] << 23 << 29 << QDeclarativeTextEdit::SelectWords << 20 << 31 << true; - QTest::newRow("()the|words") + QTest::newRow("<()>the|words") << standard[0] << 0 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 0 << true; - QTest::newRow("dog()|words") + QTest::newRow("dog<()>|words") << standard[0] << 44 << 44 << QDeclarativeTextEdit::SelectWords << 44 << 44 << true; - QTest::newRow("jum()ped|words") + QTest::newRow("jum<()>ped|words") << standard[0] << 23 << 23 << QDeclarativeTextEdit::SelectWords << 23 << 23 << true; - QTest::newRow("Hello(,) |words") + QTest::newRow("Hello<(,)> |words") << standard[2] << 5 << 6 << QDeclarativeTextEdit::SelectWords << 5 << 6 << true; - QTest::newRow("Hello(, )|words") - << standard[2] << 5 << 7 << QDeclarativeTextEdit::SelectWords << 5 << 6 << true; - QTest::newRow("Hel(lo, )|words") - << standard[2] << 3 << 7 << QDeclarativeTextEdit::SelectWords << 0 << 6 << true; - QTest::newRow("Hel(lo),|words") + QTest::newRow("Hello<(, )>world|words") + << standard[2] << 5 << 7 << QDeclarativeTextEdit::SelectWords << 5 << 7 << false; + QTest::newRow("Hello<(, )world>|words,reversed") + << standard[2] << 7 << 5 << QDeclarativeTextEdit::SelectWords << 5 << 12 << false; + QTest::newRow("<Hel(lo, )>world|words") + << standard[2] << 3 << 7 << QDeclarativeTextEdit::SelectWords << 0 << 7 << false; + QTest::newRow("<Hel(lo, )world>|words,reversed") + << standard[2] << 7 << 3 << QDeclarativeTextEdit::SelectWords << 0 << 12 << false; + QTest::newRow("<Hel(lo)>,|words") << standard[2] << 3 << 5 << QDeclarativeTextEdit::SelectWords << 0 << 5 << true; - QTest::newRow("Hello(),|words") + QTest::newRow("Hello<()>,|words") << standard[2] << 5 << 5 << QDeclarativeTextEdit::SelectWords << 5 << 5 << true; - QTest::newRow("Hello,()|words") + QTest::newRow("Hello,<()>|words") << standard[2] << 6 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 6 << true; - QTest::newRow("Hello,( )|words") - << standard[2] << 6 << 7 << QDeclarativeTextEdit::SelectWords << 7 << 7 << false; - QTest::newRow("Hello,( )|words") - << standard[2] << 7 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 6 << false; - QTest::newRow("Hello,( world)|words") - << standard[2] << 6 << 12 << QDeclarativeTextEdit::SelectWords << 7 << 12 << true; - QTest::newRow("Hello,( world!)|words") - << standard[2] << 6 << 13 << QDeclarativeTextEdit::SelectWords << 7 << 13 << true; - QTest::newRow("Hello(, world!)|words") + QTest::newRow("Hello<,( )>world|words") + << standard[2] << 6 << 7 << QDeclarativeTextEdit::SelectWords << 5 << 7 << false; + QTest::newRow("Hello,<( )world>|words,reversed") + << standard[2] << 7 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 12 << false; + QTest::newRow("Hello<,( world)>|words") + << standard[2] << 6 << 12 << QDeclarativeTextEdit::SelectWords << 5 << 12 << false; + QTest::newRow("Hello,<( world)>|words,reversed") + << standard[2] << 12 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 12 << false; + QTest::newRow("Hello<,( world!)>|words") + << standard[2] << 6 << 13 << QDeclarativeTextEdit::SelectWords << 5 << 13 << false; + QTest::newRow("Hello,<( world!)>|words,reversed") + << standard[2] << 13 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 13 << false; + QTest::newRow("Hello<(, world!)>|words") << standard[2] << 5 << 13 << QDeclarativeTextEdit::SelectWords << 5 << 13 << true; - QTest::newRow("world(!)|words") + QTest::newRow("world<(!)>|words") << standard[2] << 12 << 13 << QDeclarativeTextEdit::SelectWords << 12 << 13 << true; - QTest::newRow("world!())|words") + QTest::newRow("world!<()>)|words") << standard[2] << 13 << 13 << QDeclarativeTextEdit::SelectWords << 13 << 13 << true; - QTest::newRow("world()!)|words") + QTest::newRow("world<()>!)|words") << standard[2] << 12 << 12 << QDeclarativeTextEdit::SelectWords << 12 << 12 << true; - QTest::newRow("(,)olleH |words") + QTest::newRow("<(,)>olleH |words") << standard[3] << 7 << 8 << QDeclarativeTextEdit::SelectWords << 7 << 8 << true; - QTest::newRow("( ,)olleH|words") - << standard[3] << 6 << 8 << QDeclarativeTextEdit::SelectWords << 7 << 8 << true; - QTest::newRow("( ,ol)leH|words") - << standard[3] << 6 << 10 << QDeclarativeTextEdit::SelectWords << 7 << 13 << true; - QTest::newRow(",(ol)leH,|words") + QTest::newRow("<dlrow( ,)>olleH|words") + << standard[3] << 6 << 8 << QDeclarativeTextEdit::SelectWords << 1 << 8 << false; + QTest::newRow("dlrow<( ,)>olleH|words,reversed") + << standard[3] << 8 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 8 << false; + QTest::newRow("<dlrow( ,ol)leH>|words") + << standard[3] << 6 << 10 << QDeclarativeTextEdit::SelectWords << 1 << 13 << false; + QTest::newRow("dlrow<( ,ol)leH>|words,reversed") + << standard[3] << 10 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 13 << false; + QTest::newRow(",<(ol)leH>,|words") << standard[3] << 8 << 10 << QDeclarativeTextEdit::SelectWords << 8 << 13 << true; - QTest::newRow(",()olleH|words") + QTest::newRow(",<()>olleH|words") << standard[3] << 8 << 8 << QDeclarativeTextEdit::SelectWords << 8 << 8 << true; - QTest::newRow("(),olleH|words") + QTest::newRow("<()>,olleH|words") << standard[3] << 7 << 7 << QDeclarativeTextEdit::SelectWords << 7 << 7 << true; - QTest::newRow("( ),olleH|words") - << standard[3] << 6 << 7 << QDeclarativeTextEdit::SelectWords << 7 << 7 << false; - QTest::newRow("( ),olleH|words,reversed") - << standard[3] << 7 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 6 << false; - QTest::newRow("(dlrow ),olleH|words") - << standard[3] << 1 << 7 << QDeclarativeTextEdit::SelectWords << 1 << 6 << true; - QTest::newRow("(!dlrow ),olleH|words") - << standard[3] << 0 << 7 << QDeclarativeTextEdit::SelectWords << 0 << 6 << true; + QTest::newRow("<dlrow( )>,olleH|words") + << standard[3] << 6 << 7 << QDeclarativeTextEdit::SelectWords << 1 << 7 << false; + QTest::newRow("dlrow<( ),>olleH|words,reversed") + << standard[3] << 7 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 8 << false; + QTest::newRow("<(dlrow )>,olleH|words") + << standard[3] << 1 << 7 << QDeclarativeTextEdit::SelectWords << 1 << 7 << false; + QTest::newRow("<(dlrow ),>olleH|words,reversed") + << standard[3] << 7 << 1 << QDeclarativeTextEdit::SelectWords << 1 << 8 << false; + QTest::newRow("<(!dlrow )>,olleH|words") + << standard[3] << 0 << 7 << QDeclarativeTextEdit::SelectWords << 0 << 7 << false; + QTest::newRow("<(!dlrow ),>olleH|words,reversed") + << standard[3] << 7 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 8 << false; QTest::newRow("(!dlrow ,)olleH|words") << standard[3] << 0 << 8 << QDeclarativeTextEdit::SelectWords << 0 << 8 << true; - QTest::newRow("(!)dlrow|words") + QTest::newRow("<(!)>dlrow|words") << standard[3] << 0 << 1 << QDeclarativeTextEdit::SelectWords << 0 << 1 << true; - QTest::newRow("()!dlrow|words") + QTest::newRow("<()>!dlrow|words") << standard[3] << 0 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 0 << true; - QTest::newRow("!()dlrow|words") + QTest::newRow("!<()>dlrow|words") << standard[3] << 1 << 1 << QDeclarativeTextEdit::SelectWords << 1 << 1 << true; } @@ -893,6 +919,7 @@ void tst_qdeclarativetextedit::moveCursorSelection() texteditObject->setCursorPosition(cursorPosition); texteditObject->moveCursorSelection(movePosition, mode); + QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); QCOMPARE(texteditObject->selectionStart(), selectionStart); QCOMPARE(texteditObject->selectionEnd(), selectionEnd); @@ -900,11 +927,168 @@ void tst_qdeclarativetextedit::moveCursorSelection() texteditObject->setCursorPosition(movePosition); texteditObject->moveCursorSelection(cursorPosition, mode); + QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); QCOMPARE(texteditObject->selectionStart(), selectionStart); QCOMPARE(texteditObject->selectionEnd(), selectionEnd); } } +void tst_qdeclarativetextedit::moveCursorSelectionSequence_data() +{ + QTest::addColumn<QString>("testStr"); + QTest::addColumn<int>("cursorPosition"); + QTest::addColumn<int>("movePosition1"); + QTest::addColumn<int>("movePosition2"); + QTest::addColumn<int>("selection1Start"); + QTest::addColumn<int>("selection1End"); + QTest::addColumn<int>("selection2Start"); + QTest::addColumn<int>("selection2End"); + + QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr") + << standard[0] + << 9 << 13 << 17 + << 4 << 15 + << 4 << 19; + QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") + << standard[0] + << 13 << 9 << 17 + << 9 << 15 + << 10 << 19; + QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr") + << standard[0] + << 9 << 13 << 16 + << 4 << 15 + << 4 << 16; + QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") + << standard[0] + << 13 << 9 << 16 + << 9 << 15 + << 10 << 16; + QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr") + << standard[0] + << 9 << 13 << 15 + << 4 << 15 + << 4 << 15; + QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") + << standard[0] + << 13 << 9 << 15 + << 9 << 15 + << 10 << 15; + QTest::newRow("the {<quick() ^}bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 10 + << 4 << 15 + << 4 << 10; + QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl") + << standard[0] + << 13 << 9 << 10 + << 9 << 15 + << 10 << 15; + QTest::newRow("the {<quick^}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 9 + << 4 << 15 + << 4 << 9; + QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") + << standard[0] + << 13 << 9 << 9 + << 9 << 15 + << 9 << 15; + QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 7 + << 4 << 15 + << 4 << 9; + QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl") + << standard[0] + << 13 << 9 << 7 + << 9 << 15 + << 4 << 15; + QTest::newRow("the {<^quick}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 4 + << 4 << 15 + << 4 << 9; + QTest::newRow("the {<^quick}( bro)wn> fox|rtl") + << standard[0] + << 13 << 9 << 4 + << 9 << 15 + << 4 << 15; + QTest::newRow("the{^ <quick}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 3 + << 4 << 15 + << 3 << 9; + QTest::newRow("the{^ <quick}( bro)wn> fox|rtl") + << standard[0] + << 13 << 9 << 3 + << 9 << 15 + << 3 << 15; + QTest::newRow("{t^he <quick}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 1 + << 4 << 15 + << 0 << 9; + QTest::newRow("{t^he <quick}( bro)wn> fox|rtl") + << standard[0] + << 13 << 9 << 1 + << 9 << 15 + << 0 << 15; + + QTest::newRow("{<He(ll)o>, w^orld}!|ltr") + << standard[2] + << 2 << 4 << 8 + << 0 << 5 + << 0 << 12; + QTest::newRow("{<He(ll)o>, w^orld}!|rtl") + << standard[2] + << 4 << 2 << 8 + << 0 << 5 + << 0 << 12; + + QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr") + << standard[3] + << 9 << 11 << 5 + << 8 << 13 + << 1 << 13; + QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl") + << standard[3] + << 11 << 9 << 5 + << 8 << 13 + << 1 << 13; +} + +void tst_qdeclarativetextedit::moveCursorSelectionSequence() +{ + QFETCH(QString, testStr); + QFETCH(int, cursorPosition); + QFETCH(int, movePosition1); + QFETCH(int, movePosition2); + QFETCH(int, selection1Start); + QFETCH(int, selection1End); + QFETCH(int, selection2Start); + QFETCH(int, selection2End); + + QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }"; + QDeclarativeComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextEdit *texteditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); + QVERIFY(texteditObject != 0); + + texteditObject->setCursorPosition(cursorPosition); + + texteditObject->moveCursorSelection(movePosition1, QDeclarativeTextEdit::SelectWords); + QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); + QCOMPARE(texteditObject->selectionStart(), selection1Start); + QCOMPARE(texteditObject->selectionEnd(), selection1End); + + texteditObject->moveCursorSelection(movePosition2, QDeclarativeTextEdit::SelectWords); + QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); + QCOMPARE(texteditObject->selectionStart(), selection2Start); + QCOMPARE(texteditObject->selectionEnd(), selection2End); +} + + void tst_qdeclarativetextedit::mouseSelection_data() { QTest::addColumn<QString>("qmlfile"); @@ -995,6 +1179,55 @@ void tst_qdeclarativetextedit::dragMouseSelection() QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and doesn't not the first moved. } +void tst_qdeclarativetextedit::mouseSelectionMode_data() +{ + QTest::addColumn<QString>("qmlfile"); + QTest::addColumn<bool>("selectWords"); + + // import installed + QTest::newRow("SelectWords") << SRCDIR "/data/mouseselectionmode_words.qml" << true; + QTest::newRow("SelectCharacters") << SRCDIR "/data/mouseselectionmode_characters.qml" << false; + QTest::newRow("default") << SRCDIR "/data/mouseselectionmode_default.qml" << false; +} + +void tst_qdeclarativetextedit::mouseSelectionMode() +{ + QFETCH(QString, qmlfile); + QFETCH(bool, selectWords); + + QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + QDeclarativeView *canvas = createView(qmlfile); + + 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-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textEditObject->height()/2; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); + //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y))); + QString str = textEditObject->selectedText(); + if (selectWords) { + QCOMPARE(str, text); + } else { + QVERIFY(str.length() > 3); + QVERIFY(str != text); + } + + delete canvas; +} + void tst_qdeclarativetextedit::inputMethodHints() { QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); |