diff options
author | Michael Valenta | 2004-01-23 21:51:43 +0000 |
---|---|---|
committer | Michael Valenta | 2004-01-23 21:51:43 +0000 |
commit | bc76249996578adfcbac04655ed939328df9e4a7 (patch) | |
tree | 8374d9d8c6605fad8cd749ab871652a5d1316fdb /tests/org.eclipse.team.tests.core | |
parent | 6b9ca5beb7879f877d070461cdae3b40cfc5f2fb (diff) | |
download | eclipse.platform.team-bc76249996578adfcbac04655ed939328df9e4a7.tar.gz eclipse.platform.team-bc76249996578adfcbac04655ed939328df9e4a7.tar.xz eclipse.platform.team-bc76249996578adfcbac04655ed939328df9e4a7.zip |
*** empty log message ***
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
6 files changed, 344 insertions, 1 deletions
diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml index 7064a441b..a99182bcb 100644 --- a/tests/org.eclipse.team.tests.core/plugin.xml +++ b/tests/org.eclipse.team.tests.core/plugin.xml @@ -21,7 +21,7 @@ <import plugin="org.eclipse.ui.editors" optional="true"/> <import plugin="org.eclipse.core.tests.harness"/> <import plugin="org.eclipse.core.resources"/> - <import plugin="org.eclipse.core.runtime.compatibility"/> + <import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.core.boot"/> <import plugin="org.eclipse.team.core"/> <import plugin="org.eclipse.team.cvs.core"/> @@ -91,5 +91,18 @@ id="org.eclipse.team.tests.core.linking"> </repository> </extension> + <extension + point="org.eclipse.ui.views"> + <category + name="Team Test Views" + id="org.eclipse.team.tests.core"> + </category> + <view + name="Content Provider Test View" + category="org.eclipse.team.tests.core" + class="org.eclipse.team.tests.ui.views.ContentProviderTestView" + id="org.eclipse.team.tests.ui.views.ContentProviderTestView"> + </view> + </extension> </plugin> diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java new file mode 100644 index 000000000..3a5c9f441 --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.synchronize; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.subscribers.MutableSyncInfoSet; +import org.eclipse.team.core.subscribers.SyncInfo; +import org.eclipse.team.tests.core.TeamTest; +import org.eclipse.team.tests.ui.views.*; + +/** + * Tests for the SyncInfoSet content providers. + */ +public class SyncInfoSetContentProviderTest extends TeamTest { + + public static final TestSubscriber subscriber = new TestSubscriber(); + /* + * This method creates a project with the given resources, imports + * it to CVS and checks it out + */ + protected IProject createProject(String prefix, String[] resources) throws CoreException { + IProject project = getUniqueTestProject(prefix); + buildResources(project, resources, true); + return project; + } + + /* + * Create a test project using the currently running test case as the project name prefix + */ + protected IProject createProject(String[] resources) throws CoreException { + return createProject(getName(), resources); + } + + private MutableSyncInfoSet createSet(IProject project, String[] resources, int[] syncKind) throws TeamException { + MutableSyncInfoSet set = new MutableSyncInfoSet(); + adjustSet( + set, + project, + resources, + syncKind); + return set; + } + + private void adjustSet(MutableSyncInfoSet set, IProject project, String[] resourceStrings, int[] syncKind) throws TeamException { + IResource[] resources = buildResources(project, resourceStrings); + set.beginInput(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + int kind = syncKind[i]; + if (kind == SyncInfo.IN_SYNC) { + set.remove(resource); + } else { + SyncInfo newInfo = subscriber.getSyncInfo(resource, kind); + if (set.getSyncInfo(resource) != null) { + set.changed(newInfo); + } else { + set.add(newInfo); + } + } + } + set.endInput(new NullProgressMonitor()); + } + + /** + * Ensure that the resource + * @param resources + */ + private void assertVisible(IProject project, String[] resources) { + // TODO Auto-generated method stub + + } + + public void simpleTest() throws CoreException { + IProject project = createProject(new String[] { "file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt"}); + MutableSyncInfoSet set = createSet( + project, + new String[] { "file.txt" }, + new int[] {SyncInfo.OUTGOING | SyncInfo.CHANGE}); + assertVisible(project, new String[] { "file.txt" }); + + adjustSet( + set, + project, + new String[] { "folder1/file2.txt", "folder1/folder2/file3.txt" }, + new int[] { + SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.CHANGE}); + assertVisible(project, new String[] { "file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt" }); + + adjustSet( + set, + project, + new String[] { "folder1/file2.txt"}, + new int[] { + SyncInfo.IN_SYNC, + }); + assertVisible(project, new String[] { "file.txt", "folder1/folder2/file3.txt" }); + + } + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + TestTreeViewer viewer = new TestTreeViewer(null); + } + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ + protected void tearDown() throws Exception { + // TODO Dispose of whatever was created + super.tearDown(); + } +} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSubscriber.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSubscriber.java new file mode 100644 index 000000000..0f1129ca7 --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSubscriber.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.synchronize; + +import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.subscribers.*; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestSubscriber extends TeamSubscriber { + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#getDescription() + */ + public String getDescription() { + return "Test Subscriber"; + } + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource) + */ + public boolean isSupervised(IResource resource) throws TeamException { + return true; + } + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#members(org.eclipse.core.resources.IResource) + */ + public IResource[] members(IResource resource) throws TeamException { + if (resource.getType() == IResource.FILE) { + return new IResource[0]; + } + try { + return ((IContainer)resource).members(); + } catch (CoreException e) { + throw TeamException.asTeamException(e); + } + } + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#roots() + */ + public IResource[] roots() { + return ResourcesPlugin.getWorkspace().getRoot().getProjects(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#getSyncInfo(org.eclipse.core.resources.IResource) + */ + public SyncInfo getSyncInfo(IResource resource) throws TeamException { + return getSyncInfo(resource, SyncInfo.IN_SYNC); + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#refresh(org.eclipse.core.resources.IResource[], int, org.eclipse.core.runtime.IProgressMonitor) + */ + public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { + // Nothing to do + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#getDefaultComparisonCriteria() + */ + public IComparisonCriteria getDefaultComparisonCriteria() { + return new IComparisonCriteria() { + public boolean compare(Object e1, Object e2) { + return false; + } + }; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.TeamSubscriber#isThreeWay() + */ + public boolean isThreeWay() { + return false; + } + + public SyncInfo getSyncInfo(IResource resource, int i) throws TeamException { + return new TestSyncInfo(resource, i, this); + } +} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java new file mode 100644 index 000000000..75812e94c --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.synchronize; + +import org.eclipse.core.resources.IResource; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.subscribers.SyncInfo; + +public class TestSyncInfo extends SyncInfo { + + private int kind; + + public TestSyncInfo(IResource resource, int kind, TestSubscriber subscriber) throws TeamException { + super(resource, null, null, subscriber); + this.kind = kind; + } + + /* (non-Javadoc) + * @see org.eclipse.team.core.subscribers.SyncInfo#calculateKind() + */ + protected int calculateKind() throws TeamException { + return this.kind; + } +} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java new file mode 100644 index 000000000..6e230dcaf --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.views; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.team.core.subscribers.SyncInfo; +import org.eclipse.team.core.subscribers.SyncInfoSet; +import org.eclipse.team.internal.ui.synchronize.views.CompressedFolderContentProvider; +import org.eclipse.team.ui.synchronize.SyncInfoDiffNode; +import org.eclipse.team.ui.synchronize.TeamSubscriberParticipantLabelProvider; +import org.eclipse.ui.part.ViewPart; + +public class ContentProviderTestView extends ViewPart { + + public static final String ID = "org.eclipse.team.tests.ui.views.ContentProviderTestView"; + + private TestTreeViewer viewer; + + public ContentProviderTestView() { + } + + public void createPartControl(Composite parent) { + viewer = new TestTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(new CompressedFolderContentProvider()); + viewer.setLabelProvider(new TeamSubscriberParticipantLabelProvider()); + setInput(new SyncInfoSet(new SyncInfo[0])); + } + + public void setInput(SyncInfoSet set) { + viewer.setInput(new SyncInfoDiffNode(set, ResourcesPlugin.getWorkspace().getRoot())); + } + + public void setFocus() { + viewer.getControl().setFocus(); + } +}
\ No newline at end of file diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java new file mode 100644 index 000000000..4284e4a27 --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ui.views; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; + +public class TestTreeViewer extends TreeViewer { + + public TestTreeViewer(Composite parent) { + super(parent); + } + + public TestTreeViewer(Composite parent, int style) { + super(parent, style); + } + + public TestTreeViewer(Tree tree) { + super(tree); + } +} |