diff options
author | toofar <toofar@spalge.com> | 2024-01-29 23:05:49 +1300 |
---|---|---|
committer | pylbrecht <pylbrecht@mailbox.org> | 2024-02-07 20:22:21 +0100 |
commit | 40823c6cb33f13608b739ecebace295026311215 (patch) | |
tree | 43146cd9f0b2317ea41842a36c08aaf9b13ae56d | |
parent | af9e13690e8cff1423fb5dd70867c4f8c99be961 (diff) | |
download | qutebrowser-40823c6cb33f13608b739ecebace295026311215.tar.gz qutebrowser-40823c6cb33f13608b739ecebace295026311215.zip |
Inch a little closer towards compare tree tabs session
Had a think about how to get tree structure things to compare. For now
I'm thinking we create a string of the format:
- about:blank?one
- about:blank?child (collapsed)
- about:blank?grandchild
- about:blank?childtwo (active)
- about:blank?two
From both a) the text fixture (we write it like that) and b) the session
data (generate it). Then we just compare the strings, hopefully much
like check_open_tabs and maybe we can even make one implementation work
for both.
The next bit to do is generate the above text from the session data. We
can start by loading the tree structure with
`SessionManager._reconstruct_tree_data()` (TODO: make that public) and
then we need to recurse through that. We can take inspiration from
`recursive_load_node()` in sessions.py
Then copy the rest of the implementation from `check_open_tabs()` and
adapt that.
And then look at `quteproc.compare_session()` as well I guess. But it
looks like it'll be a pain to write out the whole tree tab format
sessions...
-rw-r--r-- | tests/end2end/features/conftest.py | 28 | ||||
-rw-r--r-- | tests/end2end/features/treetabs.feature | 7 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 2aefe97da..c883e4f58 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -613,9 +613,37 @@ def check_open_tree_tabs(quteproc, request, tabs): It expects a tree of URLs, with an optional "(active)" suffix. """ + session = quteproc.get_session() + # TODO: support ' (collapsed)', also maybe make suffixes generic? + active_suffix = ' (active)' + pinned_suffix = ' (pinned)' + tabs = tabs.splitlines() + assert len(session['windows']) == 1 + assert len(session['windows'][0]['tabs']) == len(tabs) + + # If we don't have (active) anywhere, don't check it + has_active = any(active_suffix in line for line in tabs) + has_pinned = any(pinned_suffix in line for line in tabs) + + + from qutebrowser.misc import sessions + tree_data = sessions.SessionManager._reconstruct_tree_data(None, session['windows'][0]) + + # TODO: iterate/recurse through tree_data and build a string of the same + # format we are putting in the test fixtures + + root = [v for v in tree_data.values() if "treetab_node_data" not in v][0] + expected = "" + for uid in root["children"]: + ... + + # Then copy the remaining parts from check_open_tabs() and probably change + # it to support more leading spaces + raise NotImplementedError + @bdd.then(bdd.parsers.parse("the following tabs should be open:\n{tabs}")) def check_open_tabs(quteproc, request, tabs): """Check the list of open tabs in the session. diff --git a/tests/end2end/features/treetabs.feature b/tests/end2end/features/treetabs.feature index bc6fad45c..bb2654acd 100644 --- a/tests/end2end/features/treetabs.feature +++ b/tests/end2end/features/treetabs.feature @@ -18,3 +18,10 @@ Feature: Tree tab management And I run :tab-close --recursive Then the following tabs should be open: - data/numbers/4.txt + + Scenario: Open a child tab + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new related tab + Then the following tree tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt |