diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_console_contentview.py | 14 | ||||
-rw-r--r-- | test/tutils.py | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py index ef44f834..c2ed2ffa 100644 --- a/test/test_console_contentview.py +++ b/test/test_console_contentview.py @@ -250,3 +250,17 @@ if cv.ViewProtobuf.is_available(): def test_get_by_shortcut(): assert cv.get_by_shortcut("h") + +def test_search_highlights(): + # Default text in requests is content. We will search for nt once, and + # expect the first bit to be highlighted. We will do it again and expect the + # second to be. + f = tutils.tflowview() + + ui_elements = f.search("nt") + text_object = ui_elements.contents()[2] + assert text_object.get_text() == ('content', [(None, 2), ('dark red', 2)]) + + ui_elements = f.search("nt") + text_object = ui_elements.contents()[2] + assert text_object.get_text() == ('content', [(None, 5), ('dark red', 2)]) diff --git a/test/tutils.py b/test/tutils.py index 4cd7b7f8..afc1fb51 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -1,8 +1,11 @@ import os, shutil, tempfile from contextlib import contextmanager from libmproxy import flow, utils, controller +from libmproxy.console.flowview import FlowView +from libmproxy.console import ConsoleState from netlib import certutils from nose.plugins.skip import SkipTest +from mock import Mock def _SkipWindows(): raise SkipTest("Skipped on Windows.") @@ -57,6 +60,13 @@ def tflow_err(): f.error = terr(f.request) return f +def tflowview(): + m = Mock() + cs = ConsoleState() + flow = tflow() + fv = FlowView(m, cs, flow) + return fv + @contextmanager def tmpdir(*args, **kwargs): |