Stabilize :insert-text tests

With QtWebEngine, inserting text into the field is async, so if our
test runs too fast, it would fail. Now we instead log stuff via JS on
changes insteaad, and wait for those log messages in the tests.
This commit is contained in:
Florian Bruhin 2016-09-12 15:25:03 +02:00
parent d988f919d7
commit b645a88ade
3 changed files with 27 additions and 16 deletions

View File

@ -3,8 +3,22 @@
<head>
<meta charset="utf-8">
<title>Paste primary selection</title>
<script type="text/javascript">
function setup_event_listener() {
var textarea = document.getElementById('qute-textarea');
textarea.addEventListener('input', function() {
console.log("textarea contents: " + textarea.value);
});
}
function set_text(value) {
var textarea = document.getElementById('qute-textarea');
textarea.value = value;
console.log("textarea set to: " + value);
}
</script>
</head>
<body>
<body onload="setup_event_listener()">
<textarea id="qute-textarea"></textarea>
<textarea id="qute-textarea-noedit" readonly></textarea>
</body>

View File

@ -33,12 +33,5 @@ def init_fake_clipboard(quteproc):
@bdd.when(bdd.parsers.parse('I set the text field to "{value}"'))
def set_text_field(quteproc, value):
quteproc.send_cmd(":jseval document.getElementById('qute-textarea').value "
"= '{}';".format(value))
@bdd.then(bdd.parsers.parse('the text field should contain "{value}"'))
def check_text_field(quteproc, value):
quteproc.send_cmd(":jseval console.log('text: ' + "
"document.getElementById('qute-textarea').value);")
quteproc.wait_for_js('text: ' + value)
quteproc.send_cmd(":jseval set_text('{}')".format(value))
quteproc.wait_for_js('textarea set to: ' + value)

View File

@ -230,15 +230,17 @@ Feature: Yanking and pasting.
#### :insert-text
Scenario: Inserting text into an empty text field
When I open data/paste_primary.html
When I set general -> log-javascript-console to info
And I open data/paste_primary.html
And I run :click-element id qute-textarea
And I wait for "Clicked editable element!" in the log
And I run :insert-text Hello world
# Compare
Then the text field should contain "Hello world"
Then the javascript message "textarea contents: Hello world" should be logged
Scenario: Inserting text into a text field at specific position
When I open data/paste_primary.html
When I set general -> log-javascript-console to info
And I open data/paste_primary.html
And I set the text field to "one two three four"
And I run :click-element id qute-textarea
And I wait for "Clicked editable element!" in the log
@ -248,20 +250,22 @@ Feature: Yanking and pasting.
And I press the key "<Right>"
And I run :insert-text Hello world
# Compare
Then the text field should contain "onHello worlde two three four"
Then the javascript message "textarea contents: onHello worlde two three four" should be logged
@qtwebengine_osx_xfail
Scenario: Inserting text into a text field with undo
When I open data/paste_primary.html
When I set general -> log-javascript-console to info
And I open data/paste_primary.html
And I run :click-element id qute-textarea
And I wait for "Clicked editable element!" in the log
# Paste and undo
And I run :insert-text This text should be undone
And I wait for the javascript message "textarea contents: This text should be undone"
And I press the key "<Ctrl+z>"
# Paste final text
And I run :insert-text This text should stay
# Compare
Then the text field should contain "This text should stay"
Then the javascript message "textarea contents: This text should stay" should be logged
Scenario: Inserting text without a focused field
When I open data/paste_primary.html