Back to index

enigmail  1.4.3
Public Member Functions
runtests.TestTypelibRoundtrip Class Reference
Inheritance diagram for runtests.TestTypelibRoundtrip:
Inheritance graph
[legend]
Collaboration diagram for runtests.TestTypelibRoundtrip:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def checkRoundtrip
def test_simple
def test_parent
def test_ifaceFlags
def test_constants
def test_methods
def assertEqualTypelibs
def assertEqualInterfaces
def assertEqualMethods
def assertEqualConstants
def assertEqualParams
def assertEqualTypes

Detailed Description

Definition at line 177 of file runtests.py.


Member Function Documentation

def runtests.TypelibCompareMixin.assertEqualConstants (   self,
  c1,
  c2 
) [inherited]

Definition at line 137 of file runtests.py.

00137 
00138     def assertEqualConstants(self, c1, c2):
00139         self.assert_(c1 is not None, "Should not be None")
00140         self.assert_(c2 is not None, "Should not be None")
00141         self.assertEqual(c1.name, c2.name)
00142         self.assertEqual(c1.value, c2.value)
00143         self.assertEqualTypes(c1.type, c2.type)

Here is the call graph for this function:

Here is the caller graph for this function:

def runtests.TypelibCompareMixin.assertEqualInterfaces (   self,
  i1,
  i2 
) [inherited]

Definition at line 95 of file runtests.py.

00095 
00096     def assertEqualInterfaces(self, i1, i2):
00097         self.assert_(i1 is not None, "Should not be None")
00098         self.assert_(i2 is not None, "Should not be None")
00099         self.assertEqual(i1.name, i2.name, "Names should be equal")
00100         self.assertEqual(i1.iid, i2.iid, "IIDs should be equal")
00101         self.assertEqual(i1.namespace, i2.namespace,
00102                          "Namespaces should be equal")
00103         self.assertEqual(i1.resolved, i2.resolved,
00104                          "Resolved status should be equal")
00105         if i1.resolved:
00106             if i1.parent or i2.parent:
00107                 # Can't test exact equality, probably different objects
00108                 self.assertEqualInterfaces(i1.parent, i2.parent)
00109             self.assertEqual(len(i1.methods), len(i2.methods))
00110             for m, n in zip(i1.methods, i2.methods):
00111                 self.assertEqualMethods(m, n)
00112             self.assertEqual(len(i1.constants), len(i2.constants))
00113             for c, d in zip(i1.constants, i2.constants):
00114                 self.assertEqualConstants(c, d)
00115             self.assertEqual(i1.scriptable, i2.scriptable,
00116                              "Scriptable status should be equal")
00117             self.assertEqual(i1.function, i2.function,
00118                              "Function status should be equal")

Here is the call graph for this function:

Here is the caller graph for this function:

def runtests.TypelibCompareMixin.assertEqualMethods (   self,
  m1,
  m2 
) [inherited]

Definition at line 119 of file runtests.py.

00119 
00120     def assertEqualMethods(self, m1, m2):
00121         self.assert_(m1 is not None, "Should not be None")
00122         self.assert_(m2 is not None, "Should not be None")
00123         self.assertEqual(m1.name, m2.name, "Names should be equal")
00124         self.assertEqual(m1.getter, m2.getter, "Getter flag should be equal")
00125         self.assertEqual(m1.setter, m2.setter, "Setter flag should be equal")
00126         self.assertEqual(m1.notxpcom, m2.notxpcom,
00127                          "notxpcom flag should be equal")
00128         self.assertEqual(m1.constructor, m2.constructor,
00129                          "constructor flag should be equal")
00130         self.assertEqual(m1.hidden, m2.hidden, "hidden flag should be equal")
00131         self.assertEqual(m1.optargc, m2.optargc, "optargc flag should be equal")
00132         self.assertEqual(m1.implicit_jscontext, m2.implicit_jscontext,
00133                          "implicit_jscontext flag should be equal")
00134         for p1, p2 in zip(m1.params, m2.params):
00135             self.assertEqualParams(p1, p2)
00136         self.assertEqualParams(m1.result, m2.result)
        

Here is the call graph for this function:

Here is the caller graph for this function:

def runtests.TypelibCompareMixin.assertEqualParams (   self,
  p1,
  p2 
) [inherited]

Definition at line 144 of file runtests.py.

