mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-23 18:37:50 +02:00
build
docs
gio
completion
fam
gdbus-2.0
gvdb
inotify
kqueue
tests
cert-tests
de
desktop-files
gdbus-object-manager-example
modules
schema-tests
services
thumbnails
x-content
.gitignore
Makefile.am
actions.c
appinfo-test-actions.desktop
appinfo-test-gnome.desktop
appinfo-test-notgnome.desktop
appinfo-test.c
appinfo-test.desktop
appinfo-test2.desktop
appinfo.c
appmonitor.c
apps.c
async-close-output-stream.c
async-splice-output-stream.c
autoptr.c
basic-application.c
buffered-input-stream.c
buffered-output-stream.c
cancellable.c
contenttype.c
contexts.c
converter-stream.c
credentials.c
data-input-stream.c
data-output-stream.c
dbus-appinfo.c
dbus-launch.c
de.po
defaultvalue.c
desktop-app-info.c
echo-server.c
enums.xml.template
file.c
fileattributematcher.c
filter-cat.c
filter-streams.c
g-file-info-filesystem-readonly.c
g-file-info.c
g-file.c
g-icon.c
gapplication-example-actions.c
gapplication-example-cmdline.c
gapplication-example-cmdline2.c
gapplication-example-cmdline3.c
gapplication-example-dbushooks.c
gapplication-example-open.c
gapplication.c
gdbus-addresses.c
gdbus-auth.c
gdbus-bz627724.c
gdbus-close-pending.c
gdbus-connection-flush-helper.c
gdbus-connection-flush.c
gdbus-connection-loss.c
gdbus-connection-slow.c
gdbus-connection.c
gdbus-daemon.c
gdbus-error.c
gdbus-example-export.c
gdbus-example-objectmanager-client.c
gdbus-example-objectmanager-server.c
gdbus-example-own-name.c
gdbus-example-peer.c
gdbus-example-proxy-subclass.c
gdbus-example-server.c
gdbus-example-subtree.c
gdbus-example-unix-fd-client.c
gdbus-example-watch-name.c
gdbus-example-watch-proxy.c
gdbus-exit-on-close.c
gdbus-export.c
gdbus-introspection.c
gdbus-message.c
gdbus-names.c
gdbus-non-socket.c
gdbus-overflow.c
gdbus-peer-object-manager.c
gdbus-peer.c
gdbus-proxy-threads.c
gdbus-proxy-well-known-name.c
gdbus-proxy.c
gdbus-serialization.c
gdbus-sessionbus.c
gdbus-sessionbus.h
gdbus-test-codegen.c
gdbus-test-fixture.c
gdbus-tests.c
gdbus-tests.h
gdbus-testserver.c
gdbus-threading.c
gdbus-unix-addresses.c
gengiotypefuncs.py
gio-du.c
giomodule.c
glistmodel.c
gmenumodel.c
gnotification-server.c
gnotification-server.h
gnotification.c
gschema-compile.c
gsettings.c
gsubprocess-testprog.c
gsubprocess.c
gtesttlsbackend.c
gtesttlsbackend.h
gtlsconsoleinteraction.c
gtlsconsoleinteraction.h
httpd.c
inet-address.c
io-stream.c
live-g-file.c
live-g-file.txt
memory-input-stream.c
memory-output-stream.c
meson.build
mimeapps.c
monitor.c
network-address.c
network-monitor.c
org.gtk.schemasourcecheck.gschema.xml
org.gtk.test.dbusappinfo.desktop
org.gtk.test.gschema.xml.orig
permission.c
pollable.c
proxy-test.c
proxy.c
readwrite.c
resolver.c
resourceplugin.c
resources.c
send-data.c
simple-async-result.c
simple-proxy.c
sleepy-stream.c
socket-address.c
socket-client.c
socket-common.c
socket-listener.c
socket-server.c
socket-service.c
socket.c
srvtarget.c
stream-rw_all.c
task.c
test-codegen.xml
test-io-stream.c
test-io-stream.h
test-pipe-unix.c
test-pipe-unix.h
test.gresource.xml
test1.txt
test2.gresource.xml
test2.txt
test3.gresource.xml
test3.txt
test4.gresource.xml
testenum.h
testfilemonitor.c
thumbnail-verification.c
tls-certificate.c
tls-interaction.c
unix-fd.c
unix-mounts.c
unix-streams.c
vfs.c
volumemonitor.c
win32-streams.c
win32
xdgmime
.gitignore
ChangeLog
Makefile.am
data-to-c.py
dbus-daemon.xml
gaction.c
gaction.h
gactiongroup.c
gactiongroup.h
gactiongroupexporter.c
gactiongroupexporter.h
gactionmap.c
gactionmap.h
gappinfo.c
gappinfo.h
gappinfoprivate.h
gapplication-tool.c
gapplication.c
gapplication.h
gapplicationcommandline.c
gapplicationcommandline.h
gapplicationimpl-dbus.c
gapplicationimpl.h
gasynchelper.c
gasynchelper.h
gasyncinitable.c
gasyncinitable.h
gasyncresult.c
gasyncresult.h
gbufferedinputstream.c
gbufferedinputstream.h
gbufferedoutputstream.c
gbufferedoutputstream.h
gbytesicon.c
gbytesicon.h
gcancellable.c
gcancellable.h
gcharsetconverter.c
gcharsetconverter.h
gcocoanotificationbackend.c
gcontenttype-win32.c
gcontenttype.c
gcontenttype.h
gcontenttypeprivate.h
gcontextspecificgroup.c
gcontextspecificgroup.h
gconverter.c
gconverter.h
gconverterinputstream.c
gconverterinputstream.h
gconverteroutputstream.c
gconverteroutputstream.h
gcredentials.c
gcredentials.h
gcredentialsprivate.h
gdatagrambased.c
gdatagrambased.h
gdatainputstream.c
gdatainputstream.h
gdataoutputstream.c
gdataoutputstream.h
gdbus-tool.c
gdbusactiongroup-private.h
gdbusactiongroup.c
gdbusactiongroup.h
gdbusaddress.c
gdbusaddress.h
gdbusauth.c
gdbusauth.h
gdbusauthmechanism.c
gdbusauthmechanism.h
gdbusauthmechanismanon.c
gdbusauthmechanismanon.h
gdbusauthmechanismexternal.c
gdbusauthmechanismexternal.h
gdbusauthmechanismsha1.c
gdbusauthmechanismsha1.h
gdbusauthobserver.c
gdbusauthobserver.h
gdbusconnection.c
gdbusconnection.h
gdbusdaemon.c
gdbusdaemon.h
gdbuserror.c
gdbuserror.h
gdbusinterface.c
gdbusinterface.h
gdbusinterfaceskeleton.c
gdbusinterfaceskeleton.h
gdbusintrospection.c
gdbusintrospection.h
gdbusmenumodel.c
gdbusmenumodel.h
gdbusmessage.c
gdbusmessage.h
gdbusmethodinvocation.c
gdbusmethodinvocation.h
gdbusnameowning.c
gdbusnameowning.h
gdbusnamewatching.c
gdbusnamewatching.h
gdbusobject.c
gdbusobject.h
gdbusobjectmanager.c
gdbusobjectmanager.h
gdbusobjectmanagerclient.c
gdbusobjectmanagerclient.h
gdbusobjectmanagerserver.c
gdbusobjectmanagerserver.h
gdbusobjectproxy.c
gdbusobjectproxy.h
gdbusobjectskeleton.c
gdbusobjectskeleton.h
gdbusprivate.c
gdbusprivate.h
gdbusproxy.c
gdbusproxy.h
gdbusserver.c
gdbusserver.h
gdbusutils.c
gdbusutils.h
gdelayedsettingsbackend.c
gdelayedsettingsbackend.h
gdesktopappinfo.c
gdesktopappinfo.h
gdocumentportal.c
gdocumentportal.h
gdrive.c
gdrive.h
gdtlsclientconnection.c
gdtlsclientconnection.h
gdtlsconnection.c
gdtlsconnection.h
gdtlsserverconnection.c
gdtlsserverconnection.h
gdummyfile.c
gdummyfile.h
gdummyproxyresolver.c
gdummyproxyresolver.h
gdummytlsbackend.c
gdummytlsbackend.h
gemblem.c
gemblem.h
gemblemedicon.c
gemblemedicon.h
gfdonotificationbackend.c
gfile.c
gfile.h
gfileattribute-priv.h
gfileattribute.c
gfileattribute.h
gfiledescriptorbased.c
gfiledescriptorbased.h
gfileenumerator.c
gfileenumerator.h
gfileicon.c
gfileicon.h
gfileinfo-priv.h
gfileinfo.c
gfileinfo.h
gfileinputstream.c
gfileinputstream.h
gfileiostream.c
gfileiostream.h
gfilemonitor.c
gfilemonitor.h
gfilenamecompleter.c
gfilenamecompleter.h
gfileoutputstream.c
gfileoutputstream.h
gfilterinputstream.c
gfilterinputstream.h
gfilteroutputstream.c
gfilteroutputstream.h
ggtknotificationbackend.c
ghttpproxy.c
ghttpproxy.h
gicon.c
gicon.h
ginetaddress.c
ginetaddress.h
ginetaddressmask.c
ginetaddressmask.h
ginetsocketaddress.c
ginetsocketaddress.h
ginitable.c
ginitable.h
ginputstream.c
ginputstream.h
gio-autocleanups.h
gio-querymodules.c
gio-tool-cat.c
gio-tool-copy.c
gio-tool-info.c
gio-tool-list.c
gio-tool-mime.c
gio-tool-mkdir.c
gio-tool-monitor.c
gio-tool-mount.c
gio-tool-move.c
gio-tool-open.c
gio-tool-remove.c
gio-tool-rename.c
gio-tool-save.c
gio-tool-set.c
gio-tool-trash.c
gio-tool-tree.c
gio-tool.c
gio-tool.h
gio.h
gio.rc.in
gio.stp.in
gio_probes.d
gio_trace.h
gioenums.h
gioenumtypes.c.template
gioenumtypes.h.template
gioerror.c
gioerror.h
giomodule-priv.h
giomodule.c
giomodule.h
gioprivate.h
gioscheduler.c
gioscheduler.h
giostream.c
giostream.h
giotypes.h
giowin32-priv.h
gkeyfilesettingsbackend.c
glib-compile-resources.c
glib-compile-schemas.c
glistmodel.c
glistmodel.h
gliststore.c
gliststore.h
gloadableicon.c
gloadableicon.h
glocalfile.c
glocalfile.h
glocalfileenumerator.c
glocalfileenumerator.h
glocalfileinfo.c
glocalfileinfo.h
glocalfileinputstream.c
glocalfileinputstream.h
glocalfileiostream.c
glocalfileiostream.h
glocalfilemonitor.c
glocalfilemonitor.h
glocalfileoutputstream.c
glocalfileoutputstream.h
glocalfileprivate.h
glocalvfs.c
glocalvfs.h
gmemoryinputstream.c
gmemoryinputstream.h
gmemoryoutputstream.c
gmemoryoutputstream.h
gmemorysettingsbackend.c
gmenu.c
gmenu.h
gmenuexporter.c
gmenuexporter.h
gmenumodel.c
gmenumodel.h
gmount.c
gmount.h
gmountoperation.c
gmountoperation.h
gmountprivate.h
gnativesocketaddress.c
gnativesocketaddress.h
gnativevolumemonitor.c
gnativevolumemonitor.h
gnetworkaddress.c
gnetworkaddress.h
gnetworking.c
gnetworking.h.in
gnetworking.h.win32
gnetworkingprivate.h
gnetworkmonitor.c
gnetworkmonitor.h
gnetworkmonitorbase.c
gnetworkmonitorbase.h
gnetworkmonitornetlink.c
gnetworkmonitornetlink.h
gnetworkmonitornm.c
gnetworkmonitornm.h
gnetworkmonitorportal.c
gnetworkmonitorportal.h
gnetworkservice.c
gnetworkservice.h
gnextstepsettingsbackend.c
gnotification-private.h
gnotification.c
gnotification.h
gnotificationbackend.c
gnotificationbackend.h
gnullsettingsbackend.c
gopenuriportal.c
gopenuriportal.h
gosxappinfo.c
gosxappinfo.h
gosxcontenttype.c
goutputstream.c
goutputstream.h
gpermission.c
gpermission.h
gpollableinputstream.c
gpollableinputstream.h
gpollableoutputstream.c
gpollableoutputstream.h
gpollableutils.c
gpollableutils.h
gpollfilemonitor.c
gpollfilemonitor.h
gportalnotificationbackend.c
gportalsupport.c
gportalsupport.h
gpropertyaction.c
gpropertyaction.h
gproxy.c
gproxy.h
gproxyaddress.c
gproxyaddress.h
gproxyaddressenumerator.c
gproxyaddressenumerator.h
gproxyresolver.c
gproxyresolver.h
gproxyresolverportal.c
gproxyresolverportal.h
gregistrysettingsbackend.c
gregistrysettingsbackend.h
gremoteactiongroup.c
gremoteactiongroup.h
gresolver.c
gresolver.h
gresource-tool.c
gresource.c
gresource.h
gresourcefile.c
gresourcefile.h
gschema.dtd
gschema.its
gschema.loc
gseekable.c
gseekable.h
gsettings-mapping.c
gsettings-mapping.h
gsettings-tool.c
gsettings.c
gsettings.h
gsettingsbackend.c
gsettingsbackend.h
gsettingsbackendinternal.h
gsettingsschema-internal.h
gsettingsschema.c
gsettingsschema.h
gsimpleaction.c
gsimpleaction.h
gsimpleactiongroup.c
gsimpleactiongroup.h
gsimpleasyncresult.c
gsimpleasyncresult.h
gsimpleiostream.c
gsimpleiostream.h
gsimplepermission.c
gsimplepermission.h
gsimpleproxyresolver.c
gsimpleproxyresolver.h
gsocket.c
gsocket.h
gsocketaddress.c
gsocketaddress.h
gsocketaddressenumerator.c
gsocketaddressenumerator.h
gsocketclient.c
gsocketclient.h
gsocketconnectable.c
gsocketconnectable.h
gsocketconnection.c
gsocketconnection.h
gsocketcontrolmessage.c
gsocketcontrolmessage.h
gsocketinputstream.c
gsocketinputstream.h
gsocketlistener.c
gsocketlistener.h
gsocketoutputstream.c
gsocketoutputstream.h
gsocketservice.c
gsocketservice.h
gsocks4aproxy.c
gsocks4aproxy.h
gsocks4proxy.c
gsocks4proxy.h
gsocks5proxy.c
gsocks5proxy.h
gsrvtarget.c
gsrvtarget.h
gsubprocess.c
gsubprocess.h
gsubprocesslauncher-private.h
gsubprocesslauncher.c
gsubprocesslauncher.h
gtask.c
gtask.h
gtcpconnection.c
gtcpconnection.h
gtcpwrapperconnection.c
gtcpwrapperconnection.h
gtestdbus.c
gtestdbus.h
gthemedicon.c
gthemedicon.h
gthreadedresolver.c
gthreadedresolver.h
gthreadedsocketservice.c
gthreadedsocketservice.h
gtlsbackend.c
gtlsbackend.h
gtlscertificate.c
gtlscertificate.h
gtlsclientconnection.c
gtlsclientconnection.h
gtlsconnection.c
gtlsconnection.h
gtlsdatabase.c
gtlsdatabase.h
gtlsfiledatabase.c
gtlsfiledatabase.h
gtlsinteraction.c
gtlsinteraction.h
gtlspassword.c
gtlspassword.h
gtlsserverconnection.c
gtlsserverconnection.h
gunionvolumemonitor.c
gunionvolumemonitor.h
gunixconnection.c
gunixconnection.h
gunixcredentialsmessage.c
gunixcredentialsmessage.h
gunixfdlist.c
gunixfdlist.h
gunixfdmessage.c
gunixfdmessage.h
gunixinputstream.c
gunixinputstream.h
gunixmount.c
gunixmount.h
gunixmounts.c
gunixmounts.h
gunixoutputstream.c
gunixoutputstream.h
gunixsocketaddress.c
gunixsocketaddress.h
gunixvolume.c
gunixvolume.h
gunixvolumemonitor.c
gunixvolumemonitor.h
gvfs.c
gvfs.h
gvolume.c
gvolume.h
gvolumemonitor.c
gvolumemonitor.h
gwin32appinfo.c
gwin32appinfo.h
gwin32inputstream.c
gwin32inputstream.h
gwin32mount.c
gwin32mount.h
gwin32networking.h
gwin32outputstream.c
gwin32outputstream.h
gwin32registrykey.c
gwin32registrykey.h
gwin32volumemonitor.c
gwin32volumemonitor.h
gzlibcompressor.c
gzlibcompressor.h
gzlibdecompressor.c
gzlibdecompressor.h
meson.build
org.freedesktop.portal.Documents.xml
org.freedesktop.portal.NetworkMonitor.xml
org.freedesktop.portal.OpenURI.xml
org.freedesktop.portal.ProxyResolver.xml
strinfo.c
thumbnail-verify.c
thumbnail-verify.h
glib
gmodule
gobject
gthread
m4macros
po
subprojects
tests
win32
.dir-locals.el
.gitattributes
.gitignore
AUTHORS
COPYING
ChangeLog.pre-1-2
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-14
ChangeLog.pre-2-16
ChangeLog.pre-2-18
ChangeLog.pre-2-2
ChangeLog.pre-2-20
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
HACKING
INSTALL.in
Makefile.am
NEWS
NEWS.pre-1-3
README.commits
README.in
README.rationale
README.win32
acglib.m4
acinclude.m4
autogen.sh
check-abis.sh
config.h.meson
config.h.win32.in
configure.ac
gio-2.0.pc.in
gio-unix-2.0.pc.in
gio-windows-2.0.pc.in
glib-2.0.pc.in
glib-gettextize.in
glib-tap.mk
glib-zip.in
glib.doap
glib.mk
glib.supp
gmodule-2.0.pc.in
gmodule-export-2.0.pc.in
gmodule-no-export-2.0.pc.in
gobject-2.0.pc.in
gthread-2.0.pc.in
meson.build
meson_options.txt
msvc_recommended_pragmas.h
sanity_check
tap-driver.sh
tap-test
In the vast majority of cases, we can avoid temporary allocations for paths in g_resources_enumerate_children(). In the case we need to add a suffix "/", we can usually just build the path on the stack. In other cases, we can completely avoid the strdup, which appears to only have been added for readability. If the path is really long, we fallback to doing what we did before, and use g_strconcat(). In the case of Builder, this saved 5.3mb of temporary allocations in the process of showing the first application window. https://bugzilla.gnome.org/show_bug.cgi?id=790275
761 lines
22 KiB
C
761 lines
22 KiB
C
/* GLib testing framework examples and tests
|
|
*
|
|
* Copyright (C) 2011 Red Hat, Inc.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General
|
|
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include <gio/gio.h>
|
|
#include "gconstructor.h"
|
|
#include "test_resources2.h"
|
|
|
|
static void
|
|
test_resource (GResource *resource)
|
|
{
|
|
GError *error = NULL;
|
|
gboolean found, success;
|
|
gsize size;
|
|
guint32 flags;
|
|
GBytes *data;
|
|
char **children;
|
|
GInputStream *in;
|
|
char buffer[128];
|
|
|
|
found = g_resource_get_info (resource,
|
|
"/not/there",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (!found);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
|
|
found = g_resource_get_info (resource,
|
|
"/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpuint (flags, ==, G_RESOURCE_FLAGS_COMPRESSED);
|
|
|
|
found = g_resource_get_info (resource,
|
|
"/a_prefix/test2.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpuint (flags, ==, 0);
|
|
|
|
found = g_resource_get_info (resource,
|
|
"/a_prefix/test2-alias.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpuint (flags, ==, 0);
|
|
|
|
data = g_resource_lookup_data (resource,
|
|
"/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
|
|
g_assert_no_error (error);
|
|
g_bytes_unref (data);
|
|
|
|
in = g_resource_open_stream (resource,
|
|
"/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (in != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
success = g_input_stream_read_all (in, buffer, sizeof (buffer) - 1,
|
|
&size,
|
|
NULL, &error);
|
|
g_assert (success);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
buffer[size] = 0;
|
|
g_assert_cmpstr (buffer, ==, "test1\n");
|
|
|
|
g_input_stream_close (in, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_clear_object (&in);
|
|
|
|
data = g_resource_lookup_data (resource,
|
|
"/a_prefix/test2.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
|
|
g_bytes_unref (data);
|
|
|
|
data = g_resource_lookup_data (resource,
|
|
"/a_prefix/test2-alias.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
|
|
g_bytes_unref (data);
|
|
|
|
children = g_resource_enumerate_children (resource,
|
|
"/not/here",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (children == NULL);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
|
|
children = g_resource_enumerate_children (resource,
|
|
"/a_prefix",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (children != NULL);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (g_strv_length (children), ==, 2);
|
|
g_strfreev (children);
|
|
|
|
/* Test the preferred lookup where we have a trailing slash. */
|
|
children = g_resource_enumerate_children (resource,
|
|
"/a_prefix/",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (children != NULL);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (g_strv_length (children), ==, 2);
|
|
g_strfreev (children);
|
|
|
|
/* test with a path > 256 and no trailing slash to test the
|
|
* slow path of resources where we allocate a modified path.
|
|
*/
|
|
children = g_resource_enumerate_children (resource,
|
|
"/not/here/not/here/not/here/not/here/not/here/not/here/not/here"
|
|
"/not/here/not/here/not/here/not/here/not/here/not/here/not/here"
|
|
"/not/here/not/here/not/here/not/here/not/here/not/here/not/here"
|
|
"/not/here/not/here/not/here/not/here/not/here/not/here/not/here"
|
|
"/not/here/not/here/not/here/not/here/not/here/not/here/not/here"
|
|
"/with/no/trailing/slash",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (children == NULL);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
}
|
|
|
|
static void
|
|
test_resource_file (void)
|
|
{
|
|
GResource *resource;
|
|
GError *error = NULL;
|
|
|
|
resource = g_resource_load ("not-there", &error);
|
|
g_assert (resource == NULL);
|
|
g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
|
|
g_clear_error (&error);
|
|
|
|
resource = g_resource_load (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL), &error);
|
|
g_assert (resource != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
test_resource (resource);
|
|
g_resource_unref (resource);
|
|
}
|
|
|
|
static void
|
|
test_resource_file_path (void)
|
|
{
|
|
static const struct {
|
|
const gchar *input;
|
|
const gchar *expected;
|
|
} test_uris[] = {
|
|
{ "resource://", "resource:///" },
|
|
{ "resource:///", "resource:///" },
|
|
{ "resource://////", "resource:///" },
|
|
{ "resource:///../../../", "resource:///" },
|
|
{ "resource:///../../..", "resource:///" },
|
|
{ "resource://abc", "resource:///abc" },
|
|
{ "resource:///abc/", "resource:///abc" },
|
|
{ "resource:/a/b/../c/", "resource:///a/c" },
|
|
{ "resource://../a/b/../c/../", "resource:///a" },
|
|
{ "resource://a/b/cc//bb//a///", "resource:///a/b/cc/bb/a" },
|
|
{ "resource://././././", "resource:///" },
|
|
{ "resource://././././../", "resource:///" },
|
|
{ "resource://a/b/c/d.png", "resource:///a/b/c/d.png" },
|
|
{ "resource://a/b/c/..png", "resource:///a/b/c/..png" },
|
|
{ "resource://a/b/c/./png", "resource:///a/b/c/png" },
|
|
};
|
|
guint i;
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (test_uris); i++)
|
|
{
|
|
GFile *file;
|
|
gchar *uri;
|
|
|
|
file = g_file_new_for_uri (test_uris[i].input);
|
|
g_assert (file != NULL);
|
|
|
|
uri = g_file_get_uri (file);
|
|
g_assert (uri != NULL);
|
|
|
|
g_assert_cmpstr (uri, ==, test_uris[i].expected);
|
|
|
|
g_object_unref (file);
|
|
g_free (uri);
|
|
}
|
|
}
|
|
|
|
static void
|
|
test_resource_data (void)
|
|
{
|
|
GResource *resource;
|
|
GError *error = NULL;
|
|
gboolean loaded_file;
|
|
char *content;
|
|
gsize content_size;
|
|
GBytes *data;
|
|
|
|
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
|
&content, &content_size, NULL);
|
|
g_assert (loaded_file);
|
|
|
|
data = g_bytes_new_take (content, content_size);
|
|
resource = g_resource_new_from_data (data, &error);
|
|
g_bytes_unref (data);
|
|
g_assert (resource != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
test_resource (resource);
|
|
|
|
g_resource_unref (resource);
|
|
}
|
|
|
|
static void
|
|
test_resource_data_unaligned (void)
|
|
{
|
|
GResource *resource;
|
|
GError *error = NULL;
|
|
gboolean loaded_file;
|
|
char *content, *content_copy;
|
|
gsize content_size;
|
|
GBytes *data;
|
|
|
|
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
|
&content, &content_size, NULL);
|
|
g_assert (loaded_file);
|
|
|
|
content_copy = g_new (char, content_size + 1);
|
|
memcpy (content_copy + 1, content, content_size);
|
|
|
|
data = g_bytes_new_with_free_func (content_copy + 1, content_size,
|
|
(GDestroyNotify) g_free, content_copy);
|
|
g_free (content);
|
|
resource = g_resource_new_from_data (data, &error);
|
|
g_bytes_unref (data);
|
|
g_assert (resource != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
test_resource (resource);
|
|
|
|
g_resource_unref (resource);
|
|
}
|
|
|
|
static void
|
|
test_resource_registered (void)
|
|
{
|
|
GResource *resource;
|
|
GError *error = NULL;
|
|
gboolean found, success;
|
|
gsize size;
|
|
guint32 flags;
|
|
GBytes *data;
|
|
char **children;
|
|
GInputStream *in;
|
|
char buffer[128];
|
|
|
|
resource = g_resource_load (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL), &error);
|
|
g_assert (resource != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
found = g_resources_get_info ("/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (!found);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
|
|
g_resources_register (resource);
|
|
|
|
found = g_resources_get_info ("/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert (flags == (G_RESOURCE_FLAGS_COMPRESSED));
|
|
|
|
found = g_resources_get_info ("/a_prefix/test2.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpint (flags, ==, 0);
|
|
|
|
found = g_resources_get_info ("/a_prefix/test2-alias.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpuint (flags, ==, 0);
|
|
|
|
data = g_resources_lookup_data ("/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
|
|
g_assert_no_error (error);
|
|
g_bytes_unref (data);
|
|
|
|
in = g_resources_open_stream ("/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (in != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
success = g_input_stream_read_all (in, buffer, sizeof (buffer) - 1,
|
|
&size,
|
|
NULL, &error);
|
|
g_assert (success);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
buffer[size] = 0;
|
|
g_assert_cmpstr (buffer, ==, "test1\n");
|
|
|
|
g_input_stream_close (in, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_clear_object (&in);
|
|
|
|
data = g_resources_lookup_data ("/a_prefix/test2.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
|
|
g_bytes_unref (data);
|
|
|
|
data = g_resources_lookup_data ("/a_prefix/test2-alias.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
|
|
g_bytes_unref (data);
|
|
|
|
children = g_resources_enumerate_children ("/not/here",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (children == NULL);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
|
|
children = g_resources_enumerate_children ("/a_prefix",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (children != NULL);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (g_strv_length (children), ==, 2);
|
|
g_strfreev (children);
|
|
|
|
g_resources_unregister (resource);
|
|
g_resource_unref (resource);
|
|
|
|
found = g_resources_get_info ("/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (!found);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
}
|
|
|
|
static void
|
|
test_resource_automatic (void)
|
|
{
|
|
GError *error = NULL;
|
|
gboolean found;
|
|
gsize size;
|
|
guint32 flags;
|
|
GBytes *data;
|
|
|
|
found = g_resources_get_info ("/auto_loaded/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpint (flags, ==, 0);
|
|
|
|
data = g_resources_lookup_data ("/auto_loaded/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
|
|
g_bytes_unref (data);
|
|
}
|
|
|
|
static void
|
|
test_resource_manual (void)
|
|
{
|
|
GError *error = NULL;
|
|
gboolean found;
|
|
gsize size;
|
|
guint32 flags;
|
|
GBytes *data;
|
|
|
|
found = g_resources_get_info ("/manual_loaded/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpuint (flags, ==, 0);
|
|
|
|
data = g_resources_lookup_data ("/manual_loaded/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
|
|
g_bytes_unref (data);
|
|
}
|
|
|
|
static void
|
|
test_resource_manual2 (void)
|
|
{
|
|
GResource *resource;
|
|
GBytes *data;
|
|
gsize size;
|
|
GError *error = NULL;
|
|
|
|
resource = _g_test2_get_resource ();
|
|
|
|
data = g_resource_lookup_data (resource,
|
|
"/manual_loaded/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
|
|
g_bytes_unref (data);
|
|
|
|
g_resource_unref (resource);
|
|
}
|
|
|
|
static void
|
|
test_resource_module (void)
|
|
{
|
|
GIOModule *module;
|
|
gboolean found;
|
|
gsize size;
|
|
guint32 flags;
|
|
GBytes *data;
|
|
GError *error;
|
|
|
|
if (g_module_supported ())
|
|
{
|
|
/* For in-tree, this will find the .la file and use it to get to the .so in .libs/ */
|
|
module = g_io_module_new (g_test_get_filename (G_TEST_BUILT, "libresourceplugin", NULL));
|
|
|
|
error = NULL;
|
|
|
|
found = g_resources_get_info ("/resourceplugin/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (!found);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
|
|
g_type_module_use (G_TYPE_MODULE (module));
|
|
|
|
found = g_resources_get_info ("/resourceplugin/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (found);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpuint (flags, ==, 0);
|
|
|
|
data = g_resources_lookup_data ("/resourceplugin/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&error);
|
|
g_assert (data != NULL);
|
|
g_assert_no_error (error);
|
|
size = g_bytes_get_size (data);
|
|
g_assert_cmpint (size, ==, 6);
|
|
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
|
|
g_bytes_unref (data);
|
|
|
|
g_type_module_unuse (G_TYPE_MODULE (module));
|
|
|
|
found = g_resources_get_info ("/resourceplugin/test1.txt",
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
|
&size, &flags, &error);
|
|
g_assert (!found);
|
|
g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
|
|
g_clear_error (&error);
|
|
}
|
|
}
|
|
|
|
static void
|
|
test_uri_query_info (void)
|
|
{
|
|
GResource *resource;
|
|
GError *error = NULL;
|
|
gboolean loaded_file;
|
|
char *content;
|
|
gsize content_size;
|
|
GBytes *data;
|
|
GFile *file;
|
|
GFileInfo *info;
|
|
const char *content_type, *mime_type;
|
|
const char *fs_type;
|
|
gboolean readonly;
|
|
|
|
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
|
&content, &content_size, NULL);
|
|
g_assert (loaded_file);
|
|
|
|
data = g_bytes_new_take (content, content_size);
|
|
resource = g_resource_new_from_data (data, &error);
|
|
g_bytes_unref (data);
|
|
g_assert (resource != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
g_resources_register (resource);
|
|
|
|
file = g_file_new_for_uri ("resource://" "/a_prefix/test2-alias.txt");
|
|
|
|
info = g_file_query_info (file, "*", 0, NULL, &error);
|
|
g_assert_no_error (error);
|
|
|
|
content_type = g_file_info_get_content_type (info);
|
|
g_assert (content_type);
|
|
mime_type = g_content_type_get_mime_type (content_type);
|
|
g_assert (mime_type);
|
|
g_assert_cmpstr (mime_type, ==, "text/plain");
|
|
|
|
g_object_unref (info);
|
|
|
|
info = g_file_query_filesystem_info (file, "*", NULL, &error);
|
|
g_assert_no_error (error);
|
|
|
|
fs_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
|
|
g_assert_cmpstr (fs_type, ==, "resource");
|
|
readonly = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY);
|
|
g_assert_true (readonly);
|
|
|
|
g_object_unref (info);
|
|
|
|
g_assert_cmpuint (g_file_hash (file), !=, 0);
|
|
|
|
g_object_unref (file);
|
|
|
|
g_resources_unregister (resource);
|
|
g_resource_unref (resource);
|
|
}
|
|
|
|
static void
|
|
test_uri_file (void)
|
|
{
|
|
GResource *resource;
|
|
GError *error = NULL;
|
|
gboolean loaded_file;
|
|
char *content;
|
|
gsize content_size;
|
|
GBytes *data;
|
|
GFile *file;
|
|
GFileInfo *info;
|
|
gchar *name;
|
|
GFile *file2, *parent;
|
|
GFileEnumerator *enumerator;
|
|
gchar *scheme;
|
|
GFileAttributeInfoList *attrs;
|
|
GInputStream *stream;
|
|
gchar buf[1024];
|
|
gboolean ret;
|
|
gssize skipped;
|
|
|
|
loaded_file = g_file_get_contents (g_test_get_filename (G_TEST_BUILT, "test.gresource", NULL),
|
|
&content, &content_size, NULL);
|
|
g_assert (loaded_file);
|
|
|
|
data = g_bytes_new_take (content, content_size);
|
|
resource = g_resource_new_from_data (data, &error);
|
|
g_bytes_unref (data);
|
|
g_assert (resource != NULL);
|
|
g_assert_no_error (error);
|
|
|
|
g_resources_register (resource);
|
|
|
|
file = g_file_new_for_uri ("resource://" "/a_prefix/test2-alias.txt");
|
|
|
|
g_assert (g_file_get_path (file) == NULL);
|
|
|
|
name = g_file_get_parse_name (file);
|
|
g_assert_cmpstr (name, ==, "resource:///a_prefix/test2-alias.txt");
|
|
g_free (name);
|
|
|
|
name = g_file_get_uri (file);
|
|
g_assert_cmpstr (name, ==, "resource:///a_prefix/test2-alias.txt");
|
|
g_free (name);
|
|
|
|
g_assert (!g_file_is_native (file));
|
|
g_assert (!g_file_has_uri_scheme (file, "http"));
|
|
g_assert (g_file_has_uri_scheme (file, "resource"));
|
|
scheme = g_file_get_uri_scheme (file);
|
|
g_assert_cmpstr (scheme, ==, "resource");
|
|
g_free (scheme);
|
|
|
|
file2 = g_file_dup (file);
|
|
g_assert (g_file_equal (file, file2));
|
|
g_object_unref (file2);
|
|
|
|
parent = g_file_get_parent (file);
|
|
enumerator = g_file_enumerate_children (parent, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &error);
|
|
g_assert_no_error (error);
|
|
|
|
file2 = g_file_get_child_for_display_name (parent, "test2-alias.txt", &error);
|
|
g_assert_no_error (error);
|
|
g_assert (g_file_equal (file, file2));
|
|
g_object_unref (file2);
|
|
|
|
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_assert (info != NULL);
|
|
g_object_unref (info);
|
|
|
|
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_assert (info != NULL);
|
|
g_object_unref (info);
|
|
|
|
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_assert (info == NULL);
|
|
|
|
g_file_enumerator_close (enumerator, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_object_unref (enumerator);
|
|
|
|
file2 = g_file_new_for_uri ("resource://" "a_prefix/../a_prefix//test2-alias.txt");
|
|
g_assert (g_file_equal (file, file2));
|
|
|
|
g_assert (g_file_has_prefix (file, parent));
|
|
|
|
name = g_file_get_relative_path (parent, file);
|
|
g_assert_cmpstr (name, ==, "test2-alias.txt");
|
|
g_free (name);
|
|
|
|
g_object_unref (parent);
|
|
|
|
attrs = g_file_query_settable_attributes (file, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_file_attribute_info_list_unref (attrs);
|
|
|
|
attrs = g_file_query_writable_namespaces (file, NULL, &error);
|
|
g_assert_no_error (error);
|
|
g_file_attribute_info_list_unref (attrs);
|
|
|
|
stream = G_INPUT_STREAM (g_file_read (file, NULL, &error));
|
|
g_assert_no_error (error);
|
|
g_assert_cmpint (g_seekable_tell (G_SEEKABLE (stream)), ==, 0);
|
|
g_assert (g_seekable_can_seek (G_SEEKABLE (G_SEEKABLE (stream))));
|
|
ret = g_seekable_seek (G_SEEKABLE (stream), 1, G_SEEK_SET, NULL, &error);
|
|
g_assert (ret);
|
|
g_assert_no_error (error);
|
|
skipped = g_input_stream_skip (stream, 1, NULL, &error);
|
|
g_assert_cmpint (skipped, ==, 1);
|
|
g_assert_no_error (error);
|
|
|
|
memset (buf, 0, 1024);
|
|
ret = g_input_stream_read_all (stream, &buf, 1024, NULL, NULL, &error);
|
|
g_assert (ret);
|
|
g_assert_no_error (error);
|
|
g_assert_cmpstr (buf, ==, "st2\n");
|
|
info = g_file_input_stream_query_info (G_FILE_INPUT_STREAM (stream),
|
|
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
|
NULL,
|
|
&error);
|
|
g_assert_no_error (error);
|
|
g_assert (info != NULL);
|
|
g_assert_cmpint (g_file_info_get_size (info), ==, 6);
|
|
g_object_unref (info);
|
|
|
|
ret = g_input_stream_close (stream, NULL, &error);
|
|
g_assert (ret);
|
|
g_assert_no_error (error);
|
|
g_object_unref (stream);
|
|
|
|
g_object_unref (file);
|
|
g_object_unref (file2);
|
|
|
|
g_resources_unregister (resource);
|
|
g_resource_unref (resource);
|
|
}
|
|
|
|
int
|
|
main (int argc,
|
|
char *argv[])
|
|
{
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
_g_test2_register_resource ();
|
|
|
|
g_test_add_func ("/resource/file", test_resource_file);
|
|
g_test_add_func ("/resource/file-path", test_resource_file_path);
|
|
g_test_add_func ("/resource/data", test_resource_data);
|
|
g_test_add_func ("/resource/data_unaligned", test_resource_data_unaligned);
|
|
g_test_add_func ("/resource/registered", test_resource_registered);
|
|
g_test_add_func ("/resource/manual", test_resource_manual);
|
|
g_test_add_func ("/resource/manual2", test_resource_manual2);
|
|
#ifdef G_HAS_CONSTRUCTORS
|
|
g_test_add_func ("/resource/automatic", test_resource_automatic);
|
|
/* This only uses automatic resources too, so it tests the constructors and destructors */
|
|
g_test_add_func ("/resource/module", test_resource_module);
|
|
#endif
|
|
g_test_add_func ("/resource/uri/query-info", test_uri_query_info);
|
|
g_test_add_func ("/resource/uri/file", test_uri_file);
|
|
|
|
return g_test_run();
|
|
}
|