From af5d199e8f820c59148081a703982095902cbfea Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 31 Jan 2016 20:56:37 +0100 Subject: [PATCH] bdd: Simplify :paste-primary tests. --- tests/integration/features/test_yankpaste.py | 13 +++++++++++++ tests/integration/features/yankpaste.feature | 13 ++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/integration/features/test_yankpaste.py b/tests/integration/features/test_yankpaste.py index 67f3df8db..7fce22a0e 100644 --- a/tests/integration/features/test_yankpaste.py +++ b/tests/integration/features/test_yankpaste.py @@ -38,3 +38,16 @@ def skip_with_broken_clipboard(qtbot, qapp): if clipboard.text() != "Does this work?": pytest.skip("Clipboard seems to be broken on this platform.") + + +@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) diff --git a/tests/integration/features/yankpaste.feature b/tests/integration/features/yankpaste.feature index 3001a54d3..99a34c35a 100644 --- a/tests/integration/features/yankpaste.feature +++ b/tests/integration/features/yankpaste.feature @@ -171,6 +171,8 @@ Feature: Yanking and pasting. - active: true url: http://localhost:*/data/hello3.txt + #### :paste-primary + Scenario: Pasting the primary selection into an empty text field When selection is supported And I open data/paste_primary.html @@ -180,13 +182,12 @@ Feature: Yanking and pasting. And I run :follow-hint a And I run :paste-primary # Compare - And I run :jseval console.log(document.getElementById('qute-textarea').value); - Then the javascript message "Hello world" should be logged + Then the text field should contain "Hello world" Scenario: Pasting the primary selection into a text field at specific position When selection is supported And I open data/paste_primary.html - And I run :jseval document.getElementById('qute-textarea').value = 'one two three four'; + And I set the text field to "one two three four" And I put " Hello world" into the primary selection # Click the text field And I run :hint all @@ -197,8 +198,7 @@ Feature: Yanking and pasting. And I press the key "" And I run :paste-primary # Compare - And I run :jseval console.log(document.getElementById('qute-textarea').value); - Then the javascript message "one two Hello world three four" should be logged + Then the text field should contain "one two Hello world three four" Scenario: Pasting the primary selection into a text field with undo When selection is supported @@ -214,5 +214,4 @@ Feature: Yanking and pasting. And I put "This text should stay" into the primary selection And I run :paste-primary # Compare - And I run :jseval console.log(document.getElementById('qute-textarea').value); - Then the javascript message "This text should stay" should be logged + Then the text field should contain "This text should stay"