Back to index

lightning-sunbird  0.9+nobinonly
Functions
test_components Namespace Reference

Functions

def test_interfaces
def test_classes
def test_id

Function Documentation

Definition at line 70 of file test_components.py.

00070 
00071 def test_classes():
00072     # Need a well-known contractID here?
00073     prog_id = "@mozilla.org/supports-array;1"
00074     clsid = xpcom.components.ID("{bda17d50-0d6b-11d3-9331-00104ba0fd40}")
00075 
00076     # Check we can create the instance (dont check we can do anything with it tho!)
00077     klass = xpcom.components.classes[prog_id]
00078     instance = klass.createInstance()
00079     
00080     # Test dictionary semantics
00081     num_fetched = num_mine = 0
00082     for name, klass in xpcom.components.classes.items():
00083         num_fetched = num_fetched + 1
00084         if name == prog_id:
00085             if klass.clsid != clsid:
00086                 print "Eeek - didn't get the correct IID - got", klass.clsid
00087             num_mine = num_mine + 1
00088 
00089 # xpcom appears to add charset info to the contractid!?         
00090 #        assert xpcom.components.classes[name].contractid == prog_id, "Expected '%s', got '%s'" % (prog_id, xpcom.components.classes[name].contractid)
00091     # Check all the lengths match.
00092     if len(xpcom.components.classes.keys()) == len(xpcom.components.classes.values()) == \
00093                len(xpcom.components.classes.items()) == len(xpcom.components.classes) == \
00094                num_fetched:
00095         pass
00096     else:
00097         raise RuntimeError, "The collection lengths were wrong"
00098     if num_fetched <= 0:
00099         raise RuntimeError, "Didnt get any classes!!!"
00100     if num_mine != 1:
00101         raise RuntimeError, "Didnt find exactly 1 of my contractid! (%d)" % (num_mine,)
00102     print "The classes object appeared to work!"
    

Here is the caller graph for this function:

Definition at line 103 of file test_components.py.

00103 
00104 def test_id():
00105     id = xpcom.components.ID(str(xpcom._xpcom.IID_nsISupports))
00106     assert id == xpcom._xpcom.IID_nsISupports
00107     print "The ID function appeared to work!"
00108     
00109 
00110 # regrtest doesnt like if __name__=='__main__' blocks - it fails when running as a test!
00111 test_interfaces()
00112 test_classes()
00113 test_id()

Here is the call graph for this function:

Definition at line 46 of file test_components.py.

00046 
00047 def test_interfaces():
00048     "Test the xpcom.components.interfaces object"
00049 
00050     iid = xpcom.components.interfaces.nsISupports
00051     assert iid == xpcom._xpcom.IID_nsISupports, "Got the wrong IID!"
00052     iid = xpcom.components.interfaces['nsISupports']
00053     assert iid == xpcom._xpcom.IID_nsISupports, "Got the wrong IID!"
00054     
00055     # Test dictionary semantics
00056     num_fetched = num_nsisupports = 0
00057     for name, iid in xpcom.components.interfaces.items():
00058         num_fetched = num_fetched + 1
00059         if name == "nsISupports":
00060             num_nsisupports = num_nsisupports + 1
00061             assert iid == xpcom._xpcom.IID_nsISupports, "Got the wrong IID!"
00062         assert xpcom.components.interfaces[name] == iid
00063     # Check all the lengths match.
00064     assert len(xpcom.components.interfaces.keys()) == len(xpcom.components.interfaces.values()) == \
00065                len(xpcom.components.interfaces.items()) == len(xpcom.components.interfaces) == \
00066                num_fetched, "The collection lengths were wrong"
00067     if num_nsisupports != 1:
00068         print "Didnt find exactly 1 nsiSupports!"
00069     print "The interfaces object appeared to work!"

Here is the caller graph for this function: