/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
MozExternalRefCountType nsTestCom::Release() {
nsrefcnt res = --mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsTestCom"); if (res == 0) { deletethis;
} return res;
}
TEST(TestCOM, WindowsInterop)
{ // Test that we can QI an nsITestCom to an IUnknown.
RefPtr<nsTestCom> t = new nsTestCom();
IUnknown* iUnknown = nullptr;
nsresult rv = t->QueryInterface(NS_GET_IID(nsISupports), (void**)&iUnknown);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_TRUE(iUnknown);
// Test we can QI an IUnknown to nsITestCom.
nsCOMPtr<nsITestCom> iTestCom;
GUID testGUID = NS_ITEST_COM_IID;
HRESULT hr = iUnknown->QueryInterface(testGUID, getter_AddRefs(iTestCom));
ASSERT_TRUE(SUCCEEDED(hr));
ASSERT_TRUE(iTestCom);
// Make sure we can call our test function (and the pointer is valid).
rv = iTestCom->Test();
ASSERT_NS_SUCCEEDED(rv);
iUnknown->Release();
iTestCom = nullptr;
t = nullptr;
ASSERT_EQ(nsTestCom::sDestructions, 1);
}
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.