Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-01-20 08:40:23 +0000
committerLaurent Redor2017-01-23 13:26:46 +0000
commit24fb7cc0cadcc3ef6c68c26b873c995e205f7b6c (patch)
tree9dd764caacf2e204eaddc9f9974690d0e1acff61
parente91bf4957e7f2540984621e9b05c322896f0f895 (diff)
downloadorg.eclipse.sirius-24fb7cc0cadcc3ef6c68c26b873c995e205f7b6c.tar.gz
org.eclipse.sirius-24fb7cc0cadcc3ef6c68c26b873c995e205f7b6c.tar.xz
org.eclipse.sirius-24fb7cc0cadcc3ef6c68c26b873c995e205f7b6c.zip
[471104] Make tests fail systematically
Since the creation of tests MoveEdgeGroupTest for bug 471104, they fail randomly. This is caused by a wrong waiting condition. On standard environment the test pass (but wrongly), they should fail. And they fail randomly only on "slow" environment. This commit adds complementary waiting condition and always reveals the problem. Another commit will follow with the fix. Bug: 471104 Change-Id: I0cbe0bcb3b5ca5258ca6898bda3afb631eb822eb Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html46
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile27
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java16
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java14
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java27
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveFromEdgeMoveTest.java52
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveTest.java7
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveEdgeGroupTest.java29
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java121
9 files changed, 310 insertions, 29 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 6bf64b8745..c2a6bcd65c 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -114,6 +114,44 @@
<code>org.eclipse.sirius.tests.support.api.TestsUtil.setTargetPlatform()</code> has been added to allow to load a PDE target platform according to all known OSGi bundles. It is usefull to compile a plug-in in the execution runtime of the tests.
</li>
</ul>
+ <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support">Changes in
+ <code>org.eclipse.sirius.tests.swtbot.support</code>
+ </h4>
+ <ul>
+ <li><span class="label label-info">Modified</span> A new AtomicBoolean parameter has been added to the utility method
+ <code>mouseDragWithKey(int, int, int, int, int)</code> in classes
+ <code>org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor</code>,
+ <code>org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusGefViewer</code> and
+ <code>org.eclipse.sirius.tests.swtbot.support.api.widget.SWTBotSiriusFigureCanvas</code>. This allows to correctly wait the end of the drag&#8217;n&#8217;drop.
+ <ul>
+ <li>Sample of code to use:</li>
+ </ul>
+ </li>
+ </ul>
+ <pre>final AtomicBoolean dragFinished = new AtomicBoolean(false);
+editor.dragWithKey(start.x, start.y, endpoint.x, endpoint.y, SWT.F3, dragFinished);
+// Wait that the drag is done (the async Runnable simulating the
+// drag)
+bot.waitUntil(new ICondition() {
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+});
+// Wait that the figures are redrawn. In a fast environment, figures
+// are not really redrawn and the rest of the test is not reliable.
+SWTBotUtils.waitAllUiEvents();
+
+</pre>
<h2 id="sirius4.1.2">Changes in Sirius 4.1.2</h2>
<h3 id="UserVisibleChanges">User-Visible Changes</h3>
<ul>
@@ -630,7 +668,7 @@
<code>DView.ownedRepresentationDescriptors</code> addition.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support2">Changes in
<code>org.eclipse.sirius.tests.swtbot.support</code>
</h4>
<ul>
@@ -1130,7 +1168,7 @@
<code>SiriusTestCase.initViewpoint(String, Session, EObject)</code> has been deprecated because the last parameter is useless to activate a viewpoint.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support2">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support3">Changes in
<code>org.eclipse.sirius.tests.swtbot.support</code>
</h4>
<ul>
@@ -1640,7 +1678,7 @@
</ul>
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support3">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support4">Changes in
<code>org.eclipse.sirius.tests.swtbot.support</code>
</h4>
<ul>
@@ -2593,7 +2631,7 @@
<code>org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper.setReadOnlyStatus(boolean, IResource...)</code> can be used instead.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support4">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support5">Changes in
<code>org.eclipse.sirius.tests.swtbot.support</code>
</h4>
<ul>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index ef584041ad..2a88c248c3 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -12,6 +12,33 @@ h4. Changes in @org.eclipse.sirius.tests.junit.support@
* <span class="label label-success">Added</span> The utility method @org.eclipse.sirius.tests.support.api.TestsUtil.setTargetPlatform()@ has been added to allow to load a PDE target platform according to all known OSGi bundles. It is usefull to compile a plug-in in the execution runtime of the tests.
+h4. Changes in @org.eclipse.sirius.tests.swtbot.support@
+
+* <span class="label label-info">Modified</span> A new AtomicBoolean parameter has been added to the utility method @mouseDragWithKey(int, int, int, int, int)@ in classes @org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor@, @org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusGefViewer@ and @org.eclipse.sirius.tests.swtbot.support.api.widget.SWTBotSiriusFigureCanvas@. This allows to correctly wait the end of the drag'n'drop.
+** Sample of code to use:
+pre.. final AtomicBoolean dragFinished = new AtomicBoolean(false);
+editor.dragWithKey(start.x, start.y, endpoint.x, endpoint.y, SWT.F3, dragFinished);
+// Wait that the drag is done (the async Runnable simulating the
+// drag)
+bot.waitUntil(new ICondition() {
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+});
+// Wait that the figures are redrawn. In a fast environment, figures
+// are not really redrawn and the rest of the test is not reliable.
+SWTBotUtils.waitAllUiEvents();
+
h2(#sirius4.1.2). Changes in Sirius 4.1.2
h3. User-Visible Changes
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
index 3caf7c7709..fd730fa714 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusDiagramEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2017 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.IFigure;
@@ -935,9 +936,16 @@ public class SWTBotSiriusDiagramEditor extends SWTBotGefEditor {
* code constants in class <code>SWT</code>, or
* {@link org.eclipse.swt.SWT#None} if no key. @see
* org.eclipse.swt.SWT
- */
- public void dragWithKey(int fromXPosition, int fromYPosition, int toXPosition, int toYPosition, int keyCode) {
- ((SWTBotSiriusGefViewer) getSWTBotGefViewer()).dragWithKey(fromXPosition, fromYPosition, toXPosition, toYPosition, keyCode);
+ * @param dragFinished
+ * An AtomicBoolean allows to add a waiting condition. It was set
+ * to true when the drag is finished.<BR>
+ * Warning: When the drag is finished, the associated figures
+ * have not their "moved" bound. Another
+ * {@link org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils#waitAllUiEvents()}
+ * is needed.
+ */
+ public void dragWithKey(int fromXPosition, int fromYPosition, int toXPosition, int toYPosition, int keyCode, final AtomicBoolean dragFinished) {
+ ((SWTBotSiriusGefViewer) getSWTBotGefViewer()).dragWithKey(fromXPosition, fromYPosition, toXPosition, toYPosition, keyCode, dragFinished);
}
/**
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
index 87041ed212..435ffe8856 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotSiriusGefViewer.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@ package org.eclipse.sirius.tests.swtbot.support.api.editor;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.draw2d.FigureCanvas;
@@ -316,10 +317,17 @@ public class SWTBotSiriusGefViewer extends SWTBotGefViewer {
* code constants in class <code>SWT</code>, or
* {@link org.eclipse.swt.SWT#None} if no key. @see
* org.eclipse.swt.SWT
+ * @param dragFinished
+ * An AtomicBoolean allows to add a waiting condition. It was set
+ * to true when the drag is finished.<BR>
+ * Warning: When the drag is finished, the associated figures
+ * have not their "moved" bound. Another
+ * {@link org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils#waitAllUiEvents()}
+ * is needed.
*/
- public void dragWithKey(final int fromXPosition, final int fromYPosition, final int toXPosition, final int toYPosition, final int keyCode) {
+ public void dragWithKey(final int fromXPosition, final int fromYPosition, final int toXPosition, final int toYPosition, final int keyCode, final AtomicBoolean dragFinished) {
if (canvas instanceof SWTBotSiriusFigureCanvas) {
- ((SWTBotSiriusFigureCanvas) canvas).mouseDragWithKey(fromXPosition, fromYPosition, toXPosition, toYPosition, keyCode);
+ ((SWTBotSiriusFigureCanvas) canvas).mouseDragWithKey(fromXPosition, fromYPosition, toXPosition, toYPosition, keyCode, dragFinished);
} else {
canvas.mouseDrag(fromXPosition, fromYPosition, toXPosition, toYPosition);
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
index a543fb7441..158f8143f5 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/widget/SWTBotSiriusFigureCanvas.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2012, 2016 THALES GLOBAL SERVICES
+ * Copyright (c) 2012, 2017 THALES GLOBAL SERVICES
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*/
package org.eclipse.sirius.tests.swtbot.support.api.widget;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.swt.SWT;
@@ -20,7 +22,9 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
/**
* Specific FigureCanvas to:
@@ -202,11 +206,19 @@ public class SWTBotSiriusFigureCanvas extends SWTBotGefFigureCanvas {
* the key code of the key that was typed, as defined by the key
* code constants in class <code>SWT</code>, or {@link SWT#None}
* if no key. @see org.eclipse.swt.SWT
+ * @param dragFinished
+ * An AtomicBoolean allows to add a waiting condition. It was set
+ * to true when the drag is finished.<BR>
+ * Warning: When the drag is finished, the associated figures
+ * have not their "moved" bound. Another
+ * {@link org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils#waitAllUiEvents()}
+ * is needed.
*/
- public void mouseDragWithKey(final int fromXPosition, final int fromYPosition, final int toXPosition, final int toYPosition, final int keyCode) {
- UIThreadRunnable.asyncExec(new VoidResult() {
+ public void mouseDragWithKey(final int fromXPosition, final int fromYPosition, final int toXPosition, final int toYPosition, final int keyCode, final AtomicBoolean dragFinished) {
+ final Result<Boolean> toExecute = new Result<Boolean>() {
+
@Override
- public void run() {
+ public Boolean run() {
org.eclipse.swt.events.MouseEvent meMove = wrapMouseEvent(fromXPosition, fromYPosition, 0, 0, 0);
eventDispatcher.dispatchMouseMoved(meMove);
org.eclipse.swt.events.MouseEvent meDown = wrapMouseEvent(fromXPosition, fromYPosition, 1, SWT.BUTTON1, 1);
@@ -238,6 +250,13 @@ public class SWTBotSiriusFigureCanvas extends SWTBotGefFigureCanvas {
if (keyCode != SWT.None) {
eventDispatcher.dispatchKeyReleased(keyEvent);
}
+ return true;
+ }
+ };
+ SWTUtils.display().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ dragFinished.set(toExecute.run());
}
});
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveFromEdgeMoveTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveFromEdgeMoveTest.java
index f1d586f5e8..5a20538c88 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveFromEdgeMoveTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveFromEdgeMoveTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2015, 2017 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.IFigure;
@@ -57,6 +58,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefConnectionEditPart;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
@@ -630,7 +633,29 @@ public class EdgeLabelsMoveFromEdgeMoveTest extends AbstractSiriusSwtBotGefTestC
for (int i = 0; i < 10; i++) {
Point targetLocation = new Point(initialLocation.x + moveDelta.x, initialLocation.y + moveDelta.y);
// Perform drag
- diagramEditor.dragWithKey(initialLocation.x, initialLocation.y, targetLocation.x, targetLocation.y, SWT.None);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ diagramEditor.dragWithKey(initialLocation.x, initialLocation.y, targetLocation.x, targetLocation.y, SWT.None, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment,
+ // figures are not really redrawn and the rest of the test is
+ // not reliable.
SWTBotUtils.waitAllUiEvents();
initialLocation = targetLocation;
}
@@ -1098,7 +1123,28 @@ public class EdgeLabelsMoveFromEdgeMoveTest extends AbstractSiriusSwtBotGefTestC
Point targetLocation = new Point(initialLocation.x + moveDelta.x, initialLocation.y + moveDelta.y);
// Perform drag
- diagramEditor.dragWithKey(initialLocation.x, initialLocation.y, targetLocation.x, targetLocation.y, SWT.None);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ diagramEditor.dragWithKey(initialLocation.x, initialLocation.y, targetLocation.x, targetLocation.y, SWT.None, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
try {
assertEquals("Drag as failed: selection should be the same before and after drag.", selectedEditParts, diagramEditor.selectedEditParts());
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveTest.java
index c73093f8c3..51f161e41d 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeLabelsMoveTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2016, 2017 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.sirius.diagram.DDiagram;
@@ -155,7 +157,8 @@ public class EdgeLabelsMoveTest extends AbstractSiriusSwtBotGefTestCase {
int originalX = part.getFigure().getBounds().x;
int originalY = part.getFigure().getBounds().y;
CheckEditPartMoved checkEditPartMoved = new CheckEditPartMoved(editPart);
- diagramEditor.dragWithKey(part.getFigure().getBounds().x + 10, part.getFigure().getBounds().y, part.getFigure().getBounds().x + 10, part.getFigure().getBounds().y - 10, SWT.None);
+ diagramEditor.dragWithKey(part.getFigure().getBounds().x + 10, part.getFigure().getBounds().y, part.getFigure().getBounds().x + 10, part.getFigure().getBounds().y - 10, SWT.None,
+ new AtomicBoolean(false));
bot.waitUntil(checkEditPartMoved);
assertEquals("The x coordinate should be the same as the move is only on y axis.", originalX, part.getFigure().getBounds().x);
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveEdgeGroupTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveEdgeGroupTest.java
index 14e9952ff0..6da917dd54 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveEdgeGroupTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveEdgeGroupTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2015, 2017 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
@@ -34,6 +35,8 @@ import org.eclipse.sirius.tests.swtbot.support.api.view.DesignerViews;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -353,14 +356,34 @@ public class MoveEdgeGroupTest extends AbstractSiriusSwtBotGefTestCase {
}
}
-
final Point endpoint = new Point(start.x + delta.x, start.y + delta.y);
start.scale(zoomLevel.getAmount());
endpoint.scale(zoomLevel.getAmount());
// Move with F3 key pressed
- editor.dragWithKey(start.x, start.y, endpoint.x, endpoint.y, SWT.F3);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ editor.dragWithKey(start.x, start.y, endpoint.x, endpoint.y, SWT.F3, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
Point pointToTranslate = delta.getCopy();
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java
index cd33abaee8..c0f90fcc17 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SnapAllShapesTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2015, 2017 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
@@ -38,6 +40,8 @@ import org.eclipse.sirius.tests.swtbot.support.api.view.DesignerViews;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
/**
* Check the snap to all feature (move and resize).
@@ -315,7 +319,28 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase {
pointToMove.scale(zoomLevel.getAmount());
endpoint.scale(zoomLevel.getAmount());
// First move without F4 key pressed
- editor.dragWithKey(pointToMove.x, pointToMove.y, endpoint.x, endpoint.y, SWT.None);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ editor.dragWithKey(pointToMove.x, pointToMove.y, endpoint.x, endpoint.y, SWT.None, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
bot.waitUntil(new BendpointLocationCondition((PolylineConnection) connectionEditPart.getFigure(), 1, false, targetNodeBounds.getBottom().y - 2,
"Second bendpoint of edge is not at expected y location after resize without F4 key pressed", !ZoomLevel.ZOOM_100.equals(zoomLevel)));
@@ -327,7 +352,28 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase {
editor.scrollTo(0, 0);
// Second move with F4 key pressed
- editor.dragWithKey(pointToMove.x, pointToMove.y, endpoint.x, endpoint.y, SWT.F4);
+ dragFinished.set(false);
+ editor.dragWithKey(pointToMove.x, pointToMove.y, endpoint.x, endpoint.y, SWT.F4, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
bot.waitUntil(new BendpointLocationCondition((PolylineConnection) connectionEditPart.getFigure(), 1, false, targetNodeBounds.getBottom().y - 1,
"Second bendpoint of edge is not at expected y location after resize with F4 key pressed", !ZoomLevel.ZOOM_100.equals(zoomLevel)));
@@ -392,7 +438,28 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase {
editor.scrollTo(0, 0);
// Second move with F4 key pressed
- editor.dragWithKey(scaledPointToDrag.x, scaledPointToDrag.y, scaledEndpoint.x, scaledEndpoint.y, SWT.F4);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ editor.dragWithKey(scaledPointToDrag.x, scaledPointToDrag.y, scaledEndpoint.x, scaledEndpoint.y, SWT.F4, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
// Get the new bounds and compare with the expected. It should be
// aligned to the bottom of the other figure: at 1 pixel of the bottom
@@ -449,7 +516,28 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase {
editor.scrollTo(0, 0);
// Second move with F4 key pressed
- editor.dragWithKey(scaledPointToDrag.x, scaledPointToDrag.y, scaledEndpoint.x, scaledEndpoint.y, SWT.F4);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ editor.dragWithKey(scaledPointToDrag.x, scaledPointToDrag.y, scaledEndpoint.x, scaledEndpoint.y, SWT.F4, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
// Get the new bounds and compare with the expected. It should be
// aligned to the bottom of the other figure: at 1 pixel of the bottom
@@ -506,7 +594,28 @@ public class SnapAllShapesTest extends AbstractSiriusSwtBotGefTestCase {
editor.scrollTo(0, 0);
// Second move with F4 key pressed
- editor.dragWithKey(scaledPointToDrag.x, scaledPointToDrag.y, scaledEndpoint.x, scaledEndpoint.y, SWT.F4);
+ final AtomicBoolean dragFinished = new AtomicBoolean(false);
+ editor.dragWithKey(scaledPointToDrag.x, scaledPointToDrag.y, scaledEndpoint.x, scaledEndpoint.y, SWT.F4, dragFinished);
+ // Wait that the drag is done (the async Runnable simulating the
+ // drag)
+ bot.waitUntil(new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ return dragFinished.get();
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The drag'n'drop operation has not finished.";
+ }
+ });
+ // Wait that the figures are redrawn. In a fast environment, figures
+ // are not really redrawn and the rest of the test is not reliable.
SWTBotUtils.waitAllUiEvents();
// Get the new bounds and compare with the expected. It should be
// aligned to the bottom of the other figure: at 1 pixel of the bottom

Back to the top