2001-08-17 Lutz M�ller <urc8@rz.uni-karlsruhe.de>

* 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
This commit is contained in:
Lutz Mueller
2001-08-17 22:35:50 +00:00
parent 6bfaabb22a
commit f2bc06c8d5
10 changed files with 58 additions and 137 deletions

View File

@@ -1,3 +1,12 @@
2001-08-17 Lutz Müller <urc8@rz.uni-karlsruhe.de>
* 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 <urc8@rz.uni-karlsruhe.de>
* frontents/gtk/macros/*: Removed.

View File

@@ -9,6 +9,7 @@ SUBDIRS = \
libgphoto2 \
camlibs \
frontends \
tests \
po \
doc

View File

@@ -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 \

View File

@@ -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

View File

@@ -22,7 +22,6 @@
#include "options.h"
#include "range.h"
#include "shell.h"
#include "test.h"
#ifdef ENABLE_NLS
# include <libintl.h>
@@ -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);

View File

@@ -1,120 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gphoto2.h>
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<n; x++) {
if (gp_camera_name(x, buf) != GP_OK)
printf("cli: ERROR: camera_name error! (%i)\n", x);
printf("cli: Camera #%i name: %s\n", x, buf);
}
/* -------------------------- */
/* Choose which camera to use */
/* -------------------------- */
printf("Camera number to use? ");
fflush(stdout);
fgets(buf, 1023, stdin);
camnum = atoi(buf);
printf("cli: Setting camera #%i active\n", camnum);
/* ---------------------------------------------- */
/* Set the camera they chose as the active camera */
/* ---------------------------------------------- */
strcpy(s.path, "/dev/ttyS0");
s.speed = 57600;
if (gp_camera_set(camnum, &s) != GP_OK)
printf("cli: ERROR: camera_set error!\n");
/* ------------------------------- */
/* Retrieve the camera's abilities */
/* ------------------------------- */
if (gp_camera_abilities(camnum, &a) != GP_OK)
printf("cli: ERROR: camera_abilities error!\n");
/* ------------------------------- */
/* Set the currently active folder */
/* ------------------------------- */
if (gp_folder_set("/") != GP_OK)
printf("cli: ERROR: Can't set folder!\n");
/* ----------------------------------------- */
/* Get the number of pictures in that folder */
/* ----------------------------------------- */
m=gp_file_count();
if (m < 0)
printf("cli: ERROR: file_count error!\n");
else
printf("cli: Number of files: %i\n", n);
/* ------------------------------- */
/* Get a thumbnail from the camera */
/* ------------------------------- */
f = gp_file_new();
printf("cli: Getting preview 0\n");
if (gp_file_get_preview(0, f) != GP_OK)
printf("cli: ERROR: get_preview error!\n");
else {
printf("cli: done!\n");
gp_file_save(f, "/home/scottf/test.jpg");
}
/* ---------------------------------- */
/* Display camera/library information */
/* ---------------------------------- */
if (gp_summary(buf) != GP_OK)
printf("cli: ERROR: summary error!\n");
else
printf("cli: Summary:\n%s\n", buf);
if (gp_manual(buf) != GP_OK)
printf("cli: ERROR: manual error!\n");
else
printf("cli: Manual:\n%s\n", buf);
if (gp_about(buf) != GP_OK)
printf("cli: ERROR: about error!\n");
else
printf("cli: About:\n%s\n", buf);
/* ---------------------------- */
/* Close out the gPhoto library */
/* ---------------------------- */
gp_exit();
return (0);
#endif

View File

@@ -1 +0,0 @@
int test_gphoto ();

6
tests/.cvsignore Normal file
View File

@@ -0,0 +1,6 @@
Makefile.in
Makefile
test-gphoto2
.libs
.deps
*.o

7
tests/Makefile.am Normal file
View File

@@ -0,0 +1,7 @@
INCLUDES = -I$(top_srcdir)/include
noinst_PROGRAMS = test-gphoto2
test_gphoto2_SOURCE = test-gphoto2.c
test_gphoto2_LDADD = ../libgphoto2/libgphoto2.la

31
tests/test-gphoto2.c Normal file
View File

@@ -0,0 +1,31 @@
#include <gphoto2.h>
#include <stdio.h>
#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);
}