summaryrefslogtreecommitdiff
path: root/tests/unit/browser/test_caret.py
diff options
context:
space:
mode:
authorsvetelna <zu.miklankova@gmail.com>2020-04-28 17:45:34 +0200
committersvetelna <zu.miklankova@gmail.com>2020-05-02 21:27:28 +0200
commite0a9088f6395fe791568dff8c157fb06d208165f (patch)
treed86ee0b03c8eb103f33842585941eb3e870c69b2 /tests/unit/browser/test_caret.py
parent7db846e6443ef3f8955a554dc92e94cd5f88657c (diff)
downloadqutebrowser-e0a9088f6395fe791568dff8c157fb06d208165f.tar.gz
qutebrowser-e0a9088f6395fe791568dff8c157fb06d208165f.zip
added tests
Diffstat (limited to 'tests/unit/browser/test_caret.py')
-rw-r--r--tests/unit/browser/test_caret.py93
1 files changed, 90 insertions, 3 deletions
diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py
index fb940f7c0..e5ab90708 100644
--- a/tests/unit/browser/test_caret.py
+++ b/tests/unit/browser/test_caret.py
@@ -24,7 +24,7 @@ import textwrap
import pytest
from PyQt5.QtCore import QUrl
-from qutebrowser.utils import utils, qtutils, usertypes
+from qutebrowser.utils import usertypes
@pytest.fixture
@@ -73,9 +73,9 @@ class Selection:
def check_multiline(self, expected, *, strip=False):
self.check(textwrap.dedent(expected).strip(), strip=strip)
- def toggle(self):
+ def toggle(self, line=False):
with self._qtbot.wait_signal(self._caret.selection_toggled):
- self._caret.toggle_selection()
+ self._caret.toggle_selection(line=line)
@pytest.fixture
@@ -391,3 +391,90 @@ class TestReverse:
caret.reverse_selection()
caret.move_to_start_of_line()
selection.check("one two three")
+
+
+class TestLineSelection:
+
+ def test_toggle(self, caret, selection):
+ selection.toggle(True)
+ selection.check("one two three")
+
+ def test_toggle_untoggle(self, caret, selection):
+ selection.toggle()
+ selection.check("")
+ selection.toggle(True)
+ selection.check("one two three")
+ selection.toggle()
+ selection.check("one two three")
+
+ def test_from_center(self, caret, selection):
+ caret.move_to_next_char(4)
+ selection.toggle(True)
+ selection.check("one two three")
+
+ def test_more_lines(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_next_line(2)
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+
+ four five six
+ """, strip=True)
+
+ def test_not_selecting_char(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_next_char()
+ selection.check("one two three")
+ caret.move_to_prev_char()
+ selection.check("one two three")
+
+ def test_selecting_prev_next_word(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_next_word()
+ selection.check("one two three")
+ caret.move_to_prev_word()
+ selection.check("one two three")
+
+ def test_selecting_end_word(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_end_of_word()
+ selection.check("one two three")
+
+ def test_selecting_prev_next_line(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_next_line()
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+ """, strip=True)
+ caret.move_to_prev_line()
+ selection.check("one two three")
+
+ def test_not_selecting_start_end_line(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_end_of_line()
+ selection.check("one two three")
+ caret.move_to_start_of_line()
+ selection.check("one two three")
+
+ def test_selecting_block(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_end_of_next_block()
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+ """, strip=True)
+
+ def test_selecting_start_end_document(self, caret, selection):
+ selection.toggle(True)
+ caret.move_to_end_of_document()
+ selection.check_multiline("""
+ one two three
+ eins zwei drei
+
+ four five six
+ vier fünf sechs
+ """, strip=True)
+ caret.move_to_start_of_document()
+ selection.check("one two three")