From c8bbca3c41e5afc2545bf820729ffbe2c7ee3732 Mon Sep 17 00:00:00 2001 From: "pedemont@us.ibm.com" Date: Fri, 15 Oct 2004 21:55:14 +0000 Subject: [PATCH] Update to new method names and QI impl. Add deleting array test. --- extensions/java/xpcom/tests/Foo.java | 9 ++------- extensions/java/xpcom/tests/TestArray.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/extensions/java/xpcom/tests/Foo.java b/extensions/java/xpcom/tests/Foo.java index fe87e119573f..7255d1821cf1 100644 --- a/extensions/java/xpcom/tests/Foo.java +++ b/extensions/java/xpcom/tests/Foo.java @@ -51,14 +51,9 @@ public class Foo implements IFoo { } // nsISupports implementation - public nsISupports queryInterface(String riid) + public nsISupports queryInterface(String aIID) { - Class[] interfaces = this.getClass().getInterfaces(); - for (int i = 0; i < interfaces.length; i++ ) { - if (riid.equals(XPCOM.getInterfaceIID(interfaces[i]))) - return this; - } - return null; + return XPCOM.queryInterface(this, aIID); } // IFoo implementation diff --git a/extensions/java/xpcom/tests/TestArray.java b/extensions/java/xpcom/tests/TestArray.java index 694320e9766f..fb7c9cd9562e 100644 --- a/extensions/java/xpcom/tests/TestArray.java +++ b/extensions/java/xpcom/tests/TestArray.java @@ -60,6 +60,8 @@ import org.mozilla.xpcom.*; */ public class TestArray { + public static final String NS_ARRAY_CID = "@mozilla.org/array;1"; + public static void main(String [] args) { System.loadLibrary("javaxpcom"); @@ -68,10 +70,11 @@ public class TestArray { throw new RuntimeException("MOZILLA_FIVE_HOME system property not set."); } - nsILocalFile localFile = GeckoEmbed.NS_NewLocalFile(mozillaPath, true); - GeckoEmbed.NS_InitEmbedding(localFile, null); + nsILocalFile localFile = GeckoEmbed.newLocalFile(mozillaPath, true); + GeckoEmbed.initEmbedding(localFile, null); - nsIMutableArray array = GeckoEmbed.NS_NewArray(); + nsIComponentManager componentManager = GeckoEmbed.getComponentManager(); + nsIMutableArray array = (nsIMutableArray) componentManager.createInstanceByContractID(NS_ARRAY_CID, null, nsIMutableArray.NS_IMUTABLEARRAY_IID); if (array == null) { throw new RuntimeException("Failed to create nsIMutableArray."); } @@ -157,7 +160,14 @@ public class TestArray { fillArray(array, 4); dumpArray(array, 4, fillResult, 4); - GeckoEmbed.NS_TermEmbedding(); + // test deleting of array + System.out.println("release array:"); + array = null; + System.gc(); + + componentManager = null; + System.gc(); + GeckoEmbed.termEmbedding(); System.out.println("Test Passed."); }