summary refs log tree commit diff stats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Renamed ranger/ext/signal_dispatcher to ranger/ext/signalshut2010-10-141-1/+1
|
* Merge branch 'master' into previewhut2010-10-082-5/+5
|\ | | | | | | | | | | | | Conflicts: ranger/__init__.py ranger/core/helper.py ranger/gui/curses_shortcuts.py
| * a little restructurationhut2010-10-022-5/+5
| |
| * Revert 5 commits concerning utf (due to very poor performance)hut2010-09-301-2/+5
| | | | | | | | | | | | | | | | | | This reverts commits: 8c8e7282b3b4238a3b7cf981d9e5715b11076419 5cb67eeb96d337b55deea20131fc44a3d5447251 512f386be8753775ec824a6d9cbaf6527d50eda4 d4900452fca51685349966d527d173fdefe83f08 e6dda13a71168f9ec4a1e4844edad5a3257803e9
| * ext.utfwidth: updated algorithmshut2010-09-301-5/+0
| |
| * ext.utfwidth: stuffhut2010-09-301-0/+2
| |
* | Merge branch 'stable' into previewhut2010-10-0521-12/+268
|\| | | | | | | | | Conflicts: ranger/shared/settings.py
| * removed test/__init__.py (not needed)hut2010-08-291-0/+0
| |
| * defaults.keys: key pL to create relative symlinkshut2010-08-291-0/+47
| |
| * Removed symlink in test/hut2010-08-2919-8/+108
| |
| * Changed implementation of container.historyhut2010-08-281-8/+8
| |
| * Fixed historyhut2010-08-261-0/+19
| |
| * tc_human_readable: additional testcase (which fails)hut2010-06-251-0/+4
| |
| * ext.human_readable: more efficient implementationhut2010-06-242-0/+86
| | | | | | | | plus unit tests and benchmark.
* | Merge branch 'master' into previewhut2010-06-221-9/+8
|\|
| * all_benchmarks: shortenedhut2010-06-181-9/+8
| |
* | Merge branch 'master' into previewhut2010-06-0919-86/+121
|\| | | | | | | | | Conflicts: ranger/fsobject/file.py
| * all_benchmarks.py: fix + cleanuphut2010-06-091-40/+35
| |
| * all_tests.py: cleanuphut2010-06-091-14/+14
| |
| * Changed hashbang line to "#!/usr/bin/env python"hut2010-06-092-2/+2
| |
| * simplified all_tests.py, moved to test/hut2010-06-0719-86/+126
| |
* | gui.ansi: some modifications/completionshut2010-06-031-7/+2
| |
* | added gui/ansi.py from David Barnetts branchhut2010-06-031-0/+45
|/
* Merge branch 'utf'hut2010-05-171-0/+42
|\ | | | | | | | | Conflicts: ranger/__main__.py
| * fixed utf stuffhut2010-05-171-3/+3
| |
| * attempt to fix utf issues (wrong calculation of width)hut2010-05-101-0/+42
| |
* | fsobject.fsobject: applied patcheshut2010-05-141-0/+1
|/
* all_benchmarks: improvedhut2010-05-101-2/+0
|
* fsobject: don't unnecessarily use abspath() in __init__hut2010-05-061-1/+2
|
* cleanupshut2010-05-052-3/+6
|
* Added license header to a few fileshut2010-05-041-0/+15
|
* bm_loader: stuffhut2010-05-031-1/+35
|
* test: added TODO, skip broken testshut2010-05-034-5/+25
|
* changed testdir to /usr/includehut2010-04-291-1/+1
|
* Separated benchmark from testcasehut2010-04-293-125/+134
|
* Added tc_loaderhut2010-04-262-1/+186
|
* tc_displayable: improved (but not fixed) test_boundarieshut2010-04-181-6/+8
|
* tc_displayable: test_boundaries fails if you run it more often!hut2010-04-181-20/+21
|
* Fixed unittestshut2010-04-183-3/+5
|
* moved container.keymap.KeyBuffer into seperate modulehut2010-04-161-0/+1
|
* keymap: moved simulate_press to where it belongs: tc_newkeyshut2010-04-161-5/+14
|
* keymap: move translate_keys to ranger.ext.keybinding_parserhut2010-04-161-2/+3
|
* dirarg: added unit test and almost working implementaitonhut2010-04-131-0/+7
|
* tc_newkeys: fixed all but one testhut2010-04-091-6/+24
|
* partially fix tc_newkeyshut2010-04-091-26/+28
|
* tc_direction: fixedhut2010-04-081-1/+1
| | | | | | | | maximum=X means that the maximum value is set to X-1. Works for lists: d.move(maximum=len(lst)) is this counter intuitive?
* tc_newkey: added 2 failing test cases. Fix it!hut2010-04-081-13/+53
|
* clean uphut2010-04-081-1/+2
|
* added KeyManagerhut2010-04-072-2/+39
|
* tc_newkey: added commenthut2010-04-071-0/+1
|
{ 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 */
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

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, TODO

class TestWithFakeCurses(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.disp.destroy()
		self.disc.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_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])

gWin = None

class TestDisplayableWithCurses(unittest.TestCase):
	def setUp(self):
		global gWin
		if not gWin:
			gWin = curses.initscr()
		self.win = gWin
		curses.cbreak()
		curses.noecho()
		curses.start_color()
		curses.use_default_colors()

		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)

		self.env.termsize = self.win.getmaxyx()

	def tearDown(self):
		self.disp.destroy()
		curses.nocbreak()
		curses.echo()
		curses.endwin()

	@TODO
	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)

		for i in range(1000):
			box = [int(randint(0, hei) * 0.2), int(randint(0, wid) * 0.2)]
			box.append(randint(0, hei - box[0]))
			box.append(randint(0, wid - box[1]))

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

			disp.resize(*box)
			self.assertEqual(box, [disp.y, disp.x, disp.hei, disp.wid],
					"Resizing failed for some reason on loop " + str(i))

			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)

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

		hei, wid = self.env.termsize

		for i in range(50):
			winwid = randint(2, wid-1)
			winhei = randint(2, hei-1)
			self.disc.resize(0, 0, hei, wid)
			self.disp.resize(0, 0, winhei, winwid)
			fakepos = Fake()

			fakepos.x = winwid - 2
			fakepos.y = winhei - 2
			self.assertRaises(OK, self.disc.click, fakepos)

			fakepos.x = winwid
			fakepos.y = winhei
			self.disc.click(fakepos)


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