Erik Grinaker avatar Erik Grinaker committed e6acb28

a few more ui module unit tests

Comments (0)

Files changed (3)

 
 ---------------[ xxxx-xx-xx : 0.4.0 ]---------------
 
-2005-01-07  Erik Grinaker <erikg@codepoet.no>
+2005-01-24  Erik Grinaker <erikg@codepoet.no>
+
+	* wrote more ui module unit tests (yawn)
+
+2005-01-08  Erik Grinaker <erikg@codepoet.no>
 
 	* wrote more ui module unit tests (yawn)
 
 class TreeView(gtk.TreeView):
 	"A tree display"
 
-	def __init__(self, model = None):
+	def __init__(self, model):
 		gtk.TreeView.__init__(self, model)
 		self.set_headers_visible(False)
 		self.model = model
 
 import gobject, gtk, unittest
 
-from revelation import config, entry, ui
+from revelation import config, data, entry, ui
 
 
 
 
 
 
+# TODO fix tests for internal callbacks (keyboard handling, drag/drop etc)
+class TreeView(unittest.TestCase):
+	"TreeView"
+
+	def test_headers_visible(self):
+		"TreeView disables tree headers by default"
+
+		self.assertEquals(ui.TreeView(data.EntryStore()).get_headers_visible(), False)
+
+
+	def test_selection(self):
+		"TreeView makes selection available through selection attribute"
+
+		t = ui.TreeView(data.EntryStore())
+		self.assertEquals(t.selection is t.get_selection(), True)
+
+
+	def test_subclass(self):
+		"TreeView is subclass of gtk.TreeView"
+
+		self.assertEquals(isinstance(ui.TreeView(data.EntryStore()), gtk.TreeView), True)
+
+
+
+class TreeView_collapse_row(unittest.TestCase):
+	"TreeView.collapse_row()"
+
+	def test_collapse(self):
+		"TreeView.collapse_row() collapses row"
+
+		e = data.EntryStore()
+		fiter = e.add_entry(entry.FolderEntry())
+		iter = e.add_entry(entry.GenericEntry(), fiter)
+
+		t = ui.TreeView(e)
+		t.expand_row(fiter)
+		t.collapse_row(fiter)
+
+		self.assertEquals(t.row_expanded(( 0, )), False)
+
+
+	def test_iter(self):
+		"TreeView.collapse_row() takes iter instead of path"
+
+		e = data.EntryStore()
+		iter = e.add_entry(entry.GenericEntry())
+
+		t = ui.TreeView(e)
+		t.collapse_row(iter)
+		self.assertRaises(TypeError, t.collapse_row, ( 0, ))
+
+
+
 class Toolbar(unittest.TestCase):
 	"Toolbar"
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.