about summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
* add state arg to Text.keychord_pressedKartik K. Agaram2022-07-122-105/+105
* .Kartik K. Agaram2022-07-121-1/+1
* add state arg to Drawing.mouse_releasedKartik K. Agaram2022-07-122-21/+21
* add state arg to Drawing.keychord_pressedKartik K. Agaram2022-07-122-33/+33
* add state arg to Drawing.mouse_pressedKartik K. Agaram2022-07-122-16/+16
* add state arg to some functionsKartik K. Agaram2022-07-123-31/+31
* call edit rather than App callbacks in testsKartik K. Agaram2022-07-123-188/+231
* start passing in Editor_state explicitlyKartik K. Agaram2022-07-124-231/+232
* initialize contains test stateKartik K. Agaram2022-07-123-88/+4
* group all editor globalsKartik K. Agaram2022-07-1211-1964/+1974
* bring couple more globals back to the app levelKartik K. Agaram2022-07-122-24/+21
* button framework is at the app levelKartik K. Agaram2022-07-122-3/+4
* start decoupling editor tests from AppKartik K. Agaram2022-07-112-100/+100
* make colors easier to editKartik K. Agaram2022-07-118-37/+38
* experiment: new edit namespaceKartik K. Agaram2022-07-113-416/+463
* stop pretending globals are localKartik K. Agaram2022-07-116-19/+5
* .Kartik K. Agaram2022-07-111-1/+2
* fix a variable nameKartik K. Agaram2022-07-111-3/+3
* skip multiple consecutive whitespaceKartik K. Agaram2022-07-112-2/+49
* support other whitespace chars in word movementsKartik K. Agaram2022-07-112-5/+33
* flesh out some tests for word movementsKartik K. Agaram2022-07-111-0/+125
* done passing left/right margins everywhereKartik K. Agaram2022-07-081-16/+16
* add args to some functionsKartik K. Agaram2022-07-081-14/+14
* add args to some functionsKartik K. Agaram2022-07-081-6/+6
* add args to some functionsKartik K. Agaram2022-07-081-5/+5
* add args to some functionsKartik K. Agaram2022-07-082-11/+11
* add args to some functionsKartik K. Agaram2022-07-081-10/+12
* add args to some functionsKartik K. Agaram2022-07-081-3/+3
* add args to some functionsKartik K. Agaram2022-07-081-2/+2
* add args to some functionsKartik K. Agaram2022-07-083-8/+8
* add args to some functionsKartik K. Agaram2022-07-083-6/+5
* indentKartik K. Agaram2022-07-082-3/+12
* add args to some functionsKartik K. Agaram2022-07-083-5/+5
* add args to some functionsKartik K. Agaram2022-07-083-15/+15
* add args to some functionsKartik K. Agaram2022-07-081-28/+28
* start passing left/right margins everywhereKartik K. Agaram2022-07-082-10/+10
* rename a couple of variablesKartik K. Agaram2022-07-081-10/+10
* affirm a priorityKartik K. Agaram2022-07-081-0/+2
* drop an arg from a functionKartik K. Agaram2022-07-083-4/+4
* switch arg for a functionKartik K. Agaram2022-07-082-16/+12
* stop scanning from start of file on every App.drawKartik K. Agaram2022-07-071-40/+38
* yet another bugfix in selection managementKartik K. Agaram2022-07-072-20/+6
* just keep the cursor visible after any input eventsKartik K. Agaram2022-07-061-2/+8
* show cursor immediately after a mouse clickKartik K. Agaram2022-07-061-0/+2
* better error messageKartik K. Agaram2022-07-051-0/+3
* make freehand drawings smootherKartik K. Agaram2022-07-051-1/+17
* optimization: moving cursor to next wordKartik K. Agaram2022-07-051-4/+12
* bugfix: avoid scrolling on 'end'Kartik K. Agaram2022-07-052-8/+15
* bugfix: 'escape' to cancel a strokeKartik K. Agaram2022-07-053-6/+28
* what should happen to selection while drawing?Kartik K. Agaram2022-07-051-0/+1
alic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* 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 */
if __name__ == '__main__': from __init__ import init; init()

