From 8ab1e32a479c018766f330ecf71670ef71492300 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 15 Apr 2009 02:55:10 +0000 Subject: Merge commit 'origin/lp349874' Conflicts: source/external/source/sugar-toolkit/src/sugar/tutorius/tests/actiontests.py source/external/source/sugar-toolkit/src/sugar/tutorius/tests/filterstests.py source/external/source/sugar-toolkit/src/sugar/tutorius/tests/gtkutilstests.py source/external/source/sugar-toolkit/src/sugar/tutorius/tests/run-tests.py --- (limited to 'src/sugar/tutorius/tests') diff --git a/src/sugar/tutorius/tests/actiontests.py b/src/sugar/tutorius/tests/actiontests.py index 9c398d4..ab9cdba 100644 --- a/src/sugar/tutorius/tests/actiontests.py +++ b/src/sugar/tutorius/tests/actiontests.py @@ -153,6 +153,21 @@ class ChainActionTest(unittest.TestCase): assert len(witness) is 2, "Two actions should give 2 undo's" +class DisableWidgetActionTests(unittest.TestCase): + def test_disable(self): + btn = gtk.Button() + ObjectStore().activity = btn + btn.set_sensitive(True) + assert btn.props.sensitive is True, "Callback should have been called" + + act = DisableWidgetAction("0") + assert btn.props.sensitive is True, "Callback should have been called again" + act.do() + assert btn.props.sensitive is False, "Callback should not have been called again" + act.undo() + assert btn.props.sensitive is True, "Callback should have been called again" + if __name__ == "__main__": unittest.main() + diff --git a/src/sugar/tutorius/tests/filterstests.py b/src/sugar/tutorius/tests/filterstests.py index 4b7ae61..8ee6cc8 100644 --- a/src/sugar/tutorius/tests/filterstests.py +++ b/src/sugar/tutorius/tests/filterstests.py @@ -26,7 +26,7 @@ import time import gobject import gtk -from sugar.tutorius.filters import EventFilter, TimerEvent, GtkWidgetEventFilter +from sugar.tutorius.filters import EventFilter, TimerEvent, GtkWidgetEventFilter, GtkWidgetTypeFilter from gtkutilstests import SignalCatcher class BaseEventFilterTests(unittest.TestCase): diff --git a/src/sugar/tutorius/tests/gtkutilstests.py b/src/sugar/tutorius/tests/gtkutilstests.py index 5dfd363..41634ae 100644 --- a/src/sugar/tutorius/tests/gtkutilstests.py +++ b/src/sugar/tutorius/tests/gtkutilstests.py @@ -184,6 +184,17 @@ class GtkUtilsTests(unittest.TestCase): f = find_widget(self.top, "0.99.1.2") assert f is self.top, "Should have returned top widget" + def test_register_args_numbered(self): + #Need to check the signal catcher and stuff... grreat + while gtk.events_pending(): + gtk.main_iteration(block=False) + + + def test_register_args_normal(self): + #Need to check the signal catcher and stuff... grreat + while gtk.events_pending(): + gtk.main_iteration(block=False) + def test_notwidget(self): """Test the get_children function""" o = object() diff --git a/src/sugar/tutorius/tests/run-tests.py b/src/sugar/tutorius/tests/run-tests.py index 1cda76e..63a8de1 100755 --- a/src/sugar/tutorius/tests/run-tests.py +++ b/src/sugar/tutorius/tests/run-tests.py @@ -10,7 +10,7 @@ sys.path.insert(0, ) FULL_PATH = os.path.join(INSTALL_PATH,"sugar/tutorius") -SUBDIRS = [] +SUBDIRS = ["uam"] GLOB_PATH = os.path.join(FULL_PATH,"*.py") import unittest from glob import glob @@ -36,6 +36,7 @@ if __name__=='__main__': import overlaytests import linear_creatortests import actiontests + import uamtests import filterstests import constraintstests import propertiestests @@ -47,6 +48,7 @@ if __name__=='__main__': suite.addTests(unittest.findTestCases(overlaytests)) suite.addTests(unittest.findTestCases(linear_creatortests)) suite.addTests(unittest.findTestCases(actiontests)) + suite.addTests(unittest.findTestCases(uamtests)) suite.addTests(unittest.findTestCases(filterstests)) suite.addTests(unittest.findTestCases(constraintstests)) suite.addTests(unittest.findTestCases(propertiestests)) @@ -65,6 +67,7 @@ if __name__=='__main__': from overlaytests import * from actiontests import * from linear_creatortests import * + from uamtests import * from filterstests import * unittest.main() diff --git a/src/sugar/tutorius/tests/uamtests.py b/src/sugar/tutorius/tests/uamtests.py new file mode 100644 index 0000000..b2a5901 --- /dev/null +++ b/src/sugar/tutorius/tests/uamtests.py @@ -0,0 +1,61 @@ +# Copyright (C) 2009, Tutorius.org +# Copyright (C) 2009, Michael Janelle-Montcalm +# Copyright (C) 2009, Vincent Vinet +# +# 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 + +import unittest + +from sugar.tutorius.uam import parse_uri, SchemeError + +PARSE_SUITE={ +#URI SCHEME HOST PARAMS PATH QUERY FRAGMENT +"tap://act.tut.org/": ["tap", "act.tut.org","", "/", "", ""], +"tap.gtk://a.t.o/0/1": ["tap.gtk","a.t.o","","/0/1","","",""], +"tap.gobject://a.t.o/Timer?timeout=5":["tap.gobject","a.t.o","","/Timer","timeout=5",""], +} + +class ParseUriTests(unittest.TestCase): + """Tests the UAM parsers""" + def test_parse_uri(self): + """Test parsing results""" + for uri, test in PARSE_SUITE.items(): + res = parse_uri(uri) + + assert res.scheme == test[0], "%s : Expected scheme %s, got %s" % (uri, test[0], res.scheme) + assert res.netloc == test[1], "%s : Expected netloc %s, got %s" % (uri, test[1], res.netloc) + assert res.params == test[2], "%s : Expected params %s, got %s" % (uri, test[2], res.params) + assert res.path == test[3], "%s : Expected path %s, got %s" % (uri, test[3], res.path) + assert res.query == test[4], "%s : Expected query %s, got %s" % (uri, test[4], res.query) + assert res.fragment == test[5], "%s : Expected fragment %s, got %s" % (uri, test[5], res.fragment) + + def test_errors(self): + """Test exceptions""" + try: + parse_uri("http://something.org/path") + assert False, "Parsing http should fail" + except SchemeError: + pass + + try: + parse_uri("tap.notarealsubscheme://something.org/path") + assert False, "Invalid Subscheme should fail" + except SchemeError: + pass + + +if __name__ == "__main__": + unittest.main() + -- cgit v0.9.1