]> err.no Git - libchamplain/commitdiff
Test the property selection-mode
authorEmmanuel Rodriguez <emmanuel.rodriguez@gmail.com>
Thu, 9 Jul 2009 21:22:50 +0000 (23:22 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 28 Jul 2009 21:26:27 +0000 (17:26 -0400)
bindings/perl/Champlain/t/ChamplainSelectionLayer.t
bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs

index c042bd6961478a1111549a8bd8d22754733e0027..48c4e4517be319c6d9fb159ffe70f9d1b4ec1be2 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Clutter::TestHelper tests => 24;
+use Clutter::TestHelper tests => 39;
 
 use Champlain;
 use Data::Dumper;
@@ -11,24 +11,27 @@ use Data::Dumper;
 exit tests();
 
 sub tests {
-       test_empty();
-#      test_markers_single();
+       test_empty_multiple();
+       test_empty_single();
 
        test_markers_multiple();
        return 0;
 }
 
 
-sub test_empty {
+sub test_empty_multiple {
        my $layer = Champlain::SelectionLayer->new();
        isa_ok($layer, 'Champlain::Layer');
 
+       is($layer->get_selection_mode, 'multiple');
+       is($layer->get('selection_mode'), 'multiple');
+
        is($layer->get_selected, undef, "[empty] get_selected()");
 
        # In single mode get_selected_markers doesn't work
        is_deeply(
                [$layer->get_selected_markers],
-               [], 
+               [],
                "[empty] get_selected_markers()"
        );
 
@@ -44,6 +47,55 @@ sub test_empty {
 #      $layer->select_all();
        $layer->unselect_all();
 
+       # Change the selection mode
+       $layer->set_selection_mode('single');
+       is($layer->get_selection_mode, 'single');
+
+       $layer->set('selection_mode', 'multiple');
+       is($layer->get('selection_mode'), 'multiple');
+
+       return 0;
+}
+
+
+sub test_empty_single {
+       my $layer = Champlain::SelectionLayer->new();
+       isa_ok($layer, 'Champlain::Layer');
+
+       is($layer->get_selection_mode, 'multiple');
+       is($layer->get('selection_mode'), 'multiple');
+       $layer->set_selection_mode('single');
+       is($layer->get_selection_mode, 'single');
+       is($layer->get('selection_mode'), 'single');
+
+       is($layer->get_selected, undef, "[empty] get_selected()");
+
+       # In single mode get_selected_markers doesn't work
+       is_deeply(
+               [$layer->get_selected_markers],
+               [],
+               "[empty] get_selected_markers()"
+       );
+
+       my $count = $layer->count_selected_markers;
+       is($count, 0, "[empty] count_selected_markers()");
+
+       my $marker = Champlain::BaseMarker->new();
+       ok(!$layer->marker_is_selected($marker), "[empty] marker_is_selected()");
+
+       # Can't be tested but at least they are invoked
+       $layer->select($marker);
+       $layer->unselect($marker);
+#      $layer->select_all();
+       $layer->unselect_all();
+
+       # Change the selection mode
+       $layer->set_selection_mode('multiple');
+       is($layer->get_selection_mode, 'multiple');
+
+       $layer->set('selection_mode', 'single');
+       is($layer->get('selection_mode'), 'single');
+
        return 0;
 }
 
index 72d4f293c3b59cc629707a83378365ca7e088882..8e0f8fb09e2bcac3f2ef7518d9758241c14a66db 100644 (file)
@@ -54,3 +54,11 @@ champlain_selection_layer_marker_is_selected (ChamplainSelectionLayer *layer, Ch
 
 void
 champlain_selection_layer_unselect_all (ChamplainSelectionLayer *layer)
+
+
+void
+champlain_selection_layer_set_selection_mode (ChamplainSelectionLayer *layer, ChamplainSelectionMode mode);
+
+
+ChamplainSelectionMode
+champlain_selection_layer_get_selection_mode (ChamplainSelectionLayer *layer);