diff options
| author | Maxime PORHEL | 2014-02-19 13:00:35 +0000 |
|---|---|---|
| committer | Gerrit Code Review @ Eclipse.org | 2014-03-04 08:45:30 +0000 |
| commit | 35ab4f28ff8585f9c557141424b15f72ce9345d0 (patch) | |
| tree | eeecc527c842a4c17235162c9a6caeb82d9a9e28 | |
| parent | 34da73f4221495bd4d06e2435c71d589e4d10895 (diff) | |
| download | org.eclipse.sirius-35ab4f28ff8585f9c557141424b15f72ce9345d0.tar.gz org.eclipse.sirius-35ab4f28ff8585f9c557141424b15f72ce9345d0.tar.xz org.eclipse.sirius-35ab4f28ff8585f9c557141424b15f72ce9345d0.zip | |
[428322] Update the test api to handle the dynamic tabbar and luna
Add several methods to check the current platform during
tests. It adds a method to check if the tabbar is expected to be
dynamic.
Change-Id: I3ee4cc78d9cd885bb90fc55981139f4d6b9754b6
Signed-off-by: Maxime PORHEL <maxime.porhel@obeo.fr>
3 files changed, 77 insertions, 31 deletions
diff --git a/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/TestsUtil.java b/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/TestsUtil.java index bc026d54af..4af6f6de2a 100644 --- a/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/TestsUtil.java +++ b/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/TestsUtil.java @@ -13,6 +13,7 @@ package org.eclipse.sirius.tests.support.api; import org.eclipse.core.runtime.Platform; +import org.eclipse.sirius.diagram.tools.internal.editor.tabbar.Tabbar; import org.eclipse.ui.PlatformUI; import org.junit.Assert; import org.osgi.framework.Bundle; @@ -25,6 +26,12 @@ import org.osgi.framework.Version; */ public final class TestsUtil { + private static final String UI_WORKBENCH_JUNO_START = "3.103"; + + private static final String UI_WORKBENCH_KEPLER_START = "3.105"; + + private static final String UI_WORKBENCH_LUNA_START = "3.106"; + /** * Constructor. */ @@ -127,29 +134,66 @@ public final class TestsUtil { if (platformVersion.startsWith("3.8")) { isJuno3Platform = true; } - return isJuno3Platform; + return isJuno3Platform && !isJuno4Platform(); } /** - * Tells if the current platform corresponds to Juno, Kepler, .. (i.e. + * Tells if the current platform corresponds to Juno, Kepler, Luna, .. (i.e. * Eclipse 4.x). * * @return true if the current platform corresponds to eclipse 4.x, false * otherwise. */ public static boolean isEclipse4xPlatform() { + Version junoStart = Version.parseVersion(UI_WORKBENCH_JUNO_START); + return checkUiWorkbenchVersion(junoStart, null); + } + + /** + * Tells if the current platform corresponds to Juno (i.e. Eclipse 4.x). + * + * @return true if the current platform corresponds to Juno 4.x, false + * otherwise. + */ + public static boolean isJuno4Platform() { + Version junoStart = Version.parseVersion(UI_WORKBENCH_JUNO_START); + Version keplerStart = Version.parseVersion(UI_WORKBENCH_KEPLER_START); + return checkUiWorkbenchVersion(junoStart, keplerStart); + } + + private static boolean checkUiWorkbenchVersion(Version versiontStart, Version versionEnd) { /* * Juno/Kepler Core Runtime plugins version are 3.8/3.9 and not 4.x. So * the "org.eclipse.ui.workbench" is used instead. */ - - boolean isEclipse4Platform = false; - Version junoStart = Version.parseVersion("3.103"); Bundle uiWorkbenchBundle = Platform.getBundle("org.eclipse.ui.workbench"); - if (uiWorkbenchBundle != null && uiWorkbenchBundle.getVersion().compareTo(junoStart) >= 0) { - isEclipse4Platform = true; + if (uiWorkbenchBundle != null) { + return uiWorkbenchBundle.getVersion().compareTo(versiontStart) >= 0 && (versionEnd == null || uiWorkbenchBundle.getVersion().compareTo(versionEnd) < 0); } - return isEclipse4Platform; + return false; + } + + /** + * Tells if the current platform corresponds to Kepler. + * + * @return true if the current platform corresponds to Kepler, false + * otherwise. + */ + public static boolean isKeplerPlatform() { + Version keplerStart = Version.parseVersion(UI_WORKBENCH_KEPLER_START); + Version lunaStart = Version.parseVersion(UI_WORKBENCH_LUNA_START); + return checkUiWorkbenchVersion(keplerStart, lunaStart); + } + + /** + * Tells if the current platform corresponds to Luna. + * + * @return true if the current platform corresponds to Luna, false + * otherwise. + */ + public static boolean isLunaPlatform() { + Version keplerStart = Version.parseVersion(UI_WORKBENCH_LUNA_START); + return checkUiWorkbenchVersion(keplerStart, null); } /** @@ -231,4 +275,15 @@ public final class TestsUtil { public static void waitUntil(ICondition condition) { TestsUtil.waitUntil(condition, 5000, 500); } + + /** + * Indicates if the tabbar can be dynamic (ie: is contextual and can receive + * contributions). Some issues were detected on Juno and Kepler. + * + * @See {@link Tabbar#canBeDynamic()} + * @return true if the tabbar is dynamic. + */ + public static boolean isDynamicTabbar() { + return Tabbar.canBeDynamic(); + } } diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/AbstractSiriusSwtBotGefTestCase.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/AbstractSiriusSwtBotGefTestCase.java index 47aee1f502..760f32160e 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/AbstractSiriusSwtBotGefTestCase.java +++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/AbstractSiriusSwtBotGefTestCase.java @@ -390,9 +390,7 @@ public abstract class AbstractSiriusSwtBotGefTestCase extends SWTBotGefTestCase * Request an explicit refresh of the current diagram. */ protected void manualRefresh() { - // TODO delete the specific case of Eclipse 4.x platform once tabbar - // issues will be fixed - if (!TestsUtil.isEclipse4xPlatform()) { + if (TestsUtil.isDynamicTabbar()) { bot.toolbarButtonWithTooltip(DiagramDialectUIServices.REFRESH_DIAGRAM).click(); } else { // Use context menu instead of tabbar @@ -677,9 +675,6 @@ public abstract class AbstractSiriusSwtBotGefTestCase extends SWTBotGefTestCase editor.getCanvas().pressShortcut(SWT.CTRL | SWT.SHIFT, 'd'); SWTBotPreferences.KEYBOARD_LAYOUT = savedKeyboardLayout; SWTBotUtils.waitAllUiEvents(); - - // bot.waitUntil(condition); - // bot.toolbarButtonWithTooltip(DiagramUIActionsMessages.DeleteFromDiagram_ActionToolTipText).click(); } /** @@ -738,12 +733,7 @@ public abstract class AbstractSiriusSwtBotGefTestCase extends SWTBotGefTestCase */ protected void pressZoomInButton(SWTBotDesignerEditor swtBotDesignerEditor, int pressCount) { for (int i = 1; i <= pressCount; i++) { - // TODO remove this work-around once tabbar will contain zoom in - // button - if (TestsUtil.isEclipse4xPlatform()) { - double currentZoom = GraphicalHelper.getZoom((IGraphicalEditPart) ((DiagramRootEditPart) swtBotDesignerEditor.rootEditPart().part()).getContents()); - swtBotDesignerEditor.zoom(ZoomLevel.createNextZoomInLevel(currentZoom)); - } else { + if (TestsUtil.isDynamicTabbar()) { // 2 possible values for this tooltip according to the target // platform // No common constant was found, so we try with both possible @@ -753,6 +743,9 @@ public abstract class AbstractSiriusSwtBotGefTestCase extends SWTBotGefTestCase } catch (WidgetNotFoundException e) { swtBotDesignerEditor.bot().toolbarButtonWithTooltip("Zoom In (Ctrl+=)").click(); } + } else { + double currentZoom = GraphicalHelper.getZoom((IGraphicalEditPart) ((DiagramRootEditPart) swtBotDesignerEditor.rootEditPart().part()).getContents()); + swtBotDesignerEditor.zoom(ZoomLevel.createNextZoomInLevel(currentZoom)); } } } @@ -777,13 +770,11 @@ public abstract class AbstractSiriusSwtBotGefTestCase extends SWTBotGefTestCase */ protected void pressZoomOutButton(SWTBotDesignerEditor swtBotDesignerEditor, int pressCount) { for (int i = 1; i <= pressCount; i++) { - // TODO remove this work-around once tabbar will contain zoom out - // button - if (TestsUtil.isEclipse4xPlatform()) { + if (TestsUtil.isDynamicTabbar()) { + swtBotDesignerEditor.bot().toolbarButtonWithTooltip("Zoom Out (Ctrl+-)").click(); + } else { double currentZoom = GraphicalHelper.getZoom((IGraphicalEditPart) ((DiagramRootEditPart) swtBotDesignerEditor.rootEditPart().part()).getContents()); swtBotDesignerEditor.zoom(ZoomLevel.createNextZoomOutLevel(currentZoom)); - } else { - swtBotDesignerEditor.bot().toolbarButtonWithTooltip("Zoom Out (Ctrl+-)").click(); } } } @@ -1089,9 +1080,9 @@ public abstract class AbstractSiriusSwtBotGefTestCase extends SWTBotGefTestCase if (!"org.eclipse.ui.views.properties.tabbed".equals(status.getPlugin()) && status.getMessage() != null && !status - .getMessage() - .startsWith( - "Contributor org.eclipse.ui.navigator.ProjectExplorer cannot be created., exception: org.eclipse.core.runtime.CoreException: Plug-in \"org.eclipse.ui.navigator.resources\" was unable to instantiate class \"org.eclipse.ui.internal.navigator.resources.workbench.TabbedPropertySheetTitleProvider\".")) { + .getMessage() + .startsWith( + "Contributor org.eclipse.ui.navigator.ProjectExplorer cannot be created., exception: org.eclipse.core.runtime.CoreException: Plug-in \"org.eclipse.ui.navigator.resources\" was unable to instantiate class \"org.eclipse.ui.internal.navigator.resources.workbench.TabbedPropertySheetTitleProvider\".")) { errorOccurs(status, plugin); } } diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotDesignerEditor.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotDesignerEditor.java index 017b85374b..f121ce9685 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotDesignerEditor.java +++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/editor/SWTBotDesignerEditor.java @@ -847,10 +847,10 @@ public class SWTBotDesignerEditor extends SWTBotGefEditor { * if an exception occurs */ public void refresh() throws WidgetNotFoundException { - if (TestsUtil.isEclipse4xPlatform()) { - clickContextMenu("Refresh"); - } else { + if (TestsUtil.isDynamicTabbar()) { bot.toolbarButtonWithTooltip(DiagramDialectUIServices.REFRESH_DIAGRAM).click(); + } else { + clickContextMenu("Refresh"); } } |
