Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
TestQI Class Reference

Simple test for the XPCOM.queryInterface method. More...

List of all members.

Static Public Member Functions

static void main (String[] args) throws Exception

Detailed Description

Simple test for the XPCOM.queryInterface method.

It should be able to QI any interfaces implemented by the given object or its superclass (and so on up the inheritance chain).

See also:
XPCOM::queryInterface

Definition at line 51 of file TestQI.java.


Member Function Documentation

static void TestQI.main ( String[]  args) throws Exception [inline, static]

Definition at line 53 of file TestQI.java.

                                                           {
    System.loadLibrary("javaxpcom");

    String mozillaPath = System.getProperty("MOZILLA_FIVE_HOME");
    if (mozillaPath == null) {
      throw new RuntimeException("MOZILLA_FIVE_HOME system property not set.");
    }

    File localFile = new File(mozillaPath);
    XPCOM.initXPCOM(localFile, null);

    FooFile foo = new FooFile();

    nsIFileURL fileURL = (nsIFileURL) foo.queryInterface(nsIFileURL.NS_IFILEURL_IID);
    if (fileURL == null) {
      throw new RuntimeException("Failed to QI to nsIFileURL.");
    }

    nsIURL url = (nsIURL) foo.queryInterface(nsIURL.NS_IURL_IID);
    if (url == null) {
      throw new RuntimeException("Failed to QI to nsIURL.");
    }

    nsIURI uri = (nsIURI) foo.queryInterface(nsIURI.NS_IURI_IID);
    if (uri == null) {
      throw new RuntimeException("Failed to QI to nsIURI.");
    }

    nsISupports supp = (nsISupports) foo.queryInterface(nsISupports.NS_ISUPPORTS_IID);
    if (supp == null) {
      throw new RuntimeException("Failed to QI to nsISupports.");
    }

    XPCOM.shutdownXPCOM(null);

    System.out.println("Test Passed.");
  }

Here is the call graph for this function:


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