File: GtkRecentChooser.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 (90 lines) | stat: -rw-r--r-- 2,500 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
82
83
84
85
86
87
88
89
90
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper
  tests => 15,
  at_least_version => [2, 10, 0, "GtkRecentChooser"];

# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkRecentChooser.t,v 1.2 2006/07/13 19:04:11 kaffeetisch Exp $

unlink "./test.xbel"; # in case of an aborted run
my $manager = Glib::Object::new("Gtk2::RecentManager", filename => "./test.xbel");

my $chooser = Gtk2::RecentChooserWidget -> new_for_manager($manager);
isa_ok($chooser, "Gtk2::RecentChooser");

$chooser -> set_show_private(TRUE);
ok($chooser -> get_show_private());

$chooser -> set_show_not_found(TRUE);
ok($chooser -> get_show_not_found());

$chooser -> set_select_multiple(TRUE);
ok($chooser -> get_select_multiple());

$chooser -> set_limit(23);
is($chooser -> get_limit(), 23);

$chooser -> set_local_only(TRUE);
ok($chooser -> get_local_only());

$chooser -> set_show_tips(TRUE);
ok($chooser -> get_show_tips());

$chooser -> set_show_icons(TRUE);
ok($chooser -> get_show_icons());

$chooser -> set_sort_type("mru");
is($chooser -> get_sort_type(), "mru");

$chooser -> set_sort_func(sub { warn join ", ", @_; }, "data");
$chooser -> set_sort_func(sub { warn join ", ", @_; });

# --------------------------------------------------------------------------- #

use Cwd qw(cwd);
my $uri_one = "file://" . cwd() . "/" . $0;
my $uri_two = "file://" . $^X;

$manager -> add_item($uri_one);
$manager -> add_item($uri_two);

$chooser -> set_select_multiple(FALSE);

run_main(sub {
  $chooser -> set_current_uri($uri_one);
});

run_main(sub {
  is($chooser -> get_current_uri(), $uri_one);
  is($chooser -> get_current_item() -> get_uri(), $uri_one);
});

$chooser -> select_uri($uri_two);
$chooser -> unselect_uri($uri_two);

$chooser -> set_select_multiple(TRUE);

$chooser -> select_all();
$chooser -> unselect_all();

is_deeply([$chooser -> get_uris()], [$uri_two, $uri_one]);
is_deeply([map { $_ -> get_uri() } $chooser -> get_items()], [$uri_two, $uri_one]);

my $filter_one = Gtk2::RecentFilter -> new();
my $filter_two = Gtk2::RecentFilter -> new();

$chooser -> add_filter($filter_one);
$chooser -> add_filter($filter_two);
is_deeply([$chooser -> list_filters()], [$filter_one, $filter_two]);
$chooser -> remove_filter($filter_two);
$chooser -> remove_filter($filter_one);

$chooser -> set_filter($filter_one);
is($chooser -> get_filter(), $filter_one);

unlink "./test.xbel";

__END__

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