use of org.eclipse.swt.graphics.Region in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_hashCode.
@Test
public void test_hashCode() {
Region reg1 = new Region(display);
Region reg2 = new Region(display);
Rectangle rect1 = new Rectangle(25, 100, 200, 780);
Rectangle rect2 = new Rectangle(30, 105, 205, 785);
reg1.add(rect1);
reg2.add(rect2);
if (reg1.hashCode() == reg2.hashCode()) {
reg1.dispose();
reg2.dispose();
fail("two different regions should have different hashCode");
}
reg2.dispose();
reg2 = new Region(display);
reg2.add(rect1);
// BUG: this should pass
// if (reg1.hashCode() != reg2.hashCode()) {
// reg1.dispose();
// reg2.dispose();
// fail("two regions representing same area should have same hashCode");
// }
reg1.dispose();
reg2.dispose();
}
use of org.eclipse.swt.graphics.Region 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.graphics.Region 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.graphics.Region in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_Constructor.
@Test
public void test_Constructor() {
// test Region()
Region reg = new Region();
if (reg.isDisposed()) {
fail("Constructor for Region didn't initialize");
}
reg.dispose();
}
use of org.eclipse.swt.graphics.Region in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_add_intArray.
@Test
public void test_add_intArray() {
Region reg = new Region(display);
int[] points = new int[] { 1 };
reg.add(points);
reg.dispose();
Region reg2 = new Region(display);
points = new int[] { 1, 2 };
reg2.add(points);
reg2.dispose();
Region reg3 = new Region(display);
points = new int[] { 1, 2, 3 };
reg3.add(points);
reg3.dispose();
Region reg4 = new Region(display);
points = new int[] { 1, 2, 3, 4 };
reg4.add(points);
reg4.dispose();
Region reg5 = new Region(display);
points = new int[] { 1, 2, 3, 4, 5 };
reg5.add(points);
reg5.dispose();
Region reg6 = new Region(display);
points = new int[] { 1, 2, 3, 4, 5, 6 };
reg6.add(points);
reg6.dispose();
}
Aggregations