Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
test_isupports_primitives Namespace Reference

Classes

class  NoSupportsString
class  ImplicitSupportsString
class  ExplicitSupportsString
class  ImplicitSupportsInt
class  ExplicitSupportsInt
class  ImplicitSupportsLong
class  ExplicitSupportsLong
class  ExplicitSupportsFloat
class  ImplicitSupportsFloat

Functions

def test

Function Documentation

Definition at line 93 of file test_isupports_primitives.py.

00093 
00094 def test():
00095     import xpcom.server, xpcom.client
00096     ob = xpcom.server.WrapObject( NoSupportsString(), components.interfaces.nsISupports)
00097     if not str(ob).startswith("<XPCOM "):
00098         raise RuntimeError, "Wrong str() value: %s" % (ob,)
00099 
00100     ob = xpcom.server.WrapObject( ImplicitSupportsString(), components.interfaces.nsISupports)
00101     if str(ob) != "<MyImplicitStrObject>":
00102         raise RuntimeError, "Wrong str() value: %s" % (ob,)
00103 
00104     ob = xpcom.server.WrapObject( ExplicitSupportsString(), components.interfaces.nsISupports)
00105     if str(ob) != "<MyExplicitStrObject>":
00106         raise RuntimeError, "Wrong str() value: %s" % (ob,)
00107 
00108     # Try our conversions.
00109     try:
00110         int(ob)
00111         raise RuntimeError, "Expected to get a ValueError converting this COM object to an int"
00112     except ValueError:
00113         pass
00114     ob = xpcom.server.WrapObject( ExplicitSupportsInt(), components.interfaces.nsISupports)
00115     if int(ob) != 99:
00116         raise RuntimeError, "Bad value: %s" % (int(ob),)
00117     if float(ob) != 99.0:
00118         raise RuntimeError, "Bad value: %s" % (float(ob),)
00119 
00120     ob = xpcom.server.WrapObject( ImplicitSupportsInt(), components.interfaces.nsISupports)
00121     if int(ob) != 99:
00122         raise RuntimeError, "Bad value: %s" % (int(ob),)
00123     if float(ob) != 99.0:
00124         raise RuntimeError, "Bad value: %s" % (float(ob),)
00125 
00126     ob = xpcom.server.WrapObject( ExplicitSupportsLong(), components.interfaces.nsISupports)
00127     if long(ob) != 99 or not repr(long(ob)).endswith("L"):
00128         raise RuntimeError, "Bad value: %s" % (repr(long(ob)),)
00129     if float(ob) != 99.0:
00130         raise RuntimeError, "Bad value: %s" % (float(ob),)
00131 
00132     ob = xpcom.server.WrapObject( ImplicitSupportsLong(), components.interfaces.nsISupports)
00133     if long(ob) != 99 or not repr(long(ob)).endswith("L"):
00134         raise RuntimeError, "Bad value: %s" % (repr(long(ob)),)
00135     if float(ob) != 99.0:
00136         raise RuntimeError, "Bad value: %s" % (float(ob),)
00137 
00138     ob = xpcom.server.WrapObject( ExplicitSupportsFloat(), components.interfaces.nsISupports)
00139     if float(ob) != 99.99:
00140         raise RuntimeError, "Bad value: %s" % (float(ob),)
00141     if int(ob) != 99:
00142         raise RuntimeError, "Bad value: %s" % (int(ob),)
00143 
00144     ob = xpcom.server.WrapObject( ImplicitSupportsFloat(), components.interfaces.nsISupports)
00145     if float(ob) != 99.99:
00146         raise RuntimeError, "Bad value: %s" % (float(ob),)
00147     if int(ob) != 99:
00148         raise RuntimeError, "Bad value: %s" % (int(ob),)
00149 
00150     print "The nsISupports primitive interface tests appeared to work"
00151 test()

Here is the call graph for this function: