File: PangoLayout.t

package info (click to toggle)
libgtk2-perl 1%3A1.140-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,808 kB
  • ctags: 609
  • sloc: perl: 14,245; ansic: 118; makefile: 70
file content (158 lines) | stat: -rw-r--r-- 3,961 bytes parent folder | download | duplicates (2)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper tests => 53;

# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/PangoLayout.t,v 1.12 2005/02/26 16:28:24 kaffeetisch Exp $

my $label = Gtk2::Label -> new("Bla");
my $context = $label -> create_pango_context();

my $layout = Gtk2::Pango::Layout -> new($context);
isa_ok($layout, "Gtk2::Pango::Layout");
is($layout -> get_context(), $context);

$layout -> context_changed();

$layout -> set_text("Bla bla.");
is($layout -> get_text(), "Bla bla.");

$layout -> set_markup("Bla bla.");
is($layout -> set_markup_with_accel("Bla _bla.", "_"), "b");

my $font = Gtk2::Pango::FontDescription -> new();

$layout -> set_font_description($font);

SKIP: {
  skip("set_font_description was slightly borken", 0)
    unless (Gtk2::Pango -> CHECK_VERSION(1, 4, 0));

  $layout -> set_font_description(undef);
}

SKIP: {
  skip("new 1.8 stuff", 2)
    unless (Gtk2::Pango -> CHECK_VERSION(1, 8, 0));

  is($layout -> get_font_description(), undef);

  $layout -> set_font_description($font);
  isa_ok($layout -> get_font_description(), "Gtk2::Pango::FontDescription");
}

$layout -> set_width(23);
is($layout -> get_width(), 23);

$layout -> set_wrap("word");
is($layout -> get_wrap(), "word");

$layout -> set_indent(5);
is($layout -> get_indent(), 5);

$layout -> set_spacing(5);
is($layout -> get_spacing(), 5);

$layout -> set_justify(1);
is($layout -> get_justify(), 1);

my $attributes = $layout -> get_attributes();
isa_ok($attributes, "Gtk2::Pango::AttrList");
$layout -> set_attributes($attributes);

SKIP: {
  skip("[sg]et_auto_dir are new in 1.3.5", 1)
    unless (Gtk2::Pango -> CHECK_VERSION(1, 4, 0));

  $layout -> set_auto_dir(1);
  is($layout -> get_auto_dir(), 1);
}

$layout -> set_alignment("left");
is($layout -> get_alignment(), "left");

$layout -> set_tabs(Gtk2::Pango::TabArray -> new(8, 0));
isa_ok($layout -> get_tabs(), "Gtk2::Pango::TabArray");

$layout -> set_single_paragraph_mode(1);
is($layout -> get_single_paragraph_mode(), 1);

my $attribute = ($layout -> get_log_attrs())[0];
isa_ok($attribute, "HASH");

is_deeply($attribute, {
  is_line_break => 0,
  is_mandatory_break => 0,
  is_char_break => 1,
  is_white => 0,
  is_cursor_position => 1,
  is_word_start => 1,
  is_word_end => 0,
  is_sentence_boundary => 0,
  is_sentence_start => 1,
  is_sentence_end => 0,
  Gtk2::Pango -> CHECK_VERSION(1, 4, 0) ?
    (backspace_deletes_character => 1) :
    ()
});

foreach ($layout -> index_to_pos(23),
         $layout -> get_cursor_pos(1),
         $layout -> get_extents(),
         $layout -> get_pixel_extents()) {
  isa_ok($_, "HASH");
}

my $number = qr/^\d+$/;

my ($index, $trailing) = $layout -> xy_to_index(5, 5);
like($index, $number);
like($trailing, $number);

is_deeply([$layout -> move_cursor_visually(1, 0, 0, 1)], [1, 0]);

my ($width, $height) = $layout -> get_size();
like($width, $number);
like($height, $number);

($width, $height) = $layout -> get_pixel_size();
like($width, $number);
like($height, $number);

like($layout -> get_line_count(), $number);

my $iter = $layout -> get_iter();
isa_ok($iter, "Gtk2::Pango::LayoutIter");

foreach ($iter -> get_char_extents(),
         $iter -> get_cluster_extents(),
         $iter -> get_run_extents(),
         $iter -> get_line_extents(),
         $iter -> get_layout_extents()) {
  isa_ok($_, "HASH");
}

my ($y0, $y1) = $iter -> get_line_yrange();
like($y0, $number);
like($y1, $number);

ok($iter -> next_run());
ok($iter -> next_char());
ok($iter -> next_cluster());
ok(!$iter -> next_line());
ok($iter -> at_last_line());

like($iter -> get_index(), $number);
like($iter -> get_baseline(), $number);

SKIP: {
  skip("[sg]et_ellipsize are new in 1.6", 1)
    unless (Gtk2::Pango -> CHECK_VERSION(1, 6, 0));

  $layout -> set_ellipsize("end");
  is($layout -> get_ellipsize(), "end");
}

__END__

Copyright (C) 2003-2005 by the gtk2-perl team (see the file AUTHORS for the
full list).  See LICENSE for more information.