aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/form-xobject.test
blob: 8ae5da965b9b4a23717f8a86969c6fbd54837a04 (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
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
#!/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('form-xobject');

my $n_tests = 22;

$td->runtest("form xobject creation",
             {$td->COMMAND => "test_driver 55 fxo-red.pdf"},
             {$td->STRING => "test 55 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("compare files",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "form-xobjects-out.pdf"});
foreach (my $i = 56; $i <= 59; ++$i)
{
    # See comments in test_driver.cc for a verbal description of what
    # the resulting files should look like.
    $td->runtest("overlay transformations",
                 {$td->COMMAND => "test_driver $i fxo-red.pdf fxo-blue.pdf"},
                 {$td->STRING => "test $i done\n", $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("compare files",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "fx-overlay-$i.pdf"});
}
foreach (my $i = 64; $i <= 67; ++$i)
{
    # See comments in test_driver.cc for a verbal description of what
    # the resulting files should look like.
    $td->runtest("overlay shrink/expand",
                 {$td->COMMAND =>
                      "test_driver $i fxo-bigsmall.pdf fxo-smallbig.pdf"},
                 {$td->STRING => "test $i done\n", $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("compare files",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "fx-overlay-$i.pdf"});
}

my @uo_cases = (
    '--underlay fxo-green.pdf --repeat=z --to=1-14 --' .
    ' --overlay --file=fxo-blue.pdf --', # 1
    '--overlay fxo-green.pdf --from= --repeat=r2,r1 --' .
    ' --underlay --file=fxo-blue.pdf --from=z-1 --', # 2
    '--overlay fxo-green.pdf --from= --repeat=r2,r1 --' .
    ' --underlay fxo-blue.pdf --from=z-1 -- --coalesce-contents', # 3
    '--overlay fxo-green.pdf --', # 4
    '--underlay fxo-green.pdf --to=3-7 --', # 5
    '--overlay fxo-blue.pdf --to=1,1,1,1 --from=1-4 --' .
    ' --pages . 1 --', #6
    '--overlay 20-pages.pdf --password=user --', #7
    '--overlay fxo-blue.pdf --to=1-4 --from=1-4 --' .
    ' --overlay fxo-green.pdf --to=1-4 --from=4-1 --' .
    ' --underlay fxo-blue.pdf --to=4-1 --from=5-8 --' .
    ' --underlay fxo-green.pdf --to=4-1 --from=8-5 --' .
    ' --pages . 1-4 --', #8
    );
$n_tests += 2 * scalar(@uo_cases);
for (my $i = 1; $i <= scalar(@uo_cases); ++$i)
{
    my $args = $uo_cases[$i-1];
    my $outbase = "uo-$i";
    $td->runtest("overlay/underlay $i",
                 {$td->COMMAND =>
                      "qpdf --static-id --qdf --no-original-object-ids" .
                      " --verbose fxo-red.pdf a.pdf $args"},
                 {$td->FILE => "$outbase.out", $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("compare files",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "$outbase.pdf"});
}
$td->runtest("foreach",
             {$td->COMMAND => "test_driver 71 nested-form-xobjects.pdf"},
             {$td->FILE => "nested-form-xobjects.out",
                  $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("page operations on form xobject",
             {$td->COMMAND => "test_driver 72 nested-form-xobjects.pdf"},
             {$td->FILE => "page-ops-on-form-xobject.out",
                  $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("overlay on page with no resources",
             {$td->COMMAND =>
                  "qpdf --deterministic-id page-with-no-resources.pdf" .
                  " --overlay minimal.pdf -- a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check overlay with no resources output",
             {$td->COMMAND => "qpdf-test-compare a.pdf overlay-no-resources.pdf"},
             {$td->FILE => "overlay-no-resources.pdf", $td->EXIT_STATUS => 0});

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