Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-02-08 22:10:18 +0000
committerSteffen Pingel2013-04-12 21:42:46 +0000
commitdf08d9f31a149377edb6b7d96e8d034e8972e98a (patch)
treee568d8a9120ca954458678039d17009969dca742
parent9272712034cda71f10525c6fb0dec3a3be321adb (diff)
downloadorg.eclipse.mylyn.tasks-df08d9f31a149377edb6b7d96e8d034e8972e98a.tar.gz
org.eclipse.mylyn.tasks-df08d9f31a149377edb6b7d96e8d034e8972e98a.tar.xz
org.eclipse.mylyn.tasks-df08d9f31a149377edb6b7d96e8d034e8972e98a.zip
400370: ensure UI extensions are initialized when running UI tests
Change-Id: I390caf2f39d0806829b2678165921f34ec53a028 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400370
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TasksUiUtilTest.java30
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java28
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestUtil.java34
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java4
7 files changed, 51 insertions, 50 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java
index e47f0e6a5..3af709b9a 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java
@@ -33,6 +33,7 @@ import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tests.util.TasksUiTestUtil;
import org.eclipse.ui.PlatformUI;
/**
@@ -54,6 +55,7 @@ public class BugzillaRepositorySettingsPageTest extends TestCase {
repository.setCredentials(AuthenticationType.REPOSITORY,
new AuthenticationCredentials(credentials.getUserName(), credentials.getPassword()), false);
TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ TasksUiTestUtil.ensureTasksUiInitialization();
}
private BugzillaClient createClient(String hostUrl, String username, String password, String htAuthUser,
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
index 0bbb80513..8ad72fad5 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
@@ -29,6 +29,7 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.ui.TaskHyperlink;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tests.util.TasksUiTestUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
@@ -152,6 +153,7 @@ public class BugzillaTaskHyperlinkDetectorTest extends TestCase {
super.setUp();
detector = new TaskHyperlinkDetector();
+ TasksUiTestUtil.ensureTasksUiInitialization();
repository1 = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "repository_url1");
repository2 = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "repository_url2");
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index 058d823c5..cff0ab053 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -32,6 +32,7 @@ Require-Bundle: org.junit,
org.eclipse.mylyn.tests.util
Import-Package: com.sun.syndication.feed.synd;version="0.9.0";resolution:=optional
Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true,
+ org.eclipse.mylyn.tasks.tests.bugs;x-internal:=true,
org.eclipse.mylyn.tasks.tests.connector;x-internal:=true,
org.eclipse.mylyn.tasks.tests.core;x-internal:=true,
org.eclipse.mylyn.tasks.tests.data;x-internal:=true,
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TasksUiUtilTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TasksUiUtilTest.java
index 375a146a9..7c34fa720 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TasksUiUtilTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TasksUiUtilTest.java
@@ -28,6 +28,7 @@ import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tests.util.TasksUiTestUtil;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
@@ -74,6 +75,8 @@ public class TasksUiUtilTest extends TestCase {
activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
assertTrue(activePage.closeAllEditors(false));
assertEquals(0, activePage.getEditorReferences().length);
+
+ TasksUiTestUtil.ensureTasksUiInitialization();
}
@Override
@@ -82,20 +85,19 @@ public class TasksUiUtilTest extends TestCase {
activePage.closeAllEditors(false);
}
- // FIXME re-enable test
-// public void testOpenTaskFromTask() {
-// TasksUiUtil.openTask(cat1task1);
-// assertEquals(1, activePage.getEditorReferences().length);
-// IEditorPart editor = activePage.getEditorReferences()[0].getEditor(true);
-// assertNotNull(editor);
-// assertEquals(TaskEditor.class, editor.getClass());
-//
-// TasksUiUtil.openTask(cat1task2);
-// assertEquals(2, activePage.getEditorReferences().length);
-// editor = activePage.getEditorReferences()[1].getEditor(true);
-// assertNotNull(editor);
-// assertEquals(TaskEditor.class, editor.getClass());
-// }
+ public void testOpenTaskFromTask() {
+ TasksUiUtil.openTask(cat1task1);
+ assertEquals(1, activePage.getEditorReferences().length);
+ IEditorPart editor = activePage.getEditorReferences()[0].getEditor(true);
+ assertNotNull(editor);
+ assertEquals(TaskEditor.class, editor.getClass());
+
+ TasksUiUtil.openTask(cat1task2);
+ assertEquals(2, activePage.getEditorReferences().length);
+ editor = activePage.getEditorReferences()[1].getEditor(true);
+ assertNotNull(editor);
+ assertEquals(TaskEditor.class, editor.getClass());
+ }
public void testOpenTaskFromString() {
if (!PlatformUiUtil.hasInternalBrowser()) {
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java
new file mode 100644
index 000000000..286c037cd
--- /dev/null
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TasksUiTestUtil.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies and others.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tests.util;
+
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TasksUiTestUtil {
+
+ /**
+ * Ensures that connector UI extensions are registered (see bug 400370).
+ */
+ public static void ensureTasksUiInitialization() {
+ TasksUiExtensionReader.initWorkbenchUiExtensions();
+ }
+
+}
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestUtil.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestUtil.java
index 92862d7c7..7e0b8effa 100644
--- a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestUtil.java
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestUtil.java
@@ -144,38 +144,4 @@ public class TestUtil {
return !Boolean.parseBoolean(System.getProperty("org.eclipse.mylyn.tests.all"));
}
-// public static File getFile(String bundleId, Class<?> clazz, String filename) throws IOException {
-// Bundle bundle = Platform.getBundle(bundleId);
-// if (bundle != null) {
-// URL localURL = FileLocator.toFileURL(bundle.getEntry(filename));
-// filename = localURL.getFile();
-// } else {
-// URL localURL = clazz.getResource("");
-// String path = localURL.getFile();
-// int i = path.indexOf("!");
-// if (i != -1) {
-// int j = path.lastIndexOf(File.separatorChar, i);
-// if (j != -1) {
-// path = path.substring(0, j) + File.separator;
-// } else {
-// Assert.fail("Unable to determine location for '" + filename + "' at '" + path + "'");
-// }
-// // class file is nested in jar, use jar path as base
-// if (path.startsWith("file:")) {
-// path = path.substring(5);
-// }
-// } else {
-// // create relative path to base of class file location
-// String[] tokens = clazz.getName().split("\\.");
-// for (int j = 0; j < tokens.length - 1; j++) {
-// path += ".." + File.separator;
-// }
-// if (path.contains("bin" + File.separator)) {
-// path += ".." + File.separator;
-// }
-// }
-// filename = path + filename.replaceAll("/", File.separator);
-// }
-// return new File(filename).getCanonicalFile();
-// }
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
index 701cf2609..61ba37846 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
@@ -20,7 +20,6 @@ import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
@@ -28,6 +27,7 @@ import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage.TracValidator;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tests.util.TasksUiTestUtil;
import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -197,7 +197,7 @@ public class TracRepositorySettingsPageTest extends TestCase {
ITracClient client = connector.getClientManager().getTracClient(repository);
assertEquals(Version.TRAC_0_9, client.getAccessMode());
- TasksUiExtensionReader.initWorkbenchUiExtensions();
+ TasksUiTestUtil.ensureTasksUiInitialization();
EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

Back to the top