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 90 91 92 93 94
|
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2::TestHelper tests => 18;
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 $parent = Gtk2::HBox->new();
my $view = Gtk2::SourceView2::View->new();
$parent->add($view);
isa_ok($view, 'Gtk2::SourceView2::View');
my $buffer = Gtk2::SourceView2::Buffer->new(undef);
$view = Gtk2::SourceView2::View->new_with_buffer($buffer);
$parent->add($view);
isa_ok($view, 'Gtk2::SourceView2::View');
}
sub test_properties {
my $parent = Gtk2::HBox->new();
my $view = Gtk2::SourceView2::View->new();
$parent->add($view);
is_int_ok($view, 'tab_width', 4, 6);
is_int_ok($view, 'indent_width', 4, 6);
is_int_ok($view, 'right_margin_position', 4, 6);
is_boolean_ok($view, 'show_line_numbers');
is_boolean_ok($view, 'auto_indent');
is_boolean_ok($view, 'insert_spaces_instead_of_tabs');
is_boolean_ok($view, 'indent_on_tab');
is_boolean_ok($view, 'highlight_current_line');
is_boolean_ok($view, 'show_right_margin');
is_boolean_ok($view, 'show_line_marks');
is_enum_ok($view, 'smart_home_end', 'before', 'after');
# Draw spaces
$view->set_draw_spaces(['space', 'tab']);
# Test::Simple 0.95 no longer stringifies its arguments before comparing
is('' . $view->get_draw_spaces, '[ space tab ]', "draw_spaces");
# Mark category (pixbuf, priority, background)
my $pixbuf = Gtk2::Gdk::Pixbuf->new("rgb", FALSE, 8, 10, 10);
$view->set_mark_category_pixbuf(test => $pixbuf);
is(
$view->get_mark_category_pixbuf('test'),
$pixbuf,
"mark_category_pixbuf"
);
$view->set_mark_category_pixbuf(test => undef);
is(
$view->get_mark_category_pixbuf('test'),
undef,
"mark_category_pixbuf undef"
);
$view->set_mark_category_priority(test => 15);
is(
$view->get_mark_category_priority('test'),
15,
"mark_category_priority"
);
my $color = Gtk2::Gdk::Color->new(65535, 0, 0);
$view->set_mark_category_background(test => $color);
is(
$view->get_mark_category_background('test')->pixel,
$color->pixel,
"mark_category_background"
);
}
|