summaryrefslogtreecommitdiff
path: root/tests/unit/completion/test_models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/completion/test_models.py')
-rw-r--r--tests/unit/completion/test_models.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index a8c7d9425..8d16b4142 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -20,6 +20,8 @@
"""Tests for completion models."""
import collections
+import random
+import string
from datetime import datetime
import pytest
@@ -593,6 +595,34 @@ def test_tab_completion_delete(qtmodeltester, fake_web_tab, app_stub,
QUrl('https://duckduckgo.com')]
+def test_tab_completion_not_sorted(qtmodeltester, fake_web_tab, app_stub,
+ win_registry, tabbed_browser_stubs):
+ """Ensure that the completion row order is the same as tab index order.
+
+ Would be violated for more than 9 tabs if the completion was being
+ alphabetically sorted on the first column, or the others.
+ """
+ expected = []
+ for idx in range(1, 11):
+ url = "".join(random.sample(string.ascii_letters, 12))
+ title = "".join(random.sample(string.ascii_letters, 12))
+ expected.append(("0/{}".format(idx), url, title))
+
+ tabbed_browser_stubs[0].widget.tabs = [
+ fake_web_tab(QUrl(tab[1]), tab[2], idx)
+ for idx, tab in enumerate(expected)
+ ]
+ model = miscmodels.buffer()
+ model.set_pattern('')
+ qtmodeltester.data_display_may_return_none = True
+ qtmodeltester.check(model)
+
+ _check_completions(model, {
+ '0': expected,
+ '1': [],
+ })
+
+
def test_other_buffer_completion(qtmodeltester, fake_web_tab, app_stub,
win_registry, tabbed_browser_stubs, info):
tabbed_browser_stubs[0].widget.tabs = [