diff options
author | Florian Bruhin <me@the-compiler.org> | 2018-09-06 17:13:46 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2018-09-06 17:13:46 +0200 |
commit | ec774379bdfe2de47804f8bd529014b253c0b1ec (patch) | |
tree | d74ae598936c8b844d4d5f76f3aa6d80c73860cb /tests/unit/browser/test_history.py | |
parent | e4b7786bcc04e7cd280a3da65cab8c1c7e152888 (diff) | |
download | qutebrowser-ec774379bdfe2de47804f8bd529014b253c0b1ec.tar.gz qutebrowser-ec774379bdfe2de47804f8bd529014b253c0b1ec.zip |
Add tests for history progress
Diffstat (limited to 'tests/unit/browser/test_history.py')
-rw-r--r-- | tests/unit/browser/test_history.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index 4e4ef2e10..0dc97f316 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -41,14 +41,19 @@ class FakeHistoryProgress: """Fake for a WebHistoryProgress object.""" + def __init__(self): + self._started = False + self._finished = False + self._value = 0 + def start(self, _text, _maximum): - pass + self._started = True def tick(self): - pass + self._value += 1 def finish(self): - pass + self._finished = True @pytest.fixture() @@ -515,6 +520,21 @@ class TestRebuild: config_stub.val.history_gap_interval = 1234 assert not hist.metainfo['force_rebuild'] + @pytest.mark.parametrize('patch_threshold', [True, False]) + def test_progress(self, hist, config_stub, monkeypatch, patch_threshold): + hist.add_url(QUrl('example.com/1'), redirect=False, atime=1) + hist.add_url(QUrl('example.com/2'), redirect=False, atime=2) + hist.metainfo['force_rebuild'] = True + + if patch_threshold: + monkeypatch.setattr(history.WebHistory, '_PROGRESS_THRESHOLD', 1) + + progress = FakeHistoryProgress() + history.WebHistory(progress=progress) + assert progress._value == 2 + assert progress._finished + assert progress._started == patch_threshold + class TestCompletionMetaInfo: |