00144 
00145     def assertEqualParams(self, p1, p2):
00146         self.assert_(p1 is not None, "Should not be None")
00147         self.assert_(p2 is not None, "Should not be None")
00148         self.assertEqualTypes(p1.type, p2.type)
00149         self.assertEqual(p1.in_, p2.in_)
00150         self.assertEqual(p1.out, p2.out)
00151         self.assertEqual(p1.retval, p2.retval)
00152         self.assertEqual(p1.shared, p2.shared)
00153         self.assertEqual(p1.dipper, p2.dipper)
00154         self.assertEqual(p1.optional, p2.optional)
        

Here is the call graph for this function:

Here is the caller graph for this function:

def runtests.TypelibCompareMixin.assertEqualTypelibs (   self,
  t1,
  t2 
) [inherited]

Definition at line 86 of file runtests.py.

00086 
00087     def assertEqualTypelibs(self, t1, t2):
00088         self.assert_(t1 is not None, "Should not be None")
00089         self.assert_(t2 is not None, "Should not be None")
00090         self.assertEqual(t1.version, t2.version, "Versions should be equal")
00091         self.assertEqual(len(t1.interfaces), len(t2.interfaces),
00092                          "Number of interfaces should be equal")
00093         for i, j in zip(t1.interfaces, t2.interfaces):
00094             self.assertEqualInterfaces(i, j)

Here is the call graph for this function:

Here is the caller graph for this function:

def runtests.TypelibCompareMixin.assertEqualTypes (   self,
  t1,
  t2 
) [inherited]

Definition at line 155 of file runtests.py.

00155 
00156     def assertEqualTypes(self, t1, t2):
00157         self.assert_(t1 is not None, "Should not be None")
00158         self.assert_(t2 is not None, "Should not be None")
00159         self.assertEqual(type(t1), type(t2), "type types should be equal")
00160         self.assertEqual(t1.pointer, t2.pointer,
00161                          "pointer flag should be equal for %s and %s" % (t1, t2))
00162         self.assertEqual(t1.reference, t2.reference)
00163         if isinstance(t1, xpt.SimpleType):
00164             self.assertEqual(t1.tag, t2.tag)
00165         elif isinstance(t1, xpt.InterfaceType):
00166             self.assertEqualInterfaces(t1.iface, t2.iface)
00167         elif isinstance(t1, xpt.InterfaceIsType):
00168             self.assertEqual(t1.param_index, t2.param_index)
00169         elif isinstance(t1, xpt.ArrayType):
00170             self.assertEqualTypes(t1.element_type, t2.element_type)
00171             self.assertEqual(t1.size_is_arg_num, t2.size_is_arg_num)
00172             self.assertEqual(t1.length_is_arg_num, t2.length_is_arg_num)
00173         elif isinstance(t1, xpt.StringWithSizeType) or isinstance(t1, xpt.WideStringWithSizeType):
00174             self.assertEqual(t1.size_is_arg_num, t2.size_is_arg_num)
00175             self.assertEqual(t1.length_is_arg_num, t2.length_is_arg_num)
00176 
#TODO: test flags in various combinations

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file runtests.py.

00178 
00179     def checkRoundtrip(self, t):
00180         fd, f = tempfile.mkstemp()
00181         os.close(fd)
00182         t.write(f)
00183         t2 = xpt.Typelib.read(f)
00184         os.remove(f)
00185         self.assert_(t2 is not None)
00186         self.assertEqualTypelibs(t, t2)
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 224 of file runtests.py.

00224 
00225     def test_constants(self):
00226         c = xpt.Constant("X", xpt.SimpleType(xpt.Type.Tags.uint32),
00227                          0xF000F000)
00228         i = xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00229                           constants=[c])
00230         t = xpt.Typelib(interfaces=[i])
00231         self.checkRoundtrip(t)
00232         # tack on some more constants
00233         i.constants.append(xpt.Constant("Y",
00234                                         xpt.SimpleType(xpt.Type.Tags.int16),
00235                                         -30000))
00236         i.constants.append(xpt.Constant("Z",
00237                                         xpt.SimpleType(xpt.Type.Tags.uint16),
00238                                         0xB0B0))
00239         i.constants.append(xpt.Constant("A",
00240                                         xpt.SimpleType(xpt.Type.Tags.int32),
00241                                         -1000000))
00242         self.checkRoundtrip(t)

Here is the call graph for this function:

Test that an interface's flags are correctly serialized
and deserialized.

