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
|
#!/usr/bin/perl -w
use strict;
use Gnome2::VFS;
use Test::More;
# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gnome2-VFS/t/GnomeVFSXfer.t,v 1.8 2006/03/12 22:07:08 kaffeetisch Exp $
plan -d "$ENV{ HOME }/.gnome" ?
(tests => 11) :
(skip_all => "You have no ~/.gnome");
Gnome2::VFS -> init();
###############################################################################
use Cwd qw(cwd);
use constant TMP => cwd() . "/tmp";
unless (-e TMP) {
mkdir(TMP) or die ("Urgh, couldn't create the scratch directory: $!");
}
###############################################################################
my $progress = sub {
my ($info) = @_;
my $done_that = 0 if 0;
isa_ok($info, "HASH") unless $done_that++;
if ($info -> { status } eq "ok") {
return 1;
}
elsif ($info -> { status } eq "vfserror") {
return "abort";
}
elsif ($info -> { status } eq "overwrite") {
return "replace";
}
return 0;
};
###############################################################################
foreach (qw(a e i o)) {
my $handle = Gnome2::VFS -> create(TMP . "/bl" . $_, "write", 1, 0644);
$handle -> write("blaaa!", 6);
$handle -> close();
}
###############################################################################
my $source = Gnome2::VFS::URI -> new("file://" . TMP . "/bla");
my $destination = Gnome2::VFS::URI -> new("file://" . TMP . "/blaa");
is(Gnome2::VFS::Xfer -> uri($source,
$destination,
qw(default),
qw(query),
qw(query),
$progress), "ok");
ok(-e $destination -> to_string(qw(toplevel-method)));
is($source -> unlink(), "ok");
is($destination -> unlink(), "ok");
###############################################################################
my @source = (Gnome2::VFS::URI -> new("file://" . TMP . "/ble"),
Gnome2::VFS::URI -> new("file://" . TMP . "/bli"),
Gnome2::VFS::URI -> new("file://" . TMP . "/blo"));
my @destination = (Gnome2::VFS::URI -> new("file://" . TMP . "/blee"),
Gnome2::VFS::URI -> new("file://" . TMP . "/blii"),
Gnome2::VFS::URI -> new("file://" . TMP . "/bloo"));
is(Gnome2::VFS::Xfer -> uri_list(\@source,
\@destination,
qw(default),
qw(query),
qw(query),
$progress), "ok");
foreach (@destination) {
ok(-e $_ -> to_string(qw(toplevel-method)));
}
is(Gnome2::VFS::Xfer -> delete_list(\@source,
qw(query),
qw(default),
$progress), "ok");
is(Gnome2::VFS::Xfer -> delete_list(\@destination,
qw(query),
qw(default),
$progress), "ok");
###############################################################################
Gnome2::VFS -> shutdown();
###############################################################################
rmdir(TMP) or die("Urgh, couldn't delete the scratch directory: $!\n");
|