aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDan Cape <dcape@qnx.com>2015-08-13 14:59:52 -0400
committerDan Cape <dcape@qnx.com>2015-09-21 13:53:49 +0000
commit0f29340a10b9638666ded939b4f6bf3d891f1320 (patch)
treee96210a55e8847dc9022f263d5c8da67831f140a /tests
parent8614d4d8362e2fbc56f6b027d310a0d8f11a212f (diff)
TextEdit: selectedTextChanged not emitted when calling select 2nd time
qquicktextcontrol was only checking if the text was previous selected or not and if the current state matched the previous state it would not dispatch a selectedTextChanged event. This is wrong if you programmatically select text a second time with a different start or end of selection. You must notify that the selected text changed since visually you can see the highlight changed locations. When correcting this and creating a test case, it was seen that other tests had QEXPECT_FAIL set for this specific case. Upon further inspection, I could remove those calls and adjust the expected data that was set before the test (changing false to true). testing of tst_qquicktext: Totals: 182 passed, 0 failed, 0 skipped, 0 blacklisted testing of tst_qquicktextedit: Totals: 354 passed, 0 failed, 3 skipped, 0 blacklisted Task-number: QTBUG-38704 Change-Id: Ib5244dc264ab76951bb722a31dcb64717282725a Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 5ec8fa2e83..eda3be5c1d 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -201,6 +201,7 @@ private slots:
void emptytags_QTBUG_22058();
void cursorRectangle_QTBUG_38947();
void textCached_QTBUG_41583();
+ void doubleSelect_QTBUG_38704();
void padding();
@@ -4044,7 +4045,7 @@ void tst_qquicktextedit::append_data()
<< QString("Hello")
<< standard.at(0) + QString("\nHello")
<< 18 << standard.at(0).length() + 6 << standard.at(0).length() + 6
- << false << true;
+ << true << true;
QTest::newRow("reversed selection kept intact")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4126,11 +4127,8 @@ void tst_qquicktextedit::append()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QEXPECT_FAIL("into selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("into reversed selection", "selectedTextChanged 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", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
@@ -4213,7 +4211,7 @@ void tst_qquicktextedit::insert_data()
<< QString("Hello")
<< QString("Hello") + standard.at(0)
<< 19 << 24 << 24
- << false << true;
+ << true << true;
QTest::newRow("before reversed selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4221,7 +4219,7 @@ void tst_qquicktextedit::insert_data()
<< QString("Hello")
<< QString("Hello") + standard.at(0)
<< 19 << 24 << 19
- << false << true;
+ << true << true;
QTest::newRow("after selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4344,11 +4342,8 @@ void tst_qquicktextedit::insert()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QEXPECT_FAIL("into selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("into reversed selection", "selectedTextChanged 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", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
@@ -4458,7 +4453,7 @@ void tst_qquicktextedit::remove_data()
<< 0 << 5
<< standard.at(0).mid(5)
<< 9 << 14 << 14
- << false << true;
+ << true << true;
QTest::newRow("before reversed selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4466,7 +4461,7 @@ void tst_qquicktextedit::remove_data()
<< 0 << 5
<< standard.at(0).mid(5)
<< 9 << 14 << 9
- << false << true;
+ << true << true;
QTest::newRow("after selection")
<< standard.at(0) << QQuickTextEdit::PlainText
@@ -4588,11 +4583,8 @@ void tst_qquicktextedit::remove()
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
- QEXPECT_FAIL("from selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("from reversed selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue);
QCOMPARE(selectionSpy.count() > 0, selectionChanged);
QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue);
QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
QCOMPARE(textSpy.count() > 0, text != expectedText);
@@ -5374,6 +5366,26 @@ void tst_qquicktextedit::textCached_QTBUG_41583()
QVERIFY(!textedit->property("empty").toBool());
}
+void tst_qquicktextedit::doubleSelect_QTBUG_38704()
+{
+ QString componentStr = "import QtQuick 2.2\nTextEdit { text: \"TextEdit\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QSignalSpy selectionSpy(textEdit, SIGNAL(selectedTextChanged()));
+
+ textEdit->select(0,1); //Select some text initially
+ QCOMPARE(selectionSpy.count(), 1);
+ textEdit->select(0,1); //No change to selection start/end
+ QCOMPARE(selectionSpy.count(), 1);
+ textEdit->select(0,2); //Change selection end
+ QCOMPARE(selectionSpy.count(), 2);
+ textEdit->select(1,2); //Change selection start
+ QCOMPARE(selectionSpy.count(), 3);
+}
+
void tst_qquicktextedit::padding()
{
QScopedPointer<QQuickView> window(new QQuickView);