Add bdd test for :yank/:paste.
This commit is contained in:
parent
0d67cff5cb
commit
672d11e25a
10
tests/integration/data/yankpaste/test.html
Normal file
10
tests/integration/data/yankpaste/test.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test title</title>
|
||||
</head>
|
||||
<body>
|
||||
foo
|
||||
</body>
|
||||
</html>
|
@ -22,6 +22,8 @@ import logging
|
||||
|
||||
import pytest
|
||||
|
||||
from PyQt5.QtGui import QClipboard
|
||||
|
||||
if hasattr(sys, 'frozen'):
|
||||
pytest.skip("test")
|
||||
else:
|
||||
@ -68,7 +70,34 @@ def list_of_loaded_pages(httpbin, pages):
|
||||
assert httpbin.get_requests() == requests
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the error "{message}" should be shown.'))
|
||||
def expect_error(quteproc, message):
|
||||
quteproc.mark_expected(category='message', loglevel=logging.ERROR,
|
||||
@bdd.then(bdd.parsers.re(r'the (?P<category>error|message) "(?P<message>.*)" '
|
||||
r'should be shown.'))
|
||||
def expect_error(quteproc, httpbin, category, message):
|
||||
category_to_loglevel = {
|
||||
'message': logging.INFO,
|
||||
'error': logging.ERROR,
|
||||
}
|
||||
message = message.replace('(port)', str(httpbin.port))
|
||||
quteproc.mark_expected(category='message',
|
||||
loglevel=category_to_loglevel[category],
|
||||
message=message)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.re(r'the (?P<what>primary selection|clipboard) should '
|
||||
r'contain "(?P<content>.*)"'))
|
||||
def clipboard_contains(qapp, httpbin, what, content):
|
||||
clipboard = qapp.clipboard()
|
||||
|
||||
if what == 'clipboard':
|
||||
mode = QClipboard.Clipboard
|
||||
elif what == 'primary selection':
|
||||
if not clipboard.supportsSelection():
|
||||
pytest.skip("OS doesn't support primary selection!")
|
||||
mode = QClipboard.Selection
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
expected = content.replace('(port)', str(httpbin.port))
|
||||
|
||||
data = clipboard.text(mode=mode)
|
||||
assert data == expected
|
||||
|
26
tests/integration/features/yankpaste.feature
Normal file
26
tests/integration/features/yankpaste.feature
Normal file
@ -0,0 +1,26 @@
|
||||
Feature: Yanking and pasting.
|
||||
:yank and :paste can be used to copy/paste the URL or title from/to the
|
||||
clipboard and primary selection.
|
||||
|
||||
Background:
|
||||
Given I open data/yankpaste/test.html
|
||||
|
||||
Scenario: Yanking URLs to clipboard
|
||||
When I run :yank
|
||||
Then the message "Yanked URL to clipboard: http://localhost:(port)/data/yankpaste/test.html" should be shown.
|
||||
And the clipboard should contain "http://localhost:(port)/data/yankpaste/test.html"
|
||||
|
||||
Scenario: Yanking URLs to primary selection
|
||||
When I run :yank --sel
|
||||
Then the message "Yanked URL to primary selection: http://localhost:(port)/data/yankpaste/test.html" should be shown.
|
||||
And the primary selection should contain "http://localhost:(port)/data/yankpaste/test.html"
|
||||
|
||||
Scenario: Yanking title to clipboard
|
||||
When I run :yank --title
|
||||
Then the message "Yanked title to clipboard: Test title" should be shown.
|
||||
And the clipboard should contain "Test title"
|
||||
|
||||
Scenario: Yanking domain to clipboard
|
||||
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)"
|
Loading…
Reference in New Issue
Block a user