Adds function to insert multiple lines in the clipboard

This commit is contained in:
Tarcisio Fedrizzi 2016-01-12 09:59:03 +01:00
parent 4bbc1e2d8a
commit f08704e789
2 changed files with 20 additions and 4 deletions

View File

@ -199,13 +199,20 @@ def selection_supported(qapp):
def fill_clipboard(qtbot, qapp, httpbin, what, content):
mode = _clipboard_mode(qapp, what)
content = content.replace('(port)', str(httpbin.port))
content = content.replace('\\n', '\n')
clipboard = qapp.clipboard()
with qtbot.waitSignal(clipboard.changed):
clipboard.setText(content, mode)
@bdd.when(bdd.parsers.re(r'I put the following lines into the '
r'(?P<what>primary selection|clipboard):\n'
r'(?P<content>.+)$', flags=re.DOTALL))
def fill_clipboard_multiline(qtbot, qapp, httpbin, what, content):
content = '\n'.join(l.strip() for l in content.strip().split('\n'))
fill_clipboard(qtbot, qapp, httpbin, what, content)
## Then

View File

@ -108,7 +108,10 @@ Feature: Yanking and pasting.
Scenario: Pasting multiple urls in a new tab
Given I have a fresh instance
When I run :tab-only
And I put "http://localhost:(port)/data/hello.txt\nhttp://localhost:(port)/data/hello2.txt\nhttp://localhost:(port)/data/hello3.txt" into the clipboard
And I put the following lines into the clipboard:
http://localhost:(port)/data/hello.txt
http://localhost:(port)/data/hello2.txt
http://localhost:(port)/data/hello3.txt
And I run :paste -t
And I wait until data/hello.txt is loaded
And I wait until data/hello2.txt is loaded
@ -122,7 +125,10 @@ Feature: Yanking and pasting.
Scenario: Pasting multiple urls in a background tab
Given I open about:blank
When I run :tab-only
And I put "http://localhost:(port)/data/hello.txt\nhttp://localhost:(port)/data/hello2.txt\nhttp://localhost:(port)/data/hello3.txt" into the clipboard
And I put the following lines into the clipboard:
http://localhost:(port)/data/hello.txt
http://localhost:(port)/data/hello2.txt
http://localhost:(port)/data/hello3.txt
And I run :paste -b
And I wait until data/hello.txt is loaded
And I wait until data/hello2.txt is loaded
@ -135,7 +141,10 @@ Feature: Yanking and pasting.
Scenario: Pasting multiple urls in new windows
Given I have a fresh instance
When I put "http://localhost:(port)/data/hello.txt\nhttp://localhost:(port)/data/hello2.txt\nhttp://localhost:(port)/data/hello3.txt" into the clipboard
When I put the following lines into the clipboard:
http://localhost:(port)/data/hello.txt
http://localhost:(port)/data/hello2.txt
http://localhost:(port)/data/hello3.txt
And I run :paste -w
And I wait until data/hello.txt is loaded
And I wait until data/hello2.txt is loaded