summaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/copy-foreign-objects.test
blob: 73f50e0a42d262211aea796764e72b91b0276a14 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

unshift(@INC, '.');
require qpdf_test_helpers;

chdir("qpdf") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('copy-foreign-objects');

my $n_tests = 11;

foreach my $d ([25, 1], [26, 2], [27, 3])
{
    my ($testn, $outn) = @$d;
    $td->runtest("copy objects $outn",
                 {$td->COMMAND => "test_driver $testn" .
                      " minimal.pdf copy-foreign-objects-in.pdf"},
                 {$td->FILE => "copy-foreign-objects-$testn.out",
                      $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("check output",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "copy-foreign-objects-out$outn.pdf"});
}
$td->runtest("copy objects error",
             {$td->COMMAND => "test_driver 28" .
                  " copy-foreign-objects-in.pdf minimal.pdf"},
             {$td->FILE => "copy-foreign-objects-errors.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

# Issue 449 involved indirect /Filter or /DecodeParms in streams that
# had their stream data replaced. The hand-generated
# indirect-filter.pdf file more or less reproduces the situation but
# doesn't result in the same internal error that 449 did with 10.0.1.
# The file issue-449.pdf was minimized by hand from a test case and
# does produce an internal error, though the exact reason is unclear.
# It seems to just have to do with the order in which things are
# copied.
$td->runtest("indirect filters",
             {$td->COMMAND => "test_driver 69 indirect-filter.pdf"},
             {$td->STRING => "test 69 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
foreach my $i (0, 1)
{
    $td->runtest("check output",
                 {$td->FILE => "auto-$i.pdf"},
                 {$td->FILE => "indirect-filter-out-$i.pdf"});
}
$td->runtest("issue 449",
             {$td->COMMAND => "test_driver 69 issue-449.pdf"},
             {$td->FILE => "issue-449.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

cleanup();
$td->report($n_tests);