michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim:cindent:ts=8:et:sw=4: michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * This test is NOT intended to be run. It's a test to make sure michael@0: * a group of functions BUILD correctly. michael@0: */ michael@0: michael@0: #include "nsISupportsUtils.h" michael@0: #include "nsIWeakReference.h" michael@0: #include "nsIComponentManager.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsIInterfaceRequestor.h" michael@0: #include "nsIInterfaceRequestorUtils.h" michael@0: #include "nsComponentManagerUtils.h" michael@0: #include "nsServiceManagerUtils.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: #define NS_ITESTSERVICE_IID \ michael@0: {0x127b5253, 0x37b1, 0x43c7, \ michael@0: { 0x96, 0x2b, 0xab, 0xf1, 0x2d, 0x22, 0x56, 0xae }} michael@0: michael@0: class NS_NO_VTABLE nsITestService : public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITESTSERVICE_IID) michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsITestService, NS_ITESTSERVICE_IID) michael@0: michael@0: class nsTestService MOZ_FINAL : public nsITestService, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: }; michael@0: michael@0: NS_IMPL_ISUPPORTS(nsTestService, nsITestService, nsISupportsWeakReference) michael@0: michael@0: #define NS_TEST_SERVICE_CONTRACTID "@mozilla.org/test/testservice;1" michael@0: #define NS_TEST_SERVICE_CID \ michael@0: {0xa00c1406, 0x283a, 0x45c9, \ michael@0: {0xae, 0xd2, 0x1a, 0xb6, 0xdd, 0xba, 0xfe, 0x53}} michael@0: static NS_DEFINE_CID(kTestServiceCID, NS_TEST_SERVICE_CID); michael@0: michael@0: int main() michael@0: { michael@0: /* michael@0: * NOTE: This does NOT demonstrate how these functions are michael@0: * intended to be used. They are intended for filling in out michael@0: * parameters that need to be |AddRef|ed. I'm just too lazy michael@0: * to write lots of little getter functions for a test program michael@0: * when I don't need to. michael@0: */ michael@0: michael@0: NS_NOTREACHED("This test is not intended to run, only to compile!"); michael@0: michael@0: /* Test CallQueryInterface */ michael@0: michael@0: nsISupports *mySupportsPtr = reinterpret_cast(0x1000); michael@0: michael@0: nsITestService *myITestService = nullptr; michael@0: CallQueryInterface(mySupportsPtr, &myITestService); michael@0: michael@0: nsTestService *myTestService = michael@0: reinterpret_cast(mySupportsPtr); michael@0: nsISupportsWeakReference *mySupportsWeakRef; michael@0: CallQueryInterface(myTestService, &mySupportsWeakRef); michael@0: michael@0: nsCOMPtr mySupportsCOMPtr = mySupportsPtr; michael@0: CallQueryInterface(mySupportsCOMPtr, &myITestService); michael@0: michael@0: nsRefPtr myTestServiceRefPtr = myTestService; michael@0: CallQueryInterface(myTestServiceRefPtr, &mySupportsWeakRef); michael@0: michael@0: /* Test CallQueryReferent */ michael@0: michael@0: nsIWeakReference *myWeakRef = michael@0: static_cast(mySupportsPtr); michael@0: CallQueryReferent(myWeakRef, &myITestService); michael@0: michael@0: /* Test CallCreateInstance */ michael@0: michael@0: CallCreateInstance(kTestServiceCID, mySupportsPtr, &myITestService); michael@0: CallCreateInstance(kTestServiceCID, &myITestService); michael@0: CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, mySupportsPtr, michael@0: &myITestService); michael@0: CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, &myITestService); michael@0: michael@0: /* Test CallGetService */ michael@0: CallGetService(kTestServiceCID, &myITestService); michael@0: CallGetService(NS_TEST_SERVICE_CONTRACTID, &myITestService); michael@0: michael@0: /* Test CallGetInterface */ michael@0: nsIInterfaceRequestor *myInterfaceRequestor = michael@0: static_cast(mySupportsPtr); michael@0: CallGetInterface(myInterfaceRequestor, &myITestService); michael@0: michael@0: return 0; michael@0: }