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 82 83 84 85 86 87 88 89
|
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2::TestHelper tests => 20;
use FindBin;
use lib "$FindBin::Bin";
use my_helper;
use Glib qw(TRUE FALSE);
use Gtk2::SourceView2;
exit tests();
sub tests {
test_constructors();
test_properties();
return 0;
}
sub test_constructors {
my $print;
$print = Gtk2::SourceView2::PrintCompositor->new(
Gtk2::SourceView2::Buffer->new(undef)
);
isa_ok($print, 'Gtk2::SourceView2::PrintCompositor');
my $window = Gtk2::Window->new();
my $view = Gtk2::SourceView2::View->new();
$window->add($view);
$print = Gtk2::SourceView2::PrintCompositor->new_from_view($view);
isa_ok($print, 'Gtk2::SourceView2::PrintCompositor');
}
sub test_properties {
my $print = Gtk2::SourceView2::PrintCompositor->new(
Gtk2::SourceView2::Buffer->new(undef)
);
isa_ok($print, 'Gtk2::SourceView2::PrintCompositor');
isa_ok($print->get_buffer, 'Gtk2::SourceView2::Buffer');
is_int_ok($print, 'tab_width', 4, 6);
is_enum_ok($print, 'wrap_mode', 'word', 'char');
is_boolean_ok($print, 'highlight_syntax');
is_int_ok($print, 'print_line_numbers', 5, 10);
is_string_ok($print, 'body_font_name', "Sans 10", "Sans 12");
is_string_ok($print, 'line_numbers_font_name', "Sans 10", "Sans 12");
is_string_ok($print, 'header_font_name', "Sans 10", "Sans 12");
is_string_ok($print, 'footer_font_name', "Sans 10", "Sans 12");
is_unit_ok($print, 'top_margin', 10, 20, 'mm');
is_unit_ok($print, 'bottom_margin', 10, 20, 'inch');
is_unit_ok($print, 'left_margin', 10, 20, 'points');
is_unit_ok($print, 'right_margin', 10, 20, 'mm');
is_boolean_ok($print, 'print_header');
is_boolean_ok($print, 'print_footer');
is($print->get_n_pages, -1, "get_n_pages");
is($print->get_pagination_progress, 0, "get_pagination_progress");
# Can't be tested but at least we try them
$print->set_header_format(TRUE, "hello", "world", "!");
$print->set_header_format(TRUE, undef, undef, undef);
$print->set_footer_format(TRUE, "perl", "gtk2", "sourceview");
$print->set_footer_format(TRUE, undef, undef, undef);
}
sub is_unit_ok {
my ($view, $property, $val1, $val2, $unit) = @_;
my $get = "get_$property";
my $set = "set_$property";
my $value = $view->$get($unit);
my ($new_value) = ($value eq $val1 ? $val2 : $val1);
$view->$set($new_value, $unit);
my $tester = Test::Builder->new();
$tester->is_eq($view->$get($unit), $new_value, $property);
}
|