Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2010-06-18 21:20:17 +0000
committerMatthias Sohn2010-06-18 21:38:00 +0000
commitc3913dc05355986ab5ec44bc12f1180286bcfd38 (patch)
tree4d938f420e1d6403c9237dddcf76adec5613b4b8 /org.eclipse.egit.ui.test
parent4fec29460f0cd3d3a507fc5118815d991afd44cb (diff)
downloadegit-c3913dc05355986ab5ec44bc12f1180286bcfd38.tar.gz
egit-c3913dc05355986ab5ec44bc12f1180286bcfd38.tar.xz
egit-c3913dc05355986ab5ec44bc12f1180286bcfd38.zip
Fix line endings
Some sources had dos line endings. Also configure all projects to use unix line endings and UTF-8 encoding. Change-Id: I119cad245f0f5ecd20ee1450877cb7e1a5d63783 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--org.eclipse.egit.ui.test/.settings/org.eclipse.core.runtime.prefs3
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java46
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java202
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java486
5 files changed, 373 insertions, 367 deletions
diff --git a/org.eclipse.egit.ui.test/.settings/org.eclipse.core.resources.prefs b/org.eclipse.egit.ui.test/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000..acf43fe4a0
--- /dev/null
+++ b/org.eclipse.egit.ui.test/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Fri Jun 18 23:34:07 CEST 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.egit.ui.test/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.egit.ui.test/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 0000000000..7fc9adbd19
--- /dev/null
+++ b/org.eclipse.egit.ui.test/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,3 @@
+#Fri Jun 18 23:34:07 CEST 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java
index 7b01331133..8f8cb0fc2d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/AllTests.java
@@ -1,23 +1,23 @@
-/*******************************************************************************
- * Copyright (C) 2010, Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
- *
- * 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
- *******************************************************************************/
-package org.eclipse.egit.ui.test;
-
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTest;
-import org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest;
-import org.eclipse.egit.ui.wizards.share.SharingWizardTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses( { GitCloneWizardTest.class, SharingWizardTest.class,
- GitRepositoriesViewTest.class })
-public class AllTests {
- // empty class, don't need anything here
-}
+/*******************************************************************************
+ * Copyright (C) 2010, Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.test;
+
+import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTest;
+import org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest;
+import org.eclipse.egit.ui.wizards.share.SharingWizardTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses( { GitCloneWizardTest.class, SharingWizardTest.class,
+ GitRepositoriesViewTest.class })
+public class AllTests {
+ // empty class, don't need anything here
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index 1c0b6d6d84..366be1a778 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -1,101 +1,101 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
- * 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:
- * Mathias Kinzler (SAP AG) - initial implementation
- *******************************************************************************/
-package org.eclipse.egit.ui.test;
-
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.osgi.service.localization.BundleLocalization;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Utilities to be used by SWTBot tests
- */
-public class TestUtil {
-
- private static final char AMPERSAND = '&';
-
- private static final TestUtil INSTANCE = new TestUtil();
-
- public static TestUtil getInstance() {
- return INSTANCE;
- }
-
- private ResourceBundle myBundle;
-
- /**
- * Allows access to the localized values of the EGit UI Plug-in
- * <p>
- * This will effectively read the plugin.properties. Ampersands (often used
- * in menu items and field labels for keyboard shortcuts) will be filtered
- * out (see also {@link #getPluginLocalizedValue(String, boolean)} in order
- * to be able to reference these fields using SWTBot).
- *
- * @param key
- * the key, must not be null
- * @return the localized value in the current default {@link Locale}, or
- * null
- * @throws MissingResourceException
- * if no value is found for the given key
- */
- public synchronized String getPluginLocalizedValue(String key)
- throws MissingResourceException {
- return getPluginLocalizedValue(key, false);
- }
-
- /**
- * Allows access to the localized values of the EGit UI Plug-in
- * <p>
- *
- * @param key
- * see {@link #getPluginLocalizedValue(String)}
- * @param keepAmpersands
- * if <code>true</code>, ampersands will be kept
- * @return see {@link #getPluginLocalizedValue(String)}
- * @throws MissingResourceException
- * see {@link #getPluginLocalizedValue(String)}
- */
- public synchronized String getPluginLocalizedValue(String key,
- boolean keepAmpersands) throws MissingResourceException {
- if (myBundle == null) {
- ServiceTracker localizationTracker;
-
- BundleContext context = Activator.getDefault().getBundle()
- .getBundleContext();
-
- localizationTracker = new ServiceTracker(context,
- BundleLocalization.class.getName(), null);
- localizationTracker.open();
-
- BundleLocalization location = (BundleLocalization) localizationTracker
- .getService();
- if (location != null)
- myBundle = location.getLocalization(Activator.getDefault()
- .getBundle(), Locale.getDefault().toString());
- }
-
- String raw = myBundle.getString(key);
-
- if (keepAmpersands || raw.indexOf(AMPERSAND) < 0)
- return raw;
-
- StringBuilder sb = new StringBuilder(raw.length());
- for (int i = 0; i < raw.length(); i++) {
- char c = raw.charAt(i);
- if (c != AMPERSAND)
- sb.append(c);
- }
- return sb.toString();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * 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:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.test;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.osgi.service.localization.BundleLocalization;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Utilities to be used by SWTBot tests
+ */
+public class TestUtil {
+
+ private static final char AMPERSAND = '&';
+
+ private static final TestUtil INSTANCE = new TestUtil();
+
+ public static TestUtil getInstance() {
+ return INSTANCE;
+ }
+
+ private ResourceBundle myBundle;
+
+ /**
+ * Allows access to the localized values of the EGit UI Plug-in
+ * <p>
+ * This will effectively read the plugin.properties. Ampersands (often used
+ * in menu items and field labels for keyboard shortcuts) will be filtered
+ * out (see also {@link #getPluginLocalizedValue(String, boolean)} in order
+ * to be able to reference these fields using SWTBot).
+ *
+ * @param key
+ * the key, must not be null
+ * @return the localized value in the current default {@link Locale}, or
+ * null
+ * @throws MissingResourceException
+ * if no value is found for the given key
+ */
+ public synchronized String getPluginLocalizedValue(String key)
+ throws MissingResourceException {
+ return getPluginLocalizedValue(key, false);
+ }
+
+ /**
+ * Allows access to the localized values of the EGit UI Plug-in
+ * <p>
+ *
+ * @param key
+ * see {@link #getPluginLocalizedValue(String)}
+ * @param keepAmpersands
+ * if <code>true</code>, ampersands will be kept
+ * @return see {@link #getPluginLocalizedValue(String)}
+ * @throws MissingResourceException
+ * see {@link #getPluginLocalizedValue(String)}
+ */
+ public synchronized String getPluginLocalizedValue(String key,
+ boolean keepAmpersands) throws MissingResourceException {
+ if (myBundle == null) {
+ ServiceTracker localizationTracker;
+
+ BundleContext context = Activator.getDefault().getBundle()
+ .getBundleContext();
+
+ localizationTracker = new ServiceTracker(context,
+ BundleLocalization.class.getName(), null);
+ localizationTracker.open();
+
+ BundleLocalization location = (BundleLocalization) localizationTracker
+ .getService();
+ if (location != null)
+ myBundle = location.getLocalization(Activator.getDefault()
+ .getBundle(), Locale.getDefault().toString());
+ }
+
+ String raw = myBundle.getString(key);
+
+ if (keepAmpersands || raw.indexOf(AMPERSAND) < 0)
+ return raw;
+
+ StringBuilder sb = new StringBuilder(raw.length());
+ for (int i = 0; i < raw.length(); i++) {
+ char c = raw.charAt(i);
+ if (c != AMPERSAND)
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index 5523369801..904ca44e4b 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -1,243 +1,243 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
- * 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:
- * Mathias Kinzler (SAP AG) - initial implementation
- *******************************************************************************/
-package org.eclipse.egit.ui.view.repositories;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.egit.core.op.ConnectProviderOperation;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.egit.ui.test.ContextMenuHelper;
-import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.RepositoryCache.FileKey;
-import org.eclipse.jgit.util.FS;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.TableCollection;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * SWTBot Tests for the Git Repositories View
- */
-@RunWith(SWTBotJunit4ClassRunner.class)
-public class GitRepositoriesViewTest {
-
- private static final String PRJ_NAME = "ImportProjectsTest";
-
- private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
-
- private SWTBotView viewbot;
-
- private static IProject myProject;
-
- private final static TestUtil myUtil = TestUtil.getInstance();
-
- private static String viewName;
-
- private static String gitCategory;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- // the show in context menu does not appear in the project explorer for
- // general projects
- bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();
- GitCloneWizardTest.closeWelcomePage();
- myProject = ResourcesPlugin.getWorkspace().getRoot().getProject(
- PRJ_NAME);
- if (myProject.exists())
- myProject.delete(true, null);
- myProject.create(null);
- myProject.open(null);
-
- IFolder folder = myProject.getFolder("folder");
- folder.create(false, true, null);
- folder.getFile("test.txt").create(
- new ByteArrayInputStream("Hello, world".getBytes("UTF-8")),
- false, null);
-
- File dirFile = myProject.getLocation().append(".git").toFile();
- Repository repo = new Repository(dirFile);
- repo.create();
-
- new ConnectProviderOperation(myProject, dirFile).execute(null);
- Activator.getDefault().getRepositoryUtil().addConfiguredRepository(
- dirFile);
-
- viewName = myUtil.getPluginLocalizedValue("GitRepositoriesView_name");
- gitCategory = myUtil.getPluginLocalizedValue("GitCategory_name");
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- myProject.delete(true, null);
- }
-
- @Test
- public void testOpenView() throws Exception {
- getOrOpenView();
- }
-
- @Test
- @Ignore
- // TODO currently, this does not work if a refresh is currently running ->
- // fix RepositoriesView
- public void testShowIn() throws Exception {
- SWTBotTree tree = bot.viewById("org.eclipse.jdt.ui.PackageExplorer")
- .bot().tree();
- tree.getAllItems()[0].select();
- ContextMenuHelper.clickContextMenu(tree, "Show In", viewName);
-
- SWTBotTree viewerTree = getOrOpenView().bot().tree();
-
- TableCollection selection = viewerTree.selection();
- assertTrue("Selection should contain one eelement", selection
- .rowCount() == 1);
- String nodeText = selection.get(0).get(0);
- assertTrue("Node text should contain project name", nodeText
- .contains(myProject.getName()));
-
- tree.select(tree.getAllItems()[0].expand().getNode("folder").expand()
- .getNode("test.txt"));
-
- ContextMenuHelper.clickContextMenu(tree, "Show In", viewName);
-
- selection = viewerTree.selection();
- assertTrue("Selection should contain one eelement", selection
- .rowCount() == 1);
- nodeText = selection.get(0).get(0);
- assertTrue("Node text should contain file name", nodeText
- .contains("test.txt"));
- }
-
- @Test
- @Ignore
- // TODO this consistently fails with a "Widget disposed" SWT Exception
- // if run in the AllTests test suite, but consistently works
- // if this test class is run alone -> investigate
- public void testOpenFirstLevel() throws Exception {
- final SWTBotView view = getOrOpenView();
- final SWTBotTreeItem[] items = view.bot().tree().getAllItems();
- items[0].expand();
- SWTBotTreeItem[] children;
-
- children = items[0].getItems();
- assertEquals("Wrong number of children", 5, children.length);
- }
-
- @Test
- public void testHasRepo() throws Exception {
- final SWTBotView view = getOrOpenView();
- final SWTBotTreeItem[] items = view.bot().tree().getAllItems();
- boolean found = false;
- for (SWTBotTreeItem item : items) {
- if (item.getText().startsWith(PRJ_NAME)) {
- found = true;
- break;
- }
- }
- assertTrue("Tree should have item with correct text", found);
- }
-
- @Test
- public void testCopyPathToClipboard() throws Exception {
- final SWTBotView view = getOrOpenView();
- final SWTBotTreeItem[] items = view.bot().tree().getAllItems();
- items[0].select();
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- Clipboard clp = new Clipboard(Display.getCurrent());
- clp.clearContents();
- clp.setContents(new Object[] { "x" },
- new TextTransfer[] { TextTransfer.getInstance() });
- String value = (String) clp.getContents(TextTransfer
- .getInstance());
- assertEquals("Clipboard content should be x", "x", value);
-
- ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil
- .getPluginLocalizedValue("CopyPathCommand"));
-
- value = (String) clp.getContents(TextTransfer.getInstance());
- assertTrue("Clipboard content should be a repository path",
- FileKey.isGitRepository(new File(value), FS.DETECTED));
-
- clp.dispose();
- }
- });
-
- }
-
- @Test
- public void testAddRepoButton() throws Exception {
- getOrOpenView().toolbarButton(
- myUtil.getPluginLocalizedValue("AddRepositoryCommand")).click();
- SWTBotShell shell = bot.shell(
- UIText.RepositorySearchDialog_AddGitRepositories).activate();
- shell.close();
- }
-
- @Test
- public void testCloneRepoButton() throws Exception {
- getOrOpenView().toolbarButton(
- myUtil.getPluginLocalizedValue("CloneRepositoryCommand"))
- .click();
- SWTBotShell shell = bot.shell(UIText.GitCloneWizard_title).activate();
- shell.close();
- }
-
- private SWTBotView getOrOpenView() throws Exception {
- if (viewbot == null) {
- bot.menu("Window").menu("Show View").menu("Other...").click();
- SWTBotShell shell = bot.shell("Show View").activate();
- shell.bot().tree().expandNode(gitCategory).getNode(viewName)
- .select();
- shell.bot().button(0).click();
-
- viewbot = bot.viewByTitle(viewName);
-
- assertNotNull("Repositories View should not be null", viewbot);
- }
- return viewbot;
- }
-
- @Test
- @Ignore
- public void testLinkWithSelection() throws Exception {
- // TODO implement
- }
-
- @Test
- @Ignore
- public void testCollapseAll() throws Exception {
- // TODO implement
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * 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:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.view.repositories;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.core.op.ConnectProviderOperation;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryCache.FileKey;
+import org.eclipse.jgit.util.FS;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.utils.TableCollection;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * SWTBot Tests for the Git Repositories View
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class GitRepositoriesViewTest {
+
+ private static final String PRJ_NAME = "ImportProjectsTest";
+
+ private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ private SWTBotView viewbot;
+
+ private static IProject myProject;
+
+ private final static TestUtil myUtil = TestUtil.getInstance();
+
+ private static String viewName;
+
+ private static String gitCategory;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ // the show in context menu does not appear in the project explorer for
+ // general projects
+ bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();
+ GitCloneWizardTest.closeWelcomePage();
+ myProject = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PRJ_NAME);
+ if (myProject.exists())
+ myProject.delete(true, null);
+ myProject.create(null);
+ myProject.open(null);
+
+ IFolder folder = myProject.getFolder("folder");
+ folder.create(false, true, null);
+ folder.getFile("test.txt").create(
+ new ByteArrayInputStream("Hello, world".getBytes("UTF-8")),
+ false, null);
+
+ File dirFile = myProject.getLocation().append(".git").toFile();
+ Repository repo = new Repository(dirFile);
+ repo.create();
+
+ new ConnectProviderOperation(myProject, dirFile).execute(null);
+ Activator.getDefault().getRepositoryUtil().addConfiguredRepository(
+ dirFile);
+
+ viewName = myUtil.getPluginLocalizedValue("GitRepositoriesView_name");
+ gitCategory = myUtil.getPluginLocalizedValue("GitCategory_name");
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ myProject.delete(true, null);
+ }
+
+ @Test
+ public void testOpenView() throws Exception {
+ getOrOpenView();
+ }
+
+ @Test
+ @Ignore
+ // TODO currently, this does not work if a refresh is currently running ->
+ // fix RepositoriesView
+ public void testShowIn() throws Exception {
+ SWTBotTree tree = bot.viewById("org.eclipse.jdt.ui.PackageExplorer")
+ .bot().tree();
+ tree.getAllItems()[0].select();
+ ContextMenuHelper.clickContextMenu(tree, "Show In", viewName);
+
+ SWTBotTree viewerTree = getOrOpenView().bot().tree();
+
+ TableCollection selection = viewerTree.selection();
+ assertTrue("Selection should contain one eelement", selection
+ .rowCount() == 1);
+ String nodeText = selection.get(0).get(0);
+ assertTrue("Node text should contain project name", nodeText
+ .contains(myProject.getName()));
+
+ tree.select(tree.getAllItems()[0].expand().getNode("folder").expand()
+ .getNode("test.txt"));
+
+ ContextMenuHelper.clickContextMenu(tree, "Show In", viewName);
+
+ selection = viewerTree.selection();
+ assertTrue("Selection should contain one eelement", selection
+ .rowCount() == 1);
+ nodeText = selection.get(0).get(0);
+ assertTrue("Node text should contain file name", nodeText
+ .contains("test.txt"));
+ }
+
+ @Test
+ @Ignore
+ // TODO this consistently fails with a "Widget disposed" SWT Exception
+ // if run in the AllTests test suite, but consistently works
+ // if this test class is run alone -> investigate
+ public void testOpenFirstLevel() throws Exception {
+ final SWTBotView view = getOrOpenView();
+ final SWTBotTreeItem[] items = view.bot().tree().getAllItems();
+ items[0].expand();
+ SWTBotTreeItem[] children;
+
+ children = items[0].getItems();
+ assertEquals("Wrong number of children", 5, children.length);
+ }
+
+ @Test
+ public void testHasRepo() throws Exception {
+ final SWTBotView view = getOrOpenView();
+ final SWTBotTreeItem[] items = view.bot().tree().getAllItems();
+ boolean found = false;
+ for (SWTBotTreeItem item : items) {
+ if (item.getText().startsWith(PRJ_NAME)) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Tree should have item with correct text", found);
+ }
+
+ @Test
+ public void testCopyPathToClipboard() throws Exception {
+ final SWTBotView view = getOrOpenView();
+ final SWTBotTreeItem[] items = view.bot().tree().getAllItems();
+ items[0].select();
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ Clipboard clp = new Clipboard(Display.getCurrent());
+ clp.clearContents();
+ clp.setContents(new Object[] { "x" },
+ new TextTransfer[] { TextTransfer.getInstance() });
+ String value = (String) clp.getContents(TextTransfer
+ .getInstance());
+ assertEquals("Clipboard content should be x", "x", value);
+
+ ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil
+ .getPluginLocalizedValue("CopyPathCommand"));
+
+ value = (String) clp.getContents(TextTransfer.getInstance());
+ assertTrue("Clipboard content should be a repository path",
+ FileKey.isGitRepository(new File(value), FS.DETECTED));
+
+ clp.dispose();
+ }
+ });
+
+ }
+
+ @Test
+ public void testAddRepoButton() throws Exception {
+ getOrOpenView().toolbarButton(
+ myUtil.getPluginLocalizedValue("AddRepositoryCommand")).click();
+ SWTBotShell shell = bot.shell(
+ UIText.RepositorySearchDialog_AddGitRepositories).activate();
+ shell.close();
+ }
+
+ @Test
+ public void testCloneRepoButton() throws Exception {
+ getOrOpenView().toolbarButton(
+ myUtil.getPluginLocalizedValue("CloneRepositoryCommand"))
+ .click();
+ SWTBotShell shell = bot.shell(UIText.GitCloneWizard_title).activate();
+ shell.close();
+ }
+
+ private SWTBotView getOrOpenView() throws Exception {
+ if (viewbot == null) {
+ bot.menu("Window").menu("Show View").menu("Other...").click();
+ SWTBotShell shell = bot.shell("Show View").activate();
+ shell.bot().tree().expandNode(gitCategory).getNode(viewName)
+ .select();
+ shell.bot().button(0).click();
+
+ viewbot = bot.viewByTitle(viewName);
+
+ assertNotNull("Repositories View should not be null", viewbot);
+ }
+ return viewbot;
+ }
+
+ @Test
+ @Ignore
+ public void testLinkWithSelection() throws Exception {
+ // TODO implement
+ }
+
+ @Test
+ @Ignore
+ public void testCollapseAll() throws Exception {
+ // TODO implement
+ }
+}

Back to the top