From f6ab5ddb615c1b7c7eebf78069044339caaf76f0 Mon Sep 17 00:00:00 2001 From: Emmanuel Rodriguez Date: Mon, 13 Apr 2009 21:53:32 +0200 Subject: [PATCH] Use the new constructors new_from_file new_with_image. --- bindings/perl/Champlain/t/ChamplainMarker.t | 43 +++++++++++-------- bindings/perl/Champlain/xs/ChamplainMarker.xs | 13 ++++-- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/bindings/perl/Champlain/t/ChamplainMarker.t b/bindings/perl/Champlain/t/ChamplainMarker.t index 81b7647..d0b63d1 100644 --- a/bindings/perl/Champlain/t/ChamplainMarker.t +++ b/bindings/perl/Champlain/t/ChamplainMarker.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Clutter::TestHelper tests => 158; +use Clutter::TestHelper tests => 214; use Test::Builder; use Champlain ':coords'; @@ -19,8 +19,9 @@ exit tests(); sub tests { test_new(); test_new_with_text(); - test_new_with_image(); + test_new_from_file(); test_new_full(); + test_new_with_image(); return 0; } @@ -70,39 +71,43 @@ sub test_new_with_text { } -sub test_new_with_image { - my $marker = Champlain::Marker->new_with_image($FILENAME); +sub test_new_from_file { + my $marker = Champlain::Marker->new_from_file($FILENAME); isa_ok($marker, 'Champlain::Marker'); isa_ok($marker->get_image, 'Clutter::Actor'); generic_test($marker); # Assert that using a file that doesn't exist throws an exception eval { - $marker = Champlain::Marker->new_with_image("does-not-exist.gif"); + $marker = Champlain::Marker->new_from_file("does-not-exist.gif"); }; isa_ok($@, "Glib::File::Error"); } sub test_new_full { - my $marker = Champlain::Marker->new_full( - "hello", - $FILENAME, - ); + my $texture = Clutter::Texture->new(); + my $marker = Champlain::Marker->new_full("hello", $texture); isa_ok($marker, 'Champlain::Marker'); is($marker->get_text, 'hello', "new_full() sets 'text'"); isa_ok($marker->get_image, 'Clutter::Actor'); generic_test($marker); - - # Assert that using a file that doesn't exist throws an exception - $@ = undef; - eval { - $marker = Champlain::Marker->new_full( - "test", - "does-not-exist.gif", - ); - }; - isa_ok($@, "Glib::File::Error"); + + + $marker = Champlain::Marker->new_full("null-image", undef); + isa_ok($marker, 'Champlain::Marker'); + is($marker->get_text, 'null-image', "new_full(text, undef) sets 'text'"); + is($marker->get_image, undef, "new_full(text, undef) sets no image"); + generic_test($marker); +} + + +sub test_new_with_image { + my $texture = Clutter::Texture->new(); + my $marker = Champlain::Marker->new_with_image($texture); + isa_ok($marker, 'Champlain::Marker'); + isa_ok($marker->get_image, 'Clutter::Actor'); + generic_test($marker); } diff --git a/bindings/perl/Champlain/xs/ChamplainMarker.xs b/bindings/perl/Champlain/xs/ChamplainMarker.xs index 6e81c69..8f6a316 100644 --- a/bindings/perl/Champlain/xs/ChamplainMarker.xs +++ b/bindings/perl/Champlain/xs/ChamplainMarker.xs @@ -15,11 +15,11 @@ champlain_marker_new_with_text (class, const gchar *text, const gchar_ornull *fo ClutterActor* -champlain_marker_new_with_image (class, const gchar *filename) +champlain_marker_new_from_file (class, const gchar *filename) PREINIT: GError *error = NULL; CODE: - RETVAL = champlain_marker_new_with_image(filename, &error); + RETVAL = champlain_marker_new_from_file(filename, &error); if (error) { gperl_croak_gerror(NULL, error); } @@ -28,11 +28,11 @@ champlain_marker_new_with_image (class, const gchar *filename) ClutterActor* -champlain_marker_new_full (class, const gchar *text, const gchar *filename) +champlain_marker_new_full (class, const gchar *text, ClutterActor_ornull *actor) PREINIT: GError *error = NULL; CODE: - RETVAL = champlain_marker_new_full(text, filename, &error); + RETVAL = champlain_marker_new_full(text, actor, &error); if (error) { gperl_croak_gerror(NULL, error); } @@ -40,6 +40,11 @@ champlain_marker_new_full (class, const gchar *text, const gchar *filename) RETVAL +ClutterActor* +champlain_marker_new_with_image (class, ClutterActor* actor) + C_ARGS: actor + + void champlain_marker_set_text (ChamplainMarker *marker, const gchar *text) -- 2.39.5