Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sugar/tutorius/tests/gtkutilstests.py103
-rwxr-xr-xsrc/sugar/tutorius/tests/run-tests.py7
2 files changed, 109 insertions, 1 deletions
diff --git a/src/sugar/tutorius/tests/gtkutilstests.py b/src/sugar/tutorius/tests/gtkutilstests.py
new file mode 100644
index 0000000..36e76fe
--- /dev/null
+++ b/src/sugar/tutorius/tests/gtkutilstests.py
@@ -0,0 +1,103 @@
+# Copyright (C) 2009, Tutorius.org
+# Copyright (C) 2009, Simon Poirier <simpoir@gmail.com>
+# Copyright (C) 2009, Vincent Vinet <vince.vinet@gmail.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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+"""
+Gtk Utils Tests
+
+This module contains all the tests that pertain to the usage of the Tutorius
+gtkutils
+"""
+
+import unittest
+
+import logging
+import gtk, gobject
+from sugar.tutorius.gtkutils import find_widget, register_signals_numbered, register_signals
+
+
+
+class GtkUtilsTests(unittest.TestCase):
+ def __init__(self,*args):
+ unittest.TestCase.__init__(self,*args)
+ self.widgets = {}
+ self.top = None
+
+ def setUp(self):
+ #create hierarchy
+ self.top = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
+ self.top.set_name("Top")
+ self.widgets["top"] = {"named":"Top","numbered":"0","widget":self.top}
+
+ hbox = gtk.HBox()
+ self.top.add(hbox)
+ hbox.show()
+ self.widgets["hbox0"] = {"name":"Top.GtkHBox","numbered":"0.0","widget":hbox}
+
+ btn1 = gtk.Button()
+ btn1.set_name("Button1")
+ hbox.pack_start(btn1)
+ btn1.show()
+ self.widgets["btn1"] = {"name":"Top.GtkHBox.Button1","numbered":"0.0.0","widget":btn1}
+
+ btn2 = gtk.Button()
+ btn2.set_name("Button2")
+ hbox.pack_start(btn2)
+ btn2.show()
+ self.widgets["btn2"] = {"name":"Top.GtkHBox.Button2","numbered":"0.0.1","widget":btn2}
+
+ vbox = gtk.VBox()
+ vbox.set_name("VBox1")
+ hbox.pack_start(vbox)
+ hbox.show()
+ self.widgets["vbox0"] = {"name":"Top.GtkHBox.VBox1","numbered":"0.0.2","widget":vbox}
+
+ btn3 = gtk.Button()
+ btn3.set_name("Button3")
+ vbox.pack_start(btn3)
+ btn3.show()
+ self.widgets["btn3"] = {"name":"Top.GtkHBox.VBox1.Button3","numbered":"0.0.2.0","widget":btn3}
+
+ btn4 = gtk.Button()
+ vbox.pack_start(btn4)
+ btn4.show()
+ self.widgets["btn4"] = {"name":"Top.GtkHBox.VBox1.GtkButton","numbered":"0.0.2.1","widget":btn4}
+
+ def tearDown(self):
+ #destroy hierarchy
+ self.top.destroy()
+ self.top = None
+ self.widgets = {}
+
+ def test_named(self):
+ #def register_signals(target, handler, prefix=None, max_depth=None):
+ pass
+
+ def test_numbered(self):
+ #def register_signals_numbered(target, handler, prefix="0", max_depth=None):
+ while gtk.events_pending():
+ gtk.main_iteration(block=False)
+
+ def test_find_widget(self):
+ for widget in self.widgets.values():
+ f = find_widget(self.top, widget["numbered"])
+ assert f is widget["widget"], "Widget %s found with path %s, expected %s" % (f, widget["numbered"], widget["widget"])
+
+
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/src/sugar/tutorius/tests/run-tests.py b/src/sugar/tutorius/tests/run-tests.py
index db10c54..2af2afb 100755
--- a/src/sugar/tutorius/tests/run-tests.py
+++ b/src/sugar/tutorius/tests/run-tests.py
@@ -25,11 +25,14 @@ if __name__=='__main__':
import coretests
import servicestests
-
+ import gtkutilstests
+ import overlaytests
suite = unittest.TestSuite()
suite.addTests(unittest.findTestCases(coretests))
suite.addTests(unittest.findTestCases(servicestests))
+ suite.addTests(unittest.findTestCases(gtkutilstests))
+ suite.addTests(unittest.findTestCases(overlaytests))
runner = unittest.TextTestRunner()
runner.run(suite)
@@ -40,5 +43,7 @@ if __name__=='__main__':
else:
from coretests import *
from servicestests import *
+ from gtkutilstests import *
+ from overlaytests import *
unittest.main()