public void CreateInstance_CreatingSecureBrowser_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsISecureBrowserUI>("@mozilla.org/secure_browser_ui;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingSupportsId_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsISupportsID>("@mozilla.org/supports-id;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void IsOperatorRefCounterTest()
        {
            // operator is is increment com ref count - but RCW cleanup free's both references.
            // (This is a change from .net 3.5 -> 4.0)
            var item1 = Xpcom.CreateInstance <nsISupports>(Contracts.Array);
            var ptr   = Marshal.GetIUnknownForObject(item1);

            Marshal.Release(ptr);

            int comCount1 = ComDebug.GetComRefCount(item1);
            int rcwCount1 = ComDebug.GetRcwRefCount(item1);

            bool test = item1 is nsIArray;

            int comCount2 = ComDebug.GetComRefCount(item1);
            int rcwCount2 = ComDebug.GetRcwRefCount(item1);

            Marshal.AddRef(ptr);
            int free = Marshal.ReleaseComObject(item1);

            Assert.AreEqual(0, Marshal.Release(ptr), "Releasing the RCW by ReleaseComObject should have called Release twice.");

            Assert.AreEqual(1, comCount2 - comCount1);
            Assert.AreEqual(0, rcwCount2 - rcwCount1);
            Assert.AreEqual(0, free);
        }
        public void CreateInstance_CreatingArray_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIArray>("@mozilla.org/array;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingIoUtil_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIIOUtil>("@mozilla.org/io-util;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingDirectoryService_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIDirectoryService>("@mozilla.org/file/directory_service;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingCategoryManager_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsICategoryManager>("@mozilla.org/categorymanager;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingASN1Tree_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIASN1Tree>("@mozilla.org/security/nsASN1Tree;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingCertificateDialogs_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsICertificateDialogs>("@mozilla.org/nsCertificateDialogs;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingDirIndexParser_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIDirIndexParser>("@mozilla.org/dirIndexParser;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingSaxParserXmlReader_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsISAXXMLReader>("@mozilla.org/saxparser/xmlreader;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingTxtToHtmlConv_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <mozITXTToHTMLConv>("@mozilla.org/txttohtmlconv;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingCookiePermission_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsICookiePermission>("@mozilla.org/cookie/permission;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingMimeInpurtStream_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIMIMEInputStream>("@mozilla.org/network/mime-input-stream;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingVersionComparator_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIVersionComparator>("@mozilla.org/xpcom/version-comparator;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingSystemInfo_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsISupports>("@mozilla.org/system-info;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingSystemPrincipal_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIPrincipal>("@mozilla.org/systemprincipal;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingUserInfo_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIUserInfo>("@mozilla.org/userinfo;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingFileLocal_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsISupports>("@mozilla.org/file/local;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingAppShellComponentBrowserStatusFilter_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsISupports>("@mozilla.org/appshell/component/browser-status-filter;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingProperties_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIProperties>("@mozilla.org/properties;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingCrashReporter_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsICrashReporter>("@mozilla.org/toolkit/crash-reporter;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingObserverService_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIObserverService>("@mozilla.org/observer-service;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingUriLoader_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIURILoader>("@mozilla.org/uriloader;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingCycleCollector_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsICycleCollectorListener>("@mozilla.org/cycle-collector-logger;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void CreateInstance_CreatingExternalHelperAppService_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIExternalHelperAppService>("@mozilla.org/uriloader/external-helper-app-service;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
        public void QueryInterfaceRefCounterTest()
        {
            var item1 = Xpcom.CreateInstance <nsISupports>(Contracts.Array);
            var ptr   = Marshal.GetIUnknownForObject(item1);

            Marshal.Release(ptr);

            int comCount1 = ComDebug.GetComRefCount(item1);
            int rcwCount1 = ComDebug.GetRcwRefCount(item1);

            var item2 = Xpcom.QueryInterface <nsIArray>(item1);

            int comCount2 = ComDebug.GetComRefCount(item2);
            int rcwCount2 = ComDebug.GetRcwRefCount(item2);

            Marshal.AddRef(ptr);
            int free1 = Marshal.ReleaseComObject(item2);
            int free2 = Marshal.ReleaseComObject(item1);

            Assert.AreEqual(0, Marshal.Release(ptr));


            Assert.AreEqual(1, comCount2 - comCount1);
            Assert.AreEqual(1, rcwCount2 - rcwCount1);
            Assert.AreEqual(1, free1);
            Assert.AreEqual(0, free2);
        }
        public void CreateInstance_CreatingUuidGenerator_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <nsIUUIDGenerator>("@mozilla.org/uuid-generator;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }
Beispiel #29
0
        static nsILocalFile toNsFile(string file)
        {
            var nsfile = Xpcom.CreateInstance <nsILocalFile>("@mozilla.org/file/local;1");

            nsfile.InitWithPath(new nsAString(file));
            return(nsfile);
        }
        public void CreateInstance_CreatingThirdPartyUtil_ReturnsValidInstance()
        {
            var instance = Xpcom.CreateInstance <mozIThirdPartyUtil>("@mozilla.org/thirdpartyutil;1");

            Assert.IsNotNull(instance);
            Marshal.ReleaseComObject(instance);
        }