[perl-Glib-IO] Add more GFile-related tests
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-IO] Add more GFile-related tests
- Date: Mon, 19 Apr 2010 20:48:38 +0000 (UTC)
commit 0df5a3e2e067eb0139e8a72738d502b45c491a2a
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Mon Apr 19 21:44:31 2010 +0200
Add more GFile-related tests
t/file-attribute.t | 16 +++++++++++
t/file.t | 76 +++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 76 insertions(+), 16 deletions(-)
---
diff --git a/t/file-attribute.t b/t/file-attribute.t
new file mode 100644
index 0000000..69e6287
--- /dev/null
+++ b/t/file-attribute.t
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+use Glib::IO;
+
+{
+ my $file = Glib::IO::File::new_for_path ($0);
+ my $attrs = $file->query_settable_attributes ();
+
+ $attrs->add ('perl::booze', 'boolean', [qw/copy-with-file copy-when-moved/]);
+ my $attr = $attrs->lookup ('perl::booze');
+ is ($attr->{name}, 'perl::booze');
+ ok ($attr->{flags} == [qw/copy-with-file copy-when-moved/]);
+ is ($attr->{type}, 'boolean');
+}
diff --git a/t/file.t b/t/file.t
index e746d60..2091524 100644
--- a/t/file.t
+++ b/t/file.t
@@ -1,29 +1,73 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 11;
use Glib::IO;
-my $loop = Glib::MainLoop->new ();
+SKIP: {
+ skip 'hash is broken', 1;
-# FIXME: Glib::IO::File->new_for_path?
-my $file = Glib::IO::File::new_for_path ($0);
+ # FIXME: Glib::IO::File->new_for_path?
+ my $file = Glib::IO::File::new_for_path ($0);
+ ok (defined $file->hash ());
+}
+
+{
+ my $file = Glib::IO::File::new_for_path ('non-existent');
+ my $result = eval { $file->read (); 1 };
+ ok (!$result);
+ ok (defined $@);
+}
+
+{
+ my $loop = Glib::MainLoop->new ();
-$file->query_info_async ('*', [], 0, undef, \&info, [ 23, 'bla' ]);
-sub info {
- my ($file, $res, $data) = @_;
+ my $file = Glib::IO::File::new_for_path ($0);
+ $file->query_info_async ('*', [], 0, undef, \&info, [ 23, 'bla' ]);
+ sub info {
+ my ($file, $res, $data) = @_;
- my $info = $file->query_info_finish ($res);
- ok (defined $info->get_name ());
- ok (defined $info->get_size ());
+ my $info = $file->query_info_finish ($res);
+ ok (defined $info->get_name ());
+ ok (defined $info->get_size ());
- {
- local $TODO = 'FIXME: user data does not get through in this case';
- is ($data->[0], 23);
- is ($data->[1], 'bla');
+ {
+ local $TODO = 'FIXME: user data does not get through in this case';
+ is_deeply ($data, [ 23, 'bla' ]);
+ }
+
+ $loop->quit ();
}
- $loop->quit ();
+ $loop->run ();
}
-$loop->run ();
+SKIP: {
+ skip 'FIXME: copy_async with progress callback is broken', 5;
+
+ my $loop = Glib::MainLoop->new ();
+
+ my $src = Glib::IO::File::new_for_path ($0);
+ my $dst = Glib::IO::File::new_for_path ($0 . '.bak');
+ $src->copy_async ($dst, [], 0, undef, \&progress, [ 23, 'bla' ], \&read, [ 42, 'blub' ]);
+
+ my $progress_called = 0;
+ sub progress {
+ my ($current, $total, $data) = @_;
+ return if $progress_called++;
+ ok (defined $current);
+ ok (defined $total);
+ is_deeply ($data, [ 23, 'bla' ]);
+ }
+ sub read {
+ my ($file, $res, $data) = @_;
+ my $success = $file->copy_finish ($res);
+ ok ($success);
+ is_deeply ($data, [ 42, 'blub' ]);
+ $loop->quit ();
+ }
+
+ $loop->run ();
+
+ $dst->delete ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]