File: RIFF.t

package info (click to toggle)
libimage-exiftool-perl 12.57%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,740 kB
  • sloc: perl: 280,930; xml: 120; makefile: 13
file content (81 lines) | stat: -rw-r--r-- 2,413 bytes parent folder | download
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
# Before "make install", this script should be runnable with "make test".
# After "make install" it should work as "perl t/RIFF.t".

BEGIN {
    $| = 1; print "1..7\n"; $Image::ExifTool::configFile = '';
    require './t/TestLib.pm'; t::TestLib->import();
}
END {print "not ok 1\n" unless $loaded;}

# test 1: Load the module(s)
use Image::ExifTool 'ImageInfo';
use Image::ExifTool::RIFF;
$loaded = 1;
print "ok 1\n";

my $testname = 'RIFF';
my $testnum = 1;

# tests 2-4: Extract information from RIFF.wav, RIFF.avi and RIFF.webp
{
    my $ext;
    foreach $ext (qw(wav avi webp)) {
        ++$testnum;
        my $exifTool = Image::ExifTool->new;
        my $info = $exifTool->ImageInfo("t/images/RIFF.$ext");
        print 'not ' unless check($exifTool, $info, $testname, $testnum);
        print "ok $testnum\n";
    }
}

# test 5: Edit EXIF and XMP
{
    ++$testnum;
    my $exifTool = Image::ExifTool->new;
    $exifTool->SetNewValue('exif:usercomment' => 'test comment');
    $exifTool->SetNewValue('xmp:description' => 'test description');
    $testfile = "t/${testname}_${testnum}_failed.webp";
    unlink $testfile;
    writeInfo($exifTool, 't/images/RIFF.webp', $testfile);
    my $info = $exifTool->ImageInfo($testfile);
    if (check($exifTool, $info, $testname, $testnum)) {
        unlink $testfile;
    } else {
        print 'not ';
    }
    print "ok $testnum\n";
}

# test 6: Delete all metadata from a WebP file
{
    ++$testnum;
    my $exifTool = Image::ExifTool->new;
    $exifTool->SetNewValue('all');
    $testfile = "t/${testname}_${testnum}_failed.webp";
    unlink $testfile;
    writeInfo($exifTool, 't/images/RIFF.webp', $testfile);
    my $info = $exifTool->ImageInfo($testfile);
    print 'not ' unless check($exifTool, $info, $testname, $testnum);
    print "ok $testnum\n";
}

# test 7: Add back WebP information
{
    ++$testnum;
    my $exifTool = Image::ExifTool->new;
    $exifTool->SetNewValue('exif:usercomment' => 'test comment 2');
    $exifTool->SetNewValue('xmp:description' => 'test description 2');
    my $testfile2 = "t/${testname}_${testnum}_failed.webp";
    unlink $testfile2;
    writeInfo($exifTool, $testfile, $testfile2);
    my $info = $exifTool->ImageInfo($testfile2);
    if (check($exifTool, $info, $testname, $testnum)) {
        unlink $testfile;
        unlink $testfile2;
    } else {
        print 'not ';
    }
    print "ok $testnum\n";
}

# end