Author: allain.lalonde
Date: Fri Jul 17 07:15:05 2009
New Revision: 486

Modified:
    piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java
     
piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java

Log:
Fixed Issue 92; make it check for empty stack before popping the cursor

Modified:  
piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java
==============================================================================
--- piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java     
 
(original)
+++ piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java     
 
Fri Jul 17 07:15:05 2009
@@ -331,7 +331,9 @@
       * Pop the cursor on top of the cursorStack and set it as the canvas  
cursor.
       */
      public void popCursor() {
-        setCursor((Cursor) cursorStack.pop());
+        if (!cursorStack.isEmpty()) {
+            setCursor((Cursor) cursorStack.pop());
+        }
      }

      // ****************************************************************

Modified:  
piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java
==============================================================================
---  
piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java     
 
(original)
+++  
piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java     
 
Fri Jul 17 07:15:05 2009
@@ -37,9 +37,6 @@
                assertEquals(1, mockListener.getPropertyChangeCount());
        }
        
-       /**
-        * This should work, but for some reason there's no  
getDefaultRenderQuality();
-        */
        public void testDefaultRenderQualityIsHigh() {          
                assertEquals(PPaintContext.HIGH_QUALITY_RENDERING,  
canvas.getDefaultRenderQuality());              
        }
@@ -76,15 +73,14 @@
                assertEquals(moveCursor, canvas.getCursor());                   
        
        }
        
-       // I think it should behave like this, but that's just me @allain
-       /*public void testPoppingEmptyCursorStackShouldDoNothing() {
+       public void testPoppingEmptyCursorStackShouldDoNothing() {
                try {
                        canvas.popCursor();
                } catch (IndexOutOfBoundsException e) {
                        fail("Pop cursor shouldn't fail on an empty stack");
                }
                assertEquals(Cursor.getDefaultCursor(), canvas.getCursor());
-       }*/
+       }
        
        public void testSettingCanvasBoundsAffectsCameraBounds() {
                canvas.setBounds(0, 0, 100, 100);

--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to