mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
tests: Add more tests for COM refcounts
As suggested by Luca Bacci, so that we keep track of things more clearly in terms of COM.
This commit is contained in:
parent
4ab7977a4d
commit
2af6baad08
@ -548,12 +548,14 @@ test_clear_com (void)
|
||||
g_assert_null (o);
|
||||
g_assert_true (SUCCEEDED (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (void **)&tmp)));
|
||||
g_assert_nonnull (tmp);
|
||||
tmp->QueryInterface (IID_IWICImagingFactory, (void **)&o); /* IWICImagingFactory::QueryInterface increments the refcount */
|
||||
tmp->QueryInterface (IID_IWICImagingFactory, (void **)&o); /* IWICImagingFactory::QueryInterface increments tmp's refcount */
|
||||
g_assert_nonnull (o);
|
||||
g_assert_cmpint (o->AddRef (), ==, 3); /* refcount incremented again */
|
||||
g_win32_clear_com (&o);
|
||||
g_assert_cmpint (tmp->AddRef (), ==, 3); /* tmp's refcount incremented again */
|
||||
g_win32_clear_com (&o); /* tmp's refcount gets decremented */
|
||||
g_assert_null (o);
|
||||
tmp->Release ();
|
||||
g_assert_cmpint (tmp->Release (), ==, 1); /* tmp's refcount gets decremented, again */
|
||||
g_win32_clear_com (&tmp);
|
||||
g_assert_null (tmp);
|
||||
|
||||
CoUninitialize ();
|
||||
}
|
||||
|
@ -168,12 +168,14 @@ test_clear_com (void)
|
||||
g_assert_null (o);
|
||||
g_assert_true (SUCCEEDED (CoCreateInstance (&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void **)&tmp)));
|
||||
g_assert_nonnull (tmp);
|
||||
IWICImagingFactory_QueryInterface (tmp, &IID_IWICImagingFactory, (void **)&o); /* IWICImagingFactory_QueryInterface increments the refcount */
|
||||
IWICImagingFactory_QueryInterface (tmp, &IID_IWICImagingFactory, (void **)&o); /* IWICImagingFactory_QueryInterface increments tmp's refcount */
|
||||
g_assert_nonnull (o);
|
||||
g_assert_cmpint (IWICImagingFactory_AddRef (o), ==, 3); /* refcount incremented again */
|
||||
g_win32_clear_com (&o);
|
||||
g_assert_cmpint (IWICImagingFactory_AddRef (tmp), ==, 3); /* tmp's refcount incremented, again */
|
||||
g_win32_clear_com (&o); /* tmp's refcount decrements */
|
||||
g_assert_null (o);
|
||||
IWICImagingFactory_Release (tmp);
|
||||
g_assert_cmpint (IWICImagingFactory_Release (tmp), ==, 1); /* tmp's refcount decrements, again */
|
||||
g_win32_clear_com (&tmp);
|
||||
g_assert_null (tmp);
|
||||
|
||||
CoUninitialize ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user