diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-05-31 15:25:12 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-06-02 13:30:39 -0300 |
commit | 47d4a1f545eb7f348e46d39230a73a1b465e57a4 (patch) | |
tree | e8574c6fee17835de762730cce10b82f6871c2ae /tests/samplebinding | |
parent | dfdc92fbe5288064987beb097f50a73a63d2546e (diff) |
Generator improved to handle protected enums without the protected hack.
Diffstat (limited to 'tests/samplebinding')
-rwxr-xr-x | tests/samplebinding/protected_test.py | 36 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 2 |
2 files changed, 33 insertions, 5 deletions
diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py index 6a5f732c9..efb0bedbf 100755 --- a/tests/samplebinding/protected_test.py +++ b/tests/samplebinding/protected_test.py @@ -185,12 +185,16 @@ class ExtendedProtectedEnumClass(ProtectedEnumClass): if value == ProtectedEnumClass.ProtectedItem0: return ProtectedEnumClass.ProtectedItem1 return ProtectedEnumClass.ProtectedItem0 + def publicEnumMethod(self, value): + if value == ProtectedEnumClass.PublicItem0: + return ProtectedEnumClass.PublicItem1 + return ProtectedEnumClass.PublicItem0 class ProtectedEnumTest(unittest.TestCase): '''Test cases for protected enum.''' - def testProtectedEnum(self): - '''Original protected method is being called.''' + def testProtectedMethodWithProtectedEnumArgument(self): + '''Calls protected method with protected enum argument.''' obj = ProtectedEnumClass() self.assertEqual(type(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedEnum) @@ -201,8 +205,18 @@ class ProtectedEnumTest(unittest.TestCase): self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0) self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1) - def testProtectedEnumWithMethodOverride(self): - '''Overridden protected method is being called.''' + def testProtectedMethodWithPublicEnumArgument(self): + '''Calls protected method with public enum argument.''' + obj = ProtectedEnumClass() + + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem0) + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem1) + + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem0) + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem1) + + def testOverriddenProtectedMethodWithProtectedEnumArgument(self): + '''Calls overridden protected method with protected enum argument.''' obj = ExtendedProtectedEnumClass() self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem1) @@ -214,6 +228,20 @@ class ProtectedEnumTest(unittest.TestCase): self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem1) self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem0) + def testOverriddenProtectedMethodWithPublicEnumArgument(self): + '''Calls overridden protected method with public enum argument.''' + obj = ExtendedProtectedEnumClass() + + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem1) + self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem0) + + self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem0) + self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem1) + + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem1) + self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem0) + + if __name__ == '__main__': unittest.main() diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 2a905f234..e53486fcc 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -280,9 +280,9 @@ </object-type> - // Receives and returns the same protected enum item. <object-type name="ProtectedEnumClass" /> <enum-type name="ProtectedEnumClass::ProtectedEnum" /> + <enum-type name="ProtectedEnumClass::PublicEnum" /> <template name="boolptr_at_end_fix_beginning"> bool __ok__; |