aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qtest/custom-filter.test
blob: 2d8acec6b85e56a61a549c5ffbf40a4a37310e02 (plain) (blame)
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
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

chdir("custom-filter") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('custom-filter');

# The file input.pdf contains two streams, whose contents appear
# uncompressed with explanatory text. They are marked with the keys
# that pdf-custom-filter uses to decide 1) to re-encode using the
# fictitious /XORDecode filter, and 2) whether to protect the stream
# to prevent decoding using the custom filter even when decoding
# specialized filters is requested.

$td->runtest("custom filter, decode generalized",
             {$td->COMMAND => "pdf-custom-filter input.pdf a.pdf"},
             {$td->STRING => "pdf-custom-filter: new file written to a.pdf\n",
                  $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->COMMAND => "qpdf-test-compare a.pdf generalized.pdf"},
             {$td->FILE => "generalized.pdf", $td->EXIT_STATUS => 0});

$td->runtest("custom filter, decode specialized",
             {$td->COMMAND =>
                  "pdf-custom-filter --decode-specialized input.pdf a.pdf"},
             {$td->STRING => "pdf-custom-filter: new file written to a.pdf\n",
                  $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->COMMAND => "qpdf-test-compare a.pdf specialized.pdf"},
             {$td->FILE => "specialized.pdf", $td->EXIT_STATUS => 0});

cleanup();

$td->report(4);

sub cleanup
{
    unlink "a.pdf";
}