diff options
author | Ting-Wei Lan <lantw44@gmail.com> | 2013-07-31 00:26:01 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2013-07-31 01:08:29 +0800 |
commit | 741e1dd0c7b8fe8b8d7df03cc8f21f5731d39f66 (patch) | |
tree | ec6dbf7fa50a6414b3d91b9a029f7258825410f5 /tests | |
parent | 0518cc8d8452734000adb2f872058e14004a8e57 (diff) | |
download | gsoc2013-libgnome-autoar-741e1dd0c7b8fe8b8d7df03cc8f21f5731d39f66.tar.gz gsoc2013-libgnome-autoar-741e1dd0c7b8fe8b8d7df03cc8f21f5731d39f66.tar.zst gsoc2013-libgnome-autoar-741e1dd0c7b8fe8b8d7df03cc8f21f5731d39f66.zip |
Fix build system after becoming a shared library
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 26 | ||||
-rw-r--r-- | tests/test-extract.c | 97 | ||||
-rw-r--r-- | tests/test-pref.c | 26 |
3 files changed, 149 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..6500b69 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,26 @@ +# vim: set sw=8 ts=8 sts=8 noet: + +NULL = + +noinst_PROGRAMS = test-extract test-pref +EXTRA_DIST = test-extract.c test-pref.c + +test_cflags = \ + $(DEPENDENCIES_CFLAGS) \ + $(AM_CFLAGS) \ + -I$(top_srcdir) \ + $(NULL) + +test_libs = \ + $(DEPENDENCIES_LIBS) \ + $(top_builddir)/gnome-autoar/libgnome-autoar.la \ + $(NULL) + + +test_extract_SOURCES = test-extract.c +test_extract_CFLAGS = $(test_cflags) +test_extract_LDADD = $(test_libs) + +test_pref_SOURCES = test-pref.c +test_pref_CFLAGS = $(test_cflags) +test_pref_LDADD = $(test_libs) diff --git a/tests/test-extract.c b/tests/test-extract.c new file mode 100644 index 0000000..5edbacf --- /dev/null +++ b/tests/test-extract.c @@ -0,0 +1,97 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ + +#include <gnome-autoar/autoar.h> +#include <gio/gio.h> +#include <stdlib.h> + +static void +my_handler_scanned (AutoarExtract *arextract, + guint files, + gpointer data) +{ + g_print ("Scanning OK, %d files to be extracted.\n", files); +} + +static void +my_handler_decide_dest (AutoarExtract *arextract, + GFile *dest) +{ + char *path, *uri; + path = g_file_get_path (dest); + uri = g_file_get_uri (dest); + g_print ("Destination Path: %s\n", path); + g_print ("Destination URI: %s\n", uri); + g_free (path); + g_free (uri); +} + +static void +my_handler_progress (AutoarExtract *arextract, + gdouble fraction_size, + gdouble fraction_files, + gpointer data) +{ + g_print ("\rProgress: Archive Size %.2lf %%, Files %.2lf %%", + fraction_size * 100, + fraction_files * 100); +} + +static void +my_handler_error (AutoarExtract *arextract, + GError *error, + gpointer data) +{ + g_printerr ("\nError %d: %s\n", error->code, error->message); +} + +static void +my_handler_completed (AutoarExtract *arextract, + gpointer data) +{ + g_print ("\nCompleted!\n"); +} + +int +main (int argc, + char *argv[]) +{ + AutoarExtract *arextract; + AutoarPref *arpref; + GSettings *settings; + const char *pattern[] = { + "__MACOSX", + ".DS_Store", + "._.*", + "*.in", + NULL + }; + + if (argc < 3) { + g_printerr ("Usage: %s archive_file output_dir\n", argv[0]); + return 255; + } + + settings = g_settings_new (AUTOAR_PREF_DEFAULT_GSCHEMA_ID); + + arpref = autoar_pref_new_with_gsettings (settings); + autoar_pref_set_delete_if_succeed (arpref, FALSE); + autoar_pref_set_pattern_to_ignore (arpref, pattern); + + autoar_pref_forget_changes (arpref); + autoar_pref_write_gsettings (arpref, settings); + + arextract = autoar_extract_new (argv[1], argv[2], arpref); + g_signal_connect (arextract, "scanned", G_CALLBACK (my_handler_scanned), NULL); + g_signal_connect (arextract, "decide-dest", G_CALLBACK (my_handler_decide_dest), NULL); + g_signal_connect (arextract, "progress", G_CALLBACK (my_handler_progress), NULL); + g_signal_connect (arextract, "error", G_CALLBACK (my_handler_error), NULL); + g_signal_connect (arextract, "completed", G_CALLBACK (my_handler_completed), NULL); + + autoar_extract_start (arextract); + + g_object_unref (arextract); + g_object_unref (arpref); + g_object_unref (settings); + + return 0; +} diff --git a/tests/test-pref.c b/tests/test-pref.c new file mode 100644 index 0000000..5a348c8 --- /dev/null +++ b/tests/test-pref.c @@ -0,0 +1,26 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ + +#include <gnome-autoar/autoar.h> + +int +main (int argc, + char *argv[]) +{ + AutoarPref *arpref; + GSettings *settings; + + if (argc < 2) { + g_printerr ("Usage: %s archive_file\n", argv[0]); + return 255; + } + + settings = g_settings_new (AUTOAR_PREF_DEFAULT_GSCHEMA_ID); + arpref = autoar_pref_new_with_gsettings (settings); + + g_print ("file-name-suffix check: %d\n", autoar_pref_check_file_name (arpref, argv[1])); + g_print ("file-mime-type check: %d\n", autoar_pref_check_mime_type (arpref, argv[1])); + + g_object_unref (arpref); + + return 0; +} |