summary refs log tree commit diff stats
path: root/test/tc_ui.py
blob: fbe51f64877ce322080d4c0edf7d00fef0170ef3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
if __name__ == '__main__': from __init__ import init; init()

import unittest
import curses

from ranger.gui import ui

from test import Fake, OK, raise_ok

ui.curses = Fake()

class Test(unittest.TestCase):
	def setUp(self):

		self.fm = Fake()
		self.ui = ui.UI(env=Fake(), fm=self.fm)

		def fakesetup():
			self.ui.widget = Fake()
			self.ui.add_obj(self.ui.widget)
		self.ui.setup = fakesetup

		self.ui.initialize()

	def tearDown(self):
		self.ui.destroy()
	
	def test_scrolling(self):
		# test whether scrolling works
		self.fm.scroll = raise_ok
		self.ui.get_focused_obj = lambda: False

		ui.curses.getmouse = lambda: (0, 0, 0, 0, curses.BUTTON2_PRESSED)
		self.assertRaises(OK, self.ui.handle_mouse)

		ui.curses.getmouse = lambda: (0, 0, 0, 0, curses.BUTTON4_PRESSED)
		self.assertRaises(OK, self.ui.handle_mouse)
	
	def test_passing(self):
		# Test whether certain method calls are passed to widgets
		widget = self.ui.widget

		widget.draw = raise_ok
		self.assertRaises(OK, self.ui.draw)
		widget.__clear__()

		widget.finalize = raise_ok
		self.assertRaises(OK, self.ui.finalize)
		widget.__clear__()

		widget.press = raise_ok
		random_key = 123
		self.assertRaises(OK, self.ui.handle_key, random_key)
		widget.__clear__()

		widget.destroy = raise_ok
		self.assertRaises(OK, self.ui.destroy)
		widget.__clear__()

if __name__ == '__main__':
	unittest.main()
Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
format 70

classinstance 128002 class_ref 128130 // UI
  name ""   xyz 61 4 2000 life_line_z 2000
classinstance 128258 class_ref 128770 // Widget
  name ""   xyz 169 4 2000 life_line_z 2000
classinstance 129154 class_ref 136066 // Window
  name ""   xyz 293 4 2000 life_line_z 2000
classinstance 130050 class_ref 136194 // Color
  name ""   xyz 417 4 2000 life_line_z 2000
durationcanvas 128386 classinstance_ref 128002 // :UI
  xyzwh 80 148 2010 11 45
end
durationcanvas 128514 classinstance_ref 128258 // :Widget
  xyzwh 193 151 2010 11 64
end
durationcanvas 128770 classinstance_ref 128002 // :UI
  xyzwh 80 263 2010 11 40
end
durationcanvas 128898 classinstance_ref 128258 // :Widget
  xyzwh 193 265 2010 11 149
end
durationcanvas 129282 classinstance_ref 128002 // :UI
  xyzwh 80 73 2010 11 40
end
durationcanvas 129410 classinstance_ref 129154 // :Window
  xyzwh 320 73 2010 11 25
end
durationcanvas 129666 classinstance_ref 128002 // :UI
  xyzwh 80 467 2010 11 40
end
durationcanvas 129794 classinstance_ref 129154 // :Window
  xyzwh 320 467 2010 11 25
end
durationcanvas 130434 classinstance_ref 130050 // :Color
  xyzwh 436 298 2010 11 37
end
durationcanvas 130818 classinstance_ref 129154 // :Window
  xyzwh 320 363 2010 11 26
end
msg 128642 synchronous
  from durationcanvas_ref 128386
  to durationcanvas_ref 128514
  yz 151 2015 msg operation_ref 130690 // "feed()"
  show_full_operations_definition default drawing_language default
  label_xy 107 136
msg 129026 synchronous
  from durationcanvas_ref 128770
  to durationcanvas_ref 128898
  yz 265 2015 msg operation_ref 130434 // "draw()"
  show_full_operations_definition default drawing_language default
  label_xy 118 249
msg 129538 synchronous
  from durationcanvas_ref 129282
  to durationcanvas_ref 129410
  yz 73 2015 msg operation_ref 137858 // "clear()"
  show_full_operations_definition default drawing_language default
  label_xy 219 58
msg 129922 synchronous
  from durationcanvas_ref 129666
  to durationcanvas_ref 129794
  yz 467 2015 msg operation_ref 137730 // "refresh()"
  show_full_operations_definition default drawing_language default
  label_xy 208 447
msg 130562 synchronous
  from durationcanvas_ref 128898
  to durationcanvas_ref 130434
  yz 298 2015 unspecifiedmsg
  show_full_operations_definition default drawing_language default
msg 130690 return
  from durationcanvas_ref 130434
  to durationcanvas_ref 128898
  yz 319 2015 unspecifiedmsg
  show_full_operations_definition default drawing_language default
msg 130946 synchronous
  from durationcanvas_ref 128898
  to durationcanvas_ref 130818
  yz 363 2015 msg operation_ref 137986 // "addstr()"
  show_full_operations_definition default drawing_language default
  label_xy 240 347
end