diff options
author | Michael Wenz | 2017-12-01 15:25:43 +0000 |
---|---|---|
committer | Michael Wenz | 2017-12-01 15:26:39 +0000 |
commit | c83a4ed066366ecf6a6d1e4168c20302e41dc4a2 (patch) | |
tree | c2fb1d746e30fd2a7d80ab26fac643ea7f9e3fd5 | |
parent | 2c8bfbe7e355d5c650c2182f752d53b916fd0a15 (diff) | |
download | org.eclipse.graphiti-c83a4ed066366ecf6a6d1e4168c20302e41dc4a2.tar.gz org.eclipse.graphiti-c83a4ed066366ecf6a6d1e4168c20302e41dc4a2.tar.xz org.eclipse.graphiti-c83a4ed066366ecf6a6d1e4168c20302e41dc4a2.zip |
Bug 418398 - Fix test failures * These failure appeared after upgrade to
Eclipse Platform for Luna M2 / Java 6
Change-Id: Iba71eebfbb47c9653f64e587ee74f9c67f6e6bdb
-rw-r--r-- | tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java | 631 |
1 files changed, 311 insertions, 320 deletions
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java index 8581ba47..dbb3f2a7 100644 --- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java +++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java @@ -85,6 +85,7 @@ import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateFreeform import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateGaContainerFeature; import org.eclipse.graphiti.testtool.sketch.features.create.SketchCreateGaShapeFeature; import org.eclipse.graphiti.ui.editor.IDiagramContainerUI; +import org.eclipse.graphiti.ui.internal.Messages; import org.eclipse.graphiti.ui.internal.command.CreateModelObjectCommand; import org.eclipse.graphiti.ui.internal.command.GefCommandWrapper; import org.eclipse.graphiti.ui.internal.contextbuttons.ContextButtonPad; @@ -110,6 +111,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; import org.hamcrest.Description; +import org.junit.Ignore; import org.junit.Test; @SuppressWarnings("restriction") @@ -177,41 +179,37 @@ public class GFInteractionComponentTests extends AbstractGFTests { page.getGefEditor().saveAndClose(); } - // @Test - // public void testMarqueeTool() throws Exception { - // final int x = 100; - // final int y = 100; - // final IDiagramContainerUI diagramEditor = - // openDiagramEditor(ITestConstants.DIAGRAM_TYPE_ID_ECORE); - // createClassesAndConnection(x, y, diagramEditor.getDiagramTypeProvider(), - // "Marquee", SHAPE_NAME); - // Thread.sleep(DELAY); - // // Select the newly added shapes with the marquee tool. - // syncExec(new VoidResult() { - // public void run() { - // ed.drag(x - 10, y - 10, x + SHORT_DELAY, y + SHORT_DELAY); - // } - // }); - // Thread.sleep(DELAY); - // - // syncExec(new VoidResult() { - // public void run() { - // ed.getGefEditor().activateTool("Select"); - // ed.getGefEditor().drag(x + 50, y + 50, x + 200, y + 50); - // } - // }); - // Thread.sleep(DELAY); - // IFigure figure = ed.getFigureWithLabel(SHAPE_NAME); - // int realX = figure.getBounds().x; - // int expectedX = x + 150; - // // Drag might not be accurate, add tolerance +-1 - // int tolerance = 1; - // assertTrue( - // "X value is " + realX + ", expected was " + expectedX + - // " which is out of tolerance of " + tolerance, - // (expectedX - tolerance <= realX) && (realX <= expectedX + tolerance)); - // page.shutdownEditor(diagramEditor); - // } + @Test + public void testMarqueeTool() throws Exception { + final int x = 100; + final int y = 100; + final IDiagramContainerUI diagramEditor = openDiagramEditor(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + createClassesAndConnection(x, y, diagramEditor.getDiagramTypeProvider(), "Marquee", SHAPE_NAME); + Thread.sleep(DELAY); + // Select the newly added shapes with the marquee tool. + syncExec(new VoidResult() { + public void run() { + ed.drag(x - 10, y - 10, x + SHORT_DELAY, y + SHORT_DELAY); + } + }); + Thread.sleep(DELAY); + + syncExec(new VoidResult() { + public void run() { + ed.getGefEditor().activateTool("Select"); + ed.getGefEditor().drag(x + 50, y + 50, x + 200, y + 50); + } + }); + Thread.sleep(DELAY); + IFigure figure = ed.getFigureWithLabel(SHAPE_NAME); + int realX = figure.getBounds().x; + int expectedX = x + 150; + // Drag might not be accurate, add tolerance +-1 + int tolerance = 1; + assertTrue("X value is " + realX + ", expected was " + expectedX + " which is out of tolerance of " + tolerance, + (expectedX - tolerance <= realX) && (realX <= expectedX + tolerance)); + page.shutdownEditor(diagramEditor); + } @Test public void testHideSelectionAndMarqueeTools() throws Exception { @@ -591,291 +589,284 @@ public class GFInteractionComponentTests extends AbstractGFTests { page.shutdownEditor(diagramEditor); } - // /* - // * Test for Bugzilla 323351 - // */ - // @Test - // @Ignore("Unstable, see Bugzilla 418398") - // public void testContextPadHiding() throws Exception { - // final int x = 100; - // final int y = 100; - // final IDiagramContainerUI diagramEditor = - // openDiagramEditor(ITestConstants.DIAGRAM_TYPE_ID_ECORE); - // - // syncExec(new VoidResult() { - // public void run() { - // IDiagramTypeProvider diagramTypeProvider = - // diagramEditor.getDiagramTypeProvider(); - // final IFeatureProvider fp = diagramTypeProvider.getFeatureProvider(); - // final Diagram currentDiagram = diagramTypeProvider.getDiagram(); - // executeInRecordingCommand(diagramEditor.getDiagramBehavior(), new - // Runnable() { - // public void run() { - // addClassToDiagram(fp, currentDiagram, x, y, SHAPE_NAME); - // } - // }); - // } - // }); - // Thread.sleep(DELAY); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 150, p.y + 150); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(DELAY); - // - // assertNotNull(findContextButtonPad()); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 50, p.y + 50); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(DELAY); - // - // assertNull(findContextButtonPad()); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // r.setAutoDelay(20); - // r.keyPress(KeyEvent.VK_CONTROL); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 150, p.y + 150); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(DELAY); - // - // assertNull(findContextButtonPad()); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // r.setAutoDelay(20); - // r.keyRelease(KeyEvent.VK_CONTROL); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(DELAY); - // - // syncExec(new VoidResult() { - // public void run() { - // try { - // final Robot robot = new Robot(); - // robot.setAutoDelay(10); - // try { - // robot.mousePress(InputEvent.BUTTON1_MASK); - // robot.mouseRelease(InputEvent.BUTTON1_MASK); - // robot.keyPress(KeyEvent.VK_DELETE); - // } catch (RuntimeException e) { - // fail(e.getMessage()); - // } finally { - // robot.keyRelease(KeyEvent.VK_DELETE); - // } - // } catch (Exception e) { - // fail(e.getMessage()); - // } - // } - // }); - // - // Thread.sleep(DELAY); - // - // syncExec(new VoidResult() { - // public void run() { - // try { - // final Robot robot = new Robot(); - // robot.setAutoDelay(1); - // - // try { - // robot.keyPress(KeyEvent.VK_ENTER); - // } catch (RuntimeException e) { - // fail(e.getMessage()); - // } finally { - // robot.keyRelease(KeyEvent.VK_ENTER); - // } - // } catch (Exception e) { - // fail(e.getMessage()); - // } - // } - // - // }); - // Thread.sleep(DELAY); - // page.shutdownEditor(diagramEditor); - // } - - // /* - // * Test for Bugzilla 323351 - // */ - // @Test - // @Ignore("Unstable, see Bugzilla 418398") - // public void testContextPadHidingViaToolbar() throws Exception { - // /* - // * TODO: Workaround for not displayed toolbar starting with Eclipse 4.3 - // * M1 - // */ - // syncExec(new VoidResult() { - // public void run() { - // SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot(); - // swtWorkbenchBot.menu("&Window").menu("Hide &Toolbar").click(); - // swtWorkbenchBot.menu("&Window").menu("Show &Toolbar").click(); - // } - // }); - // Thread.sleep(DELAY); - // /* End workaround */ - // - // final int x = 100; - // final int y = 100; - // final IDiagramContainerUI diagramEditor = - // openDiagramEditor(ITestConstants.DIAGRAM_TYPE_ID_ECORE); - // - // syncExec(new VoidResult() { - // public void run() { - // IDiagramTypeProvider diagramTypeProvider = - // diagramEditor.getDiagramTypeProvider(); - // final IFeatureProvider fp = diagramTypeProvider.getFeatureProvider(); - // final Diagram currentDiagram = diagramTypeProvider.getDiagram(); - // executeInRecordingCommand(diagramEditor.getDiagramBehavior(), new - // Runnable() { - // public void run() { - // addClassToDiagram(fp, currentDiagram, x, y, SHAPE_NAME); - // } - // }); - // } - // }); - // Thread.sleep(DELAY); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 10, p.y + 10); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(SHORT_DELAY); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 150, p.y + 150); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(SHORT_DELAY); - // - // assertNotNull(findContextButtonPad()); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 10, p.y + 10); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(DELAY); - // - // assertNull(findContextButtonPad()); - // - // syncExec(new VoidResult() { - // public void run() { - // Robot r; - // try { - // r = new Robot(); - // r.setAutoDelay(20); - // new - // SWTWorkbenchBot().toolbarToggleButtonWithTooltip(Messages.ToggleContextButtonPadAction_0_xmsg) - // .click(); - // Point p = ed.getOrigin(); - // r.mouseMove(p.x + 150, p.y + 150); - // } catch (AWTException e) { - // fail(e.getMessage()); - // } - // } - // }); - // Thread.sleep(DELAY); - // - // assertNull(findContextButtonPad()); - // - // syncExec(new VoidResult() { - // public void run() { - // try { - // final Robot robot = new Robot(); - // robot.setAutoDelay(1); - // try { - // robot.mousePress(InputEvent.BUTTON1_MASK); - // robot.mouseRelease(InputEvent.BUTTON1_MASK); - // robot.keyPress(KeyEvent.VK_DELETE); - // } catch (RuntimeException e) { - // fail(e.getMessage()); - // } finally { - // robot.keyRelease(KeyEvent.VK_DELETE); - // } - // } catch (Exception e) { - // fail(e.getMessage()); - // } - // } - // }); - // - // syncExec(new VoidResult() { - // public void run() { - // try { - // final Robot robot = new Robot(); - // robot.setAutoDelay(1); - // - // try { - // robot.keyPress(KeyEvent.VK_ENTER); - // } catch (RuntimeException e) { - // fail(e.getMessage()); - // } finally { - // robot.keyRelease(KeyEvent.VK_ENTER); - // } - // } catch (Exception e) { - // fail(e.getMessage()); - // } - // } - // - // }); - // Thread.sleep(DELAY); - // page.shutdownEditor(diagramEditor); - // } + /* + * Test for Bugzilla 323351 + */ + @Test + @Ignore("Unstable, see Bugzilla 418398") + public void testContextPadHiding() throws Exception { + final int x = 100; + final int y = 100; + final IDiagramContainerUI diagramEditor = openDiagramEditor(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + + syncExec(new VoidResult() { + public void run() { + IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); + final IFeatureProvider fp = diagramTypeProvider.getFeatureProvider(); + final Diagram currentDiagram = diagramTypeProvider.getDiagram(); + executeInRecordingCommand(diagramEditor.getDiagramBehavior(), new Runnable() { + public void run() { + addClassToDiagram(fp, currentDiagram, x, y, SHAPE_NAME); + } + }); + } + }); + Thread.sleep(DELAY); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 150, p.y + 150); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(DELAY); + + assertNotNull(findContextButtonPad()); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 50, p.y + 50); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(DELAY); + + assertNull(findContextButtonPad()); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + r.setAutoDelay(20); + r.keyPress(KeyEvent.VK_CONTROL); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 150, p.y + 150); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(DELAY); + + assertNull(findContextButtonPad()); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + r.setAutoDelay(20); + r.keyRelease(KeyEvent.VK_CONTROL); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(DELAY); + + syncExec(new VoidResult() { + public void run() { + try { + final Robot robot = new Robot(); + robot.setAutoDelay(10); + try { + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.keyPress(KeyEvent.VK_DELETE); + } catch (RuntimeException e) { + fail(e.getMessage()); + } finally { + robot.keyRelease(KeyEvent.VK_DELETE); + } + } catch (Exception e) { + fail(e.getMessage()); + } + } + }); + + Thread.sleep(DELAY); + + syncExec(new VoidResult() { + public void run() { + try { + final Robot robot = new Robot(); + robot.setAutoDelay(1); + + try { + robot.keyPress(KeyEvent.VK_ENTER); + } catch (RuntimeException e) { + fail(e.getMessage()); + } finally { + robot.keyRelease(KeyEvent.VK_ENTER); + } + } catch (Exception e) { + fail(e.getMessage()); + } + } + + }); + Thread.sleep(DELAY); + page.shutdownEditor(diagramEditor); + } + + /* + * Test for Bugzilla 323351 + */ + @Test + @Ignore("Unstable, see Bugzilla 418398") + public void testContextPadHidingViaToolbar() throws Exception { + /* + * TODO: Workaround for not displayed toolbar starting with Eclipse 4.3 + * M1 + */ + syncExec(new VoidResult() { + public void run() { + SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot(); + swtWorkbenchBot.menu("&Window").menu("Hide &Toolbar").click(); + swtWorkbenchBot.menu("&Window").menu("Show &Toolbar").click(); + } + }); + Thread.sleep(DELAY); + /* End workaround */ + + final int x = 100; + final int y = 100; + final IDiagramContainerUI diagramEditor = openDiagramEditor(ITestConstants.DIAGRAM_TYPE_ID_ECORE); + + syncExec(new VoidResult() { + public void run() { + IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); + final IFeatureProvider fp = diagramTypeProvider.getFeatureProvider(); + final Diagram currentDiagram = diagramTypeProvider.getDiagram(); + executeInRecordingCommand(diagramEditor.getDiagramBehavior(), new Runnable() { + public void run() { + addClassToDiagram(fp, currentDiagram, x, y, SHAPE_NAME); + } + }); + } + }); + Thread.sleep(DELAY); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 10, p.y + 10); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(SHORT_DELAY); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 150, p.y + 150); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(SHORT_DELAY); + + assertNotNull(findContextButtonPad()); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 10, p.y + 10); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(DELAY); + + assertNull(findContextButtonPad()); + + syncExec(new VoidResult() { + public void run() { + Robot r; + try { + r = new Robot(); + r.setAutoDelay(20); + new SWTWorkbenchBot().toolbarToggleButtonWithTooltip(Messages.ToggleContextButtonPadAction_0_xmsg) + .click(); + Point p = ed.getOrigin(); + r.mouseMove(p.x + 150, p.y + 150); + } catch (AWTException e) { + fail(e.getMessage()); + } + } + }); + Thread.sleep(DELAY); + + assertNull(findContextButtonPad()); + + syncExec(new VoidResult() { + public void run() { + try { + final Robot robot = new Robot(); + robot.setAutoDelay(1); + try { + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.keyPress(KeyEvent.VK_DELETE); + } catch (RuntimeException e) { + fail(e.getMessage()); + } finally { + robot.keyRelease(KeyEvent.VK_DELETE); + } + } catch (Exception e) { + fail(e.getMessage()); + } + } + }); + + syncExec(new VoidResult() { + public void run() { + try { + final Robot robot = new Robot(); + robot.setAutoDelay(1); + + try { + robot.keyPress(KeyEvent.VK_ENTER); + } catch (RuntimeException e) { + fail(e.getMessage()); + } finally { + robot.keyRelease(KeyEvent.VK_ENTER); + } + } catch (Exception e) { + fail(e.getMessage()); + } + } + + }); + Thread.sleep(DELAY); + page.shutdownEditor(diagramEditor); + } private ContextButtonPad findContextButtonPad() { SWTBotGefEditPart rootEditPart = ed.getGefEditor().rootEditPart(); |