aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/page-api.test
blob: c976a6e6e135cd6da161a4998016fc6c0a6d4fa9 (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
#!/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('page-api');

$td->runtest("basic page API",
             {$td->COMMAND => "test_driver 15 page_api_1.pdf"},
             {$td->STRING => "test 15 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "page_api_1-out.pdf"});
$td->runtest("manual page manipulation",
             {$td->COMMAND => "test_driver 16 page_api_1.pdf"},
             {$td->STRING => "test 16 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "page_api_1-out2.pdf"});
$td->runtest("duplicate page",
             {$td->COMMAND => "test_driver 17 page_api_2.pdf"},
             {$td->FILE => "page_api_2.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("delete and re-add a page",
             {$td->COMMAND => "test_driver 18 page_api_1.pdf"},
             {$td->STRING => "test 18 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "page_api_1-out3.pdf"});
$td->runtest("duplicate page",
             {$td->COMMAND => "test_driver 19 page_api_1.pdf"},
             {$td->FILE => "page_api_1.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("remove page we don't have",
             {$td->COMMAND => "test_driver 22 page_api_1.pdf"},
             {$td->FILE => "page_api_1.out2", $td->EXIT_STATUS => 2},
             $td->NORMALIZE_NEWLINES);
$td->runtest("flatten rotation",
             {$td->COMMAND => "qpdf --static-id --qdf".
                  " --no-original-object-ids" .
                  " --flatten-rotation boxes.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "boxes-flattened.pdf"});
$td->runtest("get box methods",
             {$td->COMMAND => "test_driver 94 boxes2.pdf"},
             {$td->STRING => "test 94 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

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