Fix undo with pinned tabs

Add tests for undo with a pinned tab
Add tests for clone with a pinned tab
This commit is contained in:
Jay Kamat 2017-05-21 20:29:11 -07:00
parent 2a961c3951
commit 00f001729b
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
3 changed files with 28 additions and 4 deletions

View File

@ -34,7 +34,8 @@ from qutebrowser.utils import (log, usertypes, utils, qtutils, objreg,
urlutils, message)
UndoEntry = collections.namedtuple('UndoEntry', ['url', 'history', 'index'])
UndoEntry = collections.namedtuple('UndoEntry',
['url', 'history', 'index', 'pinned'])
class TabDeletedError(Exception):
@ -294,7 +295,8 @@ class TabbedBrowser(tabwidget.TabWidget):
except browsertab.WebTabError:
pass # special URL
else:
entry = UndoEntry(tab.url(), history_data, idx)
entry = UndoEntry(tab.url(), history_data, idx,
tab.data.pinned)
self._undo_stack.append(entry)
tab.shutdown()
@ -325,7 +327,7 @@ class TabbedBrowser(tabwidget.TabWidget):
use_current_tab = (only_one_tab_open and no_history and
last_close_url_used)
url, history_data, idx = self._undo_stack.pop()
url, history_data, idx, pinned = self._undo_stack.pop()
if use_current_tab:
self.openurl(url, newtab=False)
@ -334,6 +336,7 @@ class TabbedBrowser(tabwidget.TabWidget):
newtab = self.tabopen(url, background=False, idx=idx)
newtab.history.deserialize(history_data)
self.set_tab_pinned(idx, pinned)
@pyqtSlot('QUrl', bool)
def openurl(self, url, newtab):

View File

@ -396,7 +396,8 @@ class SessionManager(QObject):
if tab.get('active', False):
tab_to_focus = i
if new_tab.data.pinned:
tabbed_browser.set_tab_pinned(i, new_tab.data.pinned, loading=True)
tabbed_browser.set_tab_pinned(
i, new_tab.data.pinned, loading=True)
if tab_to_focus is not None:
tabbed_browser.setCurrentIndex(tab_to_focus)
if win.get('active', False):

View File

@ -1124,3 +1124,23 @@ Feature: Tab management
Then the message "Tab is pinned!" should be shown
And the following tabs should be open:
- data/numbers/1.txt (active) (pinned)
Scenario: Cloning a pinned tab
When I open data/numbers/1.txt
And I run :tab-pin
And I run :tab-clone
And I wait until data/numbers/1.txt is loaded
Then the following tabs should be open:
- data/numbers/1.txt (pinned)
- data/numbers/1.txt (pinned) (active)
Scenario: Undo a pinned tab
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I run :tab-pin
And I run :tab-close --force
And I run :undo
And I wait until data/numbers/2.txt is loaded
Then the following tabs should be open:
- data/numbers/1.txt
- data/numbers/2.txt (pinned) (active)