From f2bc06c8d507a358c8f0c93248adf05275a32ed5 Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Fri, 17 Aug 2001 22:35:50 +0000 Subject: [PATCH] =?UTF-8?q?2001-08-17=20=20Lutz=20M=EF=BF=BDller=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tests/*: New * configure.in: * Makefile.am: Add tests to SUBDIRS and generate the Makefile * frontents/command-line/test.[c,h]: Removed * frontends/command-line/main.c: * frontents/command-line/Makefile.am: Reflect changes git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@1999 67ed7778-7388-44ab-90cf-0a291f65f57c --- ChangeLog | 9 +++ Makefile.am | 1 + configure.in | 2 +- frontends/command-line/Makefile.am | 3 +- frontends/command-line/main.c | 15 +--- frontends/command-line/test.c | 120 ----------------------------- frontends/command-line/test.h | 1 - tests/.cvsignore | 6 ++ tests/Makefile.am | 7 ++ tests/test-gphoto2.c | 31 ++++++++ 10 files changed, 58 insertions(+), 137 deletions(-) delete mode 100644 frontends/command-line/test.c delete mode 100644 frontends/command-line/test.h create mode 100644 tests/.cvsignore create mode 100644 tests/Makefile.am create mode 100644 tests/test-gphoto2.c diff --git a/ChangeLog b/ChangeLog index 127cf49a8..92d5432d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-08-17 Lutz Müller + + * tests/*: New + * configure.in: + * Makefile.am: Add tests to SUBDIRS and generate the Makefile + * frontents/command-line/test.[c,h]: Removed + * frontends/command-line/main.c: + * frontents/command-line/Makefile.am: Reflect changes + 2001-08-17 Lutz Müller * frontents/gtk/macros/*: Removed. diff --git a/Makefile.am b/Makefile.am index 06453182a..a294466df 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,7 @@ SUBDIRS = \ libgphoto2 \ camlibs \ frontends \ + tests \ po \ doc diff --git a/configure.in b/configure.in index 63d72106f..f818a2e5d 100644 --- a/configure.in +++ b/configure.in @@ -180,7 +180,7 @@ camlibs/sonydscf1/Makefile \ camlibs/stv0680/Makefile \ frontends/Makefile \ frontends/command-line/Makefile \ -frontends/libgphoto2_frontend/Makefile \ +tests/Makefile \ include/Makefile \ libgphoto2/Makefile \ gphoto2-config \ diff --git a/frontends/command-line/Makefile.am b/frontends/command-line/Makefile.am index ee5d13191..4afcd032e 100644 --- a/frontends/command-line/Makefile.am +++ b/frontends/command-line/Makefile.am @@ -17,8 +17,7 @@ gphoto2_SOURCES = \ main.c main.h \ options.c options.h \ range.c range.h \ - shell.c shell.h \ - test.c test.h + shell.c shell.h gphoto2_LDFLAGS = -export-dynamic diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index 82d5abab9..bd1405f1e 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -22,7 +22,6 @@ #include "options.h" #include "range.h" #include "shell.h" -#include "test.h" #ifdef ENABLE_NLS # include @@ -63,7 +62,6 @@ int set_globals(); OPTION_CALLBACK(abilities); OPTION_CALLBACK(help); -OPTION_CALLBACK(test); OPTION_CALLBACK(shell); OPTION_CALLBACK(list_cameras); OPTION_CALLBACK(auto_detect); @@ -112,7 +110,6 @@ Option option[] = { /* Display and die actions */ {"h", "help", "", "Displays this help screen", help, 0}, -{"", "verify", "", "Verifies gPhoto installation", test, 0}, {"", "list-cameras", "", "List supported camera models", list_cameras, 0}, {"", "list-ports", "", "List supported port devices", list_ports, 0}, {"", "stdout", "", "Send file to stdout", use_stdout, 0}, @@ -196,14 +193,6 @@ OPTION_CALLBACK(help) { return GP_OK; } -OPTION_CALLBACK(test) { - - cli_debug_print("Testing gPhoto Installation"); - test_gphoto(); - exit(EXIT_SUCCESS); - return GP_OK; -} - OPTION_CALLBACK(use_stdout) { glob_quiet = 1; /* implied */ @@ -752,11 +741,11 @@ int capture_generic (int type, char *name) { if (type == GP_OPERATION_CAPTURE_PREVIEW) { file = gp_file_new (); - if ((result = gp_camera_capture_preview(glob_camera, file)) != GP_OK) { + if ((result = gp_camera_capture_preview (glob_camera, file)) != GP_OK) { cli_error_print("Could not capture the preview."); return (result); } - save_camera_file_to_file(file, 0); + save_camera_file_to_file (file, 0); gp_file_free(file); } else { result = gp_camera_capture (glob_camera, type, &path); diff --git a/frontends/command-line/test.c b/frontends/command-line/test.c deleted file mode 100644 index c4ceadbe3..000000000 --- a/frontends/command-line/test.c +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include -#include - -#include - -int test_gphoto() { - /* This will let the user check to see the status of their - gPhoto installation and test to make sure everything is - in working order */ - - return (GP_OK); -} - -#if 0 - /* Example code for using gPhoto2 */ - - CameraAbilities a; - CameraPortSettings s; - CameraFile *f; - char buf[1024]; - int x, m, n, camnum; - - /* ----------------------------- */ - /* Initialize the gPhoto library */ - /* ----------------------------- */ - gp_init(0); - - /* ---------------------------------------- */ - /* Retrieve the number of cameras available */ - /* ---------------------------------------- */ - if ((n = gp_camera_count()) < 0) - printf("cli: camera_count error!\n"); - printf("cli: Number of cameras: %i\n", n); - /* ----------------------------------- */ - /* Display a list of available cameras */ - /* ----------------------------------- */ - for (x=0; x +#include + +#define CHECK(f) {int res = f; if (res < 0) {printf ("ERROR: %s\n", gp_result_as_string (res)); exit (1);}} + +int +main (int argc, char *argv []) +{ + CameraText text; + Camera *camera; + + printf ("Initializing gphoto2...\n"); + CHECK (gp_init (GP_DEBUG_NONE)); + + printf ("Creating camera...\n"); + CHECK (gp_camera_new (&camera)); + + strcpy (camera->model, "Directory Browse"); + + printf ("Initializing camera...\n"); + CHECK (gp_camera_init (camera)); + + printf ("Getting summary...\n"); + CHECK (gp_camera_get_summary (camera, &text)); + printf ("%s\n", text.text); + + printf ("Unrefing camera...\n"); + CHECK (gp_camera_unref (camera)); + + return (0); +}