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

cvs@intevation.de cvs at intevation.de
Wed Dec 15 15:49:57 CET 2004


Author: bh

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

Modified Files:
      Tag: thuban-1-0-branch
	test_viewport.py 
Log Message:
Backports from HEAD

* Thuban/UI/about.py (About.__init__): Add the
thuban at intevation.de address and rephrase the email address
section as in HEAD

* Thuban/UI/exceptiondialog.py (ExceptionDialog.dialog_layout):
Improved button string to stronger clearify that Thuban will be
closed when hitting the button.

* Thuban/UI/multiplechoicedialog.py: Add missing import of
wxPython.wx itself (as opposed to the contents of wxPython.wx).
For some reason wxPython.wx is available as wxPython.wx.wx in at
least some 2.4 releases.  Fixes RT#2482 wrt. wxPython 2.4.

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

* 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


Index: test_viewport.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_viewport.py,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -d -r1.9 -r1.9.2.1
--- test_viewport.py	6 Oct 2003 17:31:44 -0000	1.9
+++ test_viewport.py	15 Dec 2004 14:49:55 -0000	1.9.2.1
@@ -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 subscribes 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)