Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2016-02-04 14:37:43 +0000
committerFlorian Barbin2016-03-30 07:36:43 +0000
commitfcbc1898d0a2b7ec77846dd56b0ec4bc86e876dd (patch)
tree079d3b49b96d52469aeba8f62ac3e047cb024fa3
parent3bb46982b60665cf0986361b5ecfb56f5a6688f4 (diff)
downloadorg.eclipse.sirius-fcbc1898d0a2b7ec77846dd56b0ec4bc86e876dd.tar.gz
org.eclipse.sirius-fcbc1898d0a2b7ec77846dd56b0ec4bc86e876dd.tar.xz
org.eclipse.sirius-fcbc1898d0a2b7ec77846dd56b0ec4bc86e876dd.zip
[485837] Adds Junit test
Bug: 485837 Change-Id: I7c4391e69c889387c3b74d1afc21f15f382bf46d Signed-off-by: Florian Barbin <florian.barbin@obeo.fr> Cherry-picked-from: 485832
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html27
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile1
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/ShellChangedCondition.java47
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SecurityExceptionPopupTest.java85
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java1
5 files changed, 149 insertions, 12 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 45e0271ee1..52ea6141a0 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -236,16 +236,16 @@
</li>
<li><span class="label label-info">Added</span> The new internationalizable label
<code>Messages_createRepresentationInputDialog_DefaultRepresentationDescName</code> has been added (available through
- <code>org.eclipse.sirius.ui.tools.api.Messages.createRepresentationInputDialog_DefaultRepresentationDescName</code>. Its value is &#171;Representation&#187;.
+ <code>org.eclipse.sirius.ui.tools.api.Messages.createRepresentationInputDialog_DefaultRepresentationDescName</code>. Its value is &#8220;Representation&#8221;.
</li>
<li><span class="label label-info">Modified</span> The internationalizable label
- <code>Messages_createRepresentationInputDialog_NewRepresentationNameLabel</code> has been replaced by &#171;Name:&#187; (previous value was &#171;Representation name:&#187;).
+ <code>Messages_createRepresentationInputDialog_NewRepresentationNameLabel</code> has been replaced by &#8220;Name:&#8221; (previous value was &#8220;Representation name:&#8221;).
</li>
<li><span class="label label-info">Modified</span> The internationalizable label
- <code>Messages_createRepresentationInputDialog_RepresentationDescriptionLabel</code> has been replaced by &#171;Representation description: {0}&#187; (previous value was &#171;Representation description: &#187;).
+ <code>Messages_createRepresentationInputDialog_RepresentationDescriptionLabel</code> has been replaced by &#8220;Representation description: {0}&#8221; (previous value was &#8220;Representation description: &#8221;).
</li>
<li><span class="label label-info">Modified</span> The internationalizable label
- <code>Messages_createRepresentationInputDialog_Title</code> has been replaced by &#171;New {0}&#187; (previous value was &#171;New Representation&#187;).
+ <code>Messages_createRepresentationInputDialog_Title</code> has been replaced by &#8220;New {0}&#8221; (previous value was &#8220;New Representation&#8221;).
</li>
<li><span class="label label-danger">Removed</span> The class
<code>org.eclipse.sirius.ui.business.api.editor.SpecificSessionManager</code> has been removed.
@@ -320,6 +320,17 @@
<code>SWTBotTreeItem</code> in a
<code>SWTBotTreeItem</code> array.
</li>
+ <li><span class="label label-success">Added</span> The class
+ <code>org.eclipse.sirius.tests.swtbot.support.api.condition.ShellChangedCondition</code> has been added to wait until the current active shell has changed.
+ </li>
+ <li><span class="label label-info">Modified</span> A second
+ <code>String</code> parameter has been added to the method
+ <code>org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession.newDiagramRepresentation(String, String)</code>. This parameter is the label of the representation description. It is necessary since the change of the wizard to ask the new representation name (see User-Visible Changes for detail).
+ </li>
+ <li><span class="label label-info">Modified</span> A third
+ <code>String</code> parameter has been added to the constructor of
+ <code>org.eclipse.sirius.tests.swtbot.support.api.business.UINewRepresentationBuilder</code> for the same above reasons.
+ </li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.common.xtext">Changes in
<code>org.eclipse.sirius.common.xtext</code>
@@ -330,14 +341,6 @@
<code>org.eclipse.jdt.core</code> is now optional. If you need the JDT Core in your environment, you will need to add the dependency explicitly. The Sirius specification environment (
<code>org.eclipse.sirius.editor</code>) still depends on PDE (and thus indirectly the JDT too).
</li>
- <li><span class="label label-info">Modified</span> A second
- <code>String</code> parameter has been added to the method
- <code>org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession.newDiagramRepresentation(String, String)</code>. This parameter is the label of the representation description. It is necessary since the change of the wizard to ask the new representation name (see User-Visible Changes for detail).
- </li>
- <li><span class="label label-info">Modified</span> A third
- <code>String</code> parameter has been added to the constructor of
- <code>org.eclipse.sirius.tests.swtbot.support.api.business.UINewRepresentationBuilder</code> for the same above reasons.
- </li>
</ul>
<h2 id="sirius3.1.1">Changes in Sirius 3.1.1</h2>
<h3 id="SpecifierVisibleChanges2">Specifier-Visible Changes</h3>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 7a039954b1..471dfca9b9 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -92,6 +92,7 @@ h4. Changes in @org.eclipse.sirius.ui@
h4. Changes in @org.eclipse.sirius.tests.swtbot.support@
* <span class="label label-success">Added</span> The method @getTreeItem(final SWTBotTreeItem[], final String)@ has been added in @org.eclipse.sirius.tests.swtbot.support.utils@ to retrieve recursively a @SWTBotTreeItem@ in a @SWTBotTreeItem@ array.
+* <span class="label label-success">Added</span> The class @org.eclipse.sirius.tests.swtbot.support.api.condition.ShellChangedCondition@ has been added to wait until the current active shell has changed.
* <span class="label label-info">Modified</span> A second @String@ parameter has been added to the method @org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession.newDiagramRepresentation(String, String)@. This parameter is the label of the representation description. It is necessary since the change of the wizard to ask the new representation name (see User-Visible Changes for detail).
* <span class="label label-info">Modified</span> A third @String@ parameter has been added to the constructor of @org.eclipse.sirius.tests.swtbot.support.api.business.UINewRepresentationBuilder@ for the same above reasons.
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/ShellChangedCondition.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/ShellChangedCondition.java
new file mode 100644
index 0000000000..5fe6e0b41d
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/ShellChangedCondition.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.swtbot.support.api.condition;
+
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+
+/**
+ * An {@link org.eclipse.swtbot.swt.finder.waits.ICondition} only to be used to
+ * deal with unnamed shells. Tests that the active shell is different from the
+ * one given in parameter.
+ *
+ * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
+ */
+public class ShellChangedCondition extends DefaultCondition {
+
+ private SWTBotShell oldShell;
+
+ /**
+ * Tests that the active shell is different from the one given in parameter.
+ *
+ * @param oldShell
+ * the old shell that should change
+ */
+ public ShellChangedCondition(SWTBotShell oldShell) {
+ this.oldShell = oldShell;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ return oldShell.widget != bot.activeShell().widget;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Shell did not activate";
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SecurityExceptionPopupTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SecurityExceptionPopupTest.java
new file mode 100644
index 0000000000..882f892a2e
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SecurityExceptionPopupTest.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.swtbot;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.sirius.tests.SiriusTestsPlugin;
+import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.ShellChangedCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
+
+/**
+ * This test checks that the securityException opens a popup only in the case of
+ * a nonempty message.
+ *
+ * @author Florian Barbin
+ *
+ */
+public class SecurityExceptionPopupTest extends AbstractSiriusSwtBotGefTestCase {
+
+ /**
+ * Logs a SecurityException with a message and makes sure the pop-up is
+ * opened.
+ */
+ public void testSecurityExceptionWithMessage() {
+ launchExceptionAndCheck(true);
+ }
+
+ /**
+ * Logs a SecurityException without message and checks that no pop-up is
+ * opened.
+ */
+ public void testSecurityExceptionWithoutMessage() {
+ launchExceptionAndCheck(false);
+ }
+
+ private void launchExceptionAndCheck(final boolean withMessage) {
+
+ // Step 1 - Log a security exception.
+ SecurityException exception = null;
+ if (withMessage) {
+ exception = new SecurityException("test");
+ } else {
+ exception = new SecurityException();
+ }
+ ShellChangedCondition shellChangedCondition = new ShellChangedCondition(bot.activeShell());
+ SiriusTestsPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, SiriusTestsPlugin.PLUGIN_ID, "exception occurs", exception));
+
+ // Step 2 - Check whether the dialog is opened
+ // or not (if there is no message in the exception, the dialog
+ // should not be opened).
+
+ SWTBotShell shell = null;
+ try {
+ bot.waitUntil(shellChangedCondition);
+ shell = bot.activeShell();
+ assertEquals("Permission Issue", shell.getText());
+ } catch (TimeoutException e) {
+ // We throw the exception only in the case where the
+ // dialog is expected (a SecurityException with a
+ // message).
+ if (withMessage) {
+ throw e;
+ }
+ }
+ errors.clear();
+ if (shell != null) {
+ shell.close();
+ // If the exception was logged without message, we
+ // shouldn't have found a shell.
+ if (!withMessage) {
+ fail("There should not be a dialog with empty message");
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
index 8ab9229eb2..0e279ddb71 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
@@ -201,6 +201,7 @@ public class AllTestSuite extends TestCase {
suite.addTestSuite(MoveEdgeGroupTest.class);
suite.addTestSuite(TabbarContributorExtensionTest.class);
suite.addTestSuite(BorderNodeSideTest.class);
+ suite.addTestSuite(SecurityExceptionPopupTest.class);
}
/**

Back to the top