1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
# Before "make install", this script should be runnable with "make test".
# After "make install" it should work as "perl t/CanonVRD.t".
BEGIN { $| = 1; print "1..12\n"; $Image::ExifTool::noConfig = 1; }
END {print "not ok 1\n" unless $loaded;}
# test 1: Load the module(s)
use Image::ExifTool 'ImageInfo';
use Image::ExifTool::CanonVRD;
$loaded = 1;
print "ok 1\n";
use t::TestLib;
my $testname = 'CanonVRD';
my $testnum = 1;
# short list of tags to check in tests
my @checkTags = qw(FileSize Warning VRDVersion VRDOffset);
# test 2: Extract information from CanonVRD.vrd
{
++$testnum;
my $exifTool = new Image::ExifTool;
my $info = $exifTool->ImageInfo('t/images/CanonVRD.vrd', {Duplicates => 1});
print 'not ' unless check($exifTool, $info, $testname, $testnum);
print "ok $testnum\n";
}
# test 3: Test writing some information
{
++$testnum;
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg');
$exifTool->SetNewValue('xmp:*');
my $testfile = "t/${testname}_${testnum}_failed.vrd";
unlink $testfile;
$exifTool->WriteInfo('t/images/CanonVRD.vrd', $testfile);
my $info = $exifTool->ImageInfo($testfile);
if (check($exifTool, $info, $testname, $testnum)) {
unlink $testfile;
} else {
print 'not ';
}
print "ok $testnum\n";
}
# tests 4-8: Write CanonVRD as a block to various images
{
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValuesFromFile('t/images/CanonVRD.vrd', 'CanonVRD');
$exifTool->Options(PrintConv => 0);
my ($file, $ext);
foreach $file (qw(Writer.jpg ExifTool.jpg CanonRaw.cr2 CanonRaw.crw CanonVRD.vrd)) {
++$testnum;
if ($file eq 'CanonVRD.vrd') {
$exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg', 'CanonVRD');
}
($ext = $file) =~ s/^\w+//;
my $testfile = "t/${testname}_${testnum}_failed$ext";
unlink $testfile;
$exifTool->WriteInfo("t/images/$file", $testfile);
my $info = $exifTool->ImageInfo($testfile, @checkTags);
if (check($exifTool, $info, $testname, $testnum)) {
unlink $testfile;
} else {
print 'not ';
}
print "ok $testnum\n";
}
}
# test 9: Delete VRD as a block
{
++$testnum;
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValue(CanonVRD => undef, Protected => 1);
my $testfile = "t/${testname}_${testnum}_failed.jpg";
unlink $testfile;
$exifTool->WriteInfo('t/images/ExifTool.jpg', $testfile);
$exifTool->Options(PrintConv => 0);
my $info = $exifTool->ImageInfo($testfile, @checkTags);
if (check($exifTool, $info, $testname, $testnum)) {
unlink $testfile;
} else {
print 'not ';
}
print "ok $testnum\n";
}
# test 10: Create a VRD file from scratch
{
++$testnum;
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg', 'CanonVRD');
$exifTool->Options(PrintConv => 0);
my $testfile = "t/${testname}_${testnum}_failed.vrd";
unlink $testfile;
$exifTool->WriteInfo(undef, $testfile);
my $info = $exifTool->ImageInfo($testfile, @checkTags);
if (check($exifTool, $info, $testname, $testnum, 8)) {
unlink $testfile;
} else {
print 'not ';
}
print "ok $testnum\n";
}
# test 11-12: Add XMP to a VRD file
{
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValue('XMP:Title', 'XMP in VRD test');
my $srcfile;
foreach $srcfile ('t/images/CanonVRD.vrd', undef) {
++$testnum;
my $testfile = "t/${testname}_${testnum}_failed.vrd";
unlink $testfile;
$exifTool->WriteInfo($srcfile, $testfile);
my $info = $exifTool->ImageInfo($testfile);
if (check($exifTool, $info, $testname, $testnum)) {
unlink $testfile;
} else {
print 'not ';
}
print "ok $testnum\n";
}
}
# end
|