aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-09-29 12:31:30 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-30 10:37:05 +0200
commit54c1fa834aae16fc98fe2f9a3d2a93adc93254df (patch)
treebfbfea12e180fbf61339edba7d6884298e0a0309 /tests
parente1f2f15a6cbea8918e9250ff8d2826cf3ca89a50 (diff)
Fix text input delay related test failures.
Allow a small delay after mouse or key events for the events to be processed before verifying the result, and use the QTRY_ macros to be doubly sure. Task-number: QTBUG-21690 Change-Id: I44e7fa58ef2e57572b6e342af7f4f18649144770 Reviewed-on: http://codereview.qt-project.org/5763 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp23
-rw-r--r--tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp55
2 files changed, 49 insertions, 29 deletions
diff --git a/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp b/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp
index f72a028fcf..16fc63b275 100644
--- a/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp
+++ b/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp
@@ -575,7 +575,7 @@ void tst_qsgtextedit::hAlign_RightToLeft()
textEdit->setText(QString());
{ QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(&canvas, &ev); }
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
+ QEXPECT_FAIL("", "QTBUG-21691", Abort);
QCOMPARE(textEdit->hAlign(), QSGTextEdit::AlignRight);
{ QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(&canvas, &ev); }
QCOMPARE(textEdit->hAlign(), QSGTextEdit::AlignLeft);
@@ -1395,14 +1395,16 @@ void tst_qsgtextedit::mouseSelection()
QTest::mousePress(&canvas, Qt::LeftButton, 0, p1);
QTest::mouseMove(&canvas, p2);
QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2);
- QCOMPARE(textEditObject->selectedText(), selectedText);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->selectedText(), selectedText);
// Clicking and shift to clicking between the same points should select the same text.
textEditObject->setCursorPosition(0);
QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1);
QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2);
+ QTest::qWait(50);
if (!selectedText.isEmpty())
- QEXPECT_FAIL("", "QTBUG-21690", Continue);
+ QEXPECT_FAIL("", "QTBUG-21743", Continue);
QTRY_COMPARE(textEditObject->selectedText(), selectedText);
}
@@ -1607,8 +1609,8 @@ void tst_qsgtextedit::cursorDelegate()
textEditObject->setCursorPosition(0);
const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint();
QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
- QVERIFY(textEditObject->cursorPosition() != 0);
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
@@ -1619,19 +1621,22 @@ void tst_qsgtextedit::cursorDelegate()
QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
QGuiApplication::sendEvent(&view, &mv);
QTest::mouseRelease(&view, Qt::LeftButton, 0, point2);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
textEditObject->setReadOnly(true);
textEditObject->setCursorPosition(0);
QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
- QVERIFY(textEditObject->cursorPosition() != 0);
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
textEditObject->setCursorPosition(0);
QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
- QVERIFY(textEditObject->cursorPosition() != 0);
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
@@ -1986,7 +1991,7 @@ void tst_qsgtextedit::textInput()
QInputMethodEvent event;
event.setCommitString( "Hello world!", 0, 0);
QGuiApplication::sendEvent(&view, &event);
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
+ QEXPECT_FAIL("", "QTBUG-21689", Abort);
QCOMPARE(edit->text(), QString("Hello world!"));
// QTBUG-12339
diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
index 83ad1806db..0fecb54e08 100644
--- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
+++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
@@ -1247,7 +1247,7 @@ void tst_qsgtextinput::positionAt()
int diff = abs(textWidth - (textLeftWidth+textinputObject->width()/2));
// some tollerance for different fonts.
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
+ QEXPECT_FAIL("", "QTBUG-21689", Abort);
#ifdef Q_OS_LINUX
QVERIFY(diff < 2);
#else
@@ -1336,11 +1336,11 @@ void tst_qsgtextinput::maxLength()
textinputObject->setText("");
QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
for(int i=0; i<20; i++){
- QCOMPARE(textinputObject->text().length(), qMin(i,10));
+ QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
//simulateKey(&canvas, Qt::Key_A);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
+ QTest::qWait(50);
}
}
@@ -1358,12 +1358,12 @@ void tst_qsgtextinput::masks()
QVERIFY(textinputObject->text().length() == 0);
QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
for(int i=0; i<10; i++){
- QCOMPARE(qMin(i,8), textinputObject->text().length());
+ QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
//simulateKey(&canvas, Qt::Key_A);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
+ QTest::qWait(50);
}
}
@@ -1385,19 +1385,22 @@ void tst_qsgtextinput::validators()
QTRY_VERIFY(intInput->hasActiveFocus());
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QEXPECT_FAIL("", "QTBUG-21690", Abort);
- QCOMPARE(intInput->text(), QLatin1String("1"));
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
QCOMPARE(intInput->hasAcceptableInput(), false);
QTest::keyPress(&canvas, Qt::Key_2);
QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
QCOMPARE(intInput->hasAcceptableInput(), false);
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
QCOMPARE(intInput->text(), QLatin1String("11"));
QCOMPARE(intInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_0);
QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10);
+ QTest::qWait(50);
QCOMPARE(intInput->text(), QLatin1String("11"));
QCOMPARE(intInput->hasAcceptableInput(), true);
@@ -1407,27 +1410,33 @@ void tst_qsgtextinput::validators()
QVERIFY(dblInput->hasActiveFocus() == true);
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("1"));
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QTest::keyPress(&canvas, Qt::Key_2);
QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12"));
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_Period);
QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12."));
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.1"));
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QSGTextInput *strInput = qobject_cast<QSGTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("strInput")));
@@ -1436,27 +1445,33 @@ void tst_qsgtextinput::validators()
QVERIFY(strInput->hasActiveFocus() == true);
QTest::keyPress(&canvas, Qt::Key_1);
QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String(""));
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String(""));
QCOMPARE(strInput->hasAcceptableInput(), false);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("a"));
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("a"));
QCOMPARE(strInput->hasAcceptableInput(), false);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aa"));
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaa"));
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QTest::keyPress(&canvas, Qt::Key_A);
QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
}