Add (pinned) keyword to 'following tabs open' tests

This commit is contained in:
Jay Kamat 2017-05-16 20:16:43 -07:00
parent 17169812be
commit 1142a19de9
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
3 changed files with 37 additions and 20 deletions

View File

@ -535,31 +535,47 @@ def check_open_tabs(quteproc, request, tabs):
""" """
session = quteproc.get_session() session = quteproc.get_session()
active_suffix = ' (active)' active_suffix = ' (active)'
pinned_suffix = ' (pinned)'
tabs = tabs.splitlines() tabs = tabs.splitlines()
assert len(session['windows']) == 1 assert len(session['windows']) == 1
assert len(session['windows'][0]['tabs']) == len(tabs) assert len(session['windows'][0]['tabs']) == len(tabs)
# If we don't have (active) anywhere, don't check it # If we don't have (active) anywhere, don't check it
has_active = any(line.endswith(active_suffix) for line in tabs) has_active = any(active_suffix in line for line in tabs)
has_pinned = any(pinned_suffix in line for line in tabs)
for i, line in enumerate(tabs): for i, line in enumerate(tabs):
line = line.strip() line = line.strip()
assert line.startswith('- ') assert line.startswith('- ')
line = line[2:] # remove "- " prefix line = line[2:] # remove "- " prefix
if line.endswith(active_suffix):
path = line[:-len(active_suffix)] path = line
active = True active = False
else: pinned = False
path = line
active = False while line.endswith(active_suffix) or line.endswith(pinned_suffix):
if line.endswith(active_suffix):
# active
line = line[:-len(active_suffix)]
active = True
else:
# pinned
line = line[:-len(pinned_suffix)]
pinned = True
session_tab = session['windows'][0]['tabs'][i] session_tab = session['windows'][0]['tabs'][i]
assert session_tab['history'][-1]['url'] == quteproc.path_to_url(path) current_page = session_tab['history'][-1]
assert current_page['url'] == quteproc.path_to_url(line)
if active: if active:
assert session_tab['active'] assert session_tab['active']
elif has_active: elif has_active:
assert 'active' not in session_tab assert 'active' not in session_tab
if pinned:
assert current_page['pinned']
elif has_pinned:
assert not current_page['pinned']
@bdd.then(bdd.parsers.re(r'the (?P<what>primary selection|clipboard) should ' @bdd.then(bdd.parsers.re(r'the (?P<what>primary selection|clipboard) should '
r'contain "(?P<content>.*)"')) r'contain "(?P<content>.*)"'))

View File

@ -386,5 +386,5 @@ Feature: Saving and loading sessions
Then the message "Tab is pinned!" should be shown Then the message "Tab is pinned!" should be shown
And the following tabs should be open: And the following tabs should be open:
- data/numbers/1.txt - data/numbers/1.txt
- data/numbers/2.txt (active) - data/numbers/2.txt (active) (pinned)
- data/numbers/3.txt - data/numbers/3.txt

View File

@ -1037,16 +1037,17 @@ Feature: Tab management
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt - data/numbers/1.txt
- data/numbers/2.txt - data/numbers/2.txt
- data/numbers/3.txt (active) - data/numbers/3.txt (active) (pinned)
Scenario: :tab-pin unpin Scenario: :tab-pin unpin
When I open data/numbers/1.txt When I open data/numbers/1.txt
And I run :tab-pin
And I open data/numbers/2.txt in a new tab And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab And I open data/numbers/3.txt in a new tab
And I run :tab-pin And I run :tab-pin
And I run :tab-pin And I run :tab-pin
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt - data/numbers/1.txt (pinned)
- data/numbers/2.txt - data/numbers/2.txt
- data/numbers/3.txt (active) - data/numbers/3.txt (active)
@ -1057,7 +1058,7 @@ Feature: Tab management
And I run :tab-pin with count 2 And I run :tab-pin with count 2
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt - data/numbers/1.txt
- data/numbers/2.txt - data/numbers/2.txt (pinned)
- data/numbers/3.txt (active) - data/numbers/3.txt (active)
Scenario: Pinned :tab-close prompt yes Scenario: Pinned :tab-close prompt yes
@ -1069,7 +1070,7 @@ Feature: Tab management
And I wait for "*want to close a pinned tab*" in the log And I wait for "*want to close a pinned tab*" in the log
And I run :prompt-accept yes And I run :prompt-accept yes
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt (active) - data/numbers/1.txt (active) (pinned)
Scenario: Pinned :tab-close prompt no Scenario: Pinned :tab-close prompt no
When I open data/numbers/1.txt When I open data/numbers/1.txt
@ -1080,8 +1081,8 @@ Feature: Tab management
And I wait for "*want to close a pinned tab*" in the log And I wait for "*want to close a pinned tab*" in the log
And I run :prompt-accept no And I run :prompt-accept no
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt - data/numbers/1.txt (pinned)
- data/numbers/2.txt (active) - data/numbers/2.txt (active) (pinned)
Scenario: Pinned :tab-only prompt yes Scenario: Pinned :tab-only prompt yes
When I open data/numbers/1.txt When I open data/numbers/1.txt
@ -1093,7 +1094,7 @@ Feature: Tab management
And I wait for "*want to close a pinned tab*" in the log And I wait for "*want to close a pinned tab*" in the log
And I run :prompt-accept yes And I run :prompt-accept yes
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt (active) - data/numbers/1.txt (active) (pinned)
Scenario: Pinned :tab-only prompt no Scenario: Pinned :tab-only prompt no
When I open data/numbers/1.txt When I open data/numbers/1.txt
@ -1105,8 +1106,8 @@ Feature: Tab management
And I wait for "*want to close a pinned tab*" in the log And I wait for "*want to close a pinned tab*" in the log
And I run :prompt-accept no And I run :prompt-accept no
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/1.txt (active) - data/numbers/1.txt (active) (pinned)
- data/numbers/2.txt - data/numbers/2.txt (pinned)
Scenario: Pinned :tab-only close all but pinned tab Scenario: Pinned :tab-only close all but pinned tab
When I open data/numbers/1.txt When I open data/numbers/1.txt
@ -1114,7 +1115,7 @@ Feature: Tab management
And I run :tab-pin And I run :tab-pin
And I run :tab-only And I run :tab-only
Then the following tabs should be open: Then the following tabs should be open:
- data/numbers/2.txt (active) - data/numbers/2.txt (active) (pinned)
Scenario: :tab-pin open url Scenario: :tab-pin open url
When I open data/numbers/1.txt When I open data/numbers/1.txt
@ -1122,4 +1123,4 @@ Feature: Tab management
And I open data/numbers/2.txt without waiting And I open data/numbers/2.txt without waiting
Then the message "Tab is pinned!" should be shown Then the message "Tab is pinned!" should be shown
And the following tabs should be open: And the following tabs should be open:
- data/numbers/1.txt (active) - data/numbers/1.txt (active) (pinned)