diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-07-13 10:25:46 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-07-13 10:25:46 +0200 |
commit | 38092895810ed22ed69b9ecc432277d7d9f611dc (patch) | |
tree | b552a2c548faad6b77b8e1d568c1680a5ff310e2 /tests | |
parent | 0001d4fe20a4cdef9dd628fad220e09a03618932 (diff) | |
parent | d638e14b49b3b193202d5576cd0c4d848e178232 (diff) | |
download | qutebrowser-38092895810ed22ed69b9ecc432277d7d9f611dc.tar.gz qutebrowser-38092895810ed22ed69b9ecc432277d7d9f611dc.zip |
Merge remote-tracking branch 'origin/pr/6507'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/mainwindow/test_prompt.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py index 668cd0710..055e5b665 100644 --- a/tests/unit/mainwindow/test_prompt.py +++ b/tests/unit/mainwindow/test_prompt.py @@ -80,8 +80,11 @@ class TestFileCompletion: with qtbot.wait_signal(prompt._file_model.directoryLoaded): for _ in range(3): qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace) + prompt._set_fileview_root(prompt._lineedit.text()) - # foo should get completed from f + # '..' and 'foo' should get completed from 'f' + prompt.item_focus('next') + assert prompt._lineedit.text() == str(tmp_path) prompt.item_focus('next') assert prompt._lineedit.text() == str(testdir / 'foo') @@ -94,6 +97,32 @@ class TestFileCompletion: prompt.item_focus('next') assert prompt._lineedit.text() == str(testdir / 'bar') + @pytest.mark.parametrize("keys, expected", [ + ([], ['..', 'bar', 'bat', 'foo']), + ([Qt.Key_F], ['..', 'foo']), + ([Qt.Key_A], ['..', 'bar', 'bat']), + ]) + def test_filtering_path(self, qtbot, tmp_path, get_prompt, keys, expected): + testdir = tmp_path / 'test' + + for directory in ['bar', 'foo', 'bat']: + (testdir / directory).mkdir(parents=True) + + prompt = get_prompt(str(testdir) + os.sep) + for key in keys: + qtbot.keyPress(prompt._lineedit, key) + prompt._set_fileview_root(prompt._lineedit.text()) + + num_rows = prompt._file_model.rowCount(prompt._file_view.rootIndex()) + visible = [] + for row in range(num_rows): + parent = prompt._file_model.index( + os.path.dirname(prompt._lineedit.text())) + index = prompt._file_model.index(row, 0, parent) + if not prompt._file_view.isRowHidden(index.row(), index.parent()): + visible.append(index.data()) + assert visible == expected + @pytest.mark.linux def test_root_path(self, get_prompt): """With / as path, show root contents.""" |