summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-10-20 10:00:11 (EDT)
committerSteffen Kriese2010-10-20 10:00:11 (EDT)
commit885531ccd8c14c3e0c531eb67f8515514bda6ed1 (patch)
tree8e827405917fc75b7fc2bbafe5baeba892e0bb15
parentebea291850202308ea30627723c53e881d334950 (diff)
downloadorg.eclipse.riena-885531ccd8c14c3e0c531eb67f8515514bda6ed1.zip
org.eclipse.riena-885531ccd8c14c3e0c531eb67f8515514bda6ed1.tar.gz
org.eclipse.riena-885531ccd8c14c3e0c531eb67f8515514bda6ed1.tar.bz2
Added new StatusLineMessageMarkerViewerTest that doesn't use swt controls
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest.java69
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest2.java69
2 files changed, 126 insertions, 12 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest.java
index f87d6e2..12455da 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest.java
@@ -19,17 +19,19 @@ import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.riena.internal.core.test.collect.UITestCase;
+import org.eclipse.riena.internal.core.test.collect.ManualTestCase;
import org.eclipse.riena.internal.ui.ridgets.swt.TextRidget;
import org.eclipse.riena.ui.core.marker.ErrorMessageMarker;
import org.eclipse.riena.ui.core.marker.MessageMarker;
+import org.eclipse.riena.ui.ridgets.IMarkableRidget;
import org.eclipse.riena.ui.ridgets.IStatuslineRidget;
+import org.eclipse.riena.ui.ridgets.swt.AbstractSWTWidgetRidget;
import org.eclipse.riena.ui.ridgets.swt.DefaultRealm;
/**
* Tests for the {@code StatuslineMessageMarkerViewer}.
*/
-@UITestCase
+@ManualTestCase
public class StatuslineMessageMarkerViewerTest extends TestCase {
private static final String EMPTY_STATUSLINE_MESSAGE = "TestEmptyStatusline";
@@ -38,9 +40,8 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
private Shell shell;
private StatuslineMessageMarkerViewer statuslineMessageMarkerViewer;
private IStatuslineRidget statuslineRidget;
- private Text text1;
private Text text2;
- private TextRidget ridget1;
+ private MockRidget ridget1;
private TextRidget ridget2;
/**
@@ -53,9 +54,9 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
shell = new Shell();
shell.setLayout(new RowLayout(SWT.VERTICAL));
- text1 = new Text(shell, SWT.SINGLE);
+ final Text text1 = new Text(shell, SWT.SINGLE);
text2 = new Text(shell, SWT.SINGLE);
- ridget1 = new TextRidget();
+ ridget1 = new MockRidget();
ridget2 = new TextRidget();
ridget1.setUIControl(text1);
ridget2.setUIControl(text2);
@@ -69,7 +70,50 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
shell.setSize(100, 100);
shell.setLocation(0, 0);
shell.open();
- text1.setFocus();
+ ridget1.setFocus(true);
+ }
+
+ private class MockRidget extends AbstractSWTWidgetRidget implements IMarkableRidget {
+
+ private boolean focus;
+
+ public void setFocus(final boolean focus) {
+ this.focus = focus;
+ }
+
+ @Override
+ public boolean hasFocus() {
+ return focus;
+ }
+
+ public boolean isVisible() {
+ return true;
+ }
+
+ @Override
+ protected void checkUIControl(final Object uiControl) {
+ }
+
+ @Override
+ protected void bindUIControl() {
+ }
+
+ @Override
+ protected void unbindUIControl() {
+ }
+
+ @Override
+ public boolean isDisableMandatoryMarker() {
+ return false;
+ }
+
+ @Override
+ protected void updateEnabled() {
+ }
+
+ @Override
+ protected void updateToolTip() {
+ }
}
/**
@@ -81,8 +125,8 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
statuslineRidget = null;
ridget1 = null;
ridget2 = null;
- text1.dispose();
- text1 = null;
+ // text1.dispose();
+ // text1 = null;
text2.dispose();
text2 = null;
shell.dispose();
@@ -135,6 +179,7 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
EasyMock.expect(statuslineRidget.getMessage()).andReturn(testMessageBySomebodyElse);
EasyMock.replay(statuslineRidget);
+ ridget1.setFocus(false);
text2.setFocus();
EasyMock.verify(statuslineRidget);
@@ -144,7 +189,7 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
statuslineRidget.error(testErrorMessage);
EasyMock.replay(statuslineRidget);
- text1.setFocus();
+ ridget1.setFocus(true);
EasyMock.verify(statuslineRidget);
EasyMock.reset(statuslineRidget);
@@ -187,7 +232,7 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
statuslineRidget.error(testErrorMessage);
EasyMock.replay(statuslineRidget);
ridget1.addMarker(errorMessageMarker1);
- text1.setFocus();
+ ridget1.setFocus(true);
EasyMock.reset(statuslineRidget);
EasyMock.replay(statuslineRidget);
@@ -278,7 +323,7 @@ public class StatuslineMessageMarkerViewerTest extends TestCase {
EasyMock.replay(statuslineRidget);
text2.setFocus();
- text1.setFocus();
+ ridget1.setFocus(true);
EasyMock.verify(statuslineRidget);
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest2.java b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest2.java
new file mode 100644
index 0000000..1f757f1
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/StatuslineMessageMarkerViewerTest2.java
@@ -0,0 +1,69 @@
+package org.eclipse.riena.ui.ridgets.marker;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.easymock.EasyMock;
+
+import org.eclipse.riena.internal.core.test.RienaTestCase;
+import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
+import org.eclipse.riena.ui.core.marker.ErrorMessageMarker;
+import org.eclipse.riena.ui.ridgets.IBasicMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IStatuslineRidget;
+
+/**
+ * Pure Unittest for the {@link StatuslineMessageMarkerViewer} that doesn't use
+ * swt-controls for testing.
+ */
+@NonUITestCase
+public class StatuslineMessageMarkerViewerTest2 extends RienaTestCase {
+
+ private static final String MESSAGE = "message";
+ private StatuslineMessageMarkerViewerUnderTest viewer;
+ private IStatuslineRidget statuslineRidget;
+ private boolean hasRidgetFocus = true;
+ private IMarkableRidget markableRidget;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ statuslineRidget = EasyMock.createNiceMock(IStatuslineRidget.class);
+ viewer = new StatuslineMessageMarkerViewerUnderTest(statuslineRidget);
+
+ markableRidget = EasyMock.createNiceMock(IMarkableRidget.class);
+ final Collection<ErrorMessageMarker> marker = new ArrayList<ErrorMessageMarker>();
+ marker.add(new ErrorMessageMarker(MESSAGE));
+ EasyMock.expect(markableRidget.hasFocus()).andReturn(hasRidgetFocus).anyTimes();
+ EasyMock.expect(markableRidget.getMarkersOfType(ErrorMessageMarker.class)).andReturn(marker).anyTimes();
+ EasyMock.replay(markableRidget);
+ }
+
+ public void testShowMessagesWithFocus() throws Exception {
+ statuslineRidget.error(MESSAGE);
+ EasyMock.replay(statuslineRidget);
+
+ viewer.showMessages(markableRidget);
+ EasyMock.verify(statuslineRidget);
+ }
+
+ public void testShowMessagesWithoutFocus() throws Exception {
+ hasRidgetFocus = false;
+ EasyMock.replay(statuslineRidget);
+
+ viewer.showMessages(markableRidget);
+ EasyMock.verify(statuslineRidget);
+ }
+
+ private class StatuslineMessageMarkerViewerUnderTest extends StatuslineMessageMarkerViewer {
+ public StatuslineMessageMarkerViewerUnderTest(final IStatuslineRidget statuslineRidget) {
+ super(statuslineRidget);
+ }
+
+ @Override
+ public void showMessages(final IBasicMarkableRidget markableRidget) {
+ super.showMessages(markableRidget);
+ }
+ }
+
+}