aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-11-28 14:29:36 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-29 04:34:11 +0100
commit2e8059bfb80230d82bf98d7791b4dfc1d3706658 (patch)
treef5fa2314bfc8a527cf41f7986e33ed19eeb00ecf /tests
parentc648598a8ba8bf72b5d556211df877578d5f5b64 (diff)
Add a length property to TextEdit.
This returns the length of the unformatted text in a TextEdit which should be cheaper to query than the length of the text property and meaningful in the context of the selection and cursor properties. Task-number: QTBUG-18949 Change-Id: Ia25c4553693923f97d299f1fdb8bfcf7f5937b13 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
index e348cae7e6..6bcad83c52 100644
--- a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
@@ -314,6 +314,7 @@ void tst_qquicktextedit::text()
QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->text(), QString(""));
+ QCOMPARE(textEditObject->length(), 0);
}
for (int i = 0; i < standard.size(); i++)
@@ -325,6 +326,7 @@ void tst_qquicktextedit::text()
QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->text(), standard.at(i));
+ QCOMPARE(textEditObject->length(), standard.at(i).length());
}
for (int i = 0; i < richText.size(); i++)
@@ -341,6 +343,9 @@ void tst_qquicktextedit::text()
actual.replace(QRegExp("(<[^>]*>)+"),"<>");
expected.replace(QRegExp("(<[^>]*>)+"),"<>");
QCOMPARE(actual.simplified(),expected.simplified());
+
+ expected.replace("<>", " ");
+ QCOMPARE(textEditObject->length(), expected.simplified().length());
}
}
@@ -2738,7 +2743,9 @@ void tst_qquicktextedit::insert()
QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
} else {
QCOMPARE(textEdit->text(), expectedText);
+
}
+ QCOMPARE(textEdit->length(), expectedText.length());
QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
@@ -2751,7 +2758,7 @@ void tst_qquicktextedit::insert()
QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
QCOMPARE(selectionSpy.count() > 0, selectionChanged);
QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("into reversed selection", "yeah I don't know", Continue);
+ QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
@@ -2982,6 +2989,7 @@ void tst_qquicktextedit::remove()
} else {
QCOMPARE(textEdit->text(), expectedText);
}
+ QCOMPARE(textEdit->length(), expectedText.length());
if (selectionStart > selectionEnd) //
qSwap(selectionStart, selectionEnd);