TMF: Moved the ProjectModelTestData in o.e.l.tmf.ui.tests to a shared folder
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 18 Dec 2013 20:45:02 +0000 (15:45 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 19 Dec 2013 03:13:53 +0000 (22:13 -0500)
This test project can be used by tests from other ui plugins

Change-Id: Ida725bc10c9785c9d269995784d43551559f6353
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/20013
Tested-by: Hudson CI
org.eclipse.linuxtools.tmf.ui.tests/.classpath
org.eclipse.linuxtools.tmf.ui.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.ui.tests/build.properties
org.eclipse.linuxtools.tmf.ui.tests/shared/org/eclipse/linuxtools/tmf/ui/tests/shared/ProjectModelTestData.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelAnalysisTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelOutputTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java [deleted file]
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTraceTest.java

index 403a3962e1a88c6c90b53f3313d26d7820139a24..a40553cdbf274e4675aacd4b4679cb4f7d0f4a6b 100644 (file)
@@ -4,5 +4,6 @@
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="widgetStubs"/>
+       <classpathentry kind="src" path="shared"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 0578a002bf1484bb6674c78ffb13c3c9ee95e704..1542beafbcb47e6f2c8b54a0a9f02cf44d1d1b48 100644 (file)
@@ -14,5 +14,6 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
  org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0",
  org.eclipse.linuxtools.tmf.core.tests;bundle-version="3.0.0"
-Export-Package: org.eclipse.linuxtools.tmf.ui.tests
+Export-Package: org.eclipse.linuxtools.tmf.ui.tests,
+ org.eclipse.linuxtools.tmf.ui.tests.shared
 Bundle-Activator: org.eclipse.linuxtools.tmf.ui.tests.TmfUITestPlugin
index 96998eb45411db7284d9ece03797cc3cda783788..3cf0253cb19efb258ebd10a54480572369edb8e6 100644 (file)
@@ -11,7 +11,8 @@
 ###############################################################################
 
 source.. = src/,\
-           widgetStubs/
+           widgetStubs/,\
+           shared/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
diff --git a/org.eclipse.linuxtools.tmf.ui.tests/shared/org/eclipse/linuxtools/tmf/ui/tests/shared/ProjectModelTestData.java b/org.eclipse.linuxtools.tmf.ui.tests/shared/org/eclipse/linuxtools/tmf/ui/tests/shared/ProjectModelTestData.java
new file mode 100644 (file)
index 0000000..cf2afdc
--- /dev/null
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.tests.shared;
+
+import static org.junit.Assume.assumeTrue;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfImportHelper;
+import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Creates objects used for this package's testing purposes
+ *
+ * @author Geneviève Bastien
+ */
+public class ProjectModelTestData {
+
+    /** Default test project name */
+    public static final String PROJECT_NAME = "Test_Project";
+
+    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
+
+    /**
+     * Gets a project element with traces all initialized
+     *
+     * @return A project stub element
+     * @throws CoreException
+     *             If something happened with the project creation
+     */
+    public static TmfProjectElement getFilledProject() throws CoreException {
+
+        assumeTrue(CtfTmfTestTrace.KERNEL.exists());
+
+        IProject project = TmfProjectRegistry.createProject(PROJECT_NAME, null, null);
+        IFolder traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
+
+        /* Create a trace, if it exist, it will be replaced */
+        File file = new File(testTrace.getPath());
+        String path = file.getAbsolutePath();
+        final IPath pathString = Path.fromOSString(path);
+        IResource linkedTrace = TmfImportHelper.createLink(traceFolder, pathString, pathString.lastSegment());
+        if (!(linkedTrace != null && linkedTrace.exists())) {
+            return null;
+        }
+        linkedTrace.setPersistentProperty(TmfCommonConstants.TRACETYPE,
+                "org.eclipse.linuxtools.tmf.tests.ctf.tracetype");
+
+        final TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
+        TmfTraceElement traceElement = projectElement.getTracesFolder().getTraces().get(0);
+        traceElement.refreshTraceType();
+
+        return projectElement;
+    }
+
+    /**
+     * Get the name of the test trace element
+     *
+     * @return The trace name
+     */
+    public static String getTraceName() {
+        File file = new File(testTrace.getPath());
+        String path = file.getAbsolutePath();
+        final IPath pathString = Path.fromOSString(path);
+        return pathString.lastSegment();
+    }
+
+    /**
+     * Deletes a project
+     *
+     * @param project
+     *            Project to delete
+     */
+    public static void deleteProject(TmfProjectElement project) {
+        /* Delete experiments */
+        for (ITmfProjectModelElement element : project.getExperimentsFolder().getChildren()) {
+            if (element instanceof TmfExperimentElement) {
+                TmfExperimentElement experiment = (TmfExperimentElement) element;
+                IResource resource = experiment.getResource();
+
+                /* Close the experiment if open */
+                experiment.closeEditors();
+
+                IPath path = resource.getLocation();
+                if (path != null) {
+                    /* Delete supplementary files */
+                    experiment.deleteSupplementaryFolder();
+                }
+
+                /* Finally, delete the experiment */
+                try {
+                    resource.delete(true, null);
+                } catch (CoreException e) {
+                    Activator.getDefault().logError("Error deleting experiment element", e);
+                }
+            }
+        }
+
+        /* Delete traces */
+        for (ITmfProjectModelElement element : project.getTracesFolder().getChildren()) {
+            if (element instanceof TmfTraceElement) {
+                TmfTraceElement trace = (TmfTraceElement) element;
+                IResource resource = trace.getResource();
+
+                /* Close the trace if open */
+                trace.closeEditors();
+
+                IPath path = resource.getLocation();
+                if (path != null) {
+                    /* Delete supplementary files */
+                    trace.deleteSupplementaryFolder();
+                }
+
+                /* Finally, delete the trace */
+                try {
+                    resource.delete(true, new NullProgressMonitor());
+                } catch (CoreException e) {
+                    Activator.getDefault().logError("Error deleting trace element", e);
+                }
+            }
+        }
+
+        /* Delete the project itself */
+        try {
+            project.getResource().delete(true, null);
+        } catch (CoreException e) {
+            Activator.getDefault().logError("Error deleting project", e);
+        }
+    }
+
+    /**
+     * Makes the main display thread sleep, so it gives a chance to other
+     * threads needing the main display to execute
+     *
+     * @param waitTimeMillis
+     *            time to wait in millisecond
+     */
+    public static void delayThread(final long waitTimeMillis) {
+        final Display display = Display.getCurrent();
+        if (display != null) {
+            final long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+            while (System.currentTimeMillis() < endTimeMillis) {
+                if (!display.readAndDispatch()) {
+                    display.sleep();
+                }
+                display.update();
+            }
+        } else {
+            try {
+                Thread.sleep(waitTimeMillis);
+            } catch (final InterruptedException e) {
+                // Ignored
+            }
+        }
+    }
+
+}
index d0dd7c4ed9d92869a4cec44765f6deb94766250a..87125ddc37e5106875f74bfe289e0645613cadcd 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.linuxtools.tmf.ui.project.model.TmfAnalysisElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.tests.shared.ProjectModelTestData;
 import org.eclipse.linuxtools.tmf.ui.tests.stubs.analysis.TestAnalysisUi;
 import org.junit.After;
 import org.junit.Before;
index 52a5cf6cf68ac740bf4ebbc2f3617cd7cc2f318a..e6d2f6360b1f3913780d969dd2ee2a86153d062b 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.linuxtools.tmf.ui.project.model.TmfAnalysisElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfAnalysisOutputElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.tests.shared.ProjectModelTestData;
 import org.eclipse.linuxtools.tmf.ui.tests.stubs.analysis.TestAnalysisUi;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbench;
diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java
deleted file mode 100644 (file)
index 05619b9..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
- *
- * 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:
- *   Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.tests.project.model;
-
-import static org.junit.Assume.assumeTrue;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;
-import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfImportHelper;
-import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
-import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
-import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Creates objects used for this package's testing purposes
- *
- * @author Geneviève Bastien
- */
-public class ProjectModelTestData {
-
-    /** Default test project name */
-    public static final String PROJECT_NAME = "Test_Project";
-
-    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
-
-    /**
-     * Gets a project element with traces all initialized
-     *
-     * @return A project stub element
-     * @throws CoreException
-     *             If something happened with the project creation
-     */
-    public static TmfProjectElement getFilledProject() throws CoreException {
-
-        assumeTrue(CtfTmfTestTrace.KERNEL.exists());
-
-        IProject project = TmfProjectRegistry.createProject(PROJECT_NAME, null, null);
-        IFolder traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
-
-        /* Create a trace, if it exist, it will be replaced */
-        File file = new File(testTrace.getPath());
-        String path = file.getAbsolutePath();
-        final IPath pathString = Path.fromOSString(path);
-        IResource linkedTrace = TmfImportHelper.createLink(traceFolder, pathString, pathString.lastSegment());
-        if (!(linkedTrace != null && linkedTrace.exists())) {
-            return null;
-        }
-        linkedTrace.setPersistentProperty(TmfCommonConstants.TRACETYPE,
-                "org.eclipse.linuxtools.tmf.tests.ctf.tracetype");
-
-        final TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
-        TmfTraceElement traceElement = projectElement.getTracesFolder().getTraces().get(0);
-        traceElement.refreshTraceType();
-
-        return projectElement;
-    }
-
-    /**
-     * Get the name of the test trace element
-     *
-     * @return The trace name
-     */
-    public static String getTraceName() {
-        File file = new File(testTrace.getPath());
-        String path = file.getAbsolutePath();
-        final IPath pathString = Path.fromOSString(path);
-        return pathString.lastSegment();
-    }
-
-    /**
-     * Deletes a project
-     *
-     * @param project
-     *            Project to delete
-     */
-    public static void deleteProject(TmfProjectElement project) {
-        /* Delete experiments */
-        for (ITmfProjectModelElement element : project.getExperimentsFolder().getChildren()) {
-            if (element instanceof TmfExperimentElement) {
-                TmfExperimentElement experiment = (TmfExperimentElement) element;
-                IResource resource = experiment.getResource();
-
-                /* Close the experiment if open */
-                experiment.closeEditors();
-
-                IPath path = resource.getLocation();
-                if (path != null) {
-                    /* Delete supplementary files */
-                    experiment.deleteSupplementaryFolder();
-                }
-
-                /* Finally, delete the experiment */
-                try {
-                    resource.delete(true, null);
-                } catch (CoreException e) {
-                    Activator.getDefault().logError("Error deleting experiment element", e);
-                }
-            }
-        }
-
-        /* Delete traces */
-        for (ITmfProjectModelElement element : project.getTracesFolder().getChildren()) {
-            if (element instanceof TmfTraceElement) {
-                TmfTraceElement trace = (TmfTraceElement) element;
-                IResource resource = trace.getResource();
-
-                /* Close the trace if open */
-                trace.closeEditors();
-
-                IPath path = resource.getLocation();
-                if (path != null) {
-                    /* Delete supplementary files */
-                    trace.deleteSupplementaryFolder();
-                }
-
-                /* Finally, delete the trace */
-                try {
-                    resource.delete(true, new NullProgressMonitor());
-                } catch (CoreException e) {
-                    Activator.getDefault().logError("Error deleting trace element", e);
-                }
-            }
-        }
-
-        /* Delete the project itself */
-        try {
-            project.getResource().delete(true, null);
-        } catch (CoreException e) {
-            Activator.getDefault().logError("Error deleting project", e);
-        }
-    }
-
-    /**
-     * Makes the main display thread sleep, so it gives a chance to other thread
-     * needing the main display to execute
-     *
-     * @param waitTimeMillis
-     *            time to wait in millisecond
-     */
-    public static void delayThread(final long waitTimeMillis) {
-        final Display display = Display.getCurrent();
-        if (display != null) {
-            final long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
-            while (System.currentTimeMillis() < endTimeMillis) {
-                if (!display.readAndDispatch()) {
-                    display.sleep();
-                }
-                display.update();
-            }
-        } else {
-            try {
-                Thread.sleep(waitTimeMillis);
-            } catch (final InterruptedException e) {
-                // Ignored
-            }
-        }
-    }
-
-}
index ff3ed43b54a3b87ac8b79538d97bf4c184d42e1c..f125bf1ed1b7ad0ea47ea60897251b32fdab8bf8 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfOpenTraceHelper;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.tests.shared.ProjectModelTestData;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
This page took 0.033355 seconds and 5 git commands to generate.