our
$str
=
<<__EOB__
<?xml version="1.0" encoding="UTF-8"?>
<xbel version="1.0"
>
<bookmark href="file:///tmp/test-file.txt" added="2006-03-22T18:54:00Z" modified="2006-03-22T18:54:00Z" visited="2006-03-22T18:54:00Z">
<title>Test File</title>
<desc>Some test file</desc>
<info>
<mime:mime-type type="text/plain"/>
<bookmark:applications>
<bookmark:application name="Gedit" exec="gedit %u" timestamp="1143053640" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
</xbel>
__EOB__
;
SKIP: {
skip
"Glib::BookmarkFile is new in glib 2.12.0"
, 30
unless
Glib->CHECK_VERSION (2, 12, 0);
ok (
defined
Glib::BookmarkFile->new (),
'test constructor'
);
my
$bookmark_file
= Glib::BookmarkFile->new;
isa_ok (
$bookmark_file
,
'Glib::BookmarkFile'
,
'test ISA'
);
my
$size
;
$size
=
$bookmark_file
->get_size;
is (
$size
, 0,
'we have no bookmarks'
);
$bookmark_file
->load_from_data (
$str
);
$size
=
$bookmark_file
->get_size;
is (
$size
, 1,
'we have one bookmark'
);
my
@uris
=
$bookmark_file
->get_uris;
is (
@uris
,
$size
,
'check size'
);
ok (
$bookmark_file
->has_item(
$uris
[0]),
'check has item'
);
is (
$bookmark_file
->get_title(
$uris
[0]),
'Test File'
,
'check get_title'
);
$bookmark_file
->set_title(
$uris
[0],
'Test file'
);
is (
$bookmark_file
->get_title(
$uris
[0]),
'Test file'
,
'check set_title'
);
is (
$bookmark_file
->get_description(
$uris
[0]),
'Some test file'
,
'check get_description'
);
$bookmark_file
->set_description(
$uris
[0],
'Foo'
);
is (
$bookmark_file
->get_description(
$uris
[0]),
'Foo'
,
'check set_description'
);
is (
$bookmark_file
->get_mime_type(
$uris
[0]),
'text/plain'
,
'check get_mime_type'
);
$bookmark_file
->set_mime_type(
$uris
[0],
'image/png'
);
is (
$bookmark_file
->get_mime_type(
$uris
[0]),
'image/png'
,
'check set_mime_type'
);
$bookmark_file
->set_title(
$uri
,
'Another file'
);
$bookmark_file
->set_description(
$uri
,
'Yet another test file'
);
$bookmark_file
->add_group(
$uri
,
'Editors'
);
$bookmark_file
->add_group(
$uri
,
'Stuff'
);
my
@groups
=
$bookmark_file
->get_groups(
$uri
);
is (
@groups
, 2,
'check add group'
);
$bookmark_file
->remove_group(
$uri
,
'Stuff'
);
ok (!
$bookmark_file
->has_group(
$uri
,
'Stuff'
),
'check has_group'
);
$bookmark_file
->add_application(
$uri
,
'Gedit'
,
'gedit %u'
);
ok (
$bookmark_file
->has_application(
$uri
,
'Gedit'
),
'check add_application'
);
ok (!
$bookmark_file
->has_application(
$uri
,
'Vim'
),
'check has_application'
);
$bookmark_file
->add_application(
$uri
,
'Vim'
,
'gvim %f'
);
$bookmark_file
->add_application(
$uri
,
'Gedit'
,
'gedit %u'
);
my
(
$exec
,
$count
,
$stamp
) =
$bookmark_file
->get_app_info(
$uri
,
'Gedit'
);
is (
$exec
,
"gedit $uri"
,
'check get_app_info/1'
);
is (
$count
,
'2'
,
'check get_app_info/2'
);
my
$now
=
time
();
$bookmark_file
->set_app_info(
$uri
,
'Vim'
,
'gvim %f'
, 42,
$now
);
is (
$now
,
$bookmark_file
->get_modified(
$uri
),
'check set_app_info/1'
);
(
undef
,
$count
,
$stamp
) =
$bookmark_file
->get_app_info(
$uri
,
'Vim'
);
is (
$count
, 42,
'check set_app_info/2'
);
is (
$stamp
,
$now
,
'check set_app_info/3'
);
$bookmark_file
->set_app_info(
$uri
,
'Gedit'
,
''
, 0, 1);
ok (!
$bookmark_file
->has_application(
$uri
,
'Gedit'
),
'check set_app_info/4'
);
$bookmark_file
->remove_application(
$uri
,
'Vim'
);
ok (!
$bookmark_file
->has_application(
$uri
,
'Vim'
),
'check remove_application'
);
$bookmark_file
->move_item(
$uri
,
$new_uri
);
ok (
$bookmark_file
->has_item(
$new_uri
),
'check move_item/1'
);
ok (!
$bookmark_file
->has_item(
$uri
),
'check move_item/2'
);
$bookmark_file
->move_item(
$new_uri
,
undef
);
ok (!
$bookmark_file
->has_item(
$new_uri
),
'check move_item/3'
);
$bookmark_file
->remove_item(
$uris
[0]);
is (
$bookmark_file
->get_size, 0,
'check_remove_item'
);
$bookmark_file
->set_added(
$uri
,
$now
);
is (
$bookmark_file
->get_added(
$uri
),
$now
,
'check added accessors'
);
$bookmark_file
->set_modified(
$uri
,
$now
);
is (
$bookmark_file
->get_modified(
$uri
),
$now
,
'check modified accessors'
);
$bookmark_file
->set_visited(
$uri
,
$now
);
is (
$bookmark_file
->get_visited(
$uri
),
$now
,
'check visited accessors'
);
}