Definition at line 211 of file runtests.py.

00211 
00212     def test_ifaceFlags(self):
00213         """
00214         Test that an interface's flags are correctly serialized
00215         and deserialized.
00216 
00217         """
00218         t = xpt.Typelib()
00219         t.interfaces.append(xpt.Interface("IFlags", iid="11223344-5566-7788-9900-aabbccddeeff",
00220                                           resolved=True,
00221                                           scriptable=True,
00222                                           function=True))
00223         self.checkRoundtrip(t)

Here is the call graph for this function:

Definition at line 243 of file runtests.py.

00243 
00244     def test_methods(self):
00245         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00246         m = xpt.Method("Bar", p)
00247         i = xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00248                           methods=[m])
00249         t = xpt.Typelib(interfaces=[i])
00250         self.checkRoundtrip(t)
00251         # add some more methods
00252         i.methods.append(xpt.Method("One", xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00253                                     params=[
00254                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int64)),
00255                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.float, pointer=True))
00256                                         ]))
00257         self.checkRoundtrip(t)
00258         # test some other types (should really be more thorough)
00259         i.methods.append(xpt.Method("Two", xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00260                                     params=[
00261                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.UTF8String, pointer=True)),
00262                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.wchar_t_ptr, pointer=True))
00263                                         ]))
00264         self.checkRoundtrip(t)
00265         # add a method with an InterfaceType argument
00266         bar = xpt.Interface("IBar")
00267         t.interfaces.append(bar)
00268         i.methods.append(xpt.Method("IFaceMethod", xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00269                                     params=[
00270                                         xpt.Param(xpt.InterfaceType(bar))
00271                                         ]))
00272         self.checkRoundtrip(t)
00273 
00274         # add a method with an InterfaceIsType argument
00275         i.methods.append(xpt.Method("IFaceIsMethod", xpt.Param(xpt.SimpleType(xpt.Type.Tags.void)),
00276                                     params=[
00277                                         xpt.Param(xpt.InterfaceIsType(1)),
00278                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.nsIID))
00279                                         ]))
00280         self.checkRoundtrip(t)
00281 
00282         # add a method with an ArrayType argument
00283         i.methods.append(xpt.Method("ArrayMethod", xpt.Param(xpt.SimpleType(xpt.Type.Tags.void)),
00284                                     params=[
00285                                         xpt.Param(xpt.ArrayType(
00286                                             xpt.SimpleType(xpt.Type.Tags.int32),
00287                                             1, 2)),
00288                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00289                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00290                                         ]))
00291         self.checkRoundtrip(t)
00292         
00293         # add a method with a StringWithSize and WideStringWithSize arguments
00294         i.methods.append(xpt.Method("StringWithSizeMethod", xpt.Param(xpt.SimpleType(xpt.Type.Tags.void)),
00295                                     params=[
00296                                         xpt.Param(xpt.StringWithSizeType(
00297                                             1, 2)),
00298                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00299                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00300                                         xpt.Param(xpt.WideStringWithSizeType(
00301                                             4, 5)),
00302                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00303                                         xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
00304                                         ]))
00305         self.checkRoundtrip(t)

Here is the call graph for this function:

Test that an interface's parent property is correctly serialized
and deserialized.

Definition at line 198 of file runtests.py.

00198 
00199     def test_parent(self):
00200         """
00201         Test that an interface's parent property is correctly serialized
00202         and deserialized.
00203 
00204         """
00205         t = xpt.Typelib()
00206         pi = xpt.Interface("IParent")
00207         t.interfaces.append(pi)
00208         t.interfaces.append(xpt.Interface("IChild", iid="11223344-5566-7788-9900-aabbccddeeff",
00209                                           parent=pi, resolved=True))
00210         self.checkRoundtrip(t)

Here is the call graph for this function:

Definition at line 187 of file runtests.py.

00187 
00188     def test_simple(self):
00189         t = xpt.Typelib()
00190         # add an unresolved interface
00191         t.interfaces.append(xpt.Interface("IFoo"))
00192         self.checkRoundtrip(t)
00193         
00194         t = xpt.Typelib()
00195         # add an unresolved interface with an IID
00196         t.interfaces.append(xpt.Interface("IBar", "11223344-5566-7788-9900-aabbccddeeff"))
00197         self.checkRoundtrip(t)

Here is the call graph for this function:


The documentation for this class was generated from the following file: