Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
TestFactory.cpp File Reference
#include <stdio.h>
#include "TestFactory.h"
#include "nsISupports.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"

Go to the source code of this file.

Classes

class  TestClassImpl
 ITestClass implementation. More...
class  TestFactory
 TestFactory implementation. More...

Functions

 NS_DEFINE_CID (kTestFactoryCID, NS_TESTFACTORY_CID)
 NS_DEFINE_CID (kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID)
int main (int argc, char **argv)
 The Xalan testcases app.

Function Documentation

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 113 of file TestFactory.cpp.

                                {
  nsresult rv;

  {
    nsCOMPtr<nsIServiceManager> servMan;
    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
    if (NS_FAILED(rv)) return -1;
    nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
    NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
    if (registrar)
      registrar->RegisterFactory(kTestFactoryCID,
                                 nsnull,
                                 nsnull,
                                 new TestFactory());

    ITestClass *t = NULL;
    CallCreateInstance(kTestFactoryCID, &t);

    if (t != NULL) {
      t->Test();
      t->Release();
    } else {
      printf("CreateInstance failed\n");
    }

    t = NULL;

    CallCreateInstance(kTestLoadedFactoryCID, &t);

    if (t != NULL) {
      t->Test();
      t->Release();
    } else {
      printf("Dynamic CreateInstance failed\n");
    }
  } // this scopes the nsCOMPtrs
  // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
  rv = NS_ShutdownXPCOM(nsnull);
  NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
  return 0;
}

Here is the call graph for this function:

NS_DEFINE_CID ( kTestFactoryCID  ,
NS_TESTFACTORY_CID   
)
NS_DEFINE_CID ( kTestLoadedFactoryCID  ,
NS_TESTLOADEDFACTORY_CID   
)