diff options
author | Jason Rosenzweig <mail4jasonr@gmail.com> | 2021-06-04 00:34:34 +0800 |
---|---|---|
committer | Jason Rosenzweig <mail4jasonr@gmail.com> | 2021-06-04 00:34:34 +0800 |
commit | 3a0d20e5f96bb8188d2b4b29f544c35d94976923 (patch) | |
tree | 709338e662527ef1baff0cfca4c635418cdb529a /tests | |
parent | 0d7226ce14a31539e70a1d24802fd5ae9b1105dc (diff) | |
download | qutebrowser-3a0d20e5f96bb8188d2b4b29f544c35d94976923.tar.gz qutebrowser-3a0d20e5f96bb8188d2b4b29f544c35d94976923.zip |
Added new test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/mainwindow/test_prompt.py | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py index e67ab1702..8f32d6338 100644 --- a/tests/unit/mainwindow/test_prompt.py +++ b/tests/unit/mainwindow/test_prompt.py @@ -85,8 +85,6 @@ class TestFileCompletion: prompt.item_focus('next') - # qtbot.keyPress(prompt._lineedit, Qt.Key_Tab) - # qtbot.keyRelease(prompt._lineedit, Qt.Key_Tab) assert prompt._lineedit.text() == str(testdir / 'foo') # Deleting /[foo] @@ -97,6 +95,47 @@ class TestFileCompletion: prompt.item_focus('next') prompt.item_focus('next') assert prompt._lineedit.text() == str(testdir / 'bar') + + def test_filtering_path(self, qtbot, tmp_path, get_prompt): + testdir = tmp_path / 'test' + + for directory in ['bar', 'foo', 'bat']: + (testdir / directory).mkdir(parents=True) + + prompt = get_prompt(str(testdir) + os.sep) + + # Make sure all directories are shown + num_rows = prompt._file_model.rowCount(prompt._root_index) + visible = [] + for row in range(num_rows): + index = prompt._file_model.index(row, 0, prompt._file_model.index(os.path.basename(prompt._lineedit.text()))) + if prompt._file_view.isRowHidden(index.row(), index.parent()): + visible.append(index.data()) + + assert visible.sort() == ['bar', 'foo', 'bat'].sort() + + # Only foo should be completed with f + qtbot.keyPress(prompt._lineedit, Qt.Key_F) + num_rows = prompt._file_model.rowCount(prompt._root_index) + visible = [] + for row in range(num_rows): + index = prompt._file_model.index(row, 0, prompt._file_model.index(os.path.basename(prompt._lineedit.text()))) + if prompt._file_view.isRowHidden(index.row(), index.parent()): + visible.append(index.data()) + + assert visible.sort() == ['foo'].sort() + + # bat and bar should show up with a typed + qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace) + qtbot.keyPress(prompt._lineedit, Qt.Key_A) + num_rows = prompt._file_model.rowCount(prompt._root_index) + visible = [] + for row in range(num_rows): + index = prompt._file_model.index(row, 0, prompt._file_model.index(os.path.basename(prompt._lineedit.text()))) + if prompt._file_view.isRowHidden(index.row(), index.parent()): + visible.append(index.data()) + + assert visible.sort() == ['bar', 'bat'].sort() @pytest.mark.linux def test_root_path(self, get_prompt): |