bh: thuban/test test_viewport.py,1.9,1.10

cvs@intevation.de cvs at intevation.de
Fri Jul 16 21:47:31 CEST 2004


Author: bh

Update of /thubanrepository/thuban/test
In directory doto:/tmp/cvs-serv12493/test

Modified Files:
	test_viewport.py 
Log Message:
* test/test_viewport.py
(ViewPortTest.test_changing_map_projection): Check that changing
the projection of an empty map shown in a viewport doesn't lead to
exceptions in the viewport's handler for the
MAP_PROJECTION_CHANGED messages

* Thuban/UI/viewport.py (ViewPort.map_projection_changed): Only
try to keep the same region visible when the map actually contains
something


Index: test_viewport.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_viewport.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- test_viewport.py	6 Oct 2003 17:31:44 -0000	1.9
+++ test_viewport.py	16 Jul 2004 19:47:28 -0000	1.10
@@ -1,4 +1,4 @@
-# Copyright (c) 2003 by Intevation GmbH
+# Copyright (c) 2003, 2004 by Intevation GmbH
 # Authors:
 # Jonathan Coles <jonathan at intevation.de>
 #
@@ -154,6 +154,45 @@
         self.port.SetMap(self.map)
         self.check_messages([(90.582425142660739, SCALE_CHANGED),
                              (MAP_REPLACED,)])
+
+    def test_changing_map_projection(self):
+        """Test ViewPort behavior when changing the map's projection
+
+        The viewport subscribe's to the map's MAP_PROJECTION_CHANGED
+        messages and tries to adjust the viewport when the projection
+        changes to make sure the map is still visible in the window.
+        There was a bug at one point where the viewport couldn't cope
+        with the map not having a meaningful bounding box in this
+        situation.
+        """
+        # Create a projection and an empty map.  We can't use self.map
+        # here because we do need an empty one.
+        themap = Map("title", Projection(["proj=latlong",
+                                          "to_meter=.017453292519943",
+                                          "ellps=clrk66"]))
+        # Add the map to self.session so that it's properly destroyed in
+        # tearDown()
+        self.session.AddMap(themap)
+
+        # Add the map to the view port and clear the messages.  Then
+        # we're set for the actual test.
+        self.port.SetMap(themap)
+        self.clear_messages()
+
+        # The test: set another projection.  The viewport tries to
+        # adjust the view so that the currently visible region stays
+        # visible.  The viewport has to take into account that the map
+        # is empty, which it didn't in Thuban/UI/viewport.py rev <= 1.16.
+        # This part of the test is OK when the SetProjection call does
+        # not lead to an exception.
+        themap.SetProjection(Projection(["proj=latlong",
+                                         "to_meter=.017453292519943",
+                                         "ellps=clrk66"]))
+
+        # If the map weren't empty the viewport might send SCALE_CHANGED
+        # messages, but it must no do so in this case because the scale
+        # doesn't change.
+        self.check_messages([])
 
     def testFitRectToWindow(self):
         rect = self.port.win_to_proj(9, 990) + self.port.win_to_proj(990, 9)





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)