File: GtkIMContext.t

package info (click to toggle)
libgtk2-perl 1%3A1.190-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,132 kB
  • ctags: 516
  • sloc: perl: 16,575; sh: 149; ansic: 148; makefile: 76
file content (61 lines) | stat: -rw-r--r-- 1,744 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
#!/usr/bin/perl -w
# vim: set ft=perl :

use Gtk2::TestHelper tests => 7;

my $context = Gtk2::IMContextSimple->new;
isa_ok ($context, 'Gtk2::IMContextSimple');
isa_ok ($context, 'Gtk2::IMContext');
isa_ok ($context, 'Glib::Object');


# unset.
$context->set_client_window (undef);


# something with which to mock up the tests
my $drawing_area = Gtk2::DrawingArea->new;
$drawing_area->set_size_request (200, 200);
$drawing_area->show;
my $window = Gtk2::Window->new;
$window->add ($drawing_area);
$window->show_now;

$context->set_client_window ($drawing_area->window);


my ($str, $attrs, $cursor_pos) = $context->get_preedit_string ();

my $key_event = Gtk2::Gdk::Event->new ('key-press');
$key_event->window ($drawing_area->window);
my $success = $context->filter_keypress ($key_event);

$context->focus_in ();
$context->focus_out ();
$context->reset ();
$context->set_cursor_location (Gtk2::Gdk::Rectangle->new (0, 0, 10, 10));
$context->set_use_preedit (TRUE);
$context->set_use_preedit (FALSE);
$context->set_surrounding ("some text", "3");

$context->signal_connect (retrieve_surrounding => sub {
	ok (1, 'retrieve_surrounding called');
});
my ($text, $cursor_index) = $context->get_surrounding ();
# The actual behavior here is dependent on the input method being used, so
# we can't rely on that for a test.  retrieve_surrounding will have been invoked,
# so that will have to suffice.
#is ($text, 'some text');
#is ($cursor_index, 3);

my $offset = 3;
my $n_chars = 2;
$success = $context->delete_surrounding ($offset, $n_chars);


$context = Gtk2::IMMulticontext->new;
isa_ok ($context, 'Gtk2::IMMulticontext');
isa_ok ($context, 'Gtk2::IMContext');
isa_ok ($context, 'Glib::Object');

$context->append_menuitems (Gtk2::Menu->new);