-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Message bubble display access fix (#367)
* Fixed Problems with this method if setGraphics was never called and there was no run Signed-off-by: Michael Sementsov <michael.sementsov@ibykus.de> * safe-check for available ViewportPane (display) Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> Co-authored-by: Michael Sementsov <michael.sementsov@ibykus.de>
- Loading branch information
1 parent
07ce7ff
commit 63796be
Showing
3 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...dig.tool.edit.tests/src/org/locationtech/udig/tools/edit/animation/MessageBubbleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.locationtech.udig.tools.edit.animation; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
import org.easymock.EasyMock; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.junit.Test; | ||
import org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane; | ||
import org.locationtech.udig.ui.graphics.ViewportGraphics; | ||
|
||
public class MessageBubbleTest { | ||
|
||
ViewportPane viewportPaneMock = EasyMock.createNiceMock(ViewportPane.class); | ||
|
||
ViewportGraphics viewportGraphicsMock = EasyMock.createNiceMock(ViewportGraphics.class); | ||
|
||
MessageBubble messageBubble = new MessageBubble(0, 0, "whatever", (short) 1); | ||
|
||
@Test | ||
public void withoutGraphicContextNoNPEonSetValid() { | ||
messageBubble.setValid(false); | ||
assertFalse(messageBubble.isValid()); | ||
} | ||
|
||
|
||
@Test | ||
public void withoutsetGraphicContextWithNonNullDisplayRegistersListeners() { | ||
viewportPaneMock.addMouseListener(EasyMock.anyObject()); | ||
EasyMock.expectLastCall().once(); | ||
viewportPaneMock.addMouseWheelListener(EasyMock.anyObject()); | ||
EasyMock.expectLastCall().once(); | ||
|
||
EasyMock.replay(viewportGraphicsMock, viewportPaneMock); | ||
messageBubble.setGraphics(viewportGraphicsMock, viewportPaneMock); | ||
EasyMock.verify(viewportGraphicsMock, viewportPaneMock); | ||
} | ||
|
||
@Test | ||
public void withoutGraphicContextListenersRemoveNeverCalled() { | ||
viewportPaneMock.removeMouseListener(EasyMock.anyObject()); | ||
EasyMock.expectLastCall().once(); | ||
viewportPaneMock.removeMouseWheelListener(EasyMock.anyObject()); | ||
EasyMock.expectLastCall().once(); | ||
|
||
EasyMock.replay(viewportGraphicsMock, viewportPaneMock); | ||
|
||
messageBubble.setGraphics(viewportGraphicsMock, viewportPaneMock); | ||
|
||
messageBubble.setValid(false); | ||
assertFalse(messageBubble.isValid()); | ||
|
||
EasyMock.verify(viewportGraphicsMock, viewportPaneMock); | ||
} | ||
|
||
@Test | ||
public void runWithoutViewportPaneDoesNotDoAnything() throws Exception { | ||
EasyMock.replay(viewportGraphicsMock); | ||
|
||
messageBubble.setGraphics(viewportGraphicsMock, null); | ||
|
||
messageBubble.run(new NullProgressMonitor()); | ||
EasyMock.verify(viewportGraphicsMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters