Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVeronika Irvine2006-01-30 19:49:22 +0000
committerVeronika Irvine2006-01-30 19:49:22 +0000
commite2ec65253a8e34657e931525b15536b9cdc64d53 (patch)
tree26946e7679d383c3ea18fa663aafb52601143ecd /tests
parent2ed16da076fc873ec06e0a316e48d1ca2cc356e2 (diff)
downloadeclipse.platform.swt-e2ec65253a8e34657e931525b15536b9cdc64d53.tar.gz
eclipse.platform.swt-e2ec65253a8e34657e931525b15536b9cdc64d53.tar.xz
eclipse.platform.swt-e2ec65253a8e34657e931525b15536b9cdc64d53.zip
add setSelection() for one item
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabFolder.java16
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java31
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabFolder.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabFolder.java
index c211a019ab..e0418ec61c 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabFolder.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_TabFolder.java
@@ -155,6 +155,9 @@ public void test_getSelectionIndex() {
tabFolder.setSelection(items);
assertTrue(":c:", tabFolder.getSelectionIndex()==0);
+
+ tabFolder.setSelection(items[2]);
+ assertTrue(":d:", tabFolder.getSelectionIndex()==2);
}
public void test_indexOfLorg_eclipse_swt_widgets_TabItem() {
@@ -246,6 +249,16 @@ public void test_setSelectionI() {
for (int i = 0; i < number; i++)
items[i] = new TabItem(tabFolder, 0);
try {
+ tabFolder.setSelection((TabItem) null);
+ fail("No exception thrown for selection == null");
+ }
+ catch (IllegalArgumentException e) {
+ }
+ finally {
+ assertEquals(new TabItem[]{items[0]}, tabFolder.getSelection());
+ }
+
+ try {
tabFolder.setSelection((TabItem[]) null);
fail("No exception thrown for selection == null");
}
@@ -292,6 +305,9 @@ public void test_setSelectionI() {
for (int i = 0; i < number; i++)
items[i] = new TabItem(tabFolder, 0);
+ tabFolder.setSelection(items[0]);
+ assertEquals(new TabItem[]{items[0]}, tabFolder.getSelection());
+
tabFolder.setSelection(new TabItem[]{});
assertEquals(new TabItem[]{}, tabFolder.getSelection());
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java
index 7cee4863fd..1567e25f04 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java
@@ -463,6 +463,9 @@ public void test_getSelection() {
table.setSelection(items);
assertSame(items, table.getSelection());
+ table.setSelection(items[0]);
+ assertSame(new TableItem[] {items[0]}, table.getSelection());
+
// note: SWT.SINGLE
makeCleanEnvironment(true);
@@ -498,6 +501,9 @@ public void test_getSelectionCount() {
table.setSelection(new TableItem[]{items[2], items[number-1], items[10]});
assertEquals(3, table.getSelectionCount());
+ table.setSelection(items[2]);
+ assertEquals(1, table.getSelectionCount());
+
table.setSelection(items);
assertEquals(number, table.getSelectionCount());
@@ -536,6 +542,9 @@ public void test_getSelectionIndex() {
table.setSelection(new TableItem[]{items[2], items[number-1], items[10]});
assertEquals(2, table.getSelectionIndex());
+ table.setSelection(items[10]);
+ assertEquals(10, table.getSelectionIndex());
+
table.setSelection(items);
assertEquals(0, table.getSelectionIndex());
@@ -711,6 +720,15 @@ public void test_isSelectedI() {
assertTrue(":b:" + i, !table.isSelected(i));
}
+ table.setSelection(items[0]);
+ for (int i = 0; i < number; i++) {
+ if (i == 0)
+ assertTrue(":b:" + i, table.isSelected(i));
+ else
+ assertTrue(":b:" + i, !table.isSelected(i));
+ }
+
+
table.setSelection(items);
for (int i = 0; i < number; i++)
assertTrue(":c:" + i, table.isSelected(i));
@@ -1440,9 +1458,22 @@ public void test_setSelection$Lorg_eclipse_swt_widgets_TableItem() {
finally {
assertEquals(0, table.getSelectionCount());
}
+
+ try {
+ table.setSelection((TableItem) null);
+ fail("No exception thrown for selection == null");
+ }
+ catch (IllegalArgumentException e) {
+ }
+ finally {
+ assertEquals(0, table.getSelectionCount());
+ }
table.setSelection(new TableItem[]{});
assertEquals(0, table.getSelectionCount());
+
+ table.setSelection(items[0]);
+ assertEquals(1, table.getSelectionCount());
table.setSelection(new TableItem[]{items[0], items[3], items[2]});
assertSame(new TableItem[]{items[0], items[2], items[3]}, table.getSelection());

Back to the top