use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_intersectLorg_eclipse_swt_graphics_Rectangle.
@Test
public void test_intersectLorg_eclipse_swt_graphics_Rectangle() {
Rectangle rect1 = new Rectangle(0, 0, 48, 24);
Rectangle rect2 = new Rectangle(0, 0, 48, 24);
Rectangle rect3 = new Rectangle(10, 10, 10, 10);
Rectangle rect4 = new Rectangle(48, 24, 10, 10);
Rectangle rect5 = new Rectangle(24, 20, 24, 10);
Region reg = new Region(display);
reg.dispose();
try {
reg.intersect(rect1);
fail("no exception thrown on disposed region");
} catch (SWTException e) {
}
reg = new Region(display);
reg.intersect(rect1);
if (!reg.isEmpty()) {
reg.dispose();
fail("intersect failed for empty region");
}
reg.add(rect1);
reg.intersect(rect2);
Rectangle box = reg.getBounds();
if (!box.equals(rect1)) {
reg.dispose();
fail("intersect failed 1");
}
reg.intersect(rect3);
box = reg.getBounds();
if (!box.equals(rect3)) {
reg.dispose();
fail("intersect failed 2");
}
reg.intersect(rect4);
if (!reg.isEmpty()) {
reg.dispose();
fail("intersect failed 3");
}
reg.add(rect1.union(rect4));
reg.intersect(rect5);
box = reg.getBounds();
if (!box.equals(rect5)) {
reg.dispose();
fail("intersect failed 4");
}
reg.dispose();
reg = new Region(display);
reg.add(rect1);
reg.add(rect4);
reg.intersect(rect5);
box = reg.getBounds();
if (!box.equals(new Rectangle(24, 20, 24, 4))) {
reg.dispose();
fail("intersect failed 5");
}
reg.dispose();
}
use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_subtractLorg_eclipse_swt_graphics_Region.
@Test
public void test_subtractLorg_eclipse_swt_graphics_Region() {
Region reg1 = new Region(display);
reg1.add(new Rectangle(0, 0, 50, 25));
Region reg = new Region(display);
reg.dispose();
try {
reg.subtract(reg1);
reg1.dispose();
fail("no exception thrown on disposed region");
} catch (SWTException e) {
}
reg = new Region(display);
reg.subtract(reg1);
if (!reg.isEmpty()) {
reg.dispose();
reg1.dispose();
fail("subtract failed for empty region");
}
Region reg2 = new Region(display);
reg2.add(new Rectangle(0, 0, 50, 25));
reg.add(reg1);
reg.subtract(reg2);
if (!reg.isEmpty()) {
reg.dispose();
reg1.dispose();
reg2.dispose();
fail("subtract failed 1");
}
reg2.dispose();
Region reg3 = new Region(display);
reg3.add(new Rectangle(10, 10, 10, 10));
reg.add(reg1);
reg.subtract(reg3);
Rectangle box = reg.getBounds();
if (!box.equals(reg1.getBounds())) {
reg.dispose();
reg1.dispose();
reg3.dispose();
fail("subtract failed 2");
}
reg3.dispose();
Region reg4 = new Region(display);
reg4.add(new Rectangle(50, 25, 10, 10));
reg.subtract(reg4);
box = reg.getBounds();
if (!box.equals(reg1.getBounds())) {
reg.dispose();
reg1.dispose();
reg4.dispose();
fail("subtract failed 3");
}
Region reg5 = new Region(display);
reg5.add(new Rectangle(0, 0, 60, 20));
reg.add(reg1.getBounds().union(reg4.getBounds()));
reg.subtract(reg5);
box = reg.getBounds();
if (!box.equals(new Rectangle(0, 20, 60, 15))) {
reg.dispose();
reg1.dispose();
reg4.dispose();
reg5.dispose();
fail("subtract failed 4");
}
reg.dispose();
reg = new Region(display);
reg.add(reg1);
reg.add(reg4);
reg.subtract(reg5);
box = reg.getBounds();
if (!box.equals(new Rectangle(0, 20, 60, 15))) {
reg.dispose();
reg1.dispose();
reg4.dispose();
reg5.dispose();
fail("subtract failed 5");
}
reg.dispose();
reg1.dispose();
reg4.dispose();
reg5.dispose();
}
use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_subtractLorg_eclipse_swt_graphics_Rectangle.
@Test
public void test_subtractLorg_eclipse_swt_graphics_Rectangle() {
Rectangle rect1 = new Rectangle(0, 0, 50, 25);
Rectangle rect2 = new Rectangle(0, 0, 50, 25);
Rectangle rect3 = new Rectangle(10, 10, 10, 10);
Rectangle rect4 = new Rectangle(50, 25, 10, 10);
Rectangle rect5 = new Rectangle(0, 0, 60, 20);
Region reg = new Region(display);
reg.dispose();
try {
reg.subtract(rect1);
fail("no exception thrown on disposed region");
} catch (SWTException e) {
}
reg = new Region(display);
reg.subtract(rect1);
if (!reg.isEmpty()) {
reg.dispose();
fail("subtract failed for empty region");
}
reg.add(rect1);
reg.subtract(rect2);
if (!reg.isEmpty()) {
reg.dispose();
fail("subtract failed 1");
}
reg.add(rect1);
reg.subtract(rect3);
Rectangle box = reg.getBounds();
if (!box.equals(rect1)) {
reg.dispose();
fail("subtract failed 2");
}
reg.subtract(rect4);
box = reg.getBounds();
if (!box.equals(rect1)) {
reg.dispose();
fail("subtract failed 3");
}
reg.add(rect1.union(rect4));
reg.subtract(rect5);
box = reg.getBounds();
if (!box.equals(new Rectangle(0, 20, 60, 15))) {
reg.dispose();
fail("subtract failed 4");
}
reg.dispose();
reg = new Region(display);
reg.add(rect1);
reg.add(rect4);
reg.subtract(rect5);
box = reg.getBounds();
if (!box.equals(new Rectangle(0, 20, 60, 15))) {
reg.dispose();
fail("subtract failed 5");
}
reg.dispose();
}
use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_intersectLorg_eclipse_swt_graphics_Region.
@Test
public void test_intersectLorg_eclipse_swt_graphics_Region() {
Region reg = new Region(display);
Region reg1 = new Region(display);
reg1.add(new Rectangle(0, 0, 48, 24));
reg.dispose();
try {
reg.intersect(reg1);
reg1.dispose();
fail("no exception thrown on disposed region");
} catch (SWTException e) {
}
reg = new Region(display);
reg.intersect(reg1);
if (!reg.isEmpty()) {
reg.dispose();
reg1.dispose();
fail("intersect failed for empty region");
}
Region reg2 = new Region(display);
reg2.add(new Rectangle(0, 0, 48, 24));
reg.add(reg1);
reg.intersect(reg2);
Rectangle box = reg.getBounds();
if (!box.equals(reg1.getBounds())) {
reg.dispose();
reg1.dispose();
reg2.dispose();
fail("intersect failed 1");
}
reg2.dispose();
Region reg3 = new Region(display);
reg3.add(new Rectangle(10, 10, 10, 10));
reg.intersect(reg3);
box = reg.getBounds();
if (!box.equals(reg3.getBounds())) {
reg.dispose();
reg1.dispose();
reg3.dispose();
fail("intersect failed 2");
}
reg3.dispose();
Region reg4 = new Region(display);
reg4.add(new Rectangle(48, 24, 10, 10));
reg.intersect(reg4);
if (!reg.isEmpty()) {
reg.dispose();
reg1.dispose();
reg4.dispose();
fail("intersect failed 3");
}
Region reg5 = new Region(display);
reg5.add(new Rectangle(24, 20, 24, 10));
reg.add(reg1.getBounds().union(reg4.getBounds()));
reg.intersect(reg5);
box = reg.getBounds();
if (!box.equals(reg5.getBounds())) {
reg.dispose();
reg1.dispose();
reg4.dispose();
fail("intersect failed 4");
}
reg.dispose();
reg = new Region(display);
reg.add(reg1);
reg.add(reg4);
reg.intersect(reg5);
box = reg.getBounds();
if (!box.equals(new Rectangle(24, 20, 24, 4))) {
reg.dispose();
reg1.dispose();
reg4.dispose();
fail("intersect failed 5");
}
reg.dispose();
reg1.dispose();
reg4.dispose();
reg5.dispose();
}
use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Table method test_setColumnOrder$I.
@Test
public void test_setColumnOrder$I() {
assertArrayEquals(table.getColumnOrder(), new int[0]);
table.setColumnOrder(new int[0]);
assertArrayEquals(table.getColumnOrder(), new int[0]);
try {
table.setColumnOrder(null);
fail("No exception thrown for null argument");
} catch (IllegalArgumentException ex) {
}
try {
table.setColumnOrder(new int[1]);
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
TableColumn column0 = new TableColumn(table, SWT.NONE);
TableColumn column1 = new TableColumn(table, SWT.NONE);
TableColumn column2 = new TableColumn(table, SWT.NONE);
assertArrayEquals(table.getColumnOrder(), new int[] { 0, 1, 2 });
try {
table.setColumnOrder(null);
fail("No exception thrown for null argument");
} catch (IllegalArgumentException ex) {
}
try {
table.setColumnOrder(new int[0]);
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
try {
table.setColumnOrder(new int[] { 0, 1 });
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
try {
table.setColumnOrder(new int[] { 0, 1, 2, 3 });
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
try {
table.setColumnOrder(new int[] { 0, 0, 1 });
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
try {
table.setColumnOrder(new int[] { 3, 0, 1 });
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
table.setColumnOrder(new int[] { 2, 1, 0 });
assertArrayEquals(table.getColumnOrder(), new int[] { 2, 1, 0 });
column2.dispose();
assertArrayEquals(table.getColumnOrder(), new int[] { 1, 0 });
try {
table.setColumnOrder(new int[] { 0, 1, 2 });
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
column1.dispose();
assertArrayEquals(table.getColumnOrder(), new int[] { 0 });
column0.dispose();
assertArrayEquals(table.getColumnOrder(), new int[0]);
try {
table.setColumnOrder(new int[1]);
fail("No exception thrown for invalid argument");
} catch (IllegalArgumentException ex) {
}
Table table2 = new Table(table.getParent(), SWT.NONE);
table2.dispose();
try {
table2.getColumnOrder();
fail("No exception thrown for widget is Disposed");
} catch (SWTException ex) {
}
try {
table2.setColumnOrder(new int[0]);
fail("No exception thrown for widget is Disposed");
} catch (SWTException ex) {
}
}
Aggregations