aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/specialized-filter.test
blob: 605dd7f284e9c0996ad9c39a4d269780d2581121 (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
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;
use Digest::MD5;
use File::Copy;

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

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

require TestDriver;

cleanup();

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

my $n_tests = 5;
my $n_compare_pdfs = 1;

# The PDF file was submitted on bug #83 on github. All the PNG filters
# are exercised. The test suite does not exercise PNG predictors with
# LZW because I don't have a way to create such a file, but it's very
# likely that it will work since the handling of the PNG filters is
# separate from the regular decompression.
$td->runtest("decode png-filtering",
             {$td->COMMAND => "qpdf --static-id" .
                  " --compress-streams=n --decode-level=generalized" .
                  " png-filters.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "png-filters-decoded.pdf"});
compare_pdfs($td, "png-filters.pdf", "a.pdf");

$td->runtest("stream with tiff predictor",
             {$td->COMMAND => "qpdf --check tiff-predictor.pdf"},
             {$td->FILE => "tiff-predictor.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
# TC:SF_FlateLzwDecode PNG filter
# PDF:Table 8:Columns
# The test file is invalid as it does not actually use one column (as is implied by the missing
# key). However png-filters-1-column.pdf is the same file with /Columns explicitely set to 1,
# and displays the same as png-filters-no-columns.pdf and png-filters-no-columns-decoded.pdf.
$td->runtest("decode flate no /Columns",
             {$td->COMMAND => "qpdf --static-id --compress-streams=n --decode-level=all" .
                  " png-filters-no-columns.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "png-filters-no-columns-decoded.pdf"});
cleanup();
$td->report(calc_ntests($n_tests, $n_compare_pdfs));