File: 0627_Dialog_Scan_CLI.t

package info (click to toggle)
gscan2pdf 2.13.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,880 kB
  • sloc: perl: 22,686; xml: 81; makefile: 6
file content (81 lines) | stat: -rw-r--r-- 2,307 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use warnings;
use strict;
use Test::More tests => 5;
use Glib qw(TRUE FALSE);    # To get TRUE and FALSE
use Gtk3 -init;             # Could just call init separately

BEGIN {
    use_ok('Gscan2pdf::Dialog::Scan::CLI');
}

#########################

my $window = Gtk3::Window->new;

Gscan2pdf::Translation::set_domain('gscan2pdf');
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($WARN);
my $logger = Log::Log4perl::get_logger;
Gscan2pdf::Frontend::CLI->setup($logger);

ok(
    my $dialog = Gscan2pdf::Dialog::Scan::CLI->new(
        title             => 'title',
        'transient-for'   => $window,
        'logger'          => $logger,
        'reload-triggers' => qw(mode),
    ),
    'Created dialog'
);
isa_ok( $dialog, 'Gscan2pdf::Dialog::Scan::CLI' );

$dialog->set( 'cache-options', TRUE );

$dialog->signal_connect(
    'process-error' => sub {
        my ( $widget, $process, $msg ) = @_;
        Gtk3->main_quit;
    }
);

my ( $signal, $signal2 );
$signal = $dialog->signal_connect(
    'reloaded-scan-options' => sub {
        $dialog->signal_handler_disconnect($signal);

        $signal = $dialog->signal_connect(
            'changed-options-cache' => sub {
                my ( $widget, $cache ) = @_;
                $dialog->signal_handler_disconnect($signal);
                my @keys = sort keys( %{ $cache->{test} } );
                is_deeply(
                    \@keys,
                    [ 'default', 'mode,Color', 'mode,Gray' ],
                    'starting with a non-default profile'
                );
                Gtk3->main_quit;
            }
        );
        $dialog->set_option(
            $dialog->get('available-scan-options')->by_name('mode'), 'Color' );
    }
);
$dialog->set( 'device-list', [ { 'name' => 'test' } ] );
$dialog->set( 'device', 'test' );

my $filename = 'scanners/Brother_DCP-7025';
SKIP: {
    skip 'source tree not available', 1 unless -r $filename;
    my $output  = do { local ( @ARGV, $/ ) = $filename; <> };
    my $options = Gscan2pdf::Scanner::Options->new_from_data($output);
    my $opt     = $options->by_name('contrast');
    is( $dialog->value_for_active_option( TRUE, $opt ),
        FALSE,
        'value_for_active_option() with defined value and inactive option' );
}

Gtk3->main;

#########################

__END__