Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-04-17 08:59:57 -0400
committerNicolas FAUVERGUE2019-04-23 02:57:15 -0400
commita2c430c8843beba22bb5febb23cff71227c365f5 (patch)
treebc07423b6ecd92096115aee3fd5614d14ffc21e6
parent536266b56303548cbe8bdf7cce994f326393fb91 (diff)
downloadorg.eclipse.papyrus-a2c430c8843beba22bb5febb23cff71227c365f5.tar.gz
org.eclipse.papyrus-a2c430c8843beba22bb5febb23cff71227c365f5.tar.xz
org.eclipse.papyrus-a2c430c8843beba22bb5febb23cff71227c365f5.zip
Bug 546510: [Tests] SashEditor tests should be resolved and pass
Modify the path call of editor input to avoid exceptions of non existing file. Change-Id: I81fe17222186048c047344d4796f2033528ef509 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java139
1 files changed, 85 insertions, 54 deletions
diff --git a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java
index 6f3d734817c..98978a5bfa8 100644
--- a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java
+++ b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeEditorInput.java
@@ -3,6 +3,7 @@ package org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
import org.eclipse.ui.IEditorInput;
@@ -12,28 +13,29 @@ import org.eclipse.ui.part.FileEditorInput;
/**
* A fake {@link IEditorInput} suitable for creating TextEditor.
* This IEditorInput allows to carry the {@link ISashWindowsContentProvider} to the created Editor.
- *
- *
- * @copy Copied from org.eclipse.ui.internal.part.NullEditorInput v3.8
+ *
+ *
+ * @copy Copied from org.eclipse.ui.internal.part.NullEditorInput v3.8
*/
public class FakeEditorInput extends FileEditorInput implements IEditorInput {
protected ISashWindowsContentProvider contentProvider;
-
- static int count =0;
-
+
+ static int count = 0;
+
/**
* Create a temporary file to pass to the texteditor.
+ *
* @return
*/
static IFile createIFile() {
// the name used is no important as nothing is created.
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.papyrus.tests.tmp");
- IFile model1File = p.getFile("tmp/model" + count++ +".txt");
-// System.err.println("file: " + model1File.getName());
+ IFile model1File = p.getFile("tmp/model" + count++ + ".txt");
+ // System.err.println("file: " + model1File.getName());
return model1File;
}
-
+
/**
* Creates a <code>FakeEditorInput</code>.
*/
@@ -44,7 +46,7 @@ public class FakeEditorInput extends FileEditorInput implements IEditorInput {
/**
* Constructor.
* Carry the contentProvider to the created editor.
- *
+ *
* @param contentProvider
*/
public FakeEditorInput(ISashWindowsContentProvider contentProvider) {
@@ -53,7 +55,7 @@ public class FakeEditorInput extends FileEditorInput implements IEditorInput {
}
/**
- *
+ *
* @return
*/
public ISashWindowsContentProvider getContentProvider() {
@@ -61,54 +63,83 @@ public class FakeEditorInput extends FileEditorInput implements IEditorInput {
}
/**
- *
+ *
* @param contentProvider
*/
public void setContentProvider(ISashWindowsContentProvider contentProvider) {
this.contentProvider = contentProvider;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- public boolean exists() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return ImageDescriptor.getMissingImageDescriptor();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getName()
- */
-// public String getName() {
-// String result = null;
-// return ""; //$NON-NLS-1$
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#exists()
+ */
+ @Override
+ public boolean exists() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getName()
+ */
+ // public String getName() {
+ // String result = null;
+ // return ""; //$NON-NLS-1$
+ // }
+
+ /**
+ * We need to implement this method to avoid possible exceptions.
+ * Moreover, we get easier way to get the file path.
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.FileEditorInput#getPath()
+ */
+ @Override
+ public IPath getPath() {
+ return getFile().getFullPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getPersistable()
+ */
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
}

Back to the top