diff --git a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java index 5784634..cce5a91 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java @@ -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()); + } } // **************************************************************** diff --git a/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java b/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java index 07be3e8..3822845 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java @@ -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);