~ubuntu-branches/debian/sid/gscan2pdf/sid

« back to all changes in this revision

Viewing changes to t/111_save_pdf.t

  • Committer: Package Import Robot
  • Author(s): Jeffrey Ratcliffe
  • Date: 2013-10-08 09:38:10 UTC
  • mfrom: (1.3.11)
  • Revision ID: package-import@ubuntu.com-20131008093810-dhoer6ktpjentiox
Tags: 1.1.3-1
* New upstream release
  Closes: #723784 (gscan2pdf: New upstream version available)
* Removed all patches
  Removed Build-Depends: quilt
  Updated rules not to use quilt
* Bumped standards to 3.9.4 (no changes required)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Before `make install' is performed this script should be runnable with
2
 
# `make test'. After `make install' it should work as `perl Gscan2pdf.t'
3
 
 
4
 
#########################
5
 
 
6
 
# change 'tests => 1' to 'tests => last_test_to_print';
7
 
 
8
1
use warnings;
9
2
use strict;
10
 
use Test::More tests => 3;
 
3
use Test::More tests => 2;
 
4
use Gtk2 -init;    # Could just call init separately
11
5
 
12
6
BEGIN {
13
 
 use_ok('Gscan2pdf');
14
7
 use_ok('Gscan2pdf::Document');
15
 
 use PDF::API2;
16
8
}
17
9
 
18
10
#########################
19
11
 
20
 
# Insert your test code below, the Test::More module is use()ed here so read
21
 
# its man page ( perldoc Test::More ) for help writing this test script.
22
 
 
23
 
# Thumbnail dimensions
24
 
our $widtht  = 100;
25
 
our $heightt = 100;
 
12
Glib::set_application_name('gscan2pdf');
26
13
 
27
14
use Log::Log4perl qw(:easy);
28
15
Log::Log4perl->easy_init($WARN);
29
 
our $logger = Log::Log4perl::get_logger;
30
 
my $prog_name = 'gscan2pdf';
31
 
use Locale::gettext 1.05;    # For translations
32
 
our $d = Locale::gettext->domain($prog_name);
33
 
Gscan2pdf->setup( $d, $logger );
 
16
my $logger = Log::Log4perl::get_logger;
 
17
Gscan2pdf::Document->setup($logger);
34
18
 
35
19
# Create test image
36
20
system('convert rose: test.pnm');
37
21
 
38
22
my $slist = Gscan2pdf::Document->new;
 
23
 
 
24
# dir for temporary files
 
25
my $dir = File::Temp->newdir;
 
26
$slist->set_dir($dir);
 
27
 
39
28
$slist->get_file_info(
40
 
 'test.pnm',
41
 
 undef, undef, undef,
42
 
 sub {
 
29
 path              => 'test.pnm',
 
30
 finished_callback => sub {
43
31
  my ($info) = @_;
44
32
  $slist->import_file(
45
 
   $info, 1, 1, undef, undef, undef,
46
 
   sub {
47
 
    $slist->save_pdf( 'test.pdf', [ $slist->{data}[0][2] ],
48
 
     undef, undef, undef, undef, undef, sub { Gtk2->main_quit } );
 
33
   info              => $info,
 
34
   first             => 1,
 
35
   last              => 1,
 
36
   finished_callback => sub {
 
37
    $slist->save_pdf(
 
38
     path              => 'test.pdf',
 
39
     list_of_pages     => [ $slist->{data}[0][2] ],
 
40
     finished_callback => sub { Gtk2->main_quit }
 
41
    );
49
42
   }
50
43
  );
51
44
 }
52
45
);
53
46
Gtk2->main;
54
47
 
55
 
is( system('identify test.pdf'), 0, 'valid PDF created' );
 
48
is(
 
49
 `pdfinfo test.pdf | grep 'Page size:'`,
 
50
 "Page size:      70 x 46 pts\n",
 
51
 'valid PDF created'
 
52
);
56
53
 
57
54
#########################
58
55
 
59
56
unlink 'test.pnm', 'test.pdf';
60
 
Gscan2pdf->quit();
 
57
Gscan2pdf::Document->quit();