From: Emmanuel Rodriguez Date: Thu, 9 Jul 2009 21:22:50 +0000 (+0200) Subject: Test the property selection-mode X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4446c6aa4ce3280409088df256946706d991853b;p=libchamplain Test the property selection-mode --- diff --git a/bindings/perl/Champlain/t/ChamplainSelectionLayer.t b/bindings/perl/Champlain/t/ChamplainSelectionLayer.t index c042bd6..48c4e45 100644 --- a/bindings/perl/Champlain/t/ChamplainSelectionLayer.t +++ b/bindings/perl/Champlain/t/ChamplainSelectionLayer.t @@ -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; } diff --git a/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs b/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs index 72d4f29..8e0f8fb 100644 --- a/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs +++ b/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs @@ -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);