import unittest
import curses
from random import randint

from ranger.gui.displayable import Displayable, DisplayableContainer
from test import Fake, OK, raise_ok

class TestDisplayable(unittest.TestCase):
	def setUp(self):
		self.win = Fake()
		self.fm = Fake()
		self.env = Fake()
		self.settings = Fake()
		self.disp = Displayable( win=self.win,
				env=self.env, fm=self.fm, settings=self.settings)

		hei, wid = 100, 100
		self.env.termsize = (hei, wid)

	def tearDown(self):
		self.disp.destroy()

	def test_colorscheme(self):
		# Using a color method implies change of window attributes
		disp = self.disp

		disp.win.chgat = raise_ok
		disp.win.attrset = raise_ok

		self.assertRaises(OK, disp.color, 'a', 'b')
		self.assertRaises(OK, disp.color_at, 0, 0, 0, 'a', 'b')
		self.assertRaises(OK, disp.color_reset)

	def test_boundaries(self):
		disp = self.disp
		hei, wid = self.env.termsize

		self.assertRaises(ValueError, disp.resize, 0, 0, hei + 1, wid)
		self.assertRaises(ValueError, disp.resize, 0, 0, hei, wid + 1)
		self.assertRaises(ValueError, disp.resize, -1, 0, hei, wid)
		self.assertRaises(ValueError, disp.resize, 0, -1, hei, wid)

		box = (randint(10, 20), randint(30, 40), \
				randint(30, 40), randint(10, 20))

		def in_box(y, x):
			return (x >= box[1] and x < box[1] + box[3]) and \
					(y >= box[0] and y < box[0] + box[2])

		disp.resize(*box)
		for y, x in zip(range(10), range(10)):
			is_in_box = in_box(y, x)

			point1 = (y, x)
			self.assertEqual(is_in_box, point1 in disp)

			point2 = Fake()
			point2.x = x
			point2.y = y
			self.assertEqual(is_in_box, point2 in disp)

class TestDisplayableContainer(unittest.TestCase):
	def setUp(self):
		self.win = Fake()
		self.fm = Fake()
		self.env = Fake()
		self.settings = Fake()

		self.initdict = {'win': self.win, 'settings': self.settings,
				'fm': self.fm, 'env': self.env}

		self.disp = Displayable(**self.initdict)
		self.disc = DisplayableContainer(**self.initdict)
		self.disc.add_child(self.disp)

		hei, wid = (100, 100)
		self.env.termsize = (hei, wid)

	def tearDown(self):
		self.disc.destroy()

	def test_container(self):
		self.assertTrue(self.disp in self.disc.container)

	def test_click(self):
		self.disp.click = raise_ok

		self.disc.resize(0, 0, 50, 50)
		self.disp.resize(0, 0, 20, 20)
		fakepos = Fake()

		fakepos.x = 10
		fakepos.y = 10
		self.assertRaises(OK, self.disc.click, fakepos)

		fakepos.x = 30
		fakepos.y = 10
		self.disc.click(fakepos)

	def test_focused_object(self):
		d1 = Displayable(**self.initdict)
		d2 = DisplayableContainer(**self.initdict)
		for obj in (Displayable(**self.initdict) for x in range(5)):
			d2.add_child(obj)
		d3 = DisplayableContainer(**self.initdict)
		for obj in (Displayable(**self.initdict) for x in range(5)):
			d3.add_child(obj)

		for obj in (d1, d2, d3):
			self.disc.add_child(obj)

		d3.container[3].focused = True

		self.assertEqual(self.disc._get_focused_obj(), d3.container[3])

		d3.container[3].focused = False
		d2.container[0].focused = True

		self.assertEqual(self.disc._get_focused_obj(), d2.container[0])

if __name__ == '__main__':
	unittest.main()