mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-16 12:45:13 +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
|
endif
|
||||||
glib_tests += {
|
glib_tests += {
|
||||||
'win32' : {},
|
'win32' : {
|
||||||
|
'dependencies' : [wincodecs],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glib_tests += {
|
glib_tests += {
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define COBJMACROS
|
||||||
|
#include <wincodec.h>
|
||||||
|
|
||||||
static char *argv0 = NULL;
|
static char *argv0 = NULL;
|
||||||
|
|
||||||
#include "../gwin32-private.c"
|
#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);
|
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
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
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/debuggee", test_veh_debuggee);
|
||||||
g_test_add_func ("/win32/subprocess/access_violation", test_access_violation);
|
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/subprocess/illegal_instruction", test_illegal_instruction);
|
||||||
|
g_test_add_func ("/win32/com/clear", test_clear_com);
|
||||||
|
|
||||||
return g_test_run();
|
return g_test_run();
|
||||||
}
|
}
|
||||||
|
@ -2338,8 +2338,11 @@ endif
|
|||||||
|
|
||||||
if host_system == 'windows'
|
if host_system == 'windows'
|
||||||
winsock2 = cc.find_library('ws2_32')
|
winsock2 = cc.find_library('ws2_32')
|
||||||
|
# Used for g_win32_clear_com() tests...
|
||||||
|
wincodecs = cc.find_library('windowscodecs')
|
||||||
else
|
else
|
||||||
winsock2 = not_found
|
winsock2 = not_found
|
||||||
|
wincodecs = not_found
|
||||||
endif
|
endif
|
||||||
|
|
||||||
selinux_dep = []
|
selinux_dep = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user