diff options
author | Michael Valenta | 2006-06-29 17:24:47 +0000 |
---|---|---|
committer | Michael Valenta | 2006-06-29 17:24:47 +0000 |
commit | 9fc0d39e467c9b7bd93c2efe9047181f82db6379 (patch) | |
tree | 61a08e8d3ed97a944b0688a7b6eee0d0ed19bd84 | |
parent | 98c6f7330a30819b1e31d3715df1335991086cb9 (diff) | |
download | eclipse.platform.team-9fc0d39e467c9b7bd93c2efe9047181f82db6379.tar.gz eclipse.platform.team-9fc0d39e467c9b7bd93c2efe9047181f82db6379.tar.xz eclipse.platform.team-9fc0d39e467c9b7bd93c2efe9047181f82db6379.zip |
Bug 136237 [Tests] Model sync tests need to check viewer contents
12 files changed, 224 insertions, 708 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java index cdc13141b..70134ecb2 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java @@ -38,10 +38,7 @@ import org.eclipse.ui.navigator.*; */ public abstract class SynchronizationContentProvider implements ICommonContentProvider, IDiffChangeListener, IPropertyChangeListener { - private ISynchronizationScope scope; - private ISynchronizationContext context; private Viewer viewer; - private IExtensionStateModel stateModel; private boolean empty; private ICommonContentExtensionSite site; @@ -93,6 +90,7 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr empty = true; return new Object[0]; } else if (element instanceof ISynchronizationContext) { + ISynchronizationContext context = (ISynchronizationContext)element; // If the root is a context, we want to filter by the context ISynchronizationContext sc = (ISynchronizationContext) element; if (sc.getScope().getMappings(getModelProviderId()).length > 0) { @@ -109,6 +107,7 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr return new Object[0]; } if (element == getModelProvider()) { + ISynchronizationContext context = getContext(); if (context != null && !isInitialized(context)) { return new Object[0]; } @@ -120,7 +119,7 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr } } Object[] delegateChildren = getDelegateChildren(parent, isElement); - ISynchronizationContext sc = getContext(); + ISynchronizationContext context = getContext(); if (context == null) { ISynchronizationScope scope = getScope(); if (scope == null) { @@ -129,7 +128,7 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr return getChildrenInScope(scope, parent, delegateChildren); } } else { - return getChildrenInContext(sc, parent, delegateChildren); + return getChildrenInContext(context, parent, delegateChildren); } } @@ -254,7 +253,11 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() { - stateModel.removePropertyChangeListener(this); + ICommonContentExtensionSite extensionSite = getExtensionSite(); + if (extensionSite != null) { + extensionSite.getExtensionStateModel().removePropertyChangeListener(this); + } + ISynchronizationContext context = getContext(); if (context != null) context.getDiffTree().removeDiffChangeListener(this); ISynchronizePageConfiguration configuration = getConfiguration(); @@ -274,18 +277,18 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite) */ public void init(ICommonContentExtensionSite site) { + // Set the site this.site = site; - stateModel = site.getExtensionStateModel(); - stateModel.addPropertyChangeListener(this); + // Configure the content provider based on the site and state model + site.getExtensionStateModel().addPropertyChangeListener(this); ISynchronizePageConfiguration configuration = getConfiguration(); if (configuration != null) configuration.addPropertyChangeListener(this); - scope = (ISynchronizationScope)stateModel.getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_SCOPE); - context = (ISynchronizationContext)stateModel.getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT); ITreeContentProvider provider = getDelegateContentProvider(); if (provider instanceof ICommonContentProvider) { ((ICommonContentProvider) provider).init(site); } + ISynchronizationContext context = getContext(); if (context != null) context.getDiffTree().addDiffChangeListener(this); } @@ -327,7 +330,13 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr * @return the synchronization context or <code>null</code> */ protected ISynchronizationContext getContext() { - return context; + ICommonContentExtensionSite extensionSite = getExtensionSite(); + if (extensionSite != null) + return (ISynchronizationContext) extensionSite + .getExtensionStateModel() + .getProperty( + ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT); + return null; } /** @@ -337,7 +346,13 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr * @return the resource mapping scope or <code>null</code> */ protected ISynchronizationScope getScope() { - return scope; + ICommonContentExtensionSite extensionSite = getExtensionSite(); + if (extensionSite != null) + return (ISynchronizationScope) extensionSite + .getExtensionStateModel() + .getProperty( + ITeamContentProviderManager.P_SYNCHRONIZATION_SCOPE); + return null; } /** @@ -347,7 +362,13 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr * @return the synchronization page configuration or <code>null</code> */ protected ISynchronizePageConfiguration getConfiguration() { - return (ISynchronizePageConfiguration)stateModel.getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_PAGE_CONFIGURATION); + ICommonContentExtensionSite extensionSite = getExtensionSite(); + if (extensionSite != null) + return (ISynchronizePageConfiguration) extensionSite + .getExtensionStateModel() + .getProperty( + ITeamContentProviderManager.P_SYNCHRONIZATION_PAGE_CONFIGURATION); + return null; } /* (non-Javadoc) diff --git a/tests/org.eclipse.team.tests.core/plugin.xml b/tests/org.eclipse.team.tests.core/plugin.xml index 5c6ebe798..38b9658a9 100644 --- a/tests/org.eclipse.team.tests.core/plugin.xml +++ b/tests/org.eclipse.team.tests.core/plugin.xml @@ -29,6 +29,7 @@ <import plugin="org.eclipse.ui"/> <import plugin="org.junit"/> <import plugin="org.eclipse.core.tests.resources"/> + <import plugin="org.eclipse.ui.navigator"/> </requires> <!-- *************** Repository Providers **************** --> diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java index c7fa3cb7b..2b0eb01a7 100644 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/AllTeamSynchronizeTests.java @@ -17,25 +17,17 @@ import org.eclipse.core.tests.resources.ResourceTest; public class AllTeamSynchronizeTests extends ResourceTest { - /** - * Constructor for CVSClientTest. - */ public AllTeamSynchronizeTests() { super(); } - /** - * Constructor for CVSClientTest. - * @param name - */ public AllTeamSynchronizeTests(String name) { super(name); } public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(TestDiffNodePresentationModel.suite()); - suite.addTest(SyncInfoSetContentProviderTest.suite()); + suite.addTest(ResourceContentTests.suite()); return suite; } } diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java new file mode 100644 index 000000000..eb4690bbb --- /dev/null +++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java @@ -0,0 +1,188 @@ +package org.eclipse.team.tests.ui.synchronize; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import junit.framework.Test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.TreePath; +import org.eclipse.team.core.mapping.ISynchronizationContext; +import org.eclipse.team.core.mapping.ISynchronizationScope; +import org.eclipse.team.internal.ui.mapping.ResourceModelContentProvider; +import org.eclipse.team.tests.core.TeamTest; +import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; + +public class ResourceContentTests extends TeamTest { + + public static class TestableResourceModelContentProvider extends ResourceModelContentProvider { + + private final ISynchronizationScope scope; + private final ISynchronizationContext context; + private final ISynchronizePageConfiguration configuration; + + public TestableResourceModelContentProvider(ISynchronizationScope scope, ISynchronizationContext context, ISynchronizePageConfiguration configuration) { + this.scope = scope; + this.context = context; + this.configuration = configuration; + } + + public ISynchronizePageConfiguration getConfiguration() { + return configuration; + } + + public ISynchronizationContext getContext() { + return context; + } + + public ISynchronizationScope getScope() { + return scope; + } + } + + public static Test suite() { + return suite(ResourceContentTests.class); + } + + private ResourceModelContentProvider provider; + + public ResourceContentTests() { + super(); + } + + public ResourceContentTests(String name) { + super(name); + } + + protected void setUp() throws Exception { + initializeProvider(null, null, null); + super.setUp(); + } + + protected void tearDown() throws Exception { + cleanupProvider(); + super.tearDown(); + } + + private void initializeProvider(ISynchronizationScope scope, ISynchronizationContext context, ISynchronizePageConfiguration configuration) { + cleanupProvider(); + provider = new TestableResourceModelContentProvider(scope, context, configuration); + } + + private void cleanupProvider() { + if (provider != null) + provider.dispose(); + provider = null; + } + + private void assertContentMatches(IProject project, String[] leaves) { + assertContentsMatch(asResources(project, leaves)); + } + + private void assertContentsMatch(IResource[] resources) { + Set paths = getPaths(ResourcesPlugin.getWorkspace().getRoot()); + Set resourceSet = new HashSet(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + resourceSet.add(resource); + } + for (Iterator iterator = paths.iterator(); iterator.hasNext();) { + TreePath path = (TreePath) iterator.next(); + Object o = path.getLastSegment(); + // Just remove the object, we'll check for any remaining resources below + if (resourceSet.remove(o)) { + iterator.remove(); + } + } + if (!resourceSet.isEmpty()) { + fail("Tree entries were missing for " + toString(resourceSet)); + } + if (!paths.isEmpty()) { + fail("Tree entries were found for " + toString(paths)); + } + } + + private Set getPaths(Object root) { + Set result = new HashSet(); + Object[] elements = provider.getElements(root); + for (int i = 0; i < elements.length; i++) { + Object object = elements[i]; + TreePath path = new TreePath(new Object[] { object }); + Set childPaths = getPaths(provider, path); + result.addAll(childPaths); + } + return result; + } + + private Set getPaths(ResourceModelContentProvider provider, TreePath path) { + Object[] children = provider.getChildren(path); + Set result = new HashSet(); + if (children.length == 0) + result.add(path); + for (int i = 0; i < children.length; i++) { + Object object = children[i]; + TreePath childPath = path.createChildPath(object); + Set childPaths = getPaths(provider, childPath); + result.addAll(childPaths); + } + return result; + } + + private String toString(Set set) { + StringBuffer buffer = new StringBuffer(); + boolean addComma = false; + for (Iterator iterator = set.iterator(); iterator.hasNext();) { + Object resource = iterator.next(); + buffer.append(toString(resource)); + if (addComma) + buffer.append(", "); + addComma = true; + } + return buffer.toString(); + } + + private String toString(Object object) { + if (object instanceof IResource) { + return ((IResource)object).getFullPath().toString(); + } + if (object instanceof TreePath) { + return toString(((TreePath)object).getLastSegment()); + } + return object.toString(); + } + + private IResource[] asResources(IProject project, String[] resourcePaths) { + List resources = new ArrayList(); + for (int i = 0; i < resourcePaths.length; i++) { + String path = resourcePaths[i]; + if (path.endsWith("/")) { + resources.add(project.getFolder(path)); + } else { + resources.add(project.getFile(path)); + } + } + return (IResource[]) resources.toArray(new IResource[resources.size()]); + } + + public void testFileContent() throws CoreException { + String[] files = new String[] {"file.txt", "file2.txt", "folder1/file3.txt", "folder1/folder2/file4.txt"}; + IProject project = createProject(files); + files = new String[] {".project", "file.txt", "file2.txt", "folder1/file3.txt", "folder1/folder2/file4.txt"}; + assertContentMatches(project, files); + } + + public void testFileChange() throws CoreException { + String[] files = new String[] {"file.txt", "file2.txt", "folder1/file3.txt", "folder1/folder2/file4.txt"}; + IProject project = createProject(files); + + } + + + +} 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 deleted file mode 100644 index 31cc07d64..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/SyncInfoSetContentProviderTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.synchronize; - -import java.util.Iterator; -import java.util.List; - -import junit.framework.Test; - -import org.eclipse.core.resources.*; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.ui.synchronize.SynchronizeModelProvider; - -/** - * Tests for the SyncInfoSet content providers. - */ -public class SyncInfoSetContentProviderTest extends TestDiffNodePresentationModel { - - /** - * Constructor for CVSProviderTest - */ - public SyncInfoSetContentProviderTest() { - super(); - } - - /** - * Constructor for CVSProviderTest - */ - public SyncInfoSetContentProviderTest(String name) { - super(name); - } - - public static Test suite() { - return suite(SyncInfoSetContentProviderTest.class); - } - - /* (non-Javadoc) - * @see org.eclipse.team.tests.ui.synchronize.TestDiffNodePresentationModel#getDiffNodeController() - */ - protected SynchronizeModelProvider getDiffNodeController(SyncInfoTree set) { - //return new CompressedFoldersModelProvider(set); - return null; - } - - private void assertFolderPresent(IFolder folder, List resources) { - // First, if the folder is out-of-sync, it should be visible - for (Iterator iter = resources.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - if (resource.equals(folder)) { - // The folder should be present. - // Remove it since it has been verified - iter.remove(); - return; - } - } - // If the folder contains a file in the list, it is also OK - for (Iterator iter = resources.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - if (resource.getType() == IResource.FILE && resource.getParent().equals(folder)) { - // The compressed folder is valid since it contains an out-of-sync file - // However, the resource is left since it has not been verified (only it's parent) - return; - } - } - fail("Folder " + folder.getFullPath() + " should not be visible but is."); - } - - private void assertFilePresent(IResource itemResource, List resources) { - for (Iterator iter = resources.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - if (resource.equals(itemResource)) { - // The resource has been verified so it can be removed - iter.remove(); - return; - } - } - fail("Resource " + itemResource.getFullPath() + " should not be visible but is."); - } - - private void assertProjectPresent(IProject project, List resources) { -// First, if the project is out-of-sync, it should be visible - for (Iterator iter = resources.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - if (resource.equals(project)) { - // The folder should be present. - // Remove it since it has been verified - iter.remove(); - return; - } - } - for (Iterator iter = resources.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - if (resource.getProject().equals(project)) { - return; - } - } - fail("Project " + project.getName() + " should not be visible but is."); - } -} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java deleted file mode 100644 index b4c102cd8..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestDiffNodePresentationModel.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.synchronize; - -import java.util.ArrayList; -import java.util.List; -import junit.framework.Test; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.swt.widgets.Item; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.tests.core.TeamTest; -import org.eclipse.team.tests.ui.views.ContentProviderTestView; -import org.eclipse.team.tests.ui.views.TestTreeViewer; -import org.eclipse.team.ui.TeamUI; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; - - -public class TestDiffNodePresentationModel extends TeamTest { - - private ContentProviderTestView view; - private SyncInfoTree set; - private TreeViewerAdvisor configuration; - - public TestDiffNodePresentationModel() { - super(); - } - - public TestDiffNodePresentationModel(String name) { - super(name); - } - - public static Test suite() { - return suite(TestDiffNodePresentationModel.class); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - TestParticipant p = (TestParticipant)getParticipant(TestParticipant.ID); - p.reset(); - this.set = p.getSyncInfoSet(); - view = ContentProviderTestView.findViewInActivePage(null); - configuration.initializeViewer(view.getViewer()); - } - - /** - * - */ - private ISynchronizeParticipant getParticipant(String id) throws TeamException { - ISynchronizeParticipantReference reference = TeamUI.getSynchronizeManager().get(id, null); - if (reference != null) { - return reference.getParticipant(); - } - return null; - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - set = null; - configuration.dispose(); - super.tearDown(); - } - - protected SynchronizeModelProvider getDiffNodeController(SyncInfoTree set) { - //return new HierarchicalModelProvider(set); - return null; - } - - private void adjustSet(SyncInfoSet set, IProject project, String[] resourceStrings, int[] syncKind) throws TeamException { - IResource[] resources = buildResources(project, resourceStrings); - try { - 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 = new TestSyncInfo(resource, kind); - set.add(newInfo); - } - } - } finally { - set.endInput(null); - } - } - - /** - * Ensure that the resource - * @param resources - */ - protected void assertProperVisibleItems() { - IResource[] resources = set.getResources(); - List resourceList = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - resourceList.add(resource); - } - TestTreeViewer viewer = view.getViewer(); - Item[] items = viewer.getRootItems(); - if (resources.length == 0) { - assertTrue("There are items visible when there should not be.", items.length == 0); - return; - } - // Test that all items in the tree are expected - for (int i = 0; i < items.length; i++) { - Item item = items[i]; - assertThatAllOutOfSyncResourcesAreShown(item, resourceList); - } - // Test that all expected resources and their parents are present - assertTrue("The tree did not contain all expected resources: " + resourceList.toString(), resourceList.isEmpty()); - } - - /** - * Traverse every element shown in the view and ensure that every out-of-sync - * resource in the set is at least shown. This doesn't test the actual logical - * organization, but does ensure that all out-of-sync resources are shown only - * once. - */ - protected void assertThatAllOutOfSyncResourcesAreShown(Item item, List outOfSyncResources) { - Object node = item.getData(); - SyncInfo info = (SyncInfo)Utils.getAdapter(node, SyncInfo.class); - if(info != null) { - assertTrue("The tree contained an out-of-sync resource that wasn't in the set", outOfSyncResources.remove(info.getLocal())); - } - Item[] children = view.getViewer().getChildren(item); - for (int i = 0; i < children.length; i++) { - Item child = children[i]; - assertThatAllOutOfSyncResourcesAreShown(child, outOfSyncResources); - } - } - - public void testNestedFolder() throws CoreException { - IProject project = createProject(new String[]{"file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt"}); - adjustSet(set, project, - new String[]{"file.txt"}, - new int[]{SyncInfo.OUTGOING | SyncInfo.CHANGE}); - assertProperVisibleItems(); - adjustSet(set, project, - new String[]{"folder1/file2.txt", "folder1/folder2/file3.txt"}, - new int[]{SyncInfo.OUTGOING | SyncInfo.CHANGE, SyncInfo.OUTGOING | SyncInfo.CHANGE}); - assertProperVisibleItems(); - adjustSet(set, project, - new String[]{"folder1/file2.txt"}, - new int[]{SyncInfo.IN_SYNC,}); - assertProperVisibleItems(); - } - - public void testParentRemovalWithChildRemaining() throws CoreException { - IProject project = createProject(new String[]{"file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt"}); - adjustSet(set, project, - new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"}, - new int[]{SyncInfo.CONFLICTING | SyncInfo.CHANGE, SyncInfo.CONFLICTING | SyncInfo.CHANGE}); - assertProperVisibleItems(); - - adjustSet(set, project, - new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"}, - new int[]{SyncInfo.IN_SYNC, SyncInfo.OUTGOING | SyncInfo.CHANGE}); - assertProperVisibleItems(); - } - - public void testEmptyFolderChange() throws CoreException { - IProject project = createProject(new String[]{"file.txt", "folder1/file2.txt", "folder1/folder2/file3.txt", "folder3/"}); - adjustSet(set, project, - new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"}, - new int[]{SyncInfo.CONFLICTING | SyncInfo.CHANGE, SyncInfo.CONFLICTING | SyncInfo.CHANGE}); - assertProperVisibleItems(); - - adjustSet(set, project, - new String[]{"folder1/folder2/", "folder1/folder2/file3.txt"}, - new int[]{SyncInfo.IN_SYNC, SyncInfo.OUTGOING | SyncInfo.CHANGE}); - assertProperVisibleItems(); - - adjustSet(set, project, - new String[]{"folder1/folder2/file3.txt"}, - new int[]{SyncInfo.IN_SYNC}); - assertProperVisibleItems(); - - adjustSet(set, project, - new String[]{"folder3/"}, - new int[]{SyncInfo.INCOMING | SyncInfo.ADDITION}); - assertProperVisibleItems(); - } -} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java deleted file mode 100644 index ffdac9298..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestPage.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.synchronize; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.team.internal.ui.synchronize.StructuredViewerAdvisor; -import org.eclipse.team.internal.ui.synchronize.TreeViewerAdvisor; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.part.Page; - -/** - * Page for testing - */ -public class TestPage extends Page implements ISynchronizePage { - - private ISynchronizePageConfiguration configuration; - private Composite composite; - private Viewer changesViewer; - private TreeViewerAdvisor viewerAdvisor; - - public TestPage(ISynchronizePageConfiguration configuration) { - this.configuration = configuration; - configuration.setPage(this); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - composite = new Composite(parent, SWT.NONE); - //sc.setContent(composite); - GridLayout gridLayout= new GridLayout(); - gridLayout.makeColumnsEqualWidth= false; - gridLayout.marginWidth= 0; - gridLayout.marginHeight = 0; - gridLayout.verticalSpacing = 0; - composite.setLayout(gridLayout); - GridData data = new GridData(GridData.FILL_BOTH); - data.grabExcessVerticalSpace = true; - composite.setLayoutData(data); - - // Create the changes section which, in turn, creates the changes viewer and its configuration - this.changesViewer = createChangesViewer(composite); - } - - protected Viewer createChangesViewer(Composite parent) { - viewerAdvisor = new TreeViewerAdvisor(parent, configuration); - return viewerAdvisor.getViewer(); - } - - public StructuredViewerAdvisor getViewerAdvisor() { - return viewerAdvisor; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - public Control getControl() { - return composite; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() - */ - public void setFocus() { - changesViewer.getControl().setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePage#init(org.eclipse.team.ui.synchronize.ISynchronizePageSite) - */ - public void init(ISynchronizePageSite site) { - // Noop - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - // Delegate menu creation to the advisor - viewerAdvisor.setActionBars(actionBars); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.Page#dispose() - */ - public void dispose() { - composite.dispose(); - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePage#getViewer() - */ - public Viewer getViewer() { - return changesViewer; - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizePage#aboutToChangeProperty(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, java.lang.String, java.lang.Object) - */ - public boolean aboutToChangeProperty(ISynchronizePageConfiguration configuration, String key, Object newValue) { - // Allow all changes - return true; - } -} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java deleted file mode 100644 index 9a4860688..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestParticipant.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.synchronize; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.IPageBookViewPage; - -public class TestParticipant extends AbstractSynchronizeParticipant { - - public static final String ID = "org.eclipse.team.tests.ui.test-participant"; //$NON-NLS-1$ - - private SyncInfoTree set = new SyncInfoTree(); - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { - configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, set); - configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createPage(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - public IPageBookViewPage createPage(ISynchronizePageConfiguration configuration) { - return new TestPage(configuration); - } - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#createSynchronizeWizard() - */ - public IWizard createSynchronizeWizard() { - return null; - } - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#dispose() - */ - public void dispose() { - // Noop - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#run(org.eclipse.ui.IWorkbenchPart) - */ - public void run(IWorkbenchPart part) { - // TODO Auto-generated method stub - - } - - /** - * - */ - public void reset() { - set.clear(); - } - - /** - * @return - */ - public SyncInfoTree getSyncInfoSet() { - return set; - } -} 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 deleted file mode 100644 index 073a1c1ad..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestSyncInfo.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * 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.synchronize.SyncInfo; - -public class TestSyncInfo extends SyncInfo { - - private int kind; - - public TestSyncInfo(IResource resource, int kind) throws TeamException { - super(resource, null, null, null); - this.kind = kind; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.SyncInfo#calculateKind() - */ - protected int calculateKind() throws TeamException { - return this.kind; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.subscribers.SyncInfo#getKind() - */ - public int getKind() { - return kind; - } -} diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java deleted file mode 100644 index 6b83c5054..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/TestTreeViewerAdvisor.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.synchronize; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.core.synchronize.SyncInfoSet; -import org.eclipse.team.core.synchronize.SyncInfoTree; -import org.eclipse.team.internal.ui.synchronize.*; -import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; - -public class TestTreeViewerAdvisor extends TreeViewerAdvisor { - - public TestTreeViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) { - super(parent, configuration); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.TreeViewerAdvisor#createModelManager(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) - */ - protected SynchronizeModelManager createModelManager(ISynchronizePageConfiguration configuration) { - SynchronizeModelManager manager = new SynchronizeModelManager(configuration) { - protected ISynchronizeModelProvider createModelProvider(String id) { - return new HierarchicalModelProvider(getConfiguration(), getSyncInfoSet()); - } - protected ISynchronizeModelProviderDescriptor[] getSupportedModelProviders() { - return new ISynchronizeModelProviderDescriptor[] { - new HierarchicalModelProvider.HierarchicalModelProviderDescriptor()}; - } - protected SyncInfoSet getSyncInfoSet() { - return (SyncInfoTree)getConfiguration().getProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET); - } - }; - manager.setViewerAdvisor(this); - return manager; - } -} 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 deleted file mode 100644 index 493db1b59..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/ContentProviderTestView.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.internal.ui.TeamUIPlugin; -import org.eclipse.ui.*; -import org.eclipse.ui.part.ViewPart; - -public class ContentProviderTestView extends ViewPart { - - public static final String VIEW_ID = "org.eclipse.team.tests.ui.views.ContentProviderTestView"; - - private TestTreeViewer viewer; - - public static ContentProviderTestView findViewInActivePage(IWorkbenchPage activePage) { - try { - if (activePage == null) { - activePage = TeamUIPlugin.getActivePage(); - if (activePage == null) return null; - } - IViewPart part = activePage.findView(VIEW_ID); - if (part == null) - part = activePage.showView(VIEW_ID); - return (ContentProviderTestView)part; - } catch (PartInitException pe) { - return null; - } - } - - public ContentProviderTestView() { - } - - public void createPartControl(Composite parent) { - viewer = new TestTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - } - - public void setFocus() { - viewer.getControl().setFocus(); - } - - public TestTreeViewer getViewer() { - return viewer; - } -} 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 deleted file mode 100644 index 8e5d01a27..000000000 --- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/views/TestTreeViewer.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ui.views; - -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.widgets.*; - -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); - } - - public Item[] getRootItems() { - expandAll(); - return getChildren(getControl()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.AbstractTreeViewer#getChildren(org.eclipse.swt.widgets.Widget) - */ - public Item[] getChildren(Widget o) { - return super.getChildren(o); - } - - public boolean hasItemFor(DiffNode node) { - return findItem(node) != null; - } -} |