]> err.no Git - libchamplain/commitdiff
Use the new constructors new_from_file new_with_image.
authorEmmanuel Rodriguez <emmanuel.rodriguez@gmail.com>
Mon, 13 Apr 2009 19:53:32 +0000 (21:53 +0200)
committerEmmanuel Rodriguez <emmanuel.rodriguez@gmail.com>
Mon, 13 Apr 2009 19:57:56 +0000 (21:57 +0200)
bindings/perl/Champlain/t/ChamplainMarker.t
bindings/perl/Champlain/xs/ChamplainMarker.xs

index 81b76478b2163312a95a197e7ab71ae071bf2a63..d0b63d15461d196442574f1f51d5eaaab6046511 100644 (file)
@@ -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);
 }
 
 
index 6e81c6993c0106cb10fbea8cb28ce76152bc42f6..8f6a3164cead798521b678789673a2341aae64eb 100644 (file)
@@ -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)