bdd: Add some first tests for :paste.
This commit is contained in:
parent
ad8c9988f0
commit
1f3df64fe4
@ -27,22 +27,34 @@ import pytest_bdd as bdd
|
||||
bdd.scenarios('yankpaste.feature')
|
||||
|
||||
|
||||
def _get_mode(qapp, what):
|
||||
"""Get the QClipboard::Mode to use based on a string."""
|
||||
if what == 'clipboard':
|
||||
return QClipboard.Clipboard
|
||||
elif what == 'primary selection':
|
||||
assert qapp.clipboard().supportsSelection()
|
||||
return QClipboard.Selection
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
|
||||
@bdd.when("selection is supported")
|
||||
def selection_supported(qapp):
|
||||
if not qapp.clipboard().supportsSelection():
|
||||
pytest.skip("OS doesn't support primary selection!")
|
||||
|
||||
@bdd.when(bdd.parsers.re(r'I put "(?P<content>.*)" into the '
|
||||
r'(?P<what>primary selection|clipboard)'))
|
||||
def fill_clipboard(qapp, httpbin, what, content):
|
||||
mode = _get_mode(qapp, what)
|
||||
content = content.replace('(port)', str(httpbin.port))
|
||||
qapp.clipboard().setText(content, mode)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.re(r'the (?P<what>primary selection|clipboard) should '
|
||||
r'contain "(?P<content>.*)"'))
|
||||
def clipboard_contains(qapp, httpbin, what, content):
|
||||
if what == 'clipboard':
|
||||
mode = QClipboard.Clipboard
|
||||
elif what == 'primary selection':
|
||||
mode = QClipboard.Selection
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
mode = _get_mode(qapp, what)
|
||||
expected = content.replace('(port)', str(httpbin.port))
|
||||
|
||||
data = qapp.clipboard().text(mode=mode)
|
||||
|
@ -26,3 +26,18 @@ Feature: Yanking and pasting.
|
||||
When I run :yank --domain
|
||||
Then the message "Yanked domain to clipboard: http://localhost:(port)" should be shown.
|
||||
And the clipboard should contain "http://localhost:(port)"
|
||||
|
||||
Scenario: Pasting an URL
|
||||
When I put "http://localhost:(port)/data/hello.txt" into the clipboard
|
||||
And I run :paste
|
||||
And I wait until data/hello.txt is loaded
|
||||
Then the requests should be:
|
||||
data/hello.txt
|
||||
|
||||
Scenario: Pasting an URL from primary selection
|
||||
When selection is supported
|
||||
And I put "http://localhost:(port)/data/hello2.txt" into the primary selection
|
||||
And I run :paste --sel
|
||||
And I wait until data/hello2.txt is loaded
|
||||
Then the requests should be:
|
||||
data/hello2.txt
|
||||
|
Loading…
Reference in New Issue
Block a user