[Skencil-commits] r528 - in skencil/trunk: . Sketch/Editor test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Mar 4 22:36:29 CET 2006


Author: bh
Date: 2006-03-04 22:36:28 +0100 (Sat, 04 Mar 2006)
New Revision: 528

Modified:
   skencil/trunk/ChangeLog
   skencil/trunk/Sketch/Editor/tools.py
   skencil/trunk/test/ChangeLog
   skencil/trunk/test/test_tools.py
Log:

* Sketch/Editor/tools.py (ZoomToolInstance): Derive from
TemporaryToolInstance
(ZoomToolInstance.ButtonRelease, ZoomToolInstance.ButtonClick):
call self.finished so that the zoom operations are temporary.

* test_tools.py
(TestZoomTool.test_whether_zoom_is_temporary_after_area_zoom)
(TestZoomTool.test_whether_zoom_is_temporary_after_point_zoom):
New. Test whether the zoom tool is temporary


Modified: skencil/trunk/ChangeLog
===================================================================
--- skencil/trunk/ChangeLog	2006-03-04 20:49:36 UTC (rev 527)
+++ skencil/trunk/ChangeLog	2006-03-04 21:36:28 UTC (rev 528)
@@ -1,5 +1,12 @@
 2006-03-04  Bernhard Herzog  <bh at intevation.de>
 
+	* Sketch/Editor/tools.py (ZoomToolInstance): Derive from
+	TemporaryToolInstance
+	(ZoomToolInstance.ButtonRelease, ZoomToolInstance.ButtonClick):
+	call self.finished so that the zoom operations are temporary.
+
+2006-03-04  Bernhard Herzog  <bh at intevation.de>
+
 	* Sketch/Editor/doceditor.py (EditorWithSelection.ButtonClick):
 	Clarify the meaning of the state parameter a bit.
 

Modified: skencil/trunk/Sketch/Editor/tools.py
===================================================================
--- skencil/trunk/Sketch/Editor/tools.py	2006-03-04 20:49:36 UTC (rev 527)
+++ skencil/trunk/Sketch/Editor/tools.py	2006-03-04 21:36:28 UTC (rev 528)
@@ -211,7 +211,7 @@
         return cmp(id(self), id(other))
 
 
-class ZoomToolInstance(ToolInstance):
+class ZoomToolInstance(TemporaryToolInstance):
 
     title = ''"Zoom"
 
@@ -229,11 +229,13 @@
         if obj is not None:
             context.zoom_area(obj.bounding_rect,
                               out = state & const.ZoomOutMask)
+        self.finished()
 
     def ButtonClick(self, context, p, snapped, button, state, handle = None):
         ToolInstance.ButtonClick(self, context, p, snapped, button, state,
                                  handle = None)
         context.zoom_point(p, out = state & const.ZoomOutMask)
+        self.finished()
 
 ZoomTool = ToolInfo("ZoomTool", ZoomToolInstance, cursor = 'CurZoom')
 

Modified: skencil/trunk/test/ChangeLog
===================================================================
--- skencil/trunk/test/ChangeLog	2006-03-04 20:49:36 UTC (rev 527)
+++ skencil/trunk/test/ChangeLog	2006-03-04 21:36:28 UTC (rev 528)
@@ -1,5 +1,12 @@
 2006-03-04  Bernhard Herzog  <bh at intevation.de>
 
+	* test_tools.py
+	(TestZoomTool.test_whether_zoom_is_temporary_after_area_zoom)
+	(TestZoomTool.test_whether_zoom_is_temporary_after_point_zoom):
+	New. Test whether the zoom tool is temporary
+
+2006-03-04  Bernhard Herzog  <bh at intevation.de>
+
 	* test_tools.py (MockZoomCanvas.zoom_point): New.  For the point
 	zoom tests
 	(TestZoomTool.test_point_zoom_in)

Modified: skencil/trunk/test/test_tools.py
===================================================================
--- skencil/trunk/test/test_tools.py	2006-03-04 20:49:36 UTC (rev 527)
+++ skencil/trunk/test/test_tools.py	2006-03-04 21:36:28 UTC (rev 528)
@@ -440,8 +440,30 @@
         # The zoom_area method must not have been called.
         self.assertEquals(self.canvas.called_methods, [])
 
+    def test_whether_zoom_is_temporary_after_area_zoom(self):
+        """Test whether the zoom tool is temporary when doing an area zoom
+        """
+        previous_tool = self.editor.Tool()
+        self.editor.SetTool("ZoomTool")
+        self.editor.ButtonPress(self.canvas, Point(47, 123), Button1, 0)
+        self.editor.PointerMotion(self.canvas, Point(46.75, 120.5), Button1Mask)
+        self.editor.ButtonRelease(self.canvas, Point(43, 117.25), Button1,
+                                  Button1Mask)
+        # the previous tool must have been restored
+        self.assert_(previous_tool is self.editor.Tool(),
+                     "ZoomTool: area zoom is not temporary")
 
+    def test_whether_zoom_is_temporary_after_point_zoom(self):
+        """Test whether the zoom tool is temporary when doing a point zoom
+        """
+        previous_tool = self.editor.Tool()
+        self.editor.SetTool("ZoomTool")
+        self.editor.ButtonClick(self.canvas, Point(47, 123), Button1, 0)
+        # the previous tool must have been restored
+        self.assert_(previous_tool is self.editor.Tool(),
+                     "ZoomTool: point zoom is not temporary")
 
+
 if __name__ == "__main__":
     unittest.main()
 



More information about the Skencil-commits mailing list