bdd: Add "When I open ... in a new window" step.
This commit is contained in:
parent
f9645e447a
commit
18b5860584
@ -99,16 +99,23 @@ def open_path(quteproc, path):
|
|||||||
"""Open a URL.
|
"""Open a URL.
|
||||||
|
|
||||||
If used like "When I open ... in a new tab", the URL is opened in a new
|
If used like "When I open ... in a new tab", the URL is opened in a new
|
||||||
tab.
|
tab. With "... in a new window", it's opened in a new window.
|
||||||
"""
|
"""
|
||||||
new_tab_suffix = ' in a new tab'
|
new_tab_suffix = ' in a new tab'
|
||||||
|
new_window_suffix = ' in a new window'
|
||||||
if path.endswith(new_tab_suffix):
|
if path.endswith(new_tab_suffix):
|
||||||
path = path[:-len(new_tab_suffix)]
|
path = path[:-len(new_tab_suffix)]
|
||||||
new_tab = True
|
new_tab = True
|
||||||
|
new_window = False
|
||||||
|
elif path.endswith(new_window_suffix):
|
||||||
|
path = path[:-len(new_window_suffix)]
|
||||||
|
new_tab = False
|
||||||
|
new_window = True
|
||||||
else:
|
else:
|
||||||
new_tab = False
|
new_tab = False
|
||||||
|
new_window = False
|
||||||
|
|
||||||
quteproc.open_path(path, new_tab=new_tab)
|
quteproc.open_path(path, new_tab=new_tab, new_window=new_window)
|
||||||
|
|
||||||
|
|
||||||
@bdd.when(bdd.parsers.parse("I set {sect} -> {opt} to {value}"))
|
@bdd.when(bdd.parsers.parse("I set {sect} -> {opt} to {value}"))
|
||||||
|
@ -269,11 +269,16 @@ class QuteProc(testprocess.Process):
|
|||||||
yield
|
yield
|
||||||
self.set_setting(sect, opt, old_value)
|
self.set_setting(sect, opt, old_value)
|
||||||
|
|
||||||
def open_path(self, path, new_tab=False):
|
def open_path(self, path, new_tab=False, new_window=False):
|
||||||
"""Open the given path on the local webserver in qutebrowser."""
|
"""Open the given path on the local webserver in qutebrowser."""
|
||||||
|
if new_tab and new_window:
|
||||||
|
raise ValueError("new_tab and new_window given!")
|
||||||
|
|
||||||
url = self.path_to_url(path)
|
url = self.path_to_url(path)
|
||||||
if new_tab:
|
if new_tab:
|
||||||
self.send_cmd(':open -t ' + url)
|
self.send_cmd(':open -t ' + url)
|
||||||
|
elif new_window:
|
||||||
|
self.send_cmd(':open -w ' + url)
|
||||||
else:
|
else:
|
||||||
self.send_cmd(':open ' + url)
|
self.send_cmd(':open ' + url)
|
||||||
self.wait_for_load_finished(path)
|
self.wait_for_load_finished(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user