aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-04-09 16:55:58 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-04-10 14:24:40 +0300
commit80ebe0d1e3061aaf5ba792f21813e0a8804112ad (patch)
tree659abfaf1b3c9df8f1b205c16f4dd537bc1d022d
parentb22e3fab1fc028518633bbaab10e40d5920be773 (diff)
Make spell correction tests non-flaky
Replaced the timeout condition in the spell correction tests with more flexible solution where the spell correction results are polled in short intervals. Removed an unnecessary wait condition from the automatic space insertion tests where the actual spell correction results are irrelevant. Change-Id: I74eb8f2f4dfd69d47cfe55a33b743524d21759ca Task-number: QTRD-3573 Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
-rw-r--r--tests/auto/inputpanel/data/inputpanel/inputpanel.qml42
-rw-r--r--tests/auto/inputpanel/data/tst_inputpanel.qml20
2 files changed, 36 insertions, 26 deletions
diff --git a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
index fa6c9a51..e1bc3d04 100644
--- a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
+++ b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
@@ -385,25 +385,37 @@ InputPanel {
VirtualKeyboardSettings.styleName = style
}
- function selectionListSearchSuggestion(suggestion) {
+ function selectionListSearchSuggestion(suggestion, timeout) {
+ if (timeout === undefined || timeout < 0)
+ timeout = 0
var suggestionFound = false
- var origIndex = inputPanel.wordCandidateView.currentIndex
- if (origIndex !== -1) {
- while (true) {
- if (inputPanel.wordCandidateView.model.itemData(inputPanel.wordCandidateView.currentIndex) === suggestion) {
- suggestionFound = true
- break
+ var dt = new Date()
+ var startTime = dt.getTime()
+ while (true) {
+ var origIndex = inputPanel.wordCandidateView.currentIndex
+ if (origIndex !== -1) {
+ while (true) {
+ if (inputPanel.wordCandidateView.model.itemData(inputPanel.wordCandidateView.currentIndex) === suggestion) {
+ suggestionFound = true
+ break
+ }
+ if (inputPanel.wordCandidateView.currentIndex === inputPanel.wordCandidateView.count - 1)
+ break
+ inputPanel.wordCandidateView.incrementCurrentIndex()
}
- if (inputPanel.wordCandidateView.currentIndex === inputPanel.wordCandidateView.count - 1)
- break
- inputPanel.wordCandidateView.incrementCurrentIndex()
- }
- if (!suggestionFound) {
- while (inputPanel.wordCandidateView.currentIndex !== origIndex) {
- inputPanel.wordCandidateView.decrementCurrentIndex()
+ if (!suggestionFound) {
+ while (inputPanel.wordCandidateView.currentIndex !== origIndex) {
+ inputPanel.wordCandidateView.decrementCurrentIndex()
+ }
}
+ testcase.waitForRendering(inputPanel)
}
- testcase.waitForRendering(inputPanel)
+ dt = new Date()
+ var elapsedTime = dt.getTime() - startTime
+ if (suggestionFound || elapsedTime >= timeout)
+ break
+ var maxWait = Math.min(timeout - elapsedTime, 50)
+ testcase.wait(maxWait)
}
return suggestionFound
}
diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml
index 19f499b5..96e820b1 100644
--- a/tests/auto/inputpanel/data/tst_inputpanel.qml
+++ b/tests/auto/inputpanel/data/tst_inputpanel.qml
@@ -555,20 +555,22 @@ Rectangle {
for (var inputIndex in data.inputSequence) {
verify(inputPanel.virtualKeyClick(data.inputSequence[inputIndex]))
}
- wait(300)
+ waitForRendering(inputPanel)
if (data.hasOwnProperty("expectedSuggestion")) {
- if (inputPanel.wordCandidateView.count <= 1)
+ if (inputPanel.wordCandidateView.count > 0) {
+ verify(inputPanel.selectionListSearchSuggestion(data.expectedSuggestion, 2000), "The expected spell correction suggestion \"%1\" was not found".arg(data.expectedSuggestion))
+ verify(inputPanel.selectionListSelectCurrentItem(), "Word candidate not selected")
+ } else if (textInput.text !== data.outputText) {
expectFail("", "Prediction/spell correction not enabled")
- verify(inputPanel.wordCandidateView.count > 1, "Prediction/spell correction results are expected")
-
- verify(inputPanel.selectionListSearchSuggestion(data.expectedSuggestion))
- verify(inputPanel.selectionListSelectCurrentItem())
+ }
} else {
+ wait(1000)
verify(inputPanel.wordCandidateView.count <= 1, "Prediction/spell correction results are not expected")
Qt.inputMethod.commit()
waitForRendering(inputPanel)
}
+
compare(textInput.text, data.outputText)
}
@@ -595,11 +597,7 @@ Rectangle {
for (var inputIndex in data.inputSequence) {
var key = data.inputSequence[inputIndex]
if (key === Qt.Key_Select) {
- wait(300)
- if (inputPanel.wordCandidateView.count > 1)
- inputPanel.selectionListSelectCurrentItem()
- else
- expectFail("", "Prediction/spell correction not enabled")
+ inputPanel.selectionListSelectCurrentItem()
} else {
inputPanel.virtualKeyClick(key)
}