aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_console_contentview.py
diff options
context:
space:
mode:
authorroot <root@mint>2013-12-25 16:50:29 +1300
committerroot <root@mint>2013-12-25 16:50:29 +1300
commit95406bd119d87ccc3e99ddffd11c92e92a7da34b (patch)
tree84c8abdb1de710ee5682e7c3664197b750899c31 /test/test_console_contentview.py
parent932464d0a0f572e256f6dea898196db1e3f66b50 (diff)
downloadmitmproxy-95406bd119d87ccc3e99ddffd11c92e92a7da34b.tar.gz
mitmproxy-95406bd119d87ccc3e99ddffd11c92e92a7da34b.tar.bz2
mitmproxy-95406bd119d87ccc3e99ddffd11c92e92a7da34b.zip
Add focusing, and fixes non-clearance of prev searches. Add
documentation.
Diffstat (limited to 'test/test_console_contentview.py')
-rw-r--r--test/test_console_contentview.py55
1 files changed, 49 insertions, 6 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py
index c2ed2ffa..95012657 100644
--- a/test/test_console_contentview.py
+++ b/test/test_console_contentview.py
@@ -257,10 +257,53 @@ def test_search_highlights():
# 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)])
+ f.search("nt")
+ text_object = tutils.get_body_line(f.last_displayed_body, 0)
+ assert text_object.get_text() == ('content', [(None, 2), (f.highlight_color, 2)])
+
+ f.search("nt")
+ text_object = tutils.get_body_line(f.last_displayed_body, 1)
+ assert text_object.get_text() == ('content', [(None, 5), (f.highlight_color, 2)])
+
+def test_search_highlights_clears_prev():
+ f = tutils.tflowview(request_contents="this is string\nstring is string")
+
+ f.search("string")
+ text_object = tutils.get_body_line(f.last_displayed_body, 0)
+ assert text_object.get_text() == ('this is string', [(None, 8), (f.highlight_color, 6)])
+
+ # search again, it should not be highlighted again.
+ f.search("string")
+ text_object = tutils.get_body_line(f.last_displayed_body, 0)
+ assert text_object.get_text() != ('this is string', [(None, 8), (f.highlight_color, 6)])
+
+def test_search_highlights_multi_line():
+ f = tutils.tflowview(request_contents="this is string\nstring is string")
+
+ # should highlight the first line.
+ f.search("string")
+ text_object = tutils.get_body_line(f.last_displayed_body, 0)
+ assert text_object.get_text() == ('this is string', [(None, 8), (f.highlight_color, 6)])
+
+ # should highlight second line, first appearance of string.
+ f.search("string")
+ text_object = tutils.get_body_line(f.last_displayed_body, 1)
+ assert text_object.get_text() == ('string is string', [(None, 0), ('key', 6)])
+
+ # should highlight third line, second appearance of string.
+ f.search("string")
+ text_object = tutils.get_body_line(f.last_displayed_body, 1)
+ assert text_object.get_text() == ('string is string', [(None, 10), (f.highlight_color, 6)])
+
+def test_search_focuses():
+ f = tutils.tflowview(request_contents="this is string\nstring is string")
+
+ # should highlight the first line.
+ f.search("string")
+
+ # should be focusing on the 2nd text line.
+ f.search("string")
+ text_object = tutils.get_body_line(f.last_displayed_body, 1)
+ assert f.last_displayed_body.focus == text_object
+
- ui_elements = f.search("nt")
- text_object = ui_elements.contents()[2]
- assert text_object.get_text() == ('content', [(None, 5), ('dark red', 2)])