diff options
author | mathieui <mathieui@mathieui.net> | 2014-10-31 19:15:57 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-10-31 19:16:44 +0100 |
commit | 1c1ab3cb839e5509db52770e10c7190f844eb2e5 (patch) | |
tree | b331060b3dc42651e61e4ccb2dfe6af5e2e97752 /test/test_windows.py | |
parent | cedc5a6ec80a46437f42464415fd1806049c593d (diff) | |
parent | ea2b703bfd07d293ba9fdd85ac657275d43da2a7 (diff) | |
download | poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.tar.gz poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.tar.bz2 poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.tar.xz poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.zip |
Merge branch 'master' of git.poez.io:poezio into slix
Conflicts:
src/bookmark.py
src/config.py
src/connection.py
src/core/commands.py
src/core/core.py
src/core/handlers.py
src/windows/info_bar.py
src/windows/muc.py
src/windows/roster_win.py
src/windows/text_win.py
src/xhtml.py
Diffstat (limited to 'test/test_windows.py')
-rw-r--r-- | test/test_windows.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/test_windows.py b/test/test_windows.py new file mode 100644 index 00000000..8fb85295 --- /dev/null +++ b/test/test_windows.py @@ -0,0 +1,76 @@ +import pytest +import sys +sys.path.append('src') + +class ConfigShim(object): + def get(self, *args, **kwargs): + return '' + +import config +config.config = ConfigShim() +import core + +from windows import Input, HistoryInput, MessageInput, CommandInput + +@pytest.fixture +def input(): + input = Input() + input.rewrite_text = lambda: None + return input + +class TestInput(object): + + def test_do_command(self, input): + + input.do_command('a') + assert input.text == 'a' + + for char in 'coucou': + input.do_command(char) + assert input.text == 'acoucou' + + def test_empty(self, input): + assert input.is_empty() == True + input.do_command('a') + assert input.is_empty() == False + + def test_key_left(self, input): + for char in 'this is a line': + input.do_command(char) + for i in range(4): + input.key_left() + for char in 'long ': + input.do_command(char) + + assert input.text == 'this is a long line' + + def test_key_right(self, input): + for char in 'this is a line': + input.do_command(char) + for i in range(4): + input.key_left() + input.key_right() + + for char in 'iii': + input.do_command(char) + + assert input.text == 'this is a liiiine' + + def test_key_home(self, input): + for char in 'this is a line of text': + input.do_command(char) + input.do_command('z') + input.key_home() + input.do_command('a') + + assert input.text == 'athis is a line of textz' + + def test_key_end(self, input): + for char in 'this is a line of text': + input.do_command(char) + input.key_home() + input.key_end() + input.do_command('z') + + assert input.text == 'this is a line of textz' + |