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

« back to all changes in this revision

Viewing changes to t/213_rotate_with_error.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
 
 
36
                # inject error before rotate
 
37
                chmod 0500, $dir;    # no write access
 
38
 
 
39
                $slist->rotate(
 
40
                    angle          => 90,
 
41
                    page           => $slist->{data}[0][2],
 
42
                    error_callback => sub {
 
43
                        ok( 1, 'caught error injected before rotate' );
 
44
                        chmod 0700, $dir;    # allow write access
 
45
 
 
46
                        $slist->rotate(
 
47
                            angle           => 90,
 
48
                            page            => $slist->{data}[0][2],
 
49
                            queued_callback => sub {
 
50
 
 
51
                                # inject error during rotate
 
52
                                chmod 0500, $dir;    # no write access
 
53
                            },
 
54
                            error_callback => sub {
 
55
                                ok( 1,
 
56
                                    'rotate caught error injected in queue' );
 
57
                                chmod 0700, $dir;    # allow write access
 
58
                                Gtk2->main_quit;
 
59
                            }
 
60
                        );
 
61
 
 
62
                    }
 
63
                );
 
64
            }
 
65
        );
 
66
    }
 
67
);
 
68
Gtk2->main;
 
69
 
 
70
#########################
 
71
 
 
72
unlink 'test.jpg', <$dir/*>;
 
73
rmdir $dir;
 
74
Gscan2pdf::Document->quit();