From: Emmanuel Rodriguez Date: Thu, 7 May 2009 18:10:03 +0000 (+0200) Subject: Test the default view size properly X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2fc701a1e4c8c5cb7bb49df6f321bcc80bd7a0c;p=libchamplain Test the default view size properly --- diff --git a/bindings/perl/Champlain/t/ChamplainView.t b/bindings/perl/Champlain/t/ChamplainView.t index 6edbbd5..99a95f6 100644 --- a/bindings/perl/Champlain/t/ChamplainView.t +++ b/bindings/perl/Champlain/t/ChamplainView.t @@ -35,9 +35,22 @@ sub test_generic { ok($view->get('latitude') != $latitude, "center_on() changed latitude"); ok($view->get('longitude') != $longitude, "center_on() changed longitude"); + # NOTE: In recent versions of libchamplain the view requests the first tile + # (0, 0 at zoom level 0). If the tile is already in the cache then it + # will be loaded and the view's initial size will be of the tile's size. + # If the tile is not in the cache then it will be downloaded + # asynchronously and the view will have a size of (0, 0). + # + # For the moment there's no mechanism for disabling the cache nor for + # finding out if the view has a tile loaded. This is why the test for + # both. + # + # + my $source_original = $view->get('map-source'); + ok($view->get('width') == 0 || $view->get('width') == $source_original->get_tile_size, "original width"); + ok($view->get('height') || $view->get('height') == $source_original->get_tile_size, "original height"); + # set_size() can be tested by checking the properties width and height - is($view->get('width'), 0, "original width"); - is($view->get('height'), 0, "original height"); $view->set_size(600, 400); is($view->get('width'), 600, "set_size() changed width"); is($view->get('height'), 400, "set_size() changed height"); @@ -49,7 +62,6 @@ sub test_generic { # Change the map source (get a different map source) - my $source_original = $view->get('map-source'); my $factory = Champlain::MapSourceFactory->get_default(); my $source_new = $factory->create(Champlain::MapSourceFactory->OSM_MAPNIK); if ($source_original->get_id eq $source_new->get_id) {