aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-05-31 15:25:12 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-06-02 13:30:39 -0300
commit47d4a1f545eb7f348e46d39230a73a1b465e57a4 (patch)
treee8574c6fee17835de762730cce10b82f6871c2ae /tests
parentdfdc92fbe5288064987beb097f50a73a63d2546e (diff)
Generator improved to handle protected enums without the protected hack.
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/protected.h6
-rwxr-xr-xtests/samplebinding/protected_test.py36
-rw-r--r--tests/samplebinding/typesystem_sample.xml2
3 files changed, 39 insertions, 5 deletions
diff --git a/tests/libsample/protected.h b/tests/libsample/protected.h
index abbbf293..d8d55a40 100644
--- a/tests/libsample/protected.h
+++ b/tests/libsample/protected.h
@@ -111,6 +111,10 @@ class LIBSAMPLE_API ProtectedEnumClass
public:
ProtectedEnumClass() {}
virtual ~ProtectedEnumClass() {}
+ enum PublicEnum {
+ PublicItem0,
+ PublicItem1
+ };
protected:
enum ProtectedEnum {
ProtectedItem0,
@@ -118,6 +122,8 @@ protected:
};
ProtectedEnum callProtectedEnumMethod(ProtectedEnum in) { return protectedEnumMethod(in); }
virtual ProtectedEnum protectedEnumMethod(ProtectedEnum in) { return in; }
+ PublicEnum callPublicEnumMethod(PublicEnum in) { return publicEnumMethod(in); }
+ virtual PublicEnum publicEnumMethod(PublicEnum in) { return in; }
};
#endif // PROTECTED_H
diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py
index 6a5f732c..efb0bedb 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 2a905f23..e53486fc 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__;