summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-10-19 10:25:25 (EDT)
committerSteffen Kriese2010-10-19 10:25:25 (EDT)
commit05a830b703669d5c10c61e87c3fe682160edac6a (patch)
tree2ac38127bfeb33ca8eb660b3d010aaafd719f1ce
parent55712cfbf36a558f28f92109b8e8d035a18554eb (diff)
downloadorg.eclipse.riena-05a830b703669d5c10c61e87c3fe682160edac6a.zip
org.eclipse.riena-05a830b703669d5c10c61e87c3fe682160edac6a.tar.gz
org.eclipse.riena-05a830b703669d5c10c61e87c3fe682160edac6a.tar.bz2
Fixed Tests for CCombo changes
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java6
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidgetTest.java44
2 files changed, 47 insertions, 3 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java
index 727d8df..b462bfd 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/AbstractComboRidgetTest.java
@@ -517,7 +517,7 @@ public abstract class AbstractComboRidgetTest extends AbstractSWTRidgetTest {
ridget.setSelection("X");
- assertEquals("X", ridget.getSelection());
+ assertEquals(null, ridget.getSelection());
assertEquals(-1, getSelectionIndex(control));
ridget.setSelection("A");
@@ -1424,7 +1424,7 @@ public abstract class AbstractComboRidgetTest extends AbstractSWTRidgetTest {
return f + l;
}
- private String getItem(final Control control, final int index) {
+ protected String getItem(final Control control, final int index) {
if (control instanceof Combo) {
return ((Combo) control).getItem(index);
}
@@ -1450,7 +1450,7 @@ public abstract class AbstractComboRidgetTest extends AbstractSWTRidgetTest {
throw new IllegalArgumentException("unknown widget type: " + control);
}
- private int getSelectionIndex(final Control control) {
+ protected int getSelectionIndex(final Control control) {
if (control instanceof Combo) {
return ((Combo) control).getSelectionIndex();
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidgetTest.java
index a7b12a9..69b86c8 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/CComboRidgetTest.java
@@ -19,6 +19,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.riena.beans.common.StringManager;
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.ui.ridgets.IRidget;
import org.eclipse.riena.ui.ridgets.swt.AbstractComboRidget;
@@ -53,6 +54,49 @@ public class CComboRidgetTest extends AbstractComboRidgetTest {
assertSame(CComboRidget.class, mapper.getRidgetClass(getWidget()));
}
+ @Override
+ public void testSetSelectionString() {
+ final AbstractComboRidget ridget = getRidget();
+ final Control control = ridget.getUIControl();
+ final StringManager aManager = new StringManager("A", "B", "C", "D", "E");
+ ridget.bindToModel(aManager, "items", String.class, null, aManager, "selectedItem");
+ ridget.updateFromModel();
+
+ assertEquals(null, ridget.getSelection());
+
+ ridget.setSelection("A");
+
+ assertEquals("A", ridget.getSelection());
+ assertEquals("A", getItem(control, getSelectionIndex(control)));
+
+ ridget.setSelection("B");
+
+ assertEquals("B", ridget.getSelection());
+ assertEquals("B", getItem(control, getSelectionIndex(control)));
+
+ ridget.setUIControl(null);
+ ridget.setSelection("C");
+
+ assertEquals("C", ridget.getSelection());
+ assertEquals("B", getItem(control, getSelectionIndex(control)));
+
+ ridget.setUIControl(control);
+
+ assertEquals("C", ridget.getSelection());
+ assertEquals("C", getItem(control, getSelectionIndex(control)));
+
+ ridget.setSelection("X");
+
+ assertEquals("X", ridget.getSelection());
+ assertEquals(-1, getSelectionIndex(control));
+
+ ridget.setSelection("A");
+ ridget.setSelection(null);
+
+ assertEquals(null, ridget.getSelection());
+ assertEquals(-1, getSelectionIndex(control));
+ }
+
/**
* As per Bug 323449
*/