diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-03-03 05:20:17 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-03-30 00:35:10 (GMT) |
commit | 84413a25bc025f099a075387fb6ab8449d9ef217 (patch) | |
tree | 1b13a4beb5cfe6faccad0a3def7a0f05c39947c2 /tests | |
parent | f0c6b3eefdf342bbb71e9409ea050da3c92ac861 (diff) | |
download | Qt-84413a25bc025f099a075387fb6ab8449d9ef217.zip Qt-84413a25bc025f099a075387fb6ab8449d9ef217.tar.gz Qt-84413a25bc025f099a075387fb6ab8449d9ef217.tar.bz2 |
Return correct boundaries reasons from QTextBoundaryFinder.
The next character after a boundary is at pos, not pos + 1. Also
consider whether the previous and next character are whitespace in
combination when determing word boudaries otherwise positions between
whitespace characters will return both StartWord and EndWord.
And since there's no need to look ahead one character don't shortcut`
the regular logic for the boundary before the last character.
Change-Id: I2efbf3947066767945f96bf8456ef518d2149191
Task-number: QTBUG-11365
Reviewed-by: Denis Dzyubenko
Reviewed-by: Ritt Konstantin
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 35 | ||||
-rw-r--r-- | tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp | 6 |
2 files changed, 18 insertions, 23 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 45f38a4..a35a2c9 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -604,10 +604,8 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() << standard[2] << 13 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false; QTest::newRow("Hello<(, world!)>|words") << standard[2] << 5 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << true; - // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings. - // QTBUG-11365 - // QTest::newRow("world<(!)>|words") - // << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true; + QTest::newRow("world<(!)>|words") + << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true; QTest::newRow("world!<()>)|words") << standard[2] << 13 << 13 << QDeclarativeTextInput::SelectWords << 13 << 13 << true; QTest::newRow("world<()>!)|words") @@ -653,16 +651,15 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() QTest::newRow(" <s(pac)ey> text |words") << standard[4] << 1 << 4 << QDeclarativeTextInput::SelectWords << 1 << 7 << true; QTest::newRow(" spacey <t(ex)t> |words") - << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365 + << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << true; QTest::newRow("<( )>spacey text |words|ltr") << standard[4] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << false; QTest::newRow("<( )spacey> text |words|rtl") << standard[4] << 1 << 0 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; QTest::newRow("spacey <text( )>|words|ltr") << standard[4] << 14 << 15 << QDeclarativeTextInput::SelectWords << 10 << 15 << false; -// QTBUG-11365 -// QTest::newRow("spacey text<( )>|words|rtl") -// << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false; + QTest::newRow("spacey text<( )>|words|rtl") + << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false; QTest::newRow("<()> spacey text |words") << standard[4] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << false; QTest::newRow(" spacey text <()>|words") @@ -857,23 +854,21 @@ void tst_qdeclarativetextinput::moveCursorSelectionSequence_data() << 15 << 12 << 15 << 10 << 15 << 15 << 15; -// QTBUG-11365 -// QTest::newRow(" spacey <te(xt{^ )>}|rtl") -// << standard[4] -// << 15 << 12 << 14 -// << 10 << 15 -// << 14 << 15; + QTest::newRow(" spacey <te(xt{^ )>}|rtl") + << standard[4] + << 15 << 12 << 14 + << 10 << 15 + << 14 << 15; QTest::newRow(" spacey {<te(x^t} )>|ltr") << standard[4] << 12 << 15 << 13 << 10 << 15 << 10 << 14; -// QTBUG-11365 -// QTest::newRow(" spacey {<te(xt^} )>|ltr") -// << standard[4] -// << 12 << 15 << 14 -// << 10 << 15 -// << 10 << 14; + QTest::newRow(" spacey {<te(xt^} )>|ltr") + << standard[4] + << 12 << 15 << 14 + << 10 << 15 + << 10 << 14; } void tst_qdeclarativetextinput::moveCursorSelectionSequence() diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 6157004..8003c44 100644 --- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -257,10 +257,10 @@ void tst_QTextBoundaryFinder::sentenceBoundaries() void tst_QTextBoundaryFinder::isAtWordStart() { - QString txt("The quick brown fox jumped over $the lazy. dog "); + QString txt("The quick brown fox jumped over $the lazy. dog I win!"); QList<int> start, end; - start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43; - end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46; + start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43 << 48 << 50 << 53; + end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46 << 49 << 53 << 54; QTextBoundaryFinder finder(QTextBoundaryFinder::Word, txt); for(int i=0; i < txt.length(); ++i) { finder.setPosition(i); |