Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariot Chauvin2010-08-30 09:51:15 +0000
committerMariot Chauvin2010-08-30 09:51:15 +0000
commitfa10bccb3679e237f866447bb8053d7119a2dfe9 (patch)
treeae75d1148c720764b5c34dfa2538528c07b26b0b
parent6eaae106cce3696d923ffc30cfbcaa2882a25465 (diff)
downloadorg.eclipse.swtbot-fa10bccb3679e237f866447bb8053d7119a2dfe9.tar.gz
org.eclipse.swtbot-fa10bccb3679e237f866447bb8053d7119a2dfe9.tar.xz
org.eclipse.swtbot-fa10bccb3679e237f866447bb8053d7119a2dfe9.zip
Bug 321626 - Methods on SWTBotGefEditor taking a SWTBotGefEditPart as Input are wrong
-rw-r--r--examples/gef/org.eclipse.gef.examples.logic.test/src/org/eclipse/gef/examples/logic/test/unit/AllTests.java27
-rw-r--r--org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditor.java27
2 files changed, 48 insertions, 6 deletions
diff --git a/examples/gef/org.eclipse.gef.examples.logic.test/src/org/eclipse/gef/examples/logic/test/unit/AllTests.java b/examples/gef/org.eclipse.gef.examples.logic.test/src/org/eclipse/gef/examples/logic/test/unit/AllTests.java
index ee204eae..6565fef0 100644
--- a/examples/gef/org.eclipse.gef.examples.logic.test/src/org/eclipse/gef/examples/logic/test/unit/AllTests.java
+++ b/examples/gef/org.eclipse.gef.examples.logic.test/src/org/eclipse/gef/examples/logic/test/unit/AllTests.java
@@ -135,6 +135,33 @@ public class AllTests extends SWTBotGefForUnitTestsTestCase implements LogicMode
checkSize(getBounds(circuitEditPart), boundsBeforeDrag.width, boundsBeforeDrag.height);
}
+ public void testDragAndDropWithRelativeCoodinatesFigure() throws Exception {
+
+ int offset = 30;
+ int circuitFigureSize = 100;
+
+ editor.activateTool(TOOL_CIRCUIT);
+ editor.click(offset, offset);
+
+ editor.activateTool(TOOL_CIRCUIT);
+ editor.click(circuitFigureSize*2 +offset, offset);
+
+
+ SWTBotGefEditPart circuitEditPart1 = editor.editParts(instanceOf(CircuitEditPart.class)).get(0);
+ SWTBotGefEditPart circuitEditPart2 = editor.editParts(instanceOf(CircuitEditPart.class)).get(1);
+
+ /* create a child of circuitEditPart1 */
+ editor.activateTool(TOOL_CIRCUIT);
+ editor.click(circuitFigureSize/2 + offset, circuitFigureSize/2 + offset);
+
+ SWTBotGefEditPart circuitEditPart1child = circuitEditPart1.children().get(0);
+
+ editor.drag(circuitEditPart1child, 5*(circuitFigureSize/2) + offset, circuitFigureSize/2 + offset);
+ syncWithUIThread();
+ assertFalse(circuitEditPart2.children().isEmpty());
+ }
+
+
public void testResize() throws Exception {
editor.activateTool(TOOL_CIRCUIT);
editor.click(30, 30);
diff --git a/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditor.java b/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditor.java
index 7c975414..5451ac71 100644
--- a/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditor.java
+++ b/org.eclipse.swtbot.eclipse.gef.finder/src/org/eclipse/swtbot/eclipse/gef/finder/widgets/SWTBotGefEditor.java
@@ -7,9 +7,11 @@
*
* Contributors:
* MAKE Technologies Inc - initial API and implementation
- * Mariot Chauvin <mariot.chauvin@obeo.fr> - refactoring
- * Steve Monnier <steve.monnier@obeo.fr> - add mouseMoveDoubleClick action
- * Nathalie Lepine <nathalie.lepine@obeo.fr> - add mouseMoveDoubleClick action
+ * Mariot Chauvin <mariot.chauvin@obeo.fr> - Improvements and bug fixes
+ * Steve Monnier <steve.monnier@obeo.fr> - Improvements and bug fixes
+ * Nathalie Lepine <nathalie.lepine@obeo.fr> - Improvements and bug fixes
+ * Pascal Gelinas <pascal gelinas @nuecho.com> - Improvements and bug fixes
+ * Mickael Istria <mickael.istria@bonitasoft.com> - Improvements and bug fixes
*******************************************************************************/
package org.eclipse.swtbot.eclipse.gef.finder.widgets;
@@ -350,7 +352,7 @@ public class SWTBotGefEditor extends SWTBotEditor {
* @param editPart the edit part to click on
*/
public void click(final SWTBotGefEditPart editPart) {
- Rectangle bounds = ((GraphicalEditPart) editPart.part()).getFigure().getBounds();
+ Rectangle bounds = getAbsoluteBounds(editPart);
click(bounds.x, bounds.y);
}
@@ -384,7 +386,7 @@ public class SWTBotGefEditor extends SWTBotEditor {
* @param editPart the edit part to double click on
*/
public void doubleClick(final SWTBotGefEditPart editPart) {
- Rectangle bounds = ((GraphicalEditPart) editPart.part()).getFigure().getBounds();
+ Rectangle bounds = getAbsoluteBounds(editPart);
/*
* Note that a move is required before double clicking in order to update the mouse cursor with the target
* editpart. As we can not double click on the corner, we move the double click position
@@ -425,7 +427,7 @@ public class SWTBotGefEditor extends SWTBotEditor {
* @param toYPosition the y relative location
*/
public void drag(final SWTBotGefEditPart editPart, final int toXPosition, final int toYPosition) {
- Rectangle bounds = ((GraphicalEditPart) editPart.part()).getFigure().getBounds();
+ Rectangle bounds = getAbsoluteBounds(editPart);
/*
* We should increment drag location to avoid a resize. 7 comes from SquareHandle#DEFAULT_HANDLE_SIZE and we
* divided by 2 as AbstractHandle#getAccessibleLocation do that by default
@@ -435,6 +437,19 @@ public class SWTBotGefEditor extends SWTBotEditor {
}
/**
+ * Get absolute bounds of the edit part.
+ * @param editPart edit part
+ * @return the absolute bounds
+ */
+ private Rectangle getAbsoluteBounds(final SWTBotGefEditPart editPart) {
+ IFigure figure = ((GraphicalEditPart) editPart.part()).getFigure();
+ Rectangle bounds = figure.getBounds().getCopy();
+ figure.translateToAbsolute(bounds);
+ return bounds;
+ }
+
+
+ /**
* Drag and drop the edit part which owns the specified label to the specified location
*
* @param label the label to retrieve the edit part to drag and drop

Back to the top