~ubuntu-branches/ubuntu/vivid/gscan2pdf/vivid

« back to all changes in this revision

Viewing changes to t/242_cancel_threshold.t

  • Committer: Package Import Robot
  • Author(s): Jeffrey Ratcliffe
  • Date: 2015-01-30 21:49:19 UTC
  • mfrom: (1.1.23) (4.2.24 sid)
  • Revision ID: package-import@ubuntu.com-20150130214919-yhligsglhd84gsdo
Tags: 1.3.0-1
New upstream release
Closes: #774099
(avoid leading and trailing blanks in expanded filename template)
Closes: #774103 (fixes for date offset calculation)
Closes: #710428
(Add "Found ocropus" to log information on application start)
Closes: #774093 (various consistency updates for dialogs)
Closes: #774094 (misc. improvements for OCR'ed texts)
Closes: #774097 (when saving as DjVU, use MetaData)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use warnings;
 
2
use strict;
 
3
use Test::More tests => 2;
 
4
 
 
5
BEGIN {
 
6
    use Gscan2pdf::Document;
 
7
    use Gtk2 -init;    # Could just call init separately
 
8
}
 
9
 
 
10
#########################
 
11
 
 
12
use Log::Log4perl qw(:easy);
 
13
Log::Log4perl->easy_init($WARN);
 
14
my $logger = Log::Log4perl::get_logger;
 
15
Gscan2pdf::Document->setup($logger);
 
16
 
 
17
# Create test image
 
18
system('convert rose: test.jpg');
 
19
 
 
20
my $slist = Gscan2pdf::Document->new;
 
21
 
 
22
# dir for temporary files
 
23
my $dir = File::Temp->newdir;
 
24
$slist->set_dir($dir);
 
25
 
 
26
$slist->get_file_info(
 
27
    path              => 'test.jpg',
 
28
    finished_callback => sub {
 
29
        my ($info) = @_;
 
30
        $slist->import_file(
 
31
            info              => $info,
 
32
            first             => 1,
 
33
            last              => 1,
 
34
            finished_callback => sub {
 
35
                my $pid = $slist->threshold(
 
36
                    threshold          => 80,
 
37
                    page               => $slist->{data}[0][2],
 
38
                    cancelled_callback => sub {
 
39
                        is(
 
40
                            -s 'test.jpg',
 
41
                            -s "$slist->{data}[0][2]{filename}",
 
42
                            'image not modified'
 
43
                        );
 
44
                        $slist->save_image(
 
45
                            path              => 'test2.jpg',
 
46
                            list_of_pages     => [ $slist->{data}[0][2] ],
 
47
                            finished_callback => sub { Gtk2->main_quit }
 
48
                        );
 
49
                    }
 
50
                );
 
51
                $slist->cancel($pid);
 
52
            }
 
53
        );
 
54
    }
 
55
);
 
56
Gtk2->main;
 
57
 
 
58
is( system('identify test2.jpg'),
 
59
    0, 'can create a valid JPG after cancelling previous process' );
 
60
 
 
61
#########################
 
62
 
 
63
unlink 'test.jpg', 'test2.jpg';
 
64
Gscan2pdf::Document->quit();