summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-04-23 07:52:08 (EDT)
committerCarsten Drossel2009-04-23 07:52:08 (EDT)
commit0c42ca4ba89f35171d48bf278b959704d213bdd2 (patch)
treece1cfa0c47e9ce279004525911a8c221bd1922f5
parent2d4a39423325b540e9b35d95741d7aaac8bedaa3 (diff)
downloadorg.eclipse.riena-0c42ca4ba89f35171d48bf278b959704d213bdd2.zip
org.eclipse.riena-0c42ca4ba89f35171d48bf278b959704d213bdd2.tar.gz
org.eclipse.riena-0c42ca4ba89f35171d48bf278b959704d213bdd2.tar.bz2
extracted superclass to allow reuse of test cases for custom label ridgets
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractLabelRidgetTest.java371
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidgetTest.java348
2 files changed, 389 insertions, 330 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractLabelRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractLabelRidgetTest.java
new file mode 100644
index 0000000..dc8fc7a
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractLabelRidgetTest.java
@@ -0,0 +1,371 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.internal.ui.ridgets.swt;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Widget;
+
+import org.eclipse.riena.beans.common.TestBean;
+import org.eclipse.riena.core.util.ReflectionUtils;
+import org.eclipse.riena.ui.core.marker.ErrorMarker;
+import org.eclipse.riena.ui.core.marker.MandatoryMarker;
+import org.eclipse.riena.ui.core.marker.NegativeMarker;
+import org.eclipse.riena.ui.core.marker.OutputMarker;
+import org.eclipse.riena.ui.ridgets.ILabelRidget;
+import org.eclipse.riena.ui.ridgets.swt.uibinding.SwtControlRidgetMapper;
+
+/**
+ *
+ */
+public abstract class AbstractLabelRidgetTest extends AbstractSWTRidgetTest {
+
+ private final static String PLUGIN_ID = "org.eclipse.riena.tests:";
+ private final static String ICON_ECLIPSE = PLUGIN_ID + "/icons/eclipse.gif";
+
+ private final static String LABEL = "testlabel";
+ private final static String LABEL2 = "testlabel2";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ getRidget().setText(LABEL);
+ }
+
+ @Override
+ protected ILabelRidget getRidget() {
+ return (ILabelRidget) super.getRidget();
+ }
+
+ protected abstract ILabelRidget createRidget();
+
+ protected abstract String getText(Object widget);
+
+ protected abstract void setText(Object widget, String text);
+
+ protected abstract Image getImage(Object widget);
+
+ protected abstract void setImage(Object widget, Image image);
+
+ protected abstract Class<? extends ILabelRidget> getRidgetClass();
+
+ public void testRidgetMapping() {
+ SwtControlRidgetMapper mapper = SwtControlRidgetMapper.getInstance();
+ assertSame(getRidgetClass(), mapper.getRidgetClass(getWidget()));
+ }
+
+ /**
+ * Test method get/setIcon().
+ */
+ public final void testSetIcon() {
+
+ ILabelRidget ridget = getRidget();
+
+ ridget.setIcon(ICON_ECLIPSE);
+
+ assertEquals(ICON_ECLIPSE, ridget.getIcon());
+ assertNotNull(getImage(getWidget()));
+
+ ridget.setIcon(null);
+
+ assertNull(ridget.getIcon());
+ assertNull(getImage(getWidget()));
+
+ Widget label = createWidget(getShell());
+ Image labelImage = label.getDisplay().getSystemImage(SWT.ICON_INFORMATION);
+ setImage(label, labelImage);
+ ILabelRidget labelRidget = createRidget();
+ // binding doesn't remove image of label, because the icon of the ridget is null and the method #setIcon wasn't called yet.
+ labelRidget.setUIControl(label);
+ assertSame(labelImage, getImage(label));
+
+ labelRidget.setIcon(null);
+ assertNull(labelRidget.getIcon());
+ assertNull(getImage(label));
+
+ labelRidget.setIcon(ICON_ECLIPSE);
+ assertEquals(ICON_ECLIPSE, labelRidget.getIcon());
+ assertNotNull(getImage(label));
+ assertNotSame(labelImage, getImage(label));
+
+ label = createWidget(getShell());
+ setImage(label, labelImage);
+ labelRidget = createRidget();
+ labelRidget.setIcon(ICON_ECLIPSE);
+ // binding replaces image of label, because the icon of the ridget is not null.
+ labelRidget.setUIControl(label);
+ assertNotNull(getImage(label));
+ assertNotSame(labelImage, getImage(label));
+
+ }
+
+ /**
+ * Test method get/setText.
+ */
+ public final void testSetText() throws Exception {
+ ILabelRidget ridget = getRidget();
+ final Object widget = ridget.getUIControl();
+
+ ridget.setText(LABEL2);
+
+ assertEquals(LABEL2, ridget.getText());
+ assertEquals(LABEL2, getText(widget));
+
+ ridget.setText("");
+
+ assertEquals("", ridget.getText());
+ assertEquals("", getText(widget));
+
+ try {
+ ridget.setText(null);
+ fail();
+ } catch (IllegalArgumentException iae) {
+ ok();
+ }
+ }
+
+ /**
+ * Test method updateFromModel().
+ */
+ public void testUpdateFromModel() throws Exception {
+ ILabelRidget ridget = getRidget();
+ final Object widget = ridget.getUIControl();
+
+ TestBean bean = new TestBean();
+ bean.setProperty("NewLabel");
+
+ ridget.bindToModel(bean, TestBean.PROPERTY);
+
+ assertEquals("NewLabel", bean.getProperty());
+ assertEquals(LABEL, ridget.getText());
+ assertEquals(LABEL, getText(widget));
+
+ ridget.updateFromModel();
+
+ assertEquals("NewLabel", bean.getProperty());
+ assertEquals("NewLabel", ridget.getText());
+ assertEquals("NewLabel", getText(widget));
+ }
+
+ /**
+ * For LabelRidgets, ensure that updates are made to the model from the
+ * ridget.
+ */
+ public void testUpdateFromRidget() {
+ ILabelRidget ridget = getRidget();
+ final Object widget = ridget.getUIControl();
+
+ TestBean bean = new TestBean();
+ bean.setProperty("NewLabel");
+
+ ridget.bindToModel(bean, TestBean.PROPERTY);
+ ridget.updateFromModel();
+
+ assertEquals("NewLabel", bean.getProperty());
+ assertEquals("NewLabel", ridget.getText());
+ assertEquals("NewLabel", getText(widget));
+
+ ridget.setText(LABEL);
+
+ assertEquals(LABEL, bean.getProperty());
+ assertEquals(LABEL, ridget.getText());
+ assertEquals(LABEL, getText(widget));
+ }
+
+ /**
+ * For LabelRidgets, ensure that <b>no</b> updates are made to the model
+ * from the control.
+ */
+ public void testUpdateFromControl() {
+ ILabelRidget ridget = getRidget();
+ final Object widget = ridget.getUIControl();
+
+ TestBean bean = new TestBean();
+ bean.setProperty("NewLabel");
+
+ ridget.bindToModel(bean, TestBean.PROPERTY);
+ ridget.updateFromModel();
+
+ assertEquals("NewLabel", bean.getProperty());
+ assertEquals("NewLabel", ridget.getText());
+ assertEquals("NewLabel", getText(widget));
+
+ setText(widget, LABEL);
+
+ assertEquals("NewLabel", bean.getProperty());
+ assertEquals("NewLabel", ridget.getText());
+ assertEquals(LABEL, getText(widget));
+ }
+
+ public void testUpdateFromRidgetOnRebind() throws Exception {
+ ILabelRidget ridget = getRidget();
+ Object widget = ridget.getUIControl();
+
+ TestBean bean = new TestBean();
+ bean.setProperty("NewLabel");
+
+ ridget.bindToModel(bean, TestBean.PROPERTY);
+ ridget.updateFromModel();
+
+ assertEquals("NewLabel", ridget.getText());
+ assertEquals("NewLabel", getText(widget));
+
+ ridget.setUIControl(null);
+
+ assertEquals("NewLabel", ridget.getText());
+ assertEquals("NewLabel", getText(widget));
+
+ ridget.setText(LABEL);
+
+ assertEquals(LABEL, ridget.getText());
+ assertEquals("NewLabel", getText(widget));
+
+ widget = createWidget(getShell());
+ ridget.setUIControl(widget);
+
+ assertEquals(LABEL, ridget.getText());
+ assertEquals(LABEL, getText(widget));
+
+ }
+
+ /**
+ * Test for problem report #536.
+ */
+ public void testDontReadValueInConstructor() throws Exception {
+ ILabelRidget ridget = getRidget();
+
+ IObservableValue observableValue = new AbstractObservableValue() {
+ @Override
+ protected Object doGetValue() {
+ return "TestText";
+ }
+
+ public Object getValueType() {
+ return String.class;
+ }
+ };
+ ridget.bindToModel(observableValue);
+
+ assertEquals(LABEL, ridget.getText());
+
+ ridget.updateFromModel();
+
+ assertEquals("TestText", ridget.getText());
+ }
+
+ /**
+ * Test method get/setIconLocation().
+ */
+ public void testSetIconLocation() throws Exception {
+ ILabelRidget ridget = getRidget();
+ final Object widget = ridget.getUIControl();
+
+ assertNull(ridget.getIconLocation());
+ assertNull(getImage(widget));
+
+ URL url = new URL("http://www.compeople.de/assets/compeople-logo.gif");
+ ridget.setIconLocation(url);
+
+ assertEquals(url, ridget.getIconLocation());
+ assertNotNull(getImage(widget));
+
+ ridget.setIconLocation(null);
+
+ assertNull(ridget.getIconLocation());
+ assertNull(getImage(widget));
+ }
+
+ /**
+ * Test method setUIControl().
+ */
+ public void testSetUIControl() throws Exception {
+ ILabelRidget ridget = getRidget();
+
+ assertEquals(LABEL, ridget.getText());
+ assertEquals(LABEL, getText(getWidget()));
+
+ ridget.setUIControl(null);
+
+ assertEquals(LABEL, ridget.getText());
+ assertEquals(LABEL, getText(getWidget()));
+
+ ridget.setText(LABEL2);
+ ridget.setUIControl(getWidget());
+
+ assertEquals(LABEL2, ridget.getText());
+ assertEquals(LABEL2, getText(getWidget()));
+ }
+
+ /**
+ * Tests the method {@code initText}
+ */
+ public void testInitText() {
+
+ ILabelRidget ridget = getRidget();
+ final Object widget = ridget.getUIControl();
+
+ ReflectionUtils.setHidden(ridget, "textAlreadyInitialized", false);
+ ReflectionUtils.setHidden(ridget, "text", null);
+ setText(widget, "Hello!");
+
+ ReflectionUtils.invokeHidden(ridget, "initText", new Object[] {});
+ assertEquals("Hello!", ridget.getText());
+ assertEquals("Hello!", getText(widget));
+ assertTrue((Boolean) ReflectionUtils.getHidden(ridget, "textAlreadyInitialized"));
+
+ setText(widget, "World");
+ ReflectionUtils.invokeHidden(ridget, "initText", new Object[] {});
+ assertEquals("Hello!", ridget.getText());
+ assertEquals("World", getText(widget));
+
+ }
+
+ /**
+ * Tests the <i>private</i> method {@code hasChanged.}
+ *
+ * @throws MalformedURLException
+ */
+ public void testHasChanged() throws MalformedURLException {
+
+ ILabelRidget ridget = getRidget();
+
+ URL url1 = new URL("file:/a");
+ URL url2 = new URL("file:/b");
+ boolean ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", url1, url2);
+ assertTrue(ret);
+ ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", url1, url1);
+ assertFalse(ret);
+ ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", url1, (URL) null);
+ assertTrue(ret);
+ ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", (URL) null, url2);
+ assertTrue(ret);
+ ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", (URL) null, (URL) null);
+ assertFalse(ret);
+
+ }
+
+ /**
+ * Tests that markers that are irrelavant for this type of Ridget do not
+ * change the widget.
+ */
+ public void testUnsupportedMarkersIgnored() {
+ assertMarkerIgnored(new ErrorMarker());
+ assertMarkerIgnored(new MandatoryMarker());
+ assertMarkerIgnored(new OutputMarker());
+ assertMarkerIgnored(new NegativeMarker());
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidgetTest.java
index 33a9c08..c85bcdd 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/LabelRidgetTest.java
@@ -10,46 +10,17 @@
*******************************************************************************/
package org.eclipse.riena.internal.ui.ridgets.swt;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.riena.beans.common.TestBean;
-import org.eclipse.riena.core.util.ReflectionUtils;
-import org.eclipse.riena.ui.core.marker.ErrorMarker;
-import org.eclipse.riena.ui.core.marker.MandatoryMarker;
-import org.eclipse.riena.ui.core.marker.NegativeMarker;
-import org.eclipse.riena.ui.core.marker.OutputMarker;
import org.eclipse.riena.ui.ridgets.ILabelRidget;
-import org.eclipse.riena.ui.ridgets.swt.uibinding.SwtControlRidgetMapper;
/**
* Tests for the {@link LabelRidget}.
*/
-public class LabelRidgetTest extends AbstractSWTRidgetTest {
-
- private final static String PLUGIN_ID = "org.eclipse.riena.tests:";
- private final static String ICON_ECLIPSE = PLUGIN_ID + "/icons/eclipse.gif";
-
- private final static String LABEL = "testlabel";
- private final static String LABEL2 = "testlabel2";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- getRidget().setText(LABEL);
- }
-
- @Override
- protected ILabelRidget createRidget() {
- return new LabelRidget();
- }
+public class LabelRidgetTest extends AbstractLabelRidgetTest {
@Override
protected Label createWidget(Composite parent) {
@@ -57,8 +28,8 @@ public class LabelRidgetTest extends AbstractSWTRidgetTest {
}
@Override
- protected ILabelRidget getRidget() {
- return (ILabelRidget) super.getRidget();
+ protected ILabelRidget createRidget() {
+ return new LabelRidget();
}
@Override
@@ -66,311 +37,28 @@ public class LabelRidgetTest extends AbstractSWTRidgetTest {
return (Label) super.getWidget();
}
- public void testRidgetMapping() {
- SwtControlRidgetMapper mapper = SwtControlRidgetMapper.getInstance();
- assertSame(LabelRidget.class, mapper.getRidgetClass(getWidget()));
- }
-
- /**
- * Test method get/setIcon().
- */
- public final void testSetIcon() {
-
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- ridget.setIcon(ICON_ECLIPSE);
-
- assertEquals(ICON_ECLIPSE, ridget.getIcon());
- assertNotNull(control.getImage());
-
- ridget.setIcon(null);
-
- assertNull(ridget.getIcon());
- assertNull(control.getImage());
-
- Label label = createWidget(getShell());
- Image labelImage = label.getDisplay().getSystemImage(SWT.ICON_INFORMATION);
- label.setImage(labelImage);
- ILabelRidget labelRidget = createRidget();
- // binding doesn't remove image of label, because the icon of the ridget is null and the method #setIcon wasn't called yet.
- labelRidget.setUIControl(label);
- assertSame(labelImage, label.getImage());
-
- labelRidget.setIcon(null);
- assertNull(labelRidget.getIcon());
- assertNull(label.getImage());
-
- labelRidget.setIcon(ICON_ECLIPSE);
- assertEquals(ICON_ECLIPSE, labelRidget.getIcon());
- assertNotNull(label.getImage());
- assertNotSame(labelImage, label.getImage());
-
- label = createWidget(getShell());
- label.setImage(labelImage);
- labelRidget = createRidget();
- labelRidget.setIcon(ICON_ECLIPSE);
- // binding replaces image of label, because the icon of the ridget is not null.
- labelRidget.setUIControl(label);
- assertNotNull(label.getImage());
- assertNotSame(labelImage, label.getImage());
-
- }
-
- /**
- * Test method get/setText.
- */
- public final void testSetText() throws Exception {
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- ridget.setText(LABEL2);
-
- assertEquals(LABEL2, ridget.getText());
- assertEquals(LABEL2, control.getText());
-
- ridget.setText("");
-
- assertEquals("", ridget.getText());
- assertEquals("", control.getText());
-
- try {
- ridget.setText(null);
- fail();
- } catch (IllegalArgumentException iae) {
- ok();
- }
- }
-
- /**
- * Test method updateFromModel().
- */
- public void testUpdateFromModel() throws Exception {
- ILabelRidget ridget = getRidget();
-
- TestBean bean = new TestBean();
- bean.setProperty("NewLabel");
-
- ridget.bindToModel(bean, TestBean.PROPERTY);
-
- assertEquals("NewLabel", bean.getProperty());
- assertEquals(LABEL, ridget.getText());
- assertEquals(LABEL, ((Label) ridget.getUIControl()).getText());
-
- ridget.updateFromModel();
-
- assertEquals("NewLabel", bean.getProperty());
- assertEquals("NewLabel", ridget.getText());
- assertEquals("NewLabel", ((Label) ridget.getUIControl()).getText());
- }
-
- /**
- * For LabelRidgets, ensure that updates are made to the model from the
- * ridget.
- */
- public void testUpdateFromRidget() {
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- TestBean bean = new TestBean();
- bean.setProperty("NewLabel");
-
- ridget.bindToModel(bean, TestBean.PROPERTY);
- ridget.updateFromModel();
-
- assertEquals("NewLabel", bean.getProperty());
- assertEquals("NewLabel", ridget.getText());
- assertEquals("NewLabel", control.getText());
-
- ridget.setText(LABEL);
-
- assertEquals(LABEL, bean.getProperty());
- assertEquals(LABEL, ridget.getText());
- assertEquals(LABEL, control.getText());
- }
-
- /**
- * For LabelRidgets, ensure that <b>no</b> updates are made to the model
- * from the control.
- */
- public void testUpdateFromControl() {
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- TestBean bean = new TestBean();
- bean.setProperty("NewLabel");
-
- ridget.bindToModel(bean, TestBean.PROPERTY);
- ridget.updateFromModel();
-
- assertEquals("NewLabel", bean.getProperty());
- assertEquals("NewLabel", ridget.getText());
- assertEquals("NewLabel", control.getText());
-
- control.setText(LABEL);
-
- assertEquals("NewLabel", bean.getProperty());
- assertEquals("NewLabel", ridget.getText());
- assertEquals(LABEL, control.getText());
- }
-
- public void testUpdateFromRidgetOnRebind() throws Exception {
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- TestBean bean = new TestBean();
- bean.setProperty("NewLabel");
-
- ridget.bindToModel(bean, TestBean.PROPERTY);
- ridget.updateFromModel();
-
- assertEquals("NewLabel", ridget.getText());
- assertEquals("NewLabel", control.getText());
-
- ridget.setUIControl(null);
-
- assertEquals("NewLabel", ridget.getText());
- assertEquals("NewLabel", control.getText());
-
- ridget.setText(LABEL);
-
- assertEquals(LABEL, ridget.getText());
- assertEquals("NewLabel", control.getText());
-
- control = new Label(getShell(), SWT.NONE);
- ridget.setUIControl(control);
-
- assertEquals(LABEL, ridget.getText());
- assertEquals(LABEL, control.getText());
-
- }
-
- /**
- * Test for problem report #536.
- */
- public void testDontReadValueInConstructor() throws Exception {
- ILabelRidget ridget = getRidget();
-
- IObservableValue observableValue = new AbstractObservableValue() {
- @Override
- protected Object doGetValue() {
- return "TestText";
- }
-
- public Object getValueType() {
- return String.class;
- }
- };
- ridget.bindToModel(observableValue);
-
- assertEquals(LABEL, ridget.getText());
-
- ridget.updateFromModel();
-
- assertEquals("TestText", ridget.getText());
- }
-
- /**
- * Test method get/setIconLocation().
- */
- public void testSetIconLocation() throws Exception {
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- assertNull(ridget.getIconLocation());
- assertNull(control.getImage());
-
- URL url = new URL("http://www.compeople.de/assets/compeople-logo.gif");
- ridget.setIconLocation(url);
-
- assertEquals(url, ridget.getIconLocation());
- assertNotNull(control.getImage());
-
- ridget.setIconLocation(null);
-
- assertNull(ridget.getIconLocation());
- assertNull(control.getImage());
+ @Override
+ protected Image getImage(Object widget) {
+ return ((Label) widget).getImage();
}
- /**
- * Test method setUIControl().
- */
- public void testSetUIControl() throws Exception {
- ILabelRidget ridget = getRidget();
- Label control = getWidget();
-
- assertEquals(LABEL, ridget.getText());
- assertEquals(LABEL, control.getText());
-
- ridget.setUIControl(null);
-
- assertEquals(LABEL, ridget.getText());
- assertEquals(LABEL, control.getText());
-
- ridget.setText(LABEL2);
- ridget.setUIControl(control);
-
- assertEquals(LABEL2, ridget.getText());
- assertEquals(LABEL2, control.getText());
+ @Override
+ protected String getText(Object widget) {
+ return ((Label) widget).getText();
}
- /**
- * Tests the method {@code initText}
- */
- public void testInitText() {
-
- ILabelRidget ridget = getRidget();
- Label control = (Label) ridget.getUIControl();
-
- ReflectionUtils.setHidden(ridget, "textAlreadyInitialized", false);
- ReflectionUtils.setHidden(ridget, "text", null);
- control.setText("Hello!");
-
- ReflectionUtils.invokeHidden(ridget, "initText", new Object[] {});
- assertEquals("Hello!", ridget.getText());
- assertEquals("Hello!", control.getText());
- assertTrue((Boolean) ReflectionUtils.getHidden(ridget, "textAlreadyInitialized"));
-
- control.setText("World");
- ReflectionUtils.invokeHidden(ridget, "initText", new Object[] {});
- assertEquals("Hello!", ridget.getText());
- assertEquals("World", control.getText());
-
+ @Override
+ protected void setImage(Object widget, Image image) {
+ ((Label) widget).setImage(image);
}
- /**
- * Tests the <i>private</i> method {@code hasChanged.}
- *
- * @throws MalformedURLException
- */
- public void testHasChanged() throws MalformedURLException {
-
- ILabelRidget ridget = getRidget();
-
- URL url1 = new URL("file:/a");
- URL url2 = new URL("file:/b");
- boolean ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", url1, url2);
- assertTrue(ret);
- ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", url1, url1);
- assertFalse(ret);
- ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", url1, (URL) null);
- assertTrue(ret);
- ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", (URL) null, url2);
- assertTrue(ret);
- ret = ReflectionUtils.invokeHidden(ridget, "hasChanged", (URL) null, (URL) null);
- assertFalse(ret);
-
+ @Override
+ protected void setText(Object widget, String text) {
+ ((Label) widget).setText(text);
}
- /**
- * Tests that markers that are irrelavant for this type of Ridget do not
- * change the widget.
- */
- public void testUnsupportedMarkersIgnored() {
- assertMarkerIgnored(new ErrorMarker());
- assertMarkerIgnored(new MandatoryMarker());
- assertMarkerIgnored(new OutputMarker());
- assertMarkerIgnored(new NegativeMarker());
+ @Override
+ protected Class<? extends ILabelRidget> getRidgetClass() {
+ return LabelRidget.class;
}
-
}