mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-15 20:25:12 +01:00
GLib tests: Add test for g_win32_clear_com()
This mimicks the test for g_clear_object() in gobject/tests/reference.c. We use the system's wincodec library for our sample here.
This commit is contained in:
parent
aff6b930a1
commit
5642331603
@ -246,7 +246,9 @@ if host_machine.system() == 'windows'
|
||||
}
|
||||
endif
|
||||
glib_tests += {
|
||||
'win32' : {},
|
||||
'win32' : {
|
||||
'dependencies' : [wincodecs],
|
||||
},
|
||||
}
|
||||
else
|
||||
glib_tests += {
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define COBJMACROS
|
||||
#include <wincodec.h>
|
||||
|
||||
static char *argv0 = NULL;
|
||||
|
||||
#include "../gwin32-private.c"
|
||||
@ -154,6 +157,27 @@ veh_debugger (int argc, char *argv[])
|
||||
g_fprintf (stderr, "Debugger invoked, attaching to %lu and signalling %" G_GUINTPTR_FORMAT, pid, event);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_com (void)
|
||||
{
|
||||
IWICImagingFactory *o = NULL;
|
||||
IWICImagingFactory *tmp;
|
||||
|
||||
CoInitialize (NULL);
|
||||
g_win32_clear_com (&o);
|
||||
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 */
|
||||
g_assert_nonnull (o);
|
||||
g_assert_cmpint (IWICImagingFactory_AddRef (o), ==, 3); /* refcount incremented again */
|
||||
g_win32_clear_com (&o);
|
||||
g_assert_null (o);
|
||||
IWICImagingFactory_Release (tmp);
|
||||
|
||||
CoUninitialize ();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
@ -177,6 +201,7 @@ main (int argc,
|
||||
g_test_add_func ("/win32/subprocess/debuggee", test_veh_debuggee);
|
||||
g_test_add_func ("/win32/subprocess/access_violation", test_access_violation);
|
||||
g_test_add_func ("/win32/subprocess/illegal_instruction", test_illegal_instruction);
|
||||
g_test_add_func ("/win32/com/clear", test_clear_com);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
@ -2338,8 +2338,11 @@ endif
|
||||
|
||||
if host_system == 'windows'
|
||||
winsock2 = cc.find_library('ws2_32')
|
||||
# Used for g_win32_clear_com() tests...
|
||||
wincodecs = cc.find_library('windowscodecs')
|
||||
else
|
||||
winsock2 = not_found
|
||||
wincodecs = not_found
|
||||
endif
|
||||
|
||||
selinux_dep = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user