aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-01-18 18:20:00 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:53 -0300
commit91818aecdaa52facd7f62931343f0e8aa4b69f55 (patch)
tree45bc84b00f884d3f28b319d0c50eefab673b85a1
parentf23f606c02e8c62635bd0d0f030e5c9550171b9c (diff)
Added more test cases for protected attributes.
The tests are meant to be useful when compiled without the protected hack or on the win32 platform. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--tests/libsample/protected.h14
-rw-r--r--tests/samplebinding/protected_test.py44
2 files changed, 51 insertions, 7 deletions
diff --git a/tests/libsample/protected.h b/tests/libsample/protected.h
index bf4dea045..645dd93e9 100644
--- a/tests/libsample/protected.h
+++ b/tests/libsample/protected.h
@@ -24,6 +24,8 @@
#define PROTECTED_H
#include "libsamplemacros.h"
+#include "objecttype.h"
+#include "point.h"
#include <string>
class ProtectedNonPolymorphic
@@ -117,9 +119,19 @@ protected:
class ProtectedProperty
{
public:
- ProtectedProperty() : protectedProperty(0) {}
+ ProtectedProperty()
+ : protectedProperty(0),
+ protectedEnumProperty(Event::NO_EVENT),
+ protectedValueTypeProperty(Point(0, 0)),
+ protectedValueTypePointerProperty(0),
+ protectedObjectTypeProperty(0)
+ {}
protected:
int protectedProperty;
+ Event::EventType protectedEnumProperty;
+ Point protectedValueTypeProperty;
+ Point* protectedValueTypePointerProperty;
+ ObjectType* protectedObjectTypeProperty;
};
#endif // PROTECTED_H
diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py
index e9d8b81e7..8ebc99f11 100644
--- a/tests/samplebinding/protected_test.py
+++ b/tests/samplebinding/protected_test.py
@@ -27,14 +27,13 @@
'''Test cases for protected methods.'''
import unittest
-import sys
from sample import cacheSize
from sample import ProtectedNonPolymorphic, ProtectedVirtualDestructor
from sample import ProtectedPolymorphic, ProtectedPolymorphicDaughter, ProtectedPolymorphicGrandDaughter
from sample import ProtectedProperty, ProtectedEnumClass
from sample import PrivateDtor
-from sample import Point
+from sample import Event, ObjectType, Point
class ExtendedProtectedPolymorphic(ProtectedPolymorphic):
def __init__(self, name):
@@ -266,15 +265,48 @@ class ProtectedEnumTest(unittest.TestCase):
class ProtectedPropertyTest(unittest.TestCase):
'''Test cases for a class with a protected property (or field in C++).'''
+ def setUp(self):
+ self.obj = ProtectedProperty()
+
def tearDown(self):
+ del self.obj
self.assertEqual(cacheSize(), 0)
def testProtectedProperty(self):
- '''Writes and reads a protected property.'''
- obj = ProtectedProperty()
+ '''Writes and reads a protected integer property.'''
+ self.obj.protectedProperty = 3
+ self.assertEqual(self.obj.protectedProperty, 3)
+
+ def testProtectedEnumProperty(self):
+ '''Writes and reads a protected enum property.'''
+ self.obj.protectedEnumProperty = Event.SOME_EVENT
+ self.assertEqual(self.obj.protectedEnumProperty, Event.SOME_EVENT)
+
+ def testProtectedValueTypeProperty(self):
+ '''Writes and reads a protected value type property.'''
+ point = Point(12, 34)
+ self.obj.protectedValueTypeProperty = point
+ self.assertEqual(self.obj.protectedValueTypeProperty, point)
+ self.assertFalse(self.obj.protectedValueTypeProperty is point)
+ pointProperty = self.obj.protectedValueTypeProperty
+ self.assertFalse(self.obj.protectedValueTypeProperty is pointProperty)
+
+ def testProtectedValueTypePointerProperty(self):
+ '''Writes and reads a protected value type pointer property.'''
+ pt1 = Point(12, 34)
+ pt2 = Point(12, 34)
+ self.obj.protectedValueTypePointerProperty = pt1
+ self.assertEqual(self.obj.protectedValueTypePointerProperty, pt1)
+ self.assertEqual(self.obj.protectedValueTypePointerProperty, pt2)
+ self.assert_(self.obj.protectedValueTypePointerProperty is pt1)
+ self.assertFalse(self.obj.protectedValueTypePointerProperty is pt2)
+
+ def testProtectedObjectTypeProperty(self):
+ '''Writes and reads a protected object type property.'''
+ obj = ObjectType()
+ self.obj.protectedObjectTypeProperty = obj
+ self.assertEqual(self.obj.protectedObjectTypeProperty, obj)
- obj.protectedProperty = 3
- self.assertEqual(obj.protectedProperty, 3)
class PrivateDtorProtectedMethodTest(unittest.TestCase):
'''Test cases for classes with private destructors and protected methods.'''