diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2015-10-17 23:50:00 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2015-10-17 23:50:00 +0200 |
commit | 49ca8a5f8389403aa23f8cf6135c5eb2c396330b (patch) | |
tree | 8138f2faa6d876f9a0037f438b9c581eb22918d6 | |
parent | 6510e2e30527352f58d2677ee90f7c725155b7ec (diff) | |
download | libgphoto2-49ca8a5f8389403aa23f8cf6135c5eb2c396330b.tar.gz |
more capture test and refactoring
-rw-r--r-- | camlibs/ptp2/testcamera.pl | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/camlibs/ptp2/testcamera.pl b/camlibs/ptp2/testcamera.pl index 03d8346de..f887af1e2 100644 --- a/camlibs/ptp2/testcamera.pl +++ b/camlibs/ptp2/testcamera.pl @@ -8,9 +8,14 @@ my %camera = (); $camera{'havecapture'} = 1; $camera{'havecapturetarget'} = 1; -my @formats = (); +$camera{'havecapturetarget'} = 1; +my %formats = { + "jpg" => "imageformat=0", + "raw" => "imageformat=9", + "both" => "imageformat=8", +}; -$camera{'imageformats'} = \@formats; +$camera{'imageformats'} = \%formats; # returns TRUE on success, FALSE on fail sub run_gphoto2(@) { @@ -39,6 +44,47 @@ sub ok($$) { } } +sub remove_all_files { + my @files = <*>; + + foreach my $file (@files) { + next if ($file =~ /logfile/); + print STDERR "deleting $file\n"; + unlink $file; + } +} + +sub run_gphoto2_capture_target(@) { + my $text = pop; + my $nrimages = pop; + my @cmd = @_; + + ok(&run_gphoto2(@cmd),"$text: " . join(" ",@cmd)); + + my @files = <*>; + if ($nrimages+1 != @files) { + print STDERR "*** expected $nrimages files, got $@files\n"; + } + &remove_all_files(); +} + +sub run_gphoto2_capture(@) { + my @cmd = @_; + my @newcmd = @cmd; + + if ($camera{'havecapturetarget'}) { + my @newcmd = @cmd; + unshift @newcmd,"--set-config-index","capturetarget=0"; + &run_gphoto2_capture_target(@newcmd); + + @newcmd = @cmd; + unshift @newcmd,"--set-config-index","capturetarget=1"; + &run_gphoto2_capture_target(@newcmd); + } else { + &run_gphoto2_capture_target(@newcmd); + } +} + my $workdir = `mktemp -d /tmp/testcamera.XXXXXX`; chomp $workdir; die "no workdir created" unless -d $workdir; @@ -57,21 +103,10 @@ if (!run_gphoto2("-L")) { ok(run_gphoto2("-L"),"testing -L"); ok(run_gphoto2("-l"),"testing -l"); ok(run_gphoto2("--summary"),"testing --summary"); +ok(run_gphoto2("--list-all-config"),"testing --list-all-config"); +ok(run_gphoto2("--list-config"),"testing --list-config"); -sub run_gphoto2_capture(@) { - my $text = pop; - my @cmd = @_; - - if ($camera{'havecapturetarget'}) { - my @newcmd = @cmd; - unshift @newcmd,"--set-config-index","capturetarget=0"; - ok(run_gphoto2(@newcmd),"$text: " . join(" ",@newcmd)); - @newcmd = @cmd; - unshift @newcmd,"--set-config-index","capturetarget=1"; - ok(run_gphoto2(@newcmd),"$text: " . join(" ",@newcmd)); - } else { - ok(run_gphoto2("--capture-image-and-download"),$text); - } +if ($camera{'havecapture'}) { + run_gphoto2_capture("--capture-image-and-download",1,"simple capture and download"); + run_gphoto2_capture("--capture-image-and-download","-F 5","-I 3",5,"simple capture and download"); } - -run_gphoto2_capture("--capture-image-and-download","simple capture and download"); |