Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.tests/src/org')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AbstractLaunchTest.java77
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AcceleratorSubstitutionTests.java59
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java205
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java118
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java1051
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchHistoryTests.java197
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java194
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/RefreshTabTests.java204
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java31
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java69
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java91
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockDynamic.java21
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockOne.java21
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockThree.java21
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockTwo.java21
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java151
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java30
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java171
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java186
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java111
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java572
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java136
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java40
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java32
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java32
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java38
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java36
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java32
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java32
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java32
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java173
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PresentationContextTests.java53
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java213
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java477
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java649
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java374
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java94
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java205
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java31
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java80
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java35
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java31
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java31
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java31
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java91
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java46
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java113
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java29
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java56
49 files changed, 0 insertions, 6823 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AbstractLaunchTest.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AbstractLaunchTest.java
deleted file mode 100644
index d3b649354..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AbstractLaunchTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.eclipe.debug.tests.launching;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
-
-import junit.framework.TestCase;
-
-/**
- * Common function for launch related tests.
- */
-public abstract class AbstractLaunchTest extends TestCase {
-
- /**
- * Constructs a test with the given name.
- *
- * @param name
- */
- public AbstractLaunchTest(String name) {
- super(name);
- }
-
- /**
- * Returns the launch manager.
- *
- * @return launch manager
- */
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- /**
- * Returns the singleton instance of the <code>LaunchConfigurationManager</code>
- *
- * @return the singleton instance of the <code>LaunchConfigurationManager</code>
- */
- protected LaunchConfigurationManager getLaunchConfigurationManager() {
- return DebugUIPlugin.getDefault().getLaunchConfigurationManager();
- }
-
- /**
- * Returns a launch configuration with the given name, creating one if required.
- *
- * @param name configuration name
- * @return launch configuration
- * @throws CoreException
- */
- protected ILaunchConfiguration getLaunchConfiguration(String name) throws CoreException {
- ILaunchManager manager = getLaunchManager();
- ILaunchConfiguration[] configurations = manager.getLaunchConfigurations();
- for (int i = 0; i < configurations.length; i++) {
- ILaunchConfiguration config = configurations[i];
- if (config.getName().equals(name)) {
- return config;
- }
- }
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE);
- ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name);
- ILaunchConfiguration saved = wc.doSave();
- return saved;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AcceleratorSubstitutionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AcceleratorSubstitutionTests.java
deleted file mode 100644
index ddf76214e..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/AcceleratorSubstitutionTests.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipe.debug.tests.launching;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-
-/**
- * Tests accelerator adjustments for DBCS languages.
- * See bug 186921.
- *
- * @since 3.3
- */
-public class AcceleratorSubstitutionTests extends TestCase {
-
- /**
- * Constructor
- * @param name the name of the test
- */
- public AcceleratorSubstitutionTests(String name) {
- super(name);
- }
-
- /**
- * tests a string with "..."
- */
- public void testWithEllipses() {
- assertEquals("incorrect DBCS accelerator substitution",
- "Open Run Dialog(&R)...",
- DebugUIPlugin.adjustDBCSAccelerator("Open Run(&R) Dialog..."));
- }
-
- /**
- * tests a string without "..."
- */
- public void testWithoutEllipses() {
- assertEquals("incorrect DBCS accelerator substitution",
- "Open Run Dialog(&R)",
- DebugUIPlugin.adjustDBCSAccelerator("Open Run(&R) Dialog"));
- }
-
- /**
- * tests a string that should not change (no DBCS style accelerator).
- */
- public void testWithoutDBCSAcclerator() {
- assertEquals("incorrect DBCS accelerator substitution",
- "Open &Run Dialog...",
- DebugUIPlugin.adjustDBCSAccelerator("Open &Run Dialog..."));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java
deleted file mode 100644
index dfcab8ff6..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipe.debug.tests.launching;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.filesystem.provider.FileStore;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Implementation of an in memory file store to test launch configurations on EFS
- */
-public class DebugFileStore extends FileStore {
-
- /**
- * Output steam for writing a file
- */
- class DebugOutputStream extends ByteArrayOutputStream {
-
- /* (non-Javadoc)
- * @see java.io.ByteArrayOutputStream#close()
- */
- public void close() throws IOException {
- super.close();
- DebugFileSystem.getDefault().setContents(toURI(), toByteArray());
- }
-
- }
-
- private URI uri;
-
- public DebugFileStore(URI id) {
- uri = id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
- URI[] uris = DebugFileSystem.getDefault().getFileURIs();
- List children = new ArrayList();
- IPath me = getPath();
- for (int i = 0; i < uris.length; i++) {
- URI id = uris[i];
- Path path = new Path(id.getPath());
- if (path.segmentCount() > 0) {
- if (path.removeLastSegments(1).equals(me)) {
- children.add(path.lastSegment());
- }
- }
- }
- return (String[]) children.toArray(new String[children.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
- byte[] contents = DebugFileSystem.getDefault().getContents(toURI());
- FileInfo info = new FileInfo();
- info.setName(getName());
- info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
- if (contents == null) {
- info.setExists(false);
- info.setLength(0L);
- } else {
- info.setExists(true);
- info.setLength(contents.length);
- info.setDirectory(contents == DebugFileSystem.DIRECTORY_BYTES);
- if (info.isDirectory()) {
- info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
- }
- }
- return info;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#getChild(java.lang.String)
- */
- public IFileStore getChild(String name) {
- try {
- return new DebugFileStore(new URI(getFileSystem().getScheme(), getPath().append(name).toString(), null));
- } catch (URISyntaxException e) {
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#getName()
- */
- public String getName() {
- IPath path = getPath();
- if (path.segmentCount() > 0) {
- return path.lastSegment();
- }
- return "";
- }
-
- /**
- * @return
- */
- private IPath getPath() {
- URI me = toURI();
- IPath path = new Path(me.getPath());
- return path;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#getParent()
- */
- public IFileStore getParent() {
- IPath path = getPath();
- if (path.segmentCount() > 0) {
- try {
- return new DebugFileStore(new URI(getFileSystem().getScheme(), path.removeLastSegments(1).toString(), null));
- } catch (URISyntaxException e) {
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#openInputStream(int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
- byte[] contents = DebugFileSystem.getDefault().getContents(toURI());
- if (contents != null) {
- return new ByteArrayInputStream(contents);
- }
- throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests",
- "File does not exist: " + toURI()));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
- return new DebugOutputStream();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#mkdir(int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
- IFileInfo info = fetchInfo();
- if (info.exists()) {
- if (!info.isDirectory()) {
- throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests",
- "mkdir failed - file already exists with name: " + toURI()));
- }
- } else {
- IFileStore parent = getParent();
- if (parent.fetchInfo().exists()) {
- DebugFileSystem.getDefault().setContents(toURI(), DebugFileSystem.DIRECTORY_BYTES);
- } else {
- if ((options & EFS.SHALLOW) > 0) {
- throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests",
- "mkdir failed - parent does not exist: " + toURI()));
- } else {
- parent.mkdir(EFS.NONE, null);
- }
- }
- }
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#toURI()
- */
- public URI toURI() {
- return uri;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileStore#delete(int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void delete(int options, IProgressMonitor monitor) throws CoreException {
- DebugFileSystem.getDefault().delete(toURI());
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java
deleted file mode 100644
index d0a7183e4..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipe.debug.tests.launching;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileSystem;
-import org.eclipse.core.runtime.Path;
-
-/**
- * A simple in memory file system to test launch configurations in EFS
- */
-public class DebugFileSystem extends FileSystem {
-
- /**
- * represents a directory
- */
- public static final byte[] DIRECTORY_BYTES = new byte[] {1, 2, 3, 4};
-
- private static DebugFileSystem system;
-
- /**
- * Keys URIs to file stores for existing files
- */
- private Map files = new HashMap();
-
- /**
- * Constructs the singleton
- */
- public DebugFileSystem() {
- system = this;
- // create root of the file system
- try {
- setContents(new URI("debug", Path.ROOT.toString(), null), DIRECTORY_BYTES);
- } catch (URISyntaxException e) {}
- }
-
- /**
- * Returns the Debug files system.
- *
- * @return file system
- */
- static DebugFileSystem getDefault() {
- return system;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileSystem#getStore(java.net.URI)
- */
- public IFileStore getStore(URI uri) {
- return new DebugFileStore(uri);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileSystem#canDelete()
- */
- public boolean canDelete() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filesystem.provider.FileSystem#canWrite()
- */
- public boolean canWrite() {
- return true;
- }
-
- /**
- * Returns whether contents of the file or <code>null</code> if none.
- *
- * @param uri
- * @return bytes or <code>null</code>
- */
- public byte[] getContents(URI uri) {
- return (byte[]) files.get(uri);
- }
-
- /**
- * Deletes the file.
- *
- * @param uri
- */
- public void delete(URI uri) {
- files.remove(uri);
- }
-
- /**
- * Sets the content of the given file.
- *
- * @param uri
- * @param bytes
- */
- public void setContents(URI uri, byte[] bytes) {
- files.put(uri, bytes);
- }
-
- /**
- * Returns URIs of all existing files.
- *
- * @return
- */
- public URI[] getFileURIs() {
- return (URI[])files.keySet().toArray(new URI[files.size()]);
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
deleted file mode 100644
index 71d9ad534..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
+++ /dev/null
@@ -1,1051 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.launching;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileSystem;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationListener;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.core.LaunchManager;
-import org.eclipse.debug.tests.TestsPlugin;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests for launch configurations
- */
-public class LaunchConfigurationTests extends AbstractLaunchTest implements ILaunchConfigurationListener {
-
- /**
- * Identifier of test launch configuration type extension
- */
- public static final String ID_TEST_LAUNCH_TYPE = "org.eclipse.debug.tests.launch.type";
-
- /**
- * The from/to handles during rename operations
- */
- protected ILaunchConfiguration fFrom;
- protected ILaunchConfiguration fTo;
-
- protected Object fLock = new Object();
- protected ILaunchConfiguration fAdded;
- protected ILaunchConfiguration fRemoved;
-
- class Listener implements ILaunchConfigurationListener {
-
- private List addedList = new ArrayList();
- private List removedList = new ArrayList();
- private List changedList = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public void launchConfigurationAdded(ILaunchConfiguration configuration) {
- addedList.add(configuration);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public void launchConfigurationChanged(ILaunchConfiguration configuration) {
- changedList.add(configuration);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
- removedList.add(configuration);
- }
-
- public List getAdded() {
- return addedList;
- }
- public List getChanged() {
- return changedList;
- }
- public List getRemoved() {
- return removedList;
- }
-
- }
-
- /**
- * Constructor
- * @param name
- */
- public LaunchConfigurationTests(String name) {
- super(name);
- }
-
- /**
- * Returns a scratch project for launch configurations
- *
- * @return
- */
- protected IProject getProject() throws CoreException {
- return TestsPlugin.createProject("LaunchConfigurationTests");
- }
-
- /**
- * Creates and returns a new launch config the given name, local
- * or shared, with 4 attributes:
- * - String1 = "String1"
- * - Int1 = 1
- * - Boolean1 = true
- * - Boolean2 = false
- */
- protected ILaunchConfigurationWorkingCopy newConfiguration(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
- assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name);
- wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttribute("Int1", 1); //$NON-NLS-1$
- wc.setAttribute("Boolean1", true); //$NON-NLS-1$
- wc.setAttribute("Boolean2", false); //$NON-NLS-1$
- assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
- return wc;
- }
-
- /**
- * Creates and returns a new launch configuration with the given name, local
- * or shared, with no attributes
- */
- protected ILaunchConfigurationWorkingCopy newEmptyConfiguration(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name);
- assertEquals("Should have no attributes", 0, wc.getAttributes().size());
- return wc;
- }
-
- /**
- * Returns whether the given handle is contained in the specified
- * array of handles.
- */
- protected boolean existsIn(ILaunchConfiguration[] configs, ILaunchConfiguration config) {
- for (int i = 0; i < configs.length; i++) {
- if (configs[i].equals(config)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Creates a local working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes.
- *
- * @throws CoreException
- */
- public void testCreateLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$//$NON-NLS-2$
-
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Creates a local working copy configuration and tests its name.
- *
- * @throws CoreException
- */
- public void testLocalName() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "localName"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertEquals("Wrong name", handle.getName(), "localName"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Creates a shared working copy configuration and tests is name.
- */
- public void testSharedName() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "sharedName"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertEquals("Wrong name", handle.getName(), "sharedName"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Ensures that a launch configuration returns a complete attribute map
- * @throws CoreException
- */
- public void testGetAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- Map attributes = handle.getAttributes();
- // retrieve attributes
- assertEquals("String1 should be String1", "String1", attributes.get("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Int1 should be 1", new Integer(1), attributes.get("Int1")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Boolean1 should be true", Boolean.valueOf(true), attributes.get("Boolean1")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Boolean2 should be false", Boolean.valueOf(false), attributes.get("Boolean2")); //$NON-NLS-1$ //$NON-NLS-2$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Ensures that set attributes works
- * @throws CoreException
- */
- public void testSetAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- Map map = new HashMap();
- map.put("ATTR1", "ONE"); //$NON-NLS-1$ //$NON-NLS-2$
- map.put("ATTR2", "TWO"); //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttributes(map);
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- Map attributes = handle.getAttributes();
- assertEquals("should have two attributes", 2, attributes.size()); //$NON-NLS-1$
- // retrieve attributes
- assertEquals("ATTR1 should be ONE", "ONE", attributes.get("ATTR1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("ATTR2 should be TWO", "TWO", attributes.get("ATTR2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Ensures that set attributes to <code>null</code> works
- * @throws CoreException
- */
- public void testSetNullAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- wc.setAttributes(null);
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- Map attributes = handle.getAttributes();
- assertEquals("should have no attributes", 0, attributes.size()); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Creates a local working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes.
- * Copy the configuration and ensure the original still exists.
- * @throws CoreException
- */
- public void testLocalCopy() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configToCopy"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$
- assertNull("Original in copy should be null", softCopy.getOriginal()); //$NON-NLS-1$
- ILaunchConfiguration hardCopy = softCopy.doSave();
-
- // retrieve attributes
- assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- hardCopy.delete();
- assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$
- }
-
- /**
- * Create a config and save it twice, ensuring it only
- * ends up in the index once.
- * @throws CoreException
- */
- public void testDoubleSave() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configDoubleSave"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- String name = wc.getName();
- wc.rename("newName"); //$NON-NLS-1$
- wc.rename(name);
- assertTrue("Should be dirty", wc.isDirty()); //$NON-NLS-1$
- wc.doSave();
-
- ILaunchConfiguration[] newConfigs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Should be the same number of configs", newConfigs.length == configs.length); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
-
- }
-
- /**
- * Creates a local working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes. Deletes
- * the configuration and ensures it no longer exists.
- * @throws CoreException
- */
- public void testDeleteLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2delete"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- File file = wc.getLocation().toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // delete
- handle.delete();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
-
- // ensure handle is not in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
- }
-
- /**
- * Creates a local working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes. Renames
- * the configuration and ensures it's old config no longer exists,
- * and that attributes are retrievable from the new (renamed) config.
- * @throws CoreException
- */
- public void testRenameLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2rename"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // rename
- wc = handle.getWorkingCopy();
- wc.rename("config-2-rename"); //$NON-NLS-1$
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Moves a local configuration to a shared location
- * @throws CoreException
- */
- public void testMoveLocalToSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2share"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // move
- wc = handle.getWorkingCopy();
- wc.setContainer(getProject());
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Moves a local configuration to a shared location
- * @throws CoreException
- */
- public void testMoveSharedToLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2local"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // move
- wc = handle.getWorkingCopy();
- wc.setContainer(null);
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Creates a shared working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes.
- * @throws CoreException
- */
- public void testCreateSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Creates a shared working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes.
- * Copies the configuration and ensures the original still exists.
- * @throws CoreException
- */
- public void testSharedCopy() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2Copy"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- // copy
- ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$
- ILaunchConfiguration hardCopy = softCopy.doSave();
-
- // retrieve attributes
- assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- hardCopy.delete();
- assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$
- }
-
-
- /**
- * Creates a shared working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes. Deletes
- * the configuration and ensures it no longer exists.
- * @throws CoreException
- */
- public void testDeleteSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2delete"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // delete
- handle.delete();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
-
- // ensure handle is not in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
- }
-
- /**
- * Creates a shared working copy configuration, sets some attributes,
- * and saves the working copy, and retrieves the attributes. Renames
- * the configuration and ensures it's old config no longer exists,
- * and that attributes are retrievable from the new (renamed) config.
- * @throws CoreException
- */
- public void testRenameSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2rename"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // rename
- wc = handle.getWorkingCopy();
- wc.rename("shared-2-rename"); //$NON-NLS-1$
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Closes all editors in the active workbench page.
- */
- protected void closeAllEditors() {
- IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- activeWorkbenchWindow.getActivePage().closeAllEditors(false);
- }
-
- /**
- * Creates a few configs, closes the project and re-opens the
- * project to ensure the config index is persisted properly
- * @throws CoreException
- */
- public void testPersistIndex() throws CoreException {
- // close all editors before closing project: @see bug 204023
- closeAllEditors();
-
- ILaunchConfigurationWorkingCopy wc1 = newConfiguration(null, "persist1local"); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc2 = newConfiguration(getProject(), "persist2shared"); //$NON-NLS-1$
- ILaunchConfiguration lc1 = wc1.doSave();
- ILaunchConfiguration lc2 = wc2.doSave();
-
- IProject project = getProject();
- ILaunchConfiguration[] before = getLaunchManager().getLaunchConfigurations();
- assertTrue("config should be in index", existsIn(before, lc1)); //$NON-NLS-1$
- assertTrue("config should be in index", existsIn(before, lc2)); //$NON-NLS-1$
-
- project.close(null);
- ILaunchConfiguration[] during = getLaunchManager().getLaunchConfigurations();
- boolean local = true;
- for (int i = 0; i < during.length; i++) {
- // must be local, or not from the closed project
- local = local && (during[i].isLocal() || !during[i].getFile().getProject().equals(project));
- }
- project.open(null);
- assertTrue("Should only be local configs when closed", local); //$NON-NLS-1$
- ILaunchConfiguration[] after = getLaunchManager().getLaunchConfigurations();
- assertTrue("Should be same number of configs after openning", after.length == before.length); //$NON-NLS-1$
- for (int i = 0; i < before.length; i++) {
- assertTrue("Config should exist after openning", existsIn(after, before[i])); //$NON-NLS-1$
- }
-
- // cleanup
- lc1.delete();
- assertTrue("Config should not exist after deletion", !lc1.exists()); //$NON-NLS-1$
- lc2.delete();
- assertTrue("Config should not exist after deletion", !lc2.exists()); //$NON-NLS-1$
-
-
- }
-
-
- /**
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public void launchConfigurationAdded(ILaunchConfiguration configuration) {
- fFrom = getLaunchManager().getMovedFrom(configuration);
- synchronized (fLock) {
- fAdded = configuration;
- fLock.notifyAll();
- }
- }
-
- /**
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public void launchConfigurationChanged(ILaunchConfiguration configuration) {
- }
-
- /**
- * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
- */
- public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
- fTo = getLaunchManager().getMovedTo(configuration);
- synchronized (fLock) {
- fRemoved = configuration;
- fLock.notifyAll();
- }
- }
-
- protected void addConfigListener() {
- getLaunchManager().addLaunchConfigurationListener(this);
- }
-
- protected void removeConfigListener() {
- getLaunchManager().removeLaunchConfigurationListener(this);
- }
-
- /**
- * Ensures that a removal notification is sent for a shared config in a project
- * that is deleted.
- *
- * @throws Exception
- */
- public void testDeleteProjectWithSharedConfig() throws Exception {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("DeleteSharedConfig"); //$NON-NLS-1$
- try {
- assertFalse("project should not exist yet", project.exists()); //$NON-NLS-1$
- project.create(null);
- assertTrue("project should now exist", project.exists()); //$NON-NLS-1$
- project.open(null);
- assertTrue("project should be open", project.isOpen()); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc = newConfiguration(project, "ToBeDeleted"); //$NON-NLS-1$
-
- addConfigListener();
- ILaunchConfiguration configuration = wc.doSave();
- assertEquals(configuration, fAdded);
-
- synchronized (fLock) {
- fRemoved = null;
- project.delete(true, false, null);
- if (fRemoved == null) {
- fLock.wait(10000);
- }
- }
- assertEquals(configuration, fRemoved);
- } finally {
- if (project.exists()) {
- project.delete(true, false, null);
- }
- removeConfigListener();
- }
- }
-
- /**
- * Tests a nested working copy.
- *
- * @throws CoreException
- */
- public void testNestedWorkingCopyLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config123"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- // get a working copy
- wc = handle.getWorkingCopy();
- ILaunchConfigurationWorkingCopy nested = wc.getWorkingCopy();
-
- // verify nested is same as original
- assertEquals("String1 should be String1", nested.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Int1 should be 1", nested.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", nested.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !nested.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // change an attribute in the nested working copy
- nested.setAttribute("String1", "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Wrong attribute value", nested.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // save back to parent
- ILaunchConfigurationWorkingCopy parent = nested.getParent();
- assertEquals("Wrong parent", wc, parent); //$NON-NLS-1$
- assertNull("Should have no parent", wc.getParent()); //$NON-NLS-1$
- nested.doSave();
- assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // check originals
- assertEquals("Wrong original config" , handle, wc.getOriginal()); //$NON-NLS-1$
- assertEquals("Wrong original config" , handle, nested.getOriginal()); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Creates a configuration in an EFS linked folder. Deletes configuration directly.
- *
- * @throws CoreException
- * @throws URISyntaxException
- */
- public void testCreateDeleteEFS() throws CoreException, URISyntaxException {
- IFileSystem fileSystem = EFS.getFileSystem("debug");
- assertNotNull("Missing debug EFS", fileSystem);
-
- // create folder in EFS
- IFolder folder = getProject().getFolder("efs");
- folder.createLink(new URI("debug", Path.ROOT.toString(), null), 0, null);
-
- // create configuration
- ILaunchConfigurationWorkingCopy wc = newConfiguration(folder, "efsConfig"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // delete configuration
- handle.delete();
- assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$
-
- // cleanup
- folder.delete(IResource.NONE, null);
- }
-
- /**
- * Creates a configuration in an EFS linked folder. Deletes the folder to ensure the
- * configuration is also deleted.
- *
- * @throws CoreException
- * @throws URISyntaxException
- */
- public void testCreateDeleteEFSLink() throws CoreException, URISyntaxException {
- IFileSystem fileSystem = EFS.getFileSystem("debug");
- assertNotNull("Missing debug EFS", fileSystem);
-
- // create folder in EFS
- IFolder folder = getProject().getFolder("efs2");
- folder.createLink(new URI("debug", Path.ROOT.toString(), null), 0, null);
-
- // create configuration
- ILaunchConfigurationWorkingCopy wc = newConfiguration(folder, "efsConfig"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // cleanup
- folder.delete(IResource.NONE, null);
- assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$
- }
-
- /**
- * Test that renaming a project with a linked EFS folder containing a shared
- * launch configuration is properly updated.
- *
- * @throws Exception
- */
- public void testEFSProjectRename() throws Exception {
- // create test project
- IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("RenameEFS");
- if (pro.exists()) {
- pro.delete(true, true, null);
- }
- // create project
- IProject project = TestsPlugin.createProject("RenameEFS");
-
- IFileSystem fileSystem = EFS.getFileSystem("debug");
- assertNotNull("Missing debug EFS", fileSystem);
-
- // create folder in EFS
- IFolder folder = project.getFolder("efs2");
- folder.createLink(new URI("debug", Path.ROOT.toString(), null), 0, null);
-
- // create configuration
- ILaunchConfigurationWorkingCopy wc = newConfiguration(folder, "efsConfig"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // rename project
- IProjectDescription description = project.getDescription();
- description.setName("SFEemaneR"); // reverse name
- project.move(description, false, null);
-
- // original configuration should no longer exist - handle out of date
- assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$
-
- // get the new handle
- project = ResourcesPlugin.getWorkspace().getRoot().getProject("SFEemaneR");
- assertTrue("Project should exist", project.exists());
- IFile file = project.getFile(new Path("efs2/efsConfig.launch"));
- assertTrue("launch config file should exist", file.exists());
- handle = getLaunchManager().getLaunchConfiguration(file);
- assertTrue("launch config should exist", handle.exists());
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // validate shared location
- assertEquals("Shared location should be updated", file, handle.getFile());
-
- // cleanup
- project.delete(IResource.NONE, null);
- assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$
-
- }
-
- /**
- * Tests launch configuration import.
- *
- * @throws Exception
- */
- public void testImport() throws Exception {
- // create a shared configuration "Import4" in the workspace to be overwritten on import
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "Import4"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- File dir = TestsPlugin.getDefault().getFileInPlugin(new Path("test-import"));
- assertTrue("Import directory does not exist", dir.exists());
- LaunchManager manager = (LaunchManager) getLaunchManager();
-
- Listener listener = new Listener();
- try {
- getLaunchManager().addLaunchConfigurationListener(listener);
- // import
- manager.importConfigurations(dir.listFiles(
- new FileFilter() {
- public boolean accept(File file) {
- return file.isFile() &&
- file.getName().endsWith(
- ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
- }
- }),
- null);
-
- // should be one removed
- List removed = listener.getRemoved();
- assertEquals("Should be one removed config", 1, removed.size());
- assertTrue("Import4 should be removed", removed.contains(handle));
-
- // should be 5 added
- List added = listener.getAdded();
- assertEquals("Should be 5 added configs", 5, added.size());
- Set names = new HashSet();
- Iterator iterator = added.iterator();
- while (iterator.hasNext()) {
- ILaunchConfiguration lc = (ILaunchConfiguration) iterator.next();
- names.add(lc.getName());
- }
- assertTrue("Missing Name", names.contains("Import1"));
- assertTrue("Missing Name", names.contains("Import2"));
- assertTrue("Missing Name", names.contains("Import3"));
- assertTrue("Missing Name", names.contains("Import4"));
- assertTrue("Missing Name", names.contains("Import5"));
-
- // should be one changed
- List changed = listener.getChanged();
- assertEquals("Should be 1 changed config", 1, changed.size());
- assertEquals("Wrong changed config", "Import4", ((ILaunchConfiguration)changed.get(0)).getName());
- } finally {
- manager.removeLaunchConfigurationListener(listener);
- }
-
- }
-
- /**
- * Tests the location of a local working copy.
- *
- * @throws CoreException
- */
- public void testWorkingCopyGetLocation() throws CoreException {
- ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-get-location");
- IPath location = workingCopy.getLocation();
- assertEquals("Wrong path for local working copy", LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append("test-get-location.launch"), location);
- }
-
-}
-
-
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchHistoryTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchHistoryTests.java
deleted file mode 100644
index d7b1ed70f..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchHistoryTests.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipe.debug.tests.launching;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
-import org.eclipse.debug.ui.IDebugUIConstants;
-
-/**
- * Test the utilization of launch histories: sizing, ordering, completeness and correctness
- *
- * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory
- * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager
- * @see org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener
- * @see org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction
- *
- * @since 3.3
- */
-public class LaunchHistoryTests extends AbstractLaunchTest {
-
- /**
- * Constructor
- * @param name
- */
- public LaunchHistoryTests(String name) {
- super(name);
- }
-
- /**
- * Returns the run launch history
- * @return
- */
- private LaunchHistory getRunLaunchHistory() {
- return getLaunchConfigurationManager().getLaunchHistory(IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
- }
-
- /**
- * Returns the maximum allowed size of the launch histories
- * @return the maximum size of the launch histories
- */
- private int getMaxHistorySize() {
- return DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_HISTORY_SIZE);
- }
-
- /**
- * Sets the maximum size of the launch history to the specified value
- * @param value the new maximum size for launch histories
- */
- private void setMaxHistorySize(int value) {
- DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugUIConstants.PREF_MAX_HISTORY_SIZE, value);
- }
-
- /**
- * Returns the debug launch history
- * @return
- */
- private LaunchHistory getDebugLaunchHistory() {
- return getLaunchConfigurationManager().getLaunchHistory(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP);
- }
-
- /**
- * This method tests that an item added to the history is added to the head of
- * history.
- */
- public void testHistoryAddition() throws CoreException {
- LaunchHistory runhistory = getRunLaunchHistory();
- assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$
- ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- }
-
- /**
- * As both the run and the debug launch histories will accept a java application
- * launch config, both launch histories should contain the test launch configuration
- * and it should be the recent launch for both of them
- */
- public void testHistoriesInSync() throws CoreException {
- LaunchHistory runhistory = getRunLaunchHistory();
- assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$
- LaunchHistory debughistory = getDebugLaunchHistory();
- assertNotNull("the debug launch history should not be null", debughistory); //$NON-NLS-1$
- ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("the run history should contain LaunchHistoryTest", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("the run recent launch should be LaunchHistoryTest", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- assertTrue("the debug history should contain LaunchHistoryTest", debughistory.contains(config)); //$NON-NLS-1$
- assertEquals("the debug recent launch should be LaunchHistoryTest", debughistory.getRecentLaunch(), config); //$NON-NLS-1$
- }
-
- /**
- * If we launch config A, then config B, and then config A again, A should be the most recent launch
- */
- public void testHistoryReodering() throws CoreException {
- LaunchHistory runhistory = getRunLaunchHistory();
- assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$
- ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- config = getLaunchConfiguration("LaunchHistoryTest2"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest2 launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest2 config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest2", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- }
-
- /**
- * If we rename a launch configuration it should not effect the launch history if the renamed configuration
- * is present in the history.
- */
- public void testRenameConfigHistoryUpdate() throws CoreException {
- LaunchHistory runhistory = getRunLaunchHistory();
- assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$
- ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
- copy.rename("RenamedLaunchHistoryItem"); //$NON-NLS-1$
- config = copy.doSave();
- assertEquals("the renamed config should still be the first on in the history", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
-
- //rename the configuration back to what it was
- copy = config.getWorkingCopy();
- copy.rename("LaunchHistoryTest"); //$NON-NLS-1$
- config = copy.doSave();
- }
-
- /**
- * If we delete a launch configuration and the configuration is present in the launch history, it should be removed
- * from the history and the history should be shifted up one place.
- */
- public void testDeleteLaunchConfigurationHistoryUpdate() throws CoreException {
- LaunchHistory runhistory = getRunLaunchHistory();
- assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$
- ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- config = getLaunchConfiguration("LaunchHistoryTest2"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest2 launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("The run history should contain the LaunchHistoryTest2 config", runhistory.contains(config)); //$NON-NLS-1$
- assertEquals("The most recent launch should be LaunchHistoryTest2", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- config.delete();
- config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertEquals("the run history should have LaunchHistoryTest as the recent launch after delete", runhistory.getRecentLaunch(), config); //$NON-NLS-1$
- }
-
- /**
- * Tests that setting the size of the launch history appropriately changes what will be returned
- * when the history is queried for it contents
- */
- public void testLaunchHistorySize() throws CoreException {
- LaunchHistory runhistory = getRunLaunchHistory();
- assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$
- int oldsize = getMaxHistorySize();
- setMaxHistorySize(2);
- assertTrue("the maximum history size should be 2", getMaxHistorySize() == 2); //$NON-NLS-1$
- ILaunchConfiguration config = getLaunchConfiguration("LaunchHistoryTest"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- config = getLaunchConfiguration("LaunchHistoryTest2"); //$NON-NLS-1$
- assertNotNull("LaunchHistoryTest2 launch config should not be null", config); //$NON-NLS-1$
- config.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- assertTrue("there should only be two items in the history", runhistory.getHistory().length == getMaxHistorySize()); //$NON-NLS-1$
- assertTrue("the complete launch history should be greater than or equal to the history size", runhistory.getCompleteLaunchHistory().length >= runhistory.getHistory().length); //$NON-NLS-1$
-
- //reset the history size
- setMaxHistorySize(oldsize);
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java
deleted file mode 100644
index 842092b64..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.eclipe.debug.tests.launching;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.internal.core.LaunchManager;
-
-/**
- *
- * Variety of tests for the {@link org.eclipse.debug.internal.core.LaunchManager}
- *
- * @since 3.6
- */
-public class LaunchManagerTests extends AbstractLaunchTest {
-
- /**
- * Constructor
- * @param name
- */
- public LaunchManagerTests(String name) {
- super(name);
- }
-
- /**
- * Tests generating a valid launch configuration name
- */
- public void testGenereateConfigName() {
- String configname = "launch_configuration";
- String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname);
- assertTrue("the name nust be '"+configname+"'", name.equals(configname));
- }
-
- /**
- * Tests generating a launch configuration name with an unsupported char using
- * the deprecated method
- */
- public void testGenereateConfigNameBadChar() {
- String configname = "config:name";
- String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname);
- assertEquals("config name should be '"+configname+"'", configname, name);
- }
-
- /**
- * Tests generating a launch configuration name using a name that is an OS reserved
- * name. Win 32 test only.
- */
- public void testGenerateConfigNameReservedName() {
- if(Platform.OS_WIN32.equals(Platform.getOS())) {
- String configname = "aux";
- String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname);
- assertEquals("config name should be '"+configname+"'", configname, name);
- }
- }
-
- /**
- * Tests generating a configuration name that contains an invalid character
- */
- public void testGenerateBadConfigName() {
- String configname = "config:name";
- String name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be 'config_name'", "config_name", name);
- }
-
- /**
- * Tests generating a name that conflicts with an OS reserved name. This test is for windows only as there
- * are no reserved names on other OS's.
- */
- public void testGenerateConflictingName() {
- if(Platform.OS_WIN32.equals(Platform.getOS())) {
- String configname = "aux";
- String name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be 'launch_configuration'", "launch_configuration", name);
- }
- }
-
- /**
- * Tests generating a configuration name that contains an invalid character and where there
- * is another config with the replaced name already
- */
- public void testGenerateBadCharConflict() throws Exception {
- String configname = "config:name";
- String name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be 'config_name'", "config_name", name);
- getLaunchConfiguration(name);
- name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be 'config_name (1)'", "config_name (1)", name);
- ILaunchConfiguration config = getLaunchConfiguration("config_name");
- config.delete();
- }
-
- /**
- * Tests generating a name that conflicts with an OS reserved name and that
- * there is a config with the replaced name already. This test is for windows only as there
- * are no reserved names on other OS's.
- */
- public void testGenerateBadNameConflict() throws Exception {
- if(Platform.OS_WIN32.equals(Platform.getOS())) {
- String configname = "com2";
- String name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be 'launch_configuration'", "launch_configuration", name);
- getLaunchConfiguration(name);
- name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be 'launch_configuration (1)'", "launch_configuration (1)", name);
- ILaunchConfiguration config = getLaunchConfiguration("launch_configuration");
- config.delete();
- }
- }
-
- /**
- * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness
- */
- public void testValidateConfigGoodName() {
- String configname = "configname";
- try {
- getLaunchManager().isValidLaunchConfigurationName(configname);
- }
- catch(IllegalArgumentException iae) {
- fail("the config name should not have thrown an exception during validation");
- }
- }
-
- /**
- * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness
- */
- public void testValidateConfigBadCharName() {
- String configname = "config:name";
- try {
- getLaunchManager().isValidLaunchConfigurationName(configname);
- }
- catch(IllegalArgumentException iae) {
- return;
- }
- fail("the config name should have thrown an exception during validation");
- }
-
- /**
- * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness
- */
- public void testValidateConfigBadName() {
- if(Platform.OS_WIN32.equals(Platform.getOS())) {
- String configname = "com1";
- try {
- getLaunchManager().isValidLaunchConfigurationName(configname);
- }
- catch(IllegalArgumentException iae) {
- return;
- }
- fail("the config name should have thrown an exception during validation");
- }
- }
-
- /**
- * Tests that generating a configuration name when there exists a configuration with that name
- * already properly updates a '(N)' counter at the end
- */
- public void testGenerateNameExistingConfig() throws Exception {
- String configname = "x.y.z.configname";
- getLaunchConfiguration(configname);
- String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname);
- assertEquals("the configuration name should have been "+configname+" (1)", configname+" (1)", name);
- getLaunchConfiguration(name);
- name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name);
- assertEquals("the configuration name should have been "+configname+" (2)", configname+" (2)", name);
- ILaunchConfiguration config = getLaunchConfiguration(configname);
- if(config != null) {
- config.delete();
- }
- config = getLaunchConfiguration(configname +" (1)");
- if(config != null) {
- config.delete();
- }
- }
-
- /**
- * Tests that removing an accelerator properly removes it without affecting the base string (readable) value
- */
- public void testRemoveAcc() {
- String text = "&Remove";
- String label = LaunchManager.removeAccelerators(text);
- assertEquals("the label should be 'Remove'", "Remove", label);
- text = "Remo&ve";
- label = LaunchManager.removeAccelerators(text);
- assertEquals("the label should be 'Remove'", "Remove", label);
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/RefreshTabTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/RefreshTabTests.java
deleted file mode 100644
index 900e4d066..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/RefreshTabTests.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.launching;
-
-import java.io.ByteArrayInputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.RefreshUtil;
-import org.eclipse.debug.internal.core.RefreshScopeComparator;
-import org.eclipse.debug.tests.TestsPlugin;
-import org.eclipse.debug.ui.RefreshTab;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests the refresh tab.
- */
-public class RefreshTabTests extends AbstractLaunchTest {
-
- /**
- * Constructor
- * @param name
- */
- public RefreshTabTests(String name) {
- super(name);
- }
-
- /**
- * Sets the selected resource in the navigator view.
- *
- * @param resource resource to select
- */
- protected void setSelection(IResource resource) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- assertNotNull("The active workbench page should not be null", page);
- IViewPart part;
- try {
- part = page.showView("org.eclipse.ui.views.ResourceNavigator");
- IWorkbenchPartSite site = part.getSite();
- assertNotNull("The part site for org.eclipse.ui.views.ResourceNavigator should not be null ", site);
- ISelectionProvider provider = site.getSelectionProvider();
- assertNotNull("the selection provider should not be null for org.eclipse.ui.views.ResourceNavigator", provider);
- provider.setSelection(new StructuredSelection(resource));
- } catch (PartInitException e) {
- assertNotNull("Failed to open navigator view", null);
- }
- }
-
- /**
- * Tests a refresh scope of the selected resource
- * @throws CoreException
- */
- public void testSelectedResource() throws CoreException {
- String scope = "${resource}";
- IResource resource = getProject().getFolder("src");
- setSelection(resource);
- IResource[] result = RefreshTab.getRefreshResources(scope);
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(resource, result[0]);
- }
-
- /**
- * Tests a refresh scope of the selected resource's container
- * @throws CoreException
- */
- public void testSelectionsFolder() throws CoreException {
- String scope = "${container}";
- IResource resource = getProject().getFolder("src");
- setSelection(resource);
- IResource[] result = RefreshTab.getRefreshResources(scope);
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(resource.getParent(), result[0]);
- }
-
- /**
- * Tests a refresh scope of the selected resource's project
- * @throws CoreException
- */
- public void testSelectionsProject() throws CoreException {
- String scope = "${project}";
- IResource resource = getProject().getFolder("src");
- setSelection(resource);
- IResource[] result = RefreshTab.getRefreshResources(scope);
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(resource.getProject(), result[0]);
- }
-
- /**
- * Tests a refresh scope of the selected resource's project
- * @throws CoreException
- */
- public void testWorkspaceScope() throws CoreException {
- String scope = "${workspace}";
- IResource[] result = RefreshTab.getRefreshResources(scope);
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(ResourcesPlugin.getWorkspace().getRoot(), result[0]);
- }
-
- /**
- * Tests a refresh scope for a specific resource (old format)
- * @throws CoreException
- */
- public void testSpecificResource() throws CoreException {
- String scope = "${resource:/RefreshTabTests/some.file}";
- IResource resource = getProject().getFile("some.file");
- IResource[] result = RefreshTab.getRefreshResources(scope);
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(resource, result[0]);
- }
-
- /**
- * Tests a refresh scope for a working set
- * @throws CoreException
- */
- public void testWorkingSet() throws CoreException {
- String scope= "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<launchConfigurationWorkingSet factoryID=\"org.eclipse.ui.internal.WorkingSetFactory\" name=\"workingSet\" editPageId=\"org.eclipse.ui.resourceWorkingSetPage\">\n<item factoryID=\"org.eclipse.ui.internal.model.ResourceFactory\" path=\"/RefreshTabTests/some.file\" type=\"1\"/>\n</launchConfigurationWorkingSet>}"; //$NON-NLS-1$
- IResource resource = getProject().getFile("some.file");
- IResource[] result = RefreshTab.getRefreshResources(scope);
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(resource, result[0]);
- }
-
- /**
- * Returns a scratch project for launch configurations
- *
- * @return
- */
- protected IProject getProject() throws CoreException {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IProject project= root.getProject("RefreshTabTests");
- if (!project.exists()) {
- project = TestsPlugin.createProject("RefreshTabTests");
- IFolder folder = project.getFolder("src");
- folder.create(false, true, null);
- IFile file = project.getFile("some.file");
- file.create(new ByteArrayInputStream("test file".getBytes()), false, null);
- }
- return project;
- }
-
- /**
- * Tests the launch configuration attribute comparator extension for comparing
- * old/new attribute styles.
- *
- * @throws CoreException
- */
- public void testRefreshScopeComparator() throws CoreException {
- String oldStyle = "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<launchConfigurationWorkingSet factoryID=\"org.eclipse.ui.internal.WorkingSetFactory\" name=\"workingSet\" editPageId=\"org.eclipse.ui.resourceWorkingSetPage\">\n<item factoryID=\"org.eclipse.ui.internal.model.ResourceFactory\" path=\"/RefreshTabTests/some.file\" type=\"1\"/>\n</launchConfigurationWorkingSet>}"; //$NON-NLS-1$
- String newStyle = "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<resources>\n<item path=\"/RefreshTabTests/some.file\" type=\"1\"/>\n</resources>}";
- assertEquals("Comparator should return 0", 0, new RefreshScopeComparator().compare(oldStyle, newStyle));
- }
-
- /**
- * Tests persist restore of some resources.
- *
- * @throws CoreException
- */
- public void testResourceMemento() throws CoreException {
- IResource[] resources = new IResource[]{getProject(), getProject().getFile("not.exist"), getProject().getFile("some.file")};
- String memento = RefreshUtil.toMemento(resources);
- IResource[] restore = RefreshUtil.toResources(memento);
- assertEquals(resources.length, restore.length);
- assertEquals(resources[0], restore[0]);
- assertEquals(resources[1], restore[1]);
- assertEquals(resources[2], restore[2]);
- }
-
- /**
- * Tests persist/restore of empty resource collection.
- *
- * @throws CoreException
- */
- public void testEmptyResourceSet() throws CoreException {
- String memento = RefreshUtil.toMemento(new IResource[]{});
- IResource[] resources = RefreshUtil.toResources(memento);
- assertNotNull(resources);
- assertEquals("Should be empty", 0, resources.length);
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java
deleted file mode 100644
index 54994d369..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.eclipe.debug.tests.launching;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
-
-/**
- * An empty lauch delegate
- */
-public class TestLaunchDelegate extends LaunchConfigurationDelegate {
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- // do nothing
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java
deleted file mode 100644
index 0bf6f5c5e..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-import org.eclipse.debug.core.model.IMemoryBlock;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.memory.AbstractMemoryRenderingBindingsProvider;
-import org.eclipse.debug.ui.memory.IMemoryRenderingType;
-
-/**
- * Contributed dynamic rendernig bindings.
- * @since 3.1
- */
-public class DynamicRenderingBindings extends AbstractMemoryRenderingBindingsProvider {
-
- //
- private static DynamicRenderingBindings fgSingleton = null;
-
- // id of rendering type bound by this provider
- private String fId = "rendering_type_1";
-
- /**
- * Constructor
- */
- public DynamicRenderingBindings() {
- fgSingleton = this;
- }
-
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public IMemoryRenderingType[] getRenderingTypes(IMemoryBlock block) {
- return new IMemoryRenderingType[]{getPrimaryRenderingType(block)};
- }
-
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getDefaultRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public IMemoryRenderingType[] getDefaultRenderingTypes(IMemoryBlock block) {
- return new IMemoryRenderingType[]{getPrimaryRenderingType(block)};
- }
-
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getPrimaryRenderingType(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public IMemoryRenderingType getPrimaryRenderingType(IMemoryBlock block) {
- return DebugUITools.getMemoryRenderingManager().getRenderingType(fId);
- }
-
- /**
- * Sets the current rendering bound to this provider, and notifies
- * listeners of the change.
- *
- * @param id rendering id
- */
- public static void setBinding(String id) {
- fgSingleton.fId = id;
- fgSingleton.fireBindingsChanged();
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java
deleted file mode 100644
index d9705418f..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IMemoryBlock;
-
-/**
- * Dummy memory block implementation.
- *
- * @since 3.1
- */
-public class MemoryBlock implements IMemoryBlock {
-
- /**
- * @see org.eclipse.debug.core.model.IMemoryBlock#getStartAddress()
- */
- public long getStartAddress() {
- return 0;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IMemoryBlock#getLength()
- */
- public long getLength() {
- return 100;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IMemoryBlock#getBytes()
- */
- public byte[] getBytes() throws DebugException {
- byte[] bytes = new byte[(int)getLength()];
- for (int i = 0; i < bytes.length; i++) {
- bytes[i] = (byte)i;
- }
- return bytes;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IMemoryBlock#supportsValueModification()
- */
- public boolean supportsValueModification() {
- return false;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IMemoryBlock#setValue(long, byte[])
- */
- public void setValue(long offset, byte[] bytes) throws DebugException {
-
- }
-
- /**
- * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
- */
- public String getModelIdentifier() {
- return "no.debugger";
- }
-
- /**
- * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
- */
- public IDebugTarget getDebugTarget() {
- return null;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
- */
- public ILaunch getLaunch() {
- return null;
- }
-
- /**
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- return null;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockDynamic.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockDynamic.java
deleted file mode 100644
index 53ffe59ca..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockDynamic.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-
-/**
- * Dummy memory block
- *
- * @since 3.1
- */
-public class MemoryBlockDynamic extends MemoryBlock {
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockOne.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockOne.java
deleted file mode 100644
index 06a07fafa..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockOne.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-
-/**
- * Dummy memory block
- *
- * @since 3.1
- */
-public class MemoryBlockOne extends MemoryBlock {
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockThree.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockThree.java
deleted file mode 100644
index 81ac323c1..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockThree.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-
-/**
- * Dummy memory block
- *
- * @since 3.1
- */
-public class MemoryBlockThree extends MemoryBlock {
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockTwo.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockTwo.java
deleted file mode 100644
index 63c22c7d0..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlockTwo.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-
-/**
- * Dummy memory block
- *
- * @since 3.1
- */
-public class MemoryBlockTwo extends MemoryBlock {
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java
deleted file mode 100644
index 448c7ef68..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.core.model.IMemoryBlock;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.memory.IMemoryRenderingBindingsListener;
-import org.eclipse.debug.ui.memory.IMemoryRenderingManager;
-import org.eclipse.debug.ui.memory.IMemoryRenderingType;
-
-/**
- * Tests memory rendering manager
- */
-public class MemoryRenderingTests extends TestCase {
-
- public MemoryRenderingTests(String name) {
- super(name);
- }
-
- public void testRenderingTypes() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryRenderingType[] types = manager.getRenderingTypes();
- assertTrue("Wrong number of rendering types contributed", types.length > 6);
- assertTrue("Missing type 1", indexOf(manager.getRenderingType("rendering_type_1"), types) >= 0);
- assertTrue("Missing type 2", indexOf(manager.getRenderingType("rendering_type_2"), types) >= 0);
- assertTrue("Missing type 3", indexOf(manager.getRenderingType("rendering_type_3"), types) >= 0);
- assertTrue("Missing type", indexOf(manager.getRenderingType("org.eclipse.debug.ui.rendering.raw_memory"), types) >= 0);
- assertTrue("Missing type", indexOf(manager.getRenderingType("org.eclipse.debug.ui.rendering.ascii"), types) >= 0);
- assertTrue("Missing type", indexOf(manager.getRenderingType("org.eclipse.debug.ui.rendering.signedint"), types) >= 0);
- assertTrue("Missing type", indexOf(manager.getRenderingType("org.eclipse.debug.ui.rendering.unsignedint"), types) >= 0);
- }
-
- public void testRenderingTypeNames() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryRenderingType type = manager.getRenderingType("rendering_type_1");
- assertEquals("Wrong name", "Rendering One", type.getLabel());
- type = manager.getRenderingType("rendering_type_2");
- assertEquals("Wrong name", "Rendering Two", type.getLabel());
- }
-
- public void testSingleBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockOne();
- IMemoryRenderingType[] types = manager.getRenderingTypes(block);
- assertEquals("Wrong number of bindings", 1, types.length);
- assertEquals("Wrong binding", "rendering_type_1", types[0].getId());
- }
-
- public void testDoubleBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockTwo();
- IMemoryRenderingType[] types = manager.getRenderingTypes(block);
- assertEquals("Wrong number of bindings", 2, types.length);
- assertTrue("Missing binding", indexOf(manager.getRenderingType("rendering_type_1"), types) >= 0);
- assertTrue("Missing binding", indexOf(manager.getRenderingType("rendering_type_2"), types) >= 0);
- }
-
- public void testDefaultBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockOne();
- IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
- assertEquals("Wrong number of bindings", 1, types.length);
- assertEquals("Wrong binding", "rendering_type_1", types[0].getId());
- }
-
- public void testNoDefaultBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockTwo();
- IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
- assertEquals("Wrong number of bindings", 0, types.length);
- }
-
- public void testPrimaryBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockOne();
- IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
- assertEquals("Wrong binding", "rendering_type_1", type.getId());
- }
-
- public void testNoPrimaryBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockTwo();
- IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
- assertNull("Wrong binding", type);
- }
-
- public void testDefaultWithoutPrimaryBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockThree();
- IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
- assertEquals("Wrong number of bindings", 1, types.length);
- assertEquals("Wrong binding", "rendering_type_3", types[0].getId());
- }
-
- public void testDynamicBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockDynamic();
- IMemoryRenderingType[] types = manager.getRenderingTypes(block);
- assertEquals("Wrong number of bindings", 1, types.length);
- assertEquals("Wrong binding", "rendering_type_1", types[0].getId());
- types = manager.getDefaultRenderingTypes(block);
- assertEquals("Wrong number of bindings", 1, types.length);
- assertEquals("Wrong binding", "rendering_type_1", types[0].getId());
- IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
- assertEquals("Wrong bindings", manager.getRenderingType("rendering_type_1"), type);
- }
-
- public void testBindingChangeNotification() {
- final boolean[] changed = new boolean[1];
- IMemoryRenderingBindingsListener listener = new IMemoryRenderingBindingsListener() {
- public void memoryRenderingBindingsChanged() {
- changed[0] = true;
- }
- };
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- try {
- manager.addListener(listener);
- assertFalse("Renderings should not have changed yet", changed[0]);
- DynamicRenderingBindings.setBinding("rendering_type_2");
- assertTrue("Renderings should have changed", changed[0]);
- IMemoryBlock block = new MemoryBlockDynamic();
- IMemoryRenderingType[] types = manager.getRenderingTypes(block);
- assertEquals("Wrong number of bindings", 1, types.length);
- assertEquals("Wrong binding", "rendering_type_2", types[0].getId());
- } finally {
- // restore original bindings
- DynamicRenderingBindings.setBinding("rendering_type_1");
- manager.removeListener(listener);
- }
- }
-
- protected int indexOf(Object thing, Object[] list) {
- for (int i = 0; i < list.length; i++) {
- Object object2 = list[i];
- if (object2.equals(thing)) {
- return i;
- }
- }
- return -1;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java
deleted file mode 100644
index b4f9a70be..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.eclipe.debug.tests.view.memory;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.ui.memory.IMemoryRendering;
-import org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate;
-
-/**
- * Test memory rendering type delegate.
- *
- * @since 3.1
- */
-public class RenderingTypeDelegate implements IMemoryRenderingTypeDelegate {
-
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate#createRendering(java.lang.String)
- */
- public IMemoryRendering createRendering(String id) throws CoreException {
- return null;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java
deleted file mode 100644
index 1d0816d3e..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests which verify the check box support. This test is very similar to the
- * content test except that the extending class should create a viewer with
- * the SWT.CHECK style enabled. <br>
- * Most of the check box verification is performed in the test model.
- *
- * @since 3.6
- */
-abstract public class CheckTests extends TestCase {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public CheckTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- public void testSimpleSingleLevel() {
- // Create the model with test data
- TestModel model = TestModel.simpleSingleLevel();
-
- // Make sure that all elements are expanded
- fViewer.setAutoExpandLevel(-1);
-
- // Create the agent which forces the tree to populate
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- // Create the listener which determines when the view is finished updating.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the viewer input (and trigger updates).
- fViewer.setInput(model.getRootElement());
-
- // Wait for the updates to complete.
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testSimpleMultiLevel() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
-
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- fViewer.setInput(model.getRootElement());
-
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- // TODO: no idea how to trigger a toggle event on an item
-// public void testCheckReceiver() {
-// // Initial setup
-// TestModel model = TestModel.simpleSingleLevel();
-// fViewer.setAutoExpandLevel(-1);
-// //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-// fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-// fViewer.setInput(model.getRootElement());
-//
-// // Wait for the updates to complete and validate.
-// while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-// model.validateData(fViewer, TreePath.EMPTY);
-//
-// InternalTreeModelViewer treeViewer = ((InternalTreeModelViewer)fViewer);
-// TreePath elementPath = model.findElement("1");
-// TestElement element = model.getElement(elementPath);
-// boolean initialCheckState = element.getChecked();
-// Event event = new Event();
-// event.item = treeViewer.findItem(elementPath);
-// event.detail = SWT.CHECK;
-// event.display = fDisplay;
-// event.type = SWT.Selection;
-// event.widget = treeViewer.getControl();
-// fDisplay.post(event);
-//
-// while (fDisplay.readAndDispatch ());
-//
-// Assert.assertTrue(element.getChecked() != initialCheckState);
-// }
-
- public void testUpdateCheck() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
-
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.setElementChecked(elementPath, false, false);
-
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.LABEL_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java
deleted file mode 100644
index c64c9d190..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.viewers.model.ChildrenUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.ILabelUpdateListener;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.TreeModelContentProvider;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IStateUpdateListener;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.viewers.ViewerLabel;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Tests coalescing of children update requests.
- *
- * @since 3.3
- */
-public class ChildrenUpdateTests extends TestCase {
-
- class BogusModelContentProvider extends TreeModelContentProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#getViewer()
- */
- protected ITreeModelContentProviderTarget getViewer() {
- return new ITreeModelContentProviderTarget(){
-
- public void setSelection(ISelection selection) {}
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {}
- public void addSelectionChangedListener(ISelectionChangedListener listener) {}
- public void updateViewer(IModelDelta delta) {}
- public void setSelection(ISelection selection, boolean reveal, boolean force) {}
- public void setInput(Object object) {}
- public void setAutoExpandLevel(int level) {}
- public void saveElementState(TreePath path, ModelDelta delta, int flags) {}
- public void removeStateUpdateListener(IStateUpdateListener listener) {}
- public void removeViewerUpdateListener(IViewerUpdateListener listener) {}
- public void removeModelChangedListener(IModelChangedListener listener) {}
- public void removeLabelUpdateListener(ILabelUpdateListener listener) {}
- public void addViewerUpdateListener(IViewerUpdateListener listener) {}
- public void addStateUpdateListener(IStateUpdateListener listener) {}
- public void addModelChangedListener(IModelChangedListener listener) {}
- public void addLabelUpdateListener(ILabelUpdateListener listener) {}
- public void update(Object element) {}
- public void setHasChildren(Object elementOrTreePath, boolean hasChildren) {}
- public void setExpandedState(Object elementOrTreePath, boolean expanded) {}
- public void setChildCount(Object elementOrTreePath, int count) {}
- public void reveal(TreePath path, int index) {}
- public void replace(Object parentOrTreePath, int index, Object element) {}
- public void remove(Object parentOrTreePath, int index) {}
- public void remove(Object elementOrTreePath) {}
- public void refresh() {}
- public void refresh(Object element) {}
-
- public ISelection getSelection() {
- return null;
- }
-
- public IPresentationContext getPresentationContext() {
- return null;
- }
-
- public Object getInput() {
- return null;
- }
-
- public ViewerLabel getElementLabel(TreePath path, String columnId) {
- return null;
- }
-
- public Display getDisplay() {
- return DebugUIPlugin.getStandardDisplay();
- }
-
- public int getAutoExpandLevel() {
- return 0;
- }
-
-
- public boolean overrideSelection(ISelection current, ISelection candidate) {
- return false;
- }
-
- public void insert(Object parentOrTreePath, Object element, int position) {
- }
-
- public TreePath getTopElementPath() {
- return null;
- }
-
- public ViewerFilter[] getFilters() {
- return null;
- }
-
- public boolean getExpandedState(Object elementOrTreePath) {
- return false;
- }
-
- public Object getChildElement(TreePath path, int index) {
- return null;
- }
-
- public boolean getHasChildren(Object elementOrTreePath) {
- return false;
- }
-
- public int getChildCount(TreePath path) {
- return 0;
- }
-
- public int findElementIndex(TreePath parentPath, Object element) {
- return 0;
- }
-
- public void expandToLevel(Object elementOrTreePath, int level) {
- }
-
- public void autoExpand(TreePath elementPath) {
- }
-
- public boolean getElementChildrenRealized(TreePath parentPath) {
- return false;
- }
- };
- }
- }
-
- /**
- * @param name
- */
- public ChildrenUpdateTests(String name) {
- super(name);
- }
-
- protected TreeModelContentProvider getContentProvider() {
- return new BogusModelContentProvider();
- }
-
- /**
- * Tests coalescing of requests
- */
- public void testCoalesce () {
- Object element = new Object();
- TreeModelContentProvider cp = getContentProvider();
- ChildrenUpdate update1 = new ChildrenUpdate(cp, element, TreePath.EMPTY, element, 1, null, null);
- ChildrenUpdate update2 = new ChildrenUpdate(cp, element, TreePath.EMPTY, element, 2, null, null);
- assertTrue("Should coalesce", update1.coalesce(update2));
- assertEquals("Wrong offset", 1, update1.getOffset());
- assertEquals("Wrong length", 2, update1.getLength());
-
- update2 = new ChildrenUpdate(cp, element, TreePath.EMPTY, element, 3, null, null);
- assertTrue("Should coalesce", update1.coalesce(update2));
- assertEquals("Wrong offset", 1, update1.getOffset());
- assertEquals("Wrong length", 3, update1.getLength());
-
- update2 = new ChildrenUpdate(cp, element, TreePath.EMPTY, element, 2, null, null);
- assertTrue("Should coalesce", update1.coalesce(update2));
- assertEquals("Wrong offset", 1, update1.getOffset());
- assertEquals("Wrong length", 3, update1.getLength());
-
- update2 = new ChildrenUpdate(cp, element, TreePath.EMPTY, element, 5, null, null);
- assertFalse("Should not coalesce", update1.coalesce(update2));
- assertEquals("Wrong offset", 1, update1.getOffset());
- assertEquals("Wrong length", 3, update1.getLength());
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java
deleted file mode 100644
index 559940ebc..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests that verify that the viewer property retrieves all the content
- * from the model.
- *
- * @since 3.6
- */
-abstract public class ContentTests extends TestCase {
-
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public ContentTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- public void testSimpleSingleLevel() {
- // Create the model with test data
- TestModel model = TestModel.simpleSingleLevel();
-
- // Make sure that all elements are expanded
- fViewer.setAutoExpandLevel(-1);
-
- // Create the agent which forces the tree to populate
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- // Create the listener which determines when the view is finished updating.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the viewer input (and trigger updates).
- fViewer.setInput(model.getRootElement());
-
- // Wait for the updates to complete.
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testSimpleMultiLevel() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
-
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- fViewer.setInput(model.getRootElement());
-
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
deleted file mode 100644
index 5f6886270..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
+++ /dev/null
@@ -1,572 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests to verify that the viewer property retrieves and processes the
- * model deltas generated by the test model.
- */
-abstract public class DeltaTests extends TestCase {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public DeltaTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- public void testUpdateLabel() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.appendElementLabel(elementPath, "-modified");
-
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.LABEL_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testRefreshStruct() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- TestElement[] newChildren = new TestElement[] {
- new TestElement(model, "1.1 - new", new TestElement[0]),
- new TestElement(model, "1.2 - new", new TestElement[0]),
- new TestElement(model, "1.3 - new", new TestElement[0]),
- };
- ModelDelta delta = model.setElementChildren(elementPath, newChildren);
-
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testRefreshStruct2() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- String prefix = "new - ";
- model.setElementChildren(TreePath.EMPTY, new TestElement[] {
- new TestElement(model, prefix + "1", new TestElement[0]),
- new TestElement(model, prefix + "2", true, false, new TestElement[] {
- new TestElement(model, prefix + "2.1", true, true, new TestElement[0]),
- new TestElement(model, prefix + "2.2", false, true, new TestElement[0]),
- new TestElement(model, prefix + "2.3", true, false, new TestElement[0]),
- }),
- new TestElement(model, prefix + "3", new TestElement[] {
- new TestElement(model, prefix + "3.1", new TestElement[] {
- new TestElement(model, prefix + "3.1.1", new TestElement[0]),
- new TestElement(model, prefix + "3.1.2", new TestElement[0]),
- new TestElement(model, prefix + "3.1.3", new TestElement[0]),
- }),
- new TestElement(model, prefix + "3.2", new TestElement[] {
- new TestElement(model, prefix + "3.2.1", new TestElement[0]),
- new TestElement(model, prefix + "3.2.2", new TestElement[0]),
- new TestElement(model, prefix + "3.2.3", new TestElement[0]),
- }),
- new TestElement(model, prefix + "3.3", new TestElement[] {
- new TestElement(model, prefix + "3.3.1", new TestElement[0]),
- new TestElement(model, prefix + "3.3.2", new TestElement[0]),
- new TestElement(model, prefix + "3.3.3", new TestElement[0]),
- }),
- })
- });
-
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
-
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testInsert() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
-
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement element = new TestElement(model, "7", new TestElement[0]);
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 6, element);
-
- // Insert causes the update of element's data, label and children.
- // TODO: update of element's data after insert seems redundant
- // but it's probably not a big inefficiency
- fListener.reset();
- fListener.addChildreUpdate(TreePath.EMPTY, 6);
- fListener.addHasChildrenUpdate(elementPath);
- fListener.addLabelUpdate(elementPath);
- // TODO: redundant label updates on insert!
- fListener.setFailOnRedundantUpdates(false);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- /**
- * This test checks that insert and select delta flags are processed in correct order:
- * insert then select.
- */
- public void testInsertAndSelect() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
-
- while (!fListener.isFinished())
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep();
-
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- // Insert two new elements at once
- TestElement element0 = new TestElement(model, "00", new TestElement[] {});
- TestElement element1 = new TestElement(model, "01", new TestElement[] {});
- TreePath elementPath0 = new TreePath(new Object[] { element0 });
- TreePath elementPath1 = new TreePath(new Object[] { element1 });
- ModelDelta rootDelta = model.insertElementChild(TreePath.EMPTY, 0, element0);
- rootDelta = model.insertElementChild(rootDelta, TreePath.EMPTY, 1, element1);
-
- // Set the select flag on the first added node.
- ModelDelta delta0 = rootDelta.getChildDelta(element0);
- delta0.setFlags(delta0.getFlags() | IModelDelta.SELECT);
-
- fListener.reset();
- fListener.addHasChildrenUpdate(elementPath0);
- fListener.addHasChildrenUpdate(elementPath1);
- fListener.addLabelUpdate(elementPath0);
- fListener.addLabelUpdate(elementPath1);
-
- // TODO: list full set of expected updates.
- fListener.setFailOnRedundantUpdates(false);
-
- model.postDelta(rootDelta);
- while (!fListener.isFinished())
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- /**
- * This test checks that insert and remove deltas are processed in correct order:
- * remove deltas are processed first then insert deltas.
- */
- public void testInsertAndRemove() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- fViewer.setInput(model.getRootElement());
-
- while (!fListener.isFinished())
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep();
-
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- // Remove one element then insert a new one
- IModelDelta removeDelta = model.removeElementChild(TreePath.EMPTY, 3).getChildDeltas()[0];
-
- // Insert new elements at once
- TestElement element = new TestElement(model, "00", new TestElement[] {});
- TreePath elementPath = new TreePath(new Object[] { element });
- IModelDelta insertDelta = model.insertElementChild(TreePath.EMPTY, 1, element).getChildDeltas()[0];
-
- // Create a combined delta where the insert child delta is first and the remove child delta is second.
- ModelDelta combinedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE, 0, model.getRootElement().getChildren().length);
- combinedDelta.addNode(insertDelta.getElement(), insertDelta.getIndex(), insertDelta.getFlags(), insertDelta.getChildCount());
- combinedDelta.addNode(removeDelta.getElement(), removeDelta.getIndex(), removeDelta.getFlags(), removeDelta.getChildCount());
-
- // Set the select flag on the first added node.
- fListener.reset();
- fListener.addHasChildrenUpdate(elementPath);
- fListener.addLabelUpdate(elementPath);
-
- // TODO: list full set of expected updates.
- fListener.setFailOnRedundantUpdates(false);
-
- model.postDelta(combinedDelta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
-
- public void testAddElement() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement element = new TestElement(model, "7", new TestElement[0]);
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.addElementChild(TreePath.EMPTY, 6, element);
-
- // Add causes the update of parent child count and element's children.
- fListener.reset(elementPath, element, -1, true, false);
- fListener.addChildreUpdate(TreePath.EMPTY, 6);
- // TODO: redundant updates on add!
- fListener.setFailOnRedundantUpdates(false);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
-
- public void testRemove() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 5);
-
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testExpandAndSelect() {
- TestModel model = TestModel.simpleMultiLevel();
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Create the delta
- fListener.reset();
- // TODO Investigate: there seem to be unnecessary updates being issued
- // by the viewer. These include the updates that are commented out:
- // For now disable checking for extra updates.
- fListener.setFailOnRedundantUpdates(false);
- TestElement element = model.getRootElement();
- TreePath path_root = TreePath.EMPTY;
- ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
- ModelDelta deltaRoot = delta;
- element = element.getChildren()[2];
- TreePath path_root_3 = path_root.createChildPath(element);
- delta = delta.addNode(element, 2, IModelDelta.EXPAND, element.fChildren.length);
- fListener.addChildreUpdate(path_root_3, 0);
- TreePath path_root_3_1 = path_root_3.createChildPath(element.getChildren()[0]);
- fListener.addHasChildrenUpdate(path_root_3_1);
- fListener.addLabelUpdate(path_root_3_1);
- TreePath path_root_3_3 = path_root_3.createChildPath(element.getChildren()[2]);
- fListener.addHasChildrenUpdate(path_root_3_3);
- fListener.addLabelUpdate(path_root_3_3);
- //TODO unnecessary update: fListener.addChildreUpdate(path1, 1);
- fListener.addChildreUpdate(path_root_3, 2);
- element = element.getChildren()[1];
- TreePath path_root_3_2 = path_root_3.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.EXPAND, element.fChildren.length);
- fListener.addLabelUpdate(path_root_3_2);
- TreePath path_root_3_2_1 = path_root_3_2.createChildPath(element.getChildren()[0]);
- fListener.addHasChildrenUpdate(path_root_3_2_1);
- fListener.addLabelUpdate(path_root_3_2_1);
- TreePath path_root_3_2_3 = path_root_3_2.createChildPath(element.getChildren()[2]);
- fListener.addHasChildrenUpdate(path_root_3_2_3);
- fListener.addLabelUpdate(path_root_3_2_3);
- // TODO unnecessary update: fListener.addChildreCountUpdate(path2);
- fListener.addChildreUpdate(path_root_3_2, 0);
- // TODO unnecessary update: fListener.addChildreUpdate(path2, 1);
- fListener.addChildreUpdate(path_root_3_2, 2);
- element = element.getChildren()[1];
- TreePath path_root_3_2_2 = path_root_3_2.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.SELECT, element.fChildren.length);
- fListener.addLabelUpdate(path_root_3_2_2);
- fListener.addHasChildrenUpdate(path_root_3_2_2);
-
- // Validate the expansion state BEFORE posting the delta.
-
- ITreeModelContentProviderTarget contentProviderViewer = (ITreeModelContentProviderTarget)fViewer;
- Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3));
- Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3_2));
- Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
-
- model.postDelta(deltaRoot);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Validate the expansion state AFTER posting the delta.
- Assert.assertTrue(contentProviderViewer.getExpandedState(path_root_3));
- Assert.assertTrue(contentProviderViewer.getExpandedState(path_root_3_2));
- Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
-
- // Verify selection
- ISelection selection = fViewer.getSelection();
- if (selection instanceof ITreeSelection) {
- List selectionPathsList = Arrays.asList( ((ITreeSelection)selection).getPaths() );
- Assert.assertTrue(selectionPathsList.contains(path_root_3_2_2));
- } else {
- Assert.fail("Not a tree selection");
- }
- }
-
- public void testCompositeModelRefreshStruct() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.compositeMultiLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- // TODO: redundant updates on install deltas
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Update the model
- TreePath m4_2_1Path = model.findElement("m4.2.1");
- TestElement m4_2_1 = model.getElement(m4_2_1Path);
- TestModel m4 = m4_2_1.getModel();
- TestElement[] newChildren = new TestElement[] {
- new TestElement(m4, "4.2.1.new-1", new TestElement[0]),
- new TestElement(m4, "4.2.1.new-2", new TestElement[0]),
- new TestElement(m4, "4.2.1.new-3", new TestElement[0]),
- };
-
- ModelDelta delta = m4.setElementChildren(m4_2_1Path, newChildren);
-
- fListener.reset(m4_2_1Path, m4_2_1, -1, true, false);
- model.postDelta(delta);
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testCompositeModelAddElement() {
- TestModel model = TestModel.compositeMultiLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- // TODO: redundant updates on install deltas
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- TreePath m3_1Path = model.findElement("m3.1");
- TestElement m3_1 = model.getElement(m3_1Path);
- TestModel m3 = m3_1.getModel();
- TestElement m3_1_new = new TestElement(m3, "m3.1-new", new TestElement[0]);
- TreePath m3_1_newPath = m3_1Path.createChildPath(m3_1_new);
- ModelDelta delta = m3.addElementChild(m3_1Path, 0, m3_1_new);
-
- fListener.reset(m3_1_newPath, m3_1_new, -1, true, false);
- fListener.addChildreUpdate(m3_1Path, 0);
- fListener.setFailOnRedundantUpdates(false);
-
- m3.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testBug292322() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Update the model: remove one child of an un-expanded element, then
- // make sure that the number of children is correct.
- TreePath parentPath = model.findElement("2");
- TestElement parentElement = model.getElement(parentPath);
- ModelDelta delta = model.removeElementChild(parentPath, 0);
-
- // Update the viewer
- fListener.reset(parentPath, parentElement, 0, false, false);
- //fListener.addChildreCountUpdate(parentPath);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate the viewer data.
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Update the model: remove the remaining children and make sure that
- // the element children are updated to false.
- model.removeElementChild(parentPath, 0);
-
- // Update the viewer
- fListener.reset(parentPath, parentElement, 0, false, false);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate the viewer data.
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Update the model: remove the remaining children and make sure that
- // the element children are updated to false.
- model.removeElementChild(parentPath, 0);
-
- // Update the viewer
- fListener.reset(parentPath, parentElement, 0, false, false);
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate the viewer data.
- model.validateData(fViewer, TreePath.EMPTY, true);
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java
deleted file mode 100644
index 67b65d111..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.internal.ui.viewers.model.FilterTransform;
-import org.eclipse.jface.viewers.TreePath;
-
-/**
- * Tests the virtual viewer's filter transform
- * @since 3.3
- */
-public class FilterTransformTests extends TestCase {
-
- public Object root;
- public Object element0;
- public Object element1;
- public Object element2;
- public Object element3;
- public Object element4;
- public Object element5;
- public Object element6;
- public Object element7;
-
- public FilterTransform transform;
-
- /**
- * @param name
- */
- public FilterTransformTests(String name) {
- super(name);
- }
-
- /**
- * Builds a filter transform. Model has 8 elements,
- * and elements 0, 2, 3, 6, 7 are filtered. Elements
- * 1, 4, 5 are visible.
- */
- protected void setUp() throws Exception {
- super.setUp();
- transform = new FilterTransform();
- root = new Object();
- element0 = new Object();
- element1 = new Object();
- element2 = new Object();
- element3 = new Object();
- element4 = new Object();
- element5 = new Object();
- element6 = new Object();
- element7 = new Object();
- assertTrue(transform.addFilteredIndex(TreePath.EMPTY, 0, element0));
- assertTrue(transform.addFilteredIndex(TreePath.EMPTY, 2, element2));
- assertTrue(transform.addFilteredIndex(TreePath.EMPTY, 3, element3));
- assertTrue(transform.addFilteredIndex(TreePath.EMPTY, 6, element6));
- assertTrue(transform.addFilteredIndex(TreePath.EMPTY, 7, element7));
- }
-
- protected boolean equals(int[] a, int[] b) {
- if (a.length == b.length) {
- for (int i = 0; i < b.length; i++) {
- if (a[i] != b[i]) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- public void testRemoveMiddleElementFromFilters() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 3));
- transform.removeElementFromFilters(TreePath.EMPTY, element3);
- assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 3));
- assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[]{0, 2, 5, 6}));
- }
-
- public void testRemoveFirstElementFromFilters() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 0));
- transform.removeElementFromFilters(TreePath.EMPTY, element0);
- assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 0));
- assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[]{1, 2, 5, 6}));
- }
-
- public void testRemoveLastFromFilters() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 7));
- transform.removeElementFromFilters(TreePath.EMPTY, element7);
- assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 7));
- assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[]{0, 2, 3, 6}));
- }
-
- public void testClearMiddleElementFromFilters() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 3));
- transform.clear(TreePath.EMPTY, 3);
- assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 3));
- assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[]{0, 2, 6, 7}));
- }
-
- public void testClearFirstElementFromFilters() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 0));
- transform.clear(TreePath.EMPTY, 0);
- assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 0));
- assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[]{2, 3, 6, 7}));
- }
-
- public void testClearLastFromFilters() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 7));
- transform.clear(TreePath.EMPTY, 7);
- assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 7));
- assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[]{0, 2, 3, 6}));
- }
-
- public void testViewToModelCount() {
- assertEquals("Wrong model count", 8, transform.viewToModelCount(TreePath.EMPTY, 3));
- }
-
- public void testViewToModelIndex() {
- assertEquals("Wrong model index", 1, transform.viewToModelIndex(TreePath.EMPTY, 0));
- assertEquals("Wrong model index", 4, transform.viewToModelIndex(TreePath.EMPTY, 1));
- assertEquals("Wrong model index", 5, transform.viewToModelIndex(TreePath.EMPTY, 2));
- }
-
- public void testAddAlreadyFiltered() {
- assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 0));
- boolean added = transform.addFilteredIndex(TreePath.EMPTY, 0, element0);
- assertFalse("Filter should not be added - should already have been there", added);
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
deleted file mode 100644
index 10aa25c03..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-/**
- * Convenience interface with constants used by the test model update listener.
- *
- * @since 3.6
- */
-public interface ITestModelUpdatesListenerConstants {
-
- public static final int LABEL_UPDATES_COMPLETE = 0X0001;
- public static final int CONTENT_UPDATES_COMPLETE = 0X0002;
- public static final int LABEL_UPDATES = 0X0004;
- public static final int HAS_CHILDREN_UPDATES = 0X0008;
- public static final int CHILDREN_COUNT_UPDATES = 0X0010;
- public static final int CHILDREN_UPDATES = 0X0020;
- public static final int MODEL_CHANGED_COMPLETE = 0X0040;
- public static final int MODEL_PROXIES_INSTALLED = 0X0080;
- public static final int STATE_SAVE_COMPLETE = 0X0100;
- public static final int STATE_RESTORE_COMPLETE = 0X0200;
- public static final int STATE_UPDATES = 0X0400;
-
- public static final int VIEWER_UPDATES_RUNNING = 0X0800;
- public static final int LABEL_UPDATES_RUNNING = 0X1000;
-
- public static final int LABEL_COMPLETE = LABEL_UPDATES_COMPLETE | LABEL_UPDATES;
- public static final int CONTENT_COMPLETE =
- CONTENT_UPDATES_COMPLETE | HAS_CHILDREN_UPDATES | CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES;
-
- public static final int ALL_UPDATES_COMPLETE = LABEL_COMPLETE | CONTENT_COMPLETE | MODEL_PROXIES_INSTALLED | LABEL_UPDATES_RUNNING | VIEWER_UPDATES_RUNNING;
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java
deleted file mode 100644
index 7cb15a0ee..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerCheckTests extends CheckTests {
-
- public JFaceViewerCheckTests(String name) {
- super(name);
- }
-
- protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.CHECK, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java
deleted file mode 100644
index 10213a3a3..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerContentTests extends ContentTests {
-
- public JFaceViewerContentTests(String name) {
- super(name);
- }
-
- protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java
deleted file mode 100644
index ed613bd6f..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerDeltaTests extends DeltaTests {
-
- public JFaceViewerDeltaTests(String name) {
- super(name);
- }
-
- protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-
- /**
- * TODO: remove this method when bug 292322 gets fixed in TreeViewer
- */
- public void testBug292322() {
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java
deleted file mode 100644
index 865db9508..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerPerformanceTests extends PerformanceTests {
-
- public JFaceViewerPerformanceTests(String name) {
- super(name);
- }
-
- protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-
- protected int getTestModelDepth() {
- return 5;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java
deleted file mode 100644
index 6cde1fbfc..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerSelectionTests extends SelectionTests {
-
- public JFaceViewerSelectionTests(String name) {
- super(name);
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java
deleted file mode 100644
index a462f01d0..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerStateTests extends StateTests {
-
- public JFaceViewerStateTests(String name) {
- super(name);
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java
deleted file mode 100644
index 983b8d77f..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class JFaceViewerUpdateTests extends UpdateTests {
-
- public JFaceViewerUpdateTests(String name) {
- super(name);
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java
deleted file mode 100644
index f4c0786c6..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.test.performance.Performance;
-import org.eclipse.test.performance.PerformanceMeter;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests to measure the performance of the viewer updates.
- */
-abstract public class PerformanceTests extends TestCase implements ITestModelUpdatesListenerConstants {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public PerformanceTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- /**
- * Depth (size) of the test model to be used in the tests. This number allows
- * the jface based tests to use a small enough model to fit on the screen, and
- * for the virtual viewer to exercise the content provider to a greater extent.
- */
- abstract protected int getTestModelDepth();
-
- public void testRefreshStruct() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[0] ) );
- model.setElementChildren(TreePath.EMPTY, makeModelElements(model, getTestModelDepth(), "model"));
-
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 100; i++) {
- // Update the model
- model.setAllAppendix(" - pass " + i);
- //model.setElementChildren(TreePath.EMPTY, makeModelElements(model, getTestModelDepth(), "pass " + i));
-
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
-
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
- while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
-
- public void testRefreshStructReplaceElements() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[0] ) );
- model.setElementChildren(TreePath.EMPTY, makeModelElements(model, getTestModelDepth(), "model"));
-
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 2000; i++) {
- // Update the model
- model.setElementChildren(TreePath.EMPTY, makeModelElements(model, getTestModelDepth(), "pass " + i));
-
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
-
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
- while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
-
- private TestElement[] makeModelElements(TestModel model, int depth, String prefix) {
- TestElement[] elements = new TestElement[depth];
- for (int i = 0; i < depth; i++) {
- String name = prefix + "." + i;
- elements[i] = new TestElement(model, name, makeModelElements(model, i, name));
- }
- return elements;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PresentationContextTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PresentationContextTests.java
deleted file mode 100644
index 8e5028935..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PresentationContextTests.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- * IBM - moved to debug platform tests from JDT
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.XMLMemento;
-
-/**
- * Test the serialization of presentation context properties.
- *
- * @since 3.4
- */
-public class PresentationContextTests extends TestCase {
-
- public PresentationContextTests(String name) {
- super(name);
- }
-
- /**
- * Tests saving and restoring presentation context properties.
- */
- public void testSaveRestore () {
- PresentationContext context = new PresentationContext("test");
- context.setProperty("string", "string");
- context.setProperty("integer", new Integer(1));
- context.setProperty("boolean", new Boolean(true));
- context.setProperty("persistable", ResourcesPlugin.getWorkspace().getRoot().getAdapter(IPersistableElement.class));
-
- final XMLMemento memento = XMLMemento.createWriteRoot("TEST");
- context.saveProperites(memento);
-
- context = new PresentationContext("test");
- context.initProperties(memento);
- assertEquals("Wrong value restored", "string", context.getProperty("string"));
- assertEquals("Wrong value restored", new Integer(1), context.getProperty("integer"));
- assertEquals("Wrong value restored", new Boolean(true), context.getProperty("boolean"));
- assertEquals("Wrong value restored", ResourcesPlugin.getWorkspace().getRoot(), context.getProperty("persistable"));
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java
deleted file mode 100644
index aa1155466..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests to verify that the viewer properly handles selection changes.
- */
-abstract public class SelectionTests extends TestCase {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public SelectionTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelViewer createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- private static class SelectionListener implements ISelectionChangedListener {
- private List fEvents = new ArrayList(1);
-
- public void selectionChanged(SelectionChangedEvent event) {
- fEvents.add(event);
- }
- }
-
- private TestModel makeMultiLevelModel() {
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- return model;
- }
-
- /**
- * In this test:
- * - set selection to an element deep in the model
- * - verify that selection chagned listener is called
- * - verify that the selection is in the viewer is correct
- */
- public void testSimpleSetSelection() {
- // Create the model and populate the view.
- TestModel model = makeMultiLevelModel();
-
- // Create a selection object to the deepest part of the tree.
- SelectionListener listener = new SelectionListener();
- fViewer.addSelectionChangedListener(listener);
-
- // Set the selection and verify that the listener is called.
- TreeSelection selection = new TreeSelection(model.findElement("3.3.3"));
- fViewer.setSelection(selection, true, false);
- assertTrue(listener.fEvents.size() == 1);
-
- // Check that the new selection is what was requested.
- ISelection viewerSelection = fViewer.getSelection();
- assertEquals(selection, viewerSelection);
- }
-
- /**
- * In this test:
- * - set a seleciton to an element
- * - then remove that element
- * - update the view with remove delta
- * -> The selection should be re-set to empty.
- */
- public void testSelectRemove() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- // Create the model and populate the view.
- TestModel model = makeMultiLevelModel();
-
- // Create a selection object to the deepest part of the tree.
- TreePath elementPath = model.findElement("3.3.3");
- TreeSelection selection = new TreeSelection(elementPath);
-
- // Set the selection.
- fViewer.setSelection(selection, true, false);
-
- // Remove the element
- TreePath removePath = model.findElement("3");
- TreePath parentPath = removePath.getParentPath();
- int removeIndex = model.getElement(parentPath).indexOf( model.getElement(removePath) );
- ModelDelta delta = model.removeElementChild(removePath.getParentPath(), removeIndex);
-
- // Configure a selection listener
- SelectionListener listener = new SelectionListener();
- fViewer.addSelectionChangedListener(listener);
-
- // Reset the listener and update the viewer. With a remove
- // delta only wait for the delta to be processed.
- fListener.reset();
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Check to make sure the selection was made
- //assertTrue(listener.fEvents.size() == 1);
-
- // Check that the new selection is empty
- ISelection viewerSelection = fViewer.getSelection();
- assertTrue(viewerSelection.isEmpty());
- }
-
-
- /**
- * In this test:
- * - set a selection to an element
- * - then remove that element
- * - then refresh the view.
- * -> The selection should be re-set to empty.
- */
- public void testSelectRemoveRefreshStruct() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- // Create the model and populate the view.
- TestModel model = makeMultiLevelModel();
-
- // Create a selection object to the deepest part of the tree.
- TreePath elementPath = model.findElement("3.3.3");
- TreeSelection selection = new TreeSelection(elementPath);
-
- // Set the selection.
- fViewer.setSelection(selection, true, false);
-
- // Remove the element
- TreePath removePath = model.findElement("3");
- TreePath parentPath = removePath.getParentPath();
- int removeIndex = model.getElement(parentPath).indexOf( model.getElement(removePath) );
- model.removeElementChild(removePath.getParentPath(), removeIndex);
-
- // Configure a selection listener
- SelectionListener listener = new SelectionListener();
- fViewer.addSelectionChangedListener(listener);
-
- // Reset the listener to ignore redundant updates. When elements are removed
- // the viewer may still request updates for those elements.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
-
- // Refresh the viewer
- model.postDelta( new ModelDelta(model.getRootElement(), IModelDelta.CONTENT) );
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Check to make sure the selection was made
- // Commented out until JFace bug 219887 is fixed.
- //assertTrue(listener.fEvents.size() == 1);
-
- // Check that the new selection is empty
- ISelection viewerSelection = fViewer.getSelection();
- assertTrue(viewerSelection.isEmpty());
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java
deleted file mode 100644
index 04571b631..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests to verify that the viewer can save and restore correctly the expansion
- * state of elements.
- *
- * @since 3.6
- */
-abstract public class StateTests extends TestCase implements ITestModelUpdatesListenerConstants {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public StateTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
- fViewer.addStateUpdateListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelViewer createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
- fViewer.addStateUpdateListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- protected ITreeModelContentProviderTarget getCTargetViewer() {
- return (ITreeModelContentProviderTarget)fViewer;
- }
-
- public void testUpdateViewer() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleMultiLevel();
-
- // Create the listener
- fListener.reset();
- fListener.addChildreUpdate(TreePath.EMPTY, 0);
- fListener.addChildreUpdate(TreePath.EMPTY, 1);
- fListener.addChildreUpdate(TreePath.EMPTY, 2);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Create the update delta
- TestElement element = model.getRootElement();
- TreePath path0 = TreePath.EMPTY;
- ModelDelta delta = new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
- ModelDelta updateDelta = delta;
- element = element.getChildren()[2];
- TreePath path1 = path0.createChildPath(element);
- delta = delta.addNode(element, 2, IModelDelta.EXPAND, element.fChildren.length);
- element = element.getChildren()[1];
- TreePath path2 = path1.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.EXPAND, element.fChildren.length);
- element = element.getChildren()[1];
- TreePath path3 = path2.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.SELECT);
-
- fListener.reset();
- fViewer.updateViewer(updateDelta);
-
- fListener.reset();
- fListener.setFailOnRedundantUpdates(false);
- fListener.addChildreUpdate(path0, 2);
- fListener.addHasChildrenUpdate(path1);
- fListener.addChildreCountUpdate(path1);
- fListener.addLabelUpdate(path1);
- fListener.addChildreUpdate(path1, 1);
- fListener.addHasChildrenUpdate(path2);
- fListener.addChildreCountUpdate(path2);
- fListener.addLabelUpdate(path2);
- fListener.addHasChildrenUpdate(path2);
- fListener.addChildreCountUpdate(path2);
- fListener.addChildreUpdate(path2, 1);
- fListener.addHasChildrenUpdate(path3);
- fListener.addLabelUpdate(path3);
-
- while (!fListener.isFinished(CONTENT_UPDATES_COMPLETE | LABEL_UPDATES))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Extract the new state from viewer
- ModelDelta savedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(path0, savedDelta, IModelDelta.EXPAND | IModelDelta.SELECT);
-
- Assert.assertTrue( deltaMatches(updateDelta, savedDelta) );
- }
-
- boolean deltaMatches(ModelDelta requested, ModelDelta received) {
- if ( requested.getElement().equals(received.getElement()) &&
- requested.getFlags() == received.getFlags() &&
- ( requested.getChildCount() == -1 || requested.getChildCount() == received.getChildCount() )&&
- ( requested.getIndex() == -1 || requested.getIndex() == received.getIndex()) &&
- ((requested.getReplacementElement() != null && requested.getReplacementElement().equals(received.getReplacementElement())) ||
- (requested.getReplacementElement() == null && received.getReplacementElement() == null)) &&
- requested.getChildDeltas().length == received.getChildDeltas().length)
- {
- for (int i = 0; i < requested.getChildDeltas().length; i++) {
- ModelDelta requestedChildDelta = (ModelDelta)requested.getChildDeltas()[i];
- ModelDelta receivedChildDelta = received.getChildDelta(requestedChildDelta.getElement());
- if ( receivedChildDelta == null || !deltaMatches(requestedChildDelta, receivedChildDelta) ) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- private TestModel alternatingSubsreesModel() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[] {
- new TestElement(model, "1", new TestElement[] {
- new TestElement(model, "1.1", new TestElement[] {
- new TestElement(model, "1.1.1", new TestElement[0]),
- }),
- }),
- new TestElement(model, "2", new TestElement[] {
- new TestElement(model, "2.1", new TestElement[] {
- new TestElement(model, "2.1.1", new TestElement[0]),
- }),
- }),
- new TestElement(model, "3", new TestElement[] {
- new TestElement(model, "3.1", new TestElement[] {
- new TestElement(model, "3.1.1", new TestElement[0]),
- }),
- }),
- new TestElement(model, "4", new TestElement[] {
- new TestElement(model, "4.1", new TestElement[] {
- new TestElement(model, "4.1.1", new TestElement[0]),
- }),
- }),
- new TestElement(model, "5", new TestElement[] {
- new TestElement(model, "5.1", new TestElement[] {
- new TestElement(model, "5.1.1", new TestElement[0]),
- }),
- }),
- new TestElement(model, "6", new TestElement[] {
- new TestElement(model, "6.1", new TestElement[] {
- new TestElement(model, "6.1.1", new TestElement[0]),
- }),
- })
- }) );
- return model;
- }
-
- private void expandAlternateElements(TestModel model) {
- // Expand every other child
- fListener.reset();
- fListener.setFailOnRedundantUpdates(false);
- ITreeModelContentProviderTarget viewer = (ITreeModelContentProviderTarget)fViewer;
- TreePath path;
- fListener.addUpdates(path = model.findElement("1"), (TestElement)path.getLastSegment(), 1, CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES);
- viewer.setExpandedState(path, true);
- fListener.addUpdates(path = model.findElement("3"), (TestElement)path.getLastSegment(), 1, CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES);
- viewer.setExpandedState(path, true);
- fListener.addUpdates(path = model.findElement("5"), (TestElement)path.getLastSegment(), 1, CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES);
- viewer.setExpandedState(path, true);
-
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Expand the sub-children as well (so that the expanded nodes go 2 levels down.
- fListener.reset();
- fListener.addUpdates(path = model.findElement("1.1"), (TestElement)path.getLastSegment(), 1, CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES);
- viewer.setExpandedState(path, true);
- fListener.addUpdates(path = model.findElement("3.1"), (TestElement)path.getLastSegment(), 1, CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES);
- viewer.setExpandedState(path, true);
- fListener.addUpdates(path = model.findElement("5.1"), (TestElement)path.getLastSegment(), 1, CHILDREN_COUNT_UPDATES | CHILDREN_UPDATES);
- viewer.setExpandedState(path, true);
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
- }
-
- public void testPreserveExpandedOnRemove() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel();
-
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
-
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- expandAlternateElements(model);
-
- // Set a selection in view
- TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1"));
- fViewer.setSelection(originalSelection);
-
- // Update the model
- ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 0);
-
- // Remove delta should not generate any new updates
- fListener.reset();
- model.postDelta(delta);
- while (!fListener.isFinished(MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("2")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("4")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("6")) == false);
- Assert.assertEquals(originalSelection, fViewer.getSelection());
- }
-
- public void testPreserveExpandedOnInsert() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel();
-
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
-
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- expandAlternateElements(model);
-
- // Set a selection in view
- TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1"));
- fViewer.setSelection(originalSelection);
-
- // Update the model
- ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 0, new TestElement(model, "0 - new", new TestElement[0]));
-
- // Insert delta should generate updates only for the new element
- TreePath path = model.findElement("0 - new");
- // Note: redundant label updates on insert.
- fListener.reset(path, (TestElement)path.getLastSegment(), 0, false, false);
- fListener.addChildreUpdate(TreePath.EMPTY, 0);
- model.postDelta(delta);
- while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("1.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("2")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("4")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("6")) == false);
- Assert.assertEquals(originalSelection, fViewer.getSelection());
- }
-
- public void testPreserveExpandedOnContentStress() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel();
-
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
-
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- expandAlternateElements(model);
-
- // Set a selection in view
- TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1"));
- fViewer.setSelection(originalSelection);
- Assert.assertEquals(originalSelection, fViewer.getSelection());
-
- // Run this test ten times as we've seen intermittent failures related
- // to timing in it.
- for (int i = 0; i < 10; i++) {
- // Update the model
- model.removeElementChild(TreePath.EMPTY, 0);
-
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getCTargetViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("2")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("4")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("6")) == false);
- Assert.assertEquals(originalSelection, fViewer.getSelection());
-
- // Update the model again
- model.addElementChild(TreePath.EMPTY, 0, new TestElement(model, "1", new TestElement[0]));
-
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getCTargetViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("2")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("4")) == false);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("5.1")) == true);
- Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("6")) == false);
- Assert.assertEquals(originalSelection, fViewer.getSelection());
- }
- }
-
- public void testSaveAndRstore1() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel();
-
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
-
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Expand some, but not all elements
- expandAlternateElements(model);
-
- // Set a selection in view
- fViewer.setSelection(new TreeSelection(model.findElement("5.1.1")));
-
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
-
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getCTargetViewer(), TreePath.EMPTY, model.getRootElement());
- fViewer.setInput(null);
- while (!fListener.isFinished(STATE_SAVE_COMPLETE)) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // TODO: add state updates somehow?
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Extract the restored state from viewer
- ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
-
- Assert.assertTrue( deltaMatches(originalState, restoredState) );
- }
-
- public void testSaveAndRstore2() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
-
- // expand all elements
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Set a selection in view
- fViewer.setSelection(new TreeSelection(model.findElement("3.2.3")));
-
- // Turn off the auto-expand now since we want to text the auto-expand logic
- fViewer.setAutoExpandLevel(-1);
-
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
-
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getCTargetViewer(), TreePath.EMPTY, model.getRootElement());
-
- fViewer.setInput(null);
- while (!fListener.isFinished(STATE_SAVE_COMPLETE)) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // TODO: add state updates somehow?
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- // Extract the restored state from viewer
- ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
-
- Assert.assertTrue( deltaMatches(originalState, restoredState) );
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
deleted file mode 100644
index 363afc39a..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
+++ /dev/null
@@ -1,649 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import java.util.Arrays;
-
-import junit.framework.Assert;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelCheckProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory2;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Test model for the use in unit tests. This test model contains a set of
- * elements in a tree structure. It contains utility methods for modifying the
- * model and for verifying that the viewer content matches the model.
- *
- * @since 3.6
- */
-public class TestModel implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory2 , IElementMementoProvider {
-
- public static class TestElement extends PlatformObject {
- private final TestModel fModel;
- private final String fID;
- TestElement[] fChildren;
- String fLabelAppendix = "";
- boolean fExpanded;
- boolean fChecked;
- boolean fGrayed;
-
- public TestElement(TestModel model, String text, TestElement[] children) {
- this (model, text, false, false, children);
- }
-
- public TestElement(TestModel model, String text, boolean checked, boolean grayed, TestElement[] children) {
- fModel = model;
- fID = text;
- fChildren = children;
- fChecked = checked;
- fGrayed = grayed;
- }
-
- public TestModel getModel() {
- return fModel;
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter.isInstance(fModel)) {
- return fModel;
- }
- return null;
- }
-
- public String getID() {
- return fID;
- }
-
- public void setLabelAppendix(String appendix) {
- fLabelAppendix = appendix;
- }
-
- public String getLabel() {
- return fID + fLabelAppendix;
- }
-
- public TestElement[] getChildren() {
- return fChildren;
- }
-
- public boolean isExpanded() {
- return fExpanded;
- }
-
- public boolean getGrayed() {
- return fGrayed;
- }
-
- public boolean getChecked() {
- return fChecked;
- }
-
- public void setChecked(boolean checked, boolean grayed) {
- fChecked = checked;
- fGrayed = grayed;
- }
-
- public boolean equals(Object obj) {
- return obj instanceof TestElement && fID.equals(((TestElement)obj).fID);
- }
-
- public int hashCode() {
- return fID.hashCode();
- }
-
- public String toString() {
- return getLabel();
- }
-
- public int indexOf(TestElement child) {
- return Arrays.asList(fChildren).indexOf(child);
- }
- }
-
- private class ModelProxy extends AbstractModelProxy {
- public void installed(Viewer viewer) {
- super.installed(viewer);
- ModelDelta rootDelta = TestModel.this.getBaseDelta(new ModelDelta(fInput, IModelDelta.NO_CHANGE));
- installSubModelProxies(fRootPath, rootDelta);
- fireModelChanged(rootDelta);
- }
-
- private void installSubModelProxies(TreePath path, ModelDelta delta) {
- TestElement element = getElement(path);
- if (element.fModel != TestModel.this) {
- // Found an element from a different model. Install its proxy and return.
- delta.setFlags(delta.getFlags() | IModelDelta.INSTALL);
- } else {
- TestElement[] children = element.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- installSubModelProxies(path.createChildPath(children[i]), delta.addNode(children[i], IModelDelta.NO_CHANGE));
- }
- }
- }
- }
-
- private TestElement fRoot;
- private Object fInput = null;
- private TreePath fRootPath = TreePath.EMPTY;
- private ModelProxy fModelProxy;
-
- /**
- * Constructor private. Use static factory methods instead.
- */
- public TestModel() {}
-
- public TestElement getRootElement() {
- return fRoot;
- }
-
- ModelDelta getBaseDelta(ModelDelta rootDelta) {
- ModelDelta delta = rootDelta;
- for (int i = 0; i < fRootPath.getSegmentCount(); i++) {
- ModelDelta subDelta = delta.getChildDelta(fRootPath.getSegment(i));
- if (subDelta == null) {
- subDelta = delta.addNode(fRootPath.getSegment(i), IModelDelta.NO_CHANGE);
- }
- delta = subDelta;
- }
- return delta;
- }
-
- public int getModelDepth() {
- return getDepth(getRootElement(), 0);
- }
-
- private int getDepth(TestElement element, int atDepth) {
- TestElement[] children = element.getChildren();
- if (children.length == 0) {
- return atDepth;
- }
- int depth = atDepth + 1;
- for (int i = 0; i < children.length; i++) {
- depth = Math.max(depth, getDepth(children[i], atDepth + 1));
- }
-
- return depth;
- }
-
- public void update(IHasChildrenUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- TestElement element = (TestElement)updates[i].getElement();
- updates[i].setHasChilren(element.getChildren().length > 0);
- updates[i].done();
- }
- }
-
- public void update(IChildrenCountUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- TestElement element = (TestElement)updates[i].getElement();
- updates[i].setChildCount(element.getChildren().length);
- updates[i].done();
- }
- }
-
- public void update(IChildrenUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- TestElement element = (TestElement)updates[i].getElement();
- int endOffset = updates[i].getOffset() + updates[i].getLength();
- for (int j = updates[i].getOffset(); j < endOffset; j++) {
- if (j < element.getChildren().length) {
- updates[i].setChild(element.getChildren()[j], j);
- }
- }
- updates[i].done();
- }
- }
-
- public void update(ILabelUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- TestElement element = (TestElement)updates[i].getElement();
- updates[i].setLabel(element.fID, 0);
- if (updates[i] instanceof ICheckUpdate &&
- Boolean.TRUE.equals(updates[i].getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)))
- {
- ((ICheckUpdate)updates[i]).setChecked(element.getChecked(), element.getGrayed());
- }
- updates[i].done();
- }
- }
-
- public final static String ELEMENT_MEMENTO_ID = "id";
-
- public void compareElements(IElementCompareRequest[] updates) {
- for (int i = 0; i < updates.length; i++) {
- String elementID = ((TestElement)updates[i].getElement()).getID();
- String mementoID = updates[i].getMemento().getString(ELEMENT_MEMENTO_ID);
- updates[i].setEqual( elementID.equals(mementoID) );
- updates[i].done();
- }
-
- }
-
- public void encodeElements(IElementMementoRequest[] updates) {
- for (int i = 0; i < updates.length; i++) {
- String elementID = ((TestElement)updates[i].getElement()).getID();
- updates[i].getMemento().putString(ELEMENT_MEMENTO_ID, elementID);
- updates[i].done();
- }
- }
-
-
- public void elementChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) {
- TestElement element = getElement(path);
- Assert.assertFalse(element.getGrayed());
- element.setChecked(checked, false);
- }
-
- public IModelProxy createTreeModelProxy(Object input, TreePath path, IPresentationContext context) {
- fModelProxy = new ModelProxy();
- fInput = input;
- fRootPath = path;
- return fModelProxy;
- }
-
- public IModelProxy getModelProxy() {
- return fModelProxy;
- }
-
- public TestElement getElement(TreePath path) {
- if (path.getSegmentCount() == 0) {
- return getRootElement();
- } else {
- return (TestElement)path.getLastSegment();
- }
- }
-
- public void setAllExpanded() {
- doSetExpanded(fRoot);
- }
-
- private void doSetExpanded(TestElement element) {
- element.fExpanded = true;
- for (int i = 0; i < element.fChildren.length; i++) {
- doSetExpanded(element.fChildren[i]);
- }
- }
-
- public void setAllAppendix(String appendix) {
- doSetAllAppendix(fRoot, appendix);
- }
-
- private void doSetAllAppendix(TestElement element, String appendix) {
- element.setLabelAppendix(appendix);
- for (int i = 0; i < element.fChildren.length; i++) {
- doSetAllAppendix(element.fChildren[i], appendix);
- }
- }
-
- public void validateData(ITreeModelViewer viewer, TreePath path) {
-
- validateData(viewer, path, false);
- }
-
- public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly) {
- ITreeModelContentProviderTarget viewer = (ITreeModelContentProviderTarget)_viewer;
- TestElement element = getElement(path);
- if ( Boolean.TRUE.equals(_viewer.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)) ) {
- ITreeModelCheckProviderTarget checkTarget = (ITreeModelCheckProviderTarget)_viewer;
- Assert.assertEquals(element.getChecked(), checkTarget.getElementChecked(path));
- Assert.assertEquals(element.getGrayed(), checkTarget.getElementGrayed(path));
- }
-
- if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) {
- TestElement[] children = element.getChildren();
- Assert.assertEquals(children.length, viewer.getChildCount(path));
-
- for (int i = 0; i < children.length; i++) {
- Assert.assertEquals(children[i], viewer.getChildElement(path, i));
- validateData(viewer, path.createChildPath(children[i]), expandedElementsOnly);
- }
- } else if (!viewer.getExpandedState(path)) {
- // If element not expanded, verify the plus sign.
- Assert.assertEquals(viewer.getHasChildren(path), element.getChildren().length > 0);
- }
- }
-
- public void setRoot(TestElement root) {
- fRoot = root;
- }
-
- public void postDelta(IModelDelta delta) {
- fModelProxy.fireModelChanged(delta);
- }
-
- /** Create or retrieve delta for given path
- * @param combine if then new deltas for the given path are created. If false existing ones are reused.
- */
- private ModelDelta getElementDelta(ModelDelta baseDelta, TreePath path, boolean combine) {
- TestElement element = getRootElement();
- ModelDelta delta = baseDelta;
-
- for (int i = 0; i < path.getSegmentCount(); i++) {
- TestElement[] children = element.getChildren();
- delta.setChildCount(children.length);
- Object segment = path.getSegment(i);
- int j;
- for (j = 0; j < children.length; j++) {
- if (segment.equals(children[j])) {
- element = children[j];
- ModelDelta nextDelta = null;
- if (combine) {
- nextDelta = delta.getChildDelta(element);
- }
- if (nextDelta == null) {
- nextDelta = delta.addNode(element, j, IModelDelta.NO_CHANGE);
- }
- delta = nextDelta;
- break;
- }
- }
- if (j == children.length) {
- throw new IllegalArgumentException("Invalid path");
- }
- }
- return delta;
-
- }
-
- private TreePath getRelativePath(TreePath path) {
- Object[] segments = new Object[path.getSegmentCount() - fRootPath.getSegmentCount()];
- for (int i = fRootPath.getSegmentCount(), _i = 0; i < path.getSegmentCount(); i++, _i++) {
- segments[_i] = path.getSegment(i);
- }
- return new TreePath(segments);
- }
-
- public ModelDelta appendElementLabel(TreePath path, String labelAppendix) {
- Assert.assertTrue(path.startsWith(fRootPath, null));
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(path);
- TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
- element.setLabelAppendix(labelAppendix);
- delta.setFlags(delta.getFlags() | IModelDelta.STATE);
-
- return rootDelta;
- }
-
- public ModelDelta setElementChecked(TreePath path, boolean checked, boolean grayed) {
- Assert.assertTrue(path.startsWith(fRootPath, null));
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(path);
- TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
- element.setChecked(checked, grayed);
- delta.setFlags(delta.getFlags() | IModelDelta.STATE);
-
- return rootDelta;
- }
-
- public ModelDelta setElementChildren(TreePath path, TestElement[] children) {
- Assert.assertTrue(path.startsWith(fRootPath, null));
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(path);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
-
- // Set the new children array
- element.fChildren = children;
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setFlags(delta.getFlags() | IModelDelta.CONTENT);
- delta.setChildCount(children.length);
-
- return rootDelta;
- }
-
- public ModelDelta replaceElementChild(TreePath parentPath, int index, TestElement child) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(parentPath);
-
- TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
- TestElement oldChild = element.fChildren[index];
- element.fChildren[index] = child;
- delta.addNode(oldChild, child, IModelDelta.REPLACED);
- // TODO: set replacement index!?!
-
- return rootDelta;
- }
-
- public ModelDelta addElementChild(TreePath parentPath, int index, TestElement newChild) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(parentPath);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
-
- // Add the new element
- element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setChildCount(element.getChildren().length);
- delta.addNode(newChild, IModelDelta.ADDED);
-
- return rootDelta;
- }
-
- public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement newChild) {
- return insertElementChild(null, parentPath, index, newChild);
- }
-
- public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, int index, TestElement newChild) {
- if (rootDelta == null) {
- rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- }
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(parentPath);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
-
- // Add the new element
- element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setChildCount(element.getChildren().length);
- delta.addNode(newChild, index, IModelDelta.INSERTED);
-
- return rootDelta;
- }
-
- private TestElement[] doInsertElementInArray(TestElement[] children, int index, TestElement newChild) {
- // Create the new children array add the element to it and set it to
- // the parent.
- TestElement[] newChildren = new TestElement[children.length + 1];
- System.arraycopy(children, 0, newChildren, 0, index);
- newChildren[index] = newChild;
- System.arraycopy(children, index, newChildren, index + 1, children.length - index);
- return newChildren;
- }
-
- public ModelDelta removeElementChild(TreePath parentPath, int index) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(parentPath);
- ModelDelta delta= getElementDelta(baseDelta, parentPath, false);
-
- // Create a new child array with the element removed
- TestElement[] children = element.getChildren();
- TestElement childToRemove = children[index];
- TestElement[] newChildren = new TestElement[children.length - 1];
- System.arraycopy(children, 0, newChildren, 0, index);
- System.arraycopy(children, index + 1, newChildren, index, children.length - index - 1);
- element.fChildren = newChildren;
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setChildCount(element.getChildren().length);
- delta.addNode(childToRemove, index, IModelDelta.REMOVED);
-
- return rootDelta;
- }
-
- public TreePath findElement(String label) {
- return findElement(TreePath.EMPTY, label);
- }
-
- public TreePath findElement(TreePath startPath, String label) {
- TestElement element = getElement(startPath);
- for (int i = 0; i < element.getChildren().length; i++) {
- TestElement child = element.getChildren()[i];
- TreePath path = startPath.createChildPath(child);
- if ( label.equals(child.getLabel()) ) {
- return path;
- } else {
- TreePath subPath = findElement(path, label);
- if (subPath != null) {
- return subPath;
- }
- }
- }
- return null;
- }
-
- public String toString() {
- return getElementString(fRoot, "");
- }
-
- public String getElementString(TestElement element, String indent) {
- StringBuffer builder = new StringBuffer();
- builder.append(indent);
- builder.append(element.toString());
- builder.append('\n');
- TestElement[] children = element.getChildren();
- for (int i = 0; i < children.length; i++) {
- builder.append(getElementString(children[i], indent + " "));
- }
- return builder.toString();
- }
-
- public static TestModel simpleSingleLevel() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[] {
- new TestElement(model, "1", true, true, new TestElement[0]),
- new TestElement(model, "2", true, false, new TestElement[0]),
- new TestElement(model, "3", false, true, new TestElement[0]),
- new TestElement(model, "4", false, false, new TestElement[0]),
- new TestElement(model, "5", new TestElement[0]),
- new TestElement(model, "6", new TestElement[0])
- }) );
- return model;
- }
-
- public static TestModel simpleMultiLevel() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[] {
- new TestElement(model, "1", new TestElement[0]),
- new TestElement(model, "2", true, false, new TestElement[] {
- new TestElement(model, "2.1", true, true, new TestElement[0]),
- new TestElement(model, "2.2", false, true, new TestElement[0]),
- new TestElement(model, "2.3", true, false, new TestElement[0]),
- }),
- new TestElement(model, "3", new TestElement[] {
- new TestElement(model, "3.1", new TestElement[] {
- new TestElement(model, "3.1.1", new TestElement[0]),
- new TestElement(model, "3.1.2", new TestElement[0]),
- new TestElement(model, "3.1.3", new TestElement[0]),
- }),
- new TestElement(model, "3.2", new TestElement[] {
- new TestElement(model, "3.2.1", new TestElement[0]),
- new TestElement(model, "3.2.2", new TestElement[0]),
- new TestElement(model, "3.2.3", new TestElement[0]),
- }),
- new TestElement(model, "3.3", new TestElement[] {
- new TestElement(model, "3.3.1", new TestElement[0]),
- new TestElement(model, "3.3.2", new TestElement[0]),
- new TestElement(model, "3.3.3", new TestElement[0]),
- }),
- })
- }) );
- return model;
- }
-
- public static TestModel compositeMultiLevel() {
- TestModel m2 = new TestModel();
- m2.setRoot( new TestElement(m2, "m2.root", new TestElement[] {
- new TestElement(m2, "m2.1", new TestElement[0]),
- new TestElement(m2, "m2.2", true, false, new TestElement[] {
- new TestElement(m2, "m2.2.1", true, true, new TestElement[0]),
- new TestElement(m2, "m2.2.2", false, true, new TestElement[0]),
- new TestElement(m2, "m2.2.3", true, false, new TestElement[0]),
- }),
- }) );
-
- TestModel m3 = new TestModel();
- m3.setRoot( new TestElement(m3, "m3.root", new TestElement[] {
- new TestElement(m3, "m3.1", new TestElement[0]),
- new TestElement(m3, "m3.2", true, false, new TestElement[] {
- new TestElement(m3, "m3.2.1", true, true, new TestElement[0]),
- new TestElement(m3, "m3.2.2", false, true, new TestElement[0]),
- new TestElement(m3, "m3.2.3", true, false, new TestElement[0]),
- }),
- }) );
-
- TestModel m4 = new TestModel();
- m4.setRoot( new TestElement(m4, "m4.root", new TestElement[] {
- new TestElement(m4, "m4.1", new TestElement[0]),
- new TestElement(m4, "m4.2", true, false, new TestElement[] {
- new TestElement(m4, "m4.2.1", true, true, new TestElement[0]),
- new TestElement(m4, "m4.2.2", false, true, new TestElement[0]),
- new TestElement(m4, "m4.2.3", true, false, new TestElement[0]),
- }),
- }) );
-
- TestModel m1 = new TestModel();
- m1.setRoot( new TestElement(m1, "m1.root", new TestElement[] {
- new TestElement(m1, "m1.1", new TestElement[0]),
- new TestElement(m1, "m1.2", true, false, new TestElement[] {
- m2.fRoot,
- m3.fRoot,
- m4.fRoot,
- }),
- }) );
-
-
- return m1;
- }
-
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
deleted file mode 100644
index ea8e094c1..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.Assert;
-
-import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
-import org.eclipse.debug.internal.ui.viewers.model.ILabelUpdateListener;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IStateUpdateListener;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
-import org.eclipse.jface.viewers.TreePath;
-
-public class TestModelUpdatesListener
- implements IViewerUpdateListener, ILabelUpdateListener, IModelChangedListener, ITestModelUpdatesListenerConstants,
- IStateUpdateListener
-{
- private boolean fFailOnRedundantUpdates;
- private boolean fFailOnMultipleUpdateSequences;
-
- private Set fHasChildrenUpdates = new HashSet();
- private Map fChildrenUpdates = new HashMap();
- private Set fChildCountUpdates = new HashSet();
- private Set fLabelUpdates = new HashSet();
- private Set fProxyModels = new HashSet();
- private Set fStateUpdates = new HashSet();
- private boolean fViewerUpdatesComplete;
- private boolean fLabelUpdatesComplete;
- private boolean fModelChangedComplete;
- private boolean fStateSaveComplete;
- private boolean fStateRestoreComplete;
- private int fViewerUpdatesRunning;
- private int fLabelUpdatesRunning;
- private int fTimeoutInterval = 60000;
- private long fTimeoutTime;
-
-
- public TestModelUpdatesListener(boolean failOnRedundantUpdates, boolean failOnMultipleUpdateSequences) {
- setFailOnRedundantUpdates(failOnRedundantUpdates);
- setFailOnMultipleUpdateSequences(failOnMultipleUpdateSequences);
- }
-
- public void setFailOnRedundantUpdates(boolean failOnRedundantUpdates) {
- fFailOnRedundantUpdates = failOnRedundantUpdates;
- }
-
- public void setFailOnMultipleUpdateSequences(boolean failOnMultipleUpdateSequences) {
- fFailOnMultipleUpdateSequences = failOnMultipleUpdateSequences;
- }
-
- /**
- * Sets the the maximum amount of time (in milliseconds) that the update listener
- * is going to wait. If set to -1, the listener will wait indefinitely.
- */
- public void setTimeoutInterval(int milis) {
- fTimeoutInterval = milis;
- }
-
- public void reset(TreePath path, TestElement element, int levels, boolean failOnRedundantUpdates, boolean failOnMultipleUpdateSequences) {
- reset();
- addUpdates(path, element, levels);
- addProxies(element);
- setFailOnRedundantUpdates(failOnRedundantUpdates);
- setFailOnMultipleUpdateSequences(failOnMultipleUpdateSequences);
- }
-
- public void reset(boolean failOnRedundantUpdates, boolean failOnMultipleUpdateSequences) {
- reset();
- setFailOnRedundantUpdates(failOnRedundantUpdates);
- setFailOnMultipleUpdateSequences(failOnMultipleUpdateSequences);
- }
-
- public void reset() {
- fHasChildrenUpdates.clear();
- fChildrenUpdates.clear();
- fChildCountUpdates.clear();
- fLabelUpdates.clear();
- fProxyModels.clear();
- fViewerUpdatesComplete = false;
- fLabelUpdatesComplete = false;
- fModelChangedComplete = false;
- fStateSaveComplete = false;
- fStateRestoreComplete = false;
- fTimeoutTime = System.currentTimeMillis() + fTimeoutInterval;
- }
-
- public void addHasChildrenUpdate(TreePath path) {
- fHasChildrenUpdates.add(path);
- }
-
- public void removeHasChildrenUpdate(TreePath path) {
- fHasChildrenUpdates.remove(path);
- }
-
- public void addChildreCountUpdate(TreePath path) {
- fChildCountUpdates.add(path);
- }
-
- public void removeChildreCountUpdate(TreePath path) {
- fChildCountUpdates.remove(path);
- }
-
- public void addChildreUpdate(TreePath path, int index) {
- Set childrenIndexes = (Set)fChildrenUpdates.get(path);
- if (childrenIndexes == null) {
- childrenIndexes = new HashSet(1);
- fChildrenUpdates.put(path, childrenIndexes);
- }
- childrenIndexes.add(new Integer(index));
- }
-
- public void removeChildrenUpdate(TreePath path, int index) {
- Set childrenIndexes = (Set)fChildrenUpdates.get(path);
- if (childrenIndexes != null) {
- childrenIndexes.remove(new Integer(index));
- if (childrenIndexes.isEmpty()) {
- fChildrenUpdates.remove(path);
- }
- }
- }
-
- public void addLabelUpdate(TreePath path) {
- fLabelUpdates.add(path);
- }
-
- public void removeLabelUpdate(TreePath path) {
- fLabelUpdates.remove(path);
- }
-
- public void addUpdates(TreePath path, TestElement element, int levels) {
- addUpdates(path, element, levels, ALL_UPDATES_COMPLETE);
- }
-
- public void addStateUpdates(ITreeModelContentProviderTarget viewer, TreePath path, TestElement element) {
- addUpdates(viewer, path, element, -1, STATE_UPDATES);
- }
-
- public void addUpdates(TreePath path, TestElement element, int levels, int flags) {
- addUpdates(null, path, element, levels, flags);
- }
-
- public void addUpdates(ITreeModelContentProviderTarget viewer, TreePath path, TestElement element, int levels, int flags) {
- if (!path.equals(TreePath.EMPTY)) {
- if ((flags & LABEL_UPDATES) != 0) {
- fLabelUpdates.add(path);
- }
- if ((flags & HAS_CHILDREN_UPDATES) != 0) {
- fHasChildrenUpdates.add(path);
- }
- }
-
- if (levels-- != 0) {
- TestElement[] children = element.getChildren();
- if (children.length > 0 && (viewer == null || path.getSegmentCount() == 0 || viewer.getExpandedState(path))) {
- if ((flags & CHILDREN_COUNT_UPDATES) != 0) {
- fChildCountUpdates.add(path);
- }
- if ((flags & CHILDREN_UPDATES) != 0) {
- Set childrenIndexes = new HashSet();
- for (int i = 0; i < children.length; i++) {
- childrenIndexes.add(new Integer(i));
- }
- fChildrenUpdates.put(path, childrenIndexes);
- }
-
- if ((flags & STATE_UPDATES) != 0 && viewer != null) {
- fStateUpdates.add(path);
- }
-
- for (int i = 0; i < children.length; i++) {
- addUpdates(viewer, path.createChildPath(children[i]), children[i], levels, flags);
- }
- }
-
- }
- }
-
- private void addProxies(TestElement element) {
- TestModel model = element.getModel();
- if (model.getModelProxy() == null) {
- fProxyModels.add(element.getModel());
- }
- TestElement[] children = element.getChildren();
- for (int i = 0; i < children.length; i++) {
- addProxies(children[i]);
- }
- }
-
- public boolean isFinished() {
- return isFinished(ALL_UPDATES_COMPLETE);
- }
-
- public boolean isFinished(int flags) {
- if (fTimeoutInterval > 0 && fTimeoutTime < System.currentTimeMillis()) {
- throw new RuntimeException("Test timed out");
- }
-
- if ( (flags & LABEL_UPDATES_COMPLETE) != 0) {
- if (!fLabelUpdatesComplete) return false;
- }
- if ( (flags & LABEL_UPDATES) != 0) {
- if (!fLabelUpdates.isEmpty()) return false;
- }
- if ( (flags & CONTENT_UPDATES_COMPLETE) != 0) {
- if (!fViewerUpdatesComplete) return false;
- }
- if ( (flags & HAS_CHILDREN_UPDATES) != 0) {
- if (!fHasChildrenUpdates.isEmpty()) return false;
- }
- if ( (flags & CHILDREN_COUNT_UPDATES) != 0) {
- if (!fChildCountUpdates.isEmpty()) return false;
- }
- if ( (flags & CHILDREN_UPDATES) != 0) {
- if (!fChildrenUpdates.isEmpty()) return false;
- }
- if ( (flags & MODEL_CHANGED_COMPLETE) != 0) {
- if (!fModelChangedComplete) return false;
- }
- if ( (flags & STATE_SAVE_COMPLETE) != 0) {
- if (!fStateSaveComplete) return false;
- }
- if ( (flags & STATE_RESTORE_COMPLETE) != 0) {
- if (!fStateRestoreComplete) return false;
- }
- if ( (flags & MODEL_PROXIES_INSTALLED) != 0) {
- if (fProxyModels.size() != 0) return false;
- }
- if ( (flags & VIEWER_UPDATES_RUNNING) != 0) {
- if (fViewerUpdatesRunning != 0) {
- return false;
- }
- }
- if ( (flags & LABEL_UPDATES_RUNNING) != 0) {
- if (fLabelUpdatesRunning != 0) {
- return false;
- }
- }
- return true;
- }
-
- public void updateStarted(IViewerUpdate update) {
- synchronized (this) {
- fViewerUpdatesRunning++;
- }
- }
-
- public void updateComplete(IViewerUpdate update) {
- synchronized (this) {
- fViewerUpdatesRunning--;
- }
-
- if (!update.isCanceled()) {
- if (update instanceof IHasChildrenUpdate) {
- if (!fHasChildrenUpdates.remove(update.getElementPath()) && fFailOnRedundantUpdates) {
- Assert.fail("Redundant update: " + update);
- }
- } if (update instanceof IChildrenCountUpdate) {
- if (!fChildCountUpdates.remove(update.getElementPath()) && fFailOnRedundantUpdates) {
- Assert.fail("Redundant update: " + update);
- }
- } else if (update instanceof IChildrenUpdate) {
- int start = ((IChildrenUpdate)update).getOffset();
- int end = start + ((IChildrenUpdate)update).getLength();
-
- Set childrenIndexes = (Set)fChildrenUpdates.get(update.getElementPath());
- if (childrenIndexes != null) {
- for (int i = start; i < end; i++) {
- childrenIndexes.remove(new Integer(i));
- }
- if (childrenIndexes.isEmpty()) {
- fChildrenUpdates.remove(update.getElementPath());
- }
- } else if (fFailOnRedundantUpdates) {
- Assert.fail("Redundant update: " + update);
- }
- }
- }
- }
-
- public void viewerUpdatesBegin() {
-
- }
-
- public void viewerUpdatesComplete() {
- if (fFailOnMultipleUpdateSequences && fViewerUpdatesComplete) {
- Assert.fail("Multiple viewer update sequences detected");
- }
- fViewerUpdatesComplete = true;
- }
-
- public void labelUpdateComplete(ILabelUpdate update) {
- synchronized (this) {
- fLabelUpdatesRunning--;
- }
- if (!fLabelUpdates.remove(update.getElementPath()) && fFailOnRedundantUpdates) {
- Assert.fail("Redundant update: " + update);
- }
- }
-
- public void labelUpdateStarted(ILabelUpdate update) {
- synchronized (this) {
- fLabelUpdatesRunning++;
- }
- }
-
- public void labelUpdatesBegin() {
- }
-
- public void labelUpdatesComplete() {
- if (fFailOnMultipleUpdateSequences && fLabelUpdatesComplete) {
- Assert.fail("Multiple label update sequences detected");
- }
- fLabelUpdatesComplete = true;
- }
-
- public void modelChanged(IModelDelta delta, IModelProxy proxy) {
- if (fFailOnMultipleUpdateSequences && fModelChangedComplete) {
- Assert.fail("Multiple model changed sequences detected");
- }
- fModelChangedComplete = true;
-
- for (Iterator itr = fProxyModels.iterator(); itr.hasNext();) {
- TestModel model = (TestModel)itr.next();
- if (model.getModelProxy() == proxy) {
- itr.remove();
- break;
- }
- }
- }
-
- public void stateRestoreUpdatesBegin(Object input) {
- }
-
- public void stateRestoreUpdatesComplete(Object input) {
- fStateRestoreComplete = true;
- }
-
- public void stateSaveUpdatesBegin(Object input) {
- }
-
- public void stateSaveUpdatesComplete(Object input) {
- fStateSaveComplete = true;
- }
-
- public void stateUpdateComplete(Object input, IViewerUpdate update) {
- }
-
- public void stateUpdateStarted(Object input, IViewerUpdate update) {
- }
-}
-
-
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java
deleted file mode 100644
index 2600fbebb..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import java.util.LinkedList;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.jface.viewers.ILazyTreePathContentProvider;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- *
- */
-public class TreeModelViewerAutopopulateAgent implements IViewerUpdateListener {
-
- private TreeModelViewer fViewer;
-
-
- public TreeModelViewerAutopopulateAgent(TreeModelViewer viewer) {
- fViewer = viewer;
- fViewer.addViewerUpdateListener(this);
- }
-
- public void updateComplete(IViewerUpdate update) {
- if (update instanceof IChildrenCountUpdate) {
- TreePath path = update.getElementPath();
- ILazyTreePathContentProvider contentProvider = (ILazyTreePathContentProvider) fViewer.getContentProvider();
-
- Widget[] items = fViewer.testFindItems(update.getElement());
- for (int i = 0; i < items.length; i++) {
- if ( path.equals(getTreePath(items[i])) ) {
- int itemCount = getItemChildCount(items[i]);
- for (int j = 0; j < itemCount; j++) {
- contentProvider.updateElement(path, j);
- }
- }
- }
- }
- }
-
- public void updateStarted(IViewerUpdate update) {
- // TODO Auto-generated method stub
-
- }
-
- public void viewerUpdatesBegin() {
- // TODO Auto-generated method stub
-
- }
-
- public void viewerUpdatesComplete() {
- // TODO Auto-generated method stub
-
- }
-
- private TreePath getTreePath(Widget w) {
- if (w instanceof TreeItem) {
- TreeItem item = (TreeItem)w;
- LinkedList segments = new LinkedList();
- while (item != null) {
- Object segment = item.getData();
- Assert.isNotNull(segment);
- segments.addFirst(segment);
- item = item.getParentItem();
- }
- return new TreePath(segments.toArray());
- }
- return TreePath.EMPTY;
- }
-
- private int getItemChildCount(Widget w) {
- if (w instanceof Tree) {
- return ((Tree)w).getItemCount();
- } else if (w instanceof TreeItem) {
- return ((TreeItem)w).getItemCount();
- }
- return 0;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java
deleted file mode 100644
index eff52f495..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests to verify that the viewer property updates following changes in the
- * model, following simple content update deltas from the model.
- *
- * @since 3.6
- */
-abstract public class UpdateTests extends TestCase {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public UpdateTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- abstract protected ITreeModelViewer createViewer(Display display, Shell shell);
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- /**
- * This test:
- * - creates a simple model
- * - replaces the list of elements with a shorter list of elements
- * - refreshes the viewer
- */
- public void testRemoveElements() {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement root = model.getRootElement();
- TreePath rootPath = new TreePath(new Object[] {});
- TestElement[] newElements = new TestElement[] {
- new TestElement(model, "1", new TestElement[0]),
- new TestElement(model, "2", new TestElement[0]),
- new TestElement(model, "3", new TestElement[0]),
- };
- model.setElementChildren(rootPath, newElements);
-
- // Reset the listener to NOT fail on redundant updates.
- // When elements are remvoed from the model and the model is
- // refreshed the viewer will issue an IChildrenUpdate for the
- // missing elements as an optimization.
- fListener.reset(rootPath, root, -1, false, false);
-
- model.postDelta(new ModelDelta(root, IModelDelta.CONTENT));
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- /**
- * This test:
- * - creates a simple model
- * - sets a list of children to one of the elements
- * - refreshes the viewer
- */
- public void testAddNewChildren() {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- TestElement[] newChildren = new TestElement[] {
- new TestElement(model, "1.1", new TestElement[0]),
- new TestElement(model, "1.2", new TestElement[0]),
- new TestElement(model, "1.3", new TestElement[0]),
- };
- model.setElementChildren(elementPath, newChildren);
-
- // Reset the viewer to ignore redundant updates. The '1' element
- // will be updated for "hasChildren" before it is expanded, which is
- // expected.
- TreePath rootPath = TreePath.EMPTY;
- TestElement rootElement = model.getRootElement();
- fListener.reset(rootPath, rootElement, -1, false, false);
-
- // Refresh the viewer
- model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT));
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
-
- private void removeElement(TestModel model, int index) {
- ModelDelta delta = model.removeElementChild(TreePath.EMPTY, index);
-
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- private void addElement(TestModel model, String label, int position) {
- ModelDelta delta = model.addElementChild(TreePath.EMPTY, position, new TestElement(model, label, new TestElement[0]));
-
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_UPDATES_COMPLETE | TestModelUpdatesListener.LABEL_UPDATES_COMPLETE))
- if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- public void testRepeatedAddRemoveElement() {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
-
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
- while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- model.validateData(fViewer, TreePath.EMPTY);
-
- // Update the model
- removeElement(model, 2);
- addElement(model, "3-new", 3);
- removeElement(model, 4);
- addElement(model, "5-new", 5);
- removeElement(model, 1);
- addElement(model, "1-new", 1);
- removeElement(model, 3);
- addElement(model, "4-new", 4);
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java
deleted file mode 100644
index f3101784f..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class VirtualViewerDeltaTests extends DeltaTests {
-
- public VirtualViewerDeltaTests(String name) {
- super(name);
- }
-
- protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell) {
- return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java
deleted file mode 100644
index 6afa8f6de..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Tests which verify the operation of the virtual viewer in the lazy mode.
- * Note: the virtual viewer doesn't support lazy mode yet, so this class
- * is really just a big place holder.
- *
- * @since 3.6
- */
-public class VirtualViewerLazyModeTests extends TestCase {
- Display fDisplay;
- Shell fShell;
- ITreeModelViewer fViewer;
- TestModelUpdatesListener fListener;
-
- public VirtualViewerLazyModeTests(String name) {
- super(name);
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void setUp() throws Exception {
- fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
- fShell.setMaximized(true);
- fShell.setLayout(new FillLayout());
-
- fViewer = createViewer(fDisplay, fShell);
-
- fListener = new TestModelUpdatesListener(false, false);
- fViewer.addViewerUpdateListener(fListener);
- fViewer.addLabelUpdateListener(fListener);
- fViewer.addModelChangedListener(fListener);
-
- fShell.open ();
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"));
- }
-
- /**
- * @throws java.lang.Exception
- */
- protected void tearDown() throws Exception {
- fViewer.removeLabelUpdateListener(fListener);
- fViewer.removeViewerUpdateListener(fListener);
- fViewer.removeModelChangedListener(fListener);
-
- // Close the shell and exit.
- fShell.close();
- while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
- }
-
- public void test() {
- // TODO
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java
deleted file mode 100644
index 2c4e6cd6b..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class VirtualViewerPerformanceTests extends PerformanceTests {
-
- public VirtualViewerPerformanceTests(String name) {
- super(name);
- }
-
- protected ITreeModelContentProviderTarget createViewer(Display display, Shell shell) {
- return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer"));
- }
-
- protected int getTestModelDepth() {
- return 7;
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java
deleted file mode 100644
index e716acf03..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class VirtualViewerSelectionTests extends SelectionTests {
-
- public VirtualViewerSelectionTests(String name) {
- super(name);
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java
deleted file mode 100644
index 5a4e4d671..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class VirtualViewerStateTests extends StateTests {
-
- public VirtualViewerStateTests(String name) {
- super(name);
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java
deleted file mode 100644
index 507be5192..000000000
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipe.debug.tests.viewer.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.6
- */
-public class VirtualViewerUpdateTests extends UpdateTests {
-
- public VirtualViewerUpdateTests(String name) {
- super(name);
- }
-
- protected ITreeModelViewer createViewer(Display display, Shell shell) {
- return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer"));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
deleted file mode 100644
index 8d60693fb..000000000
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.debug.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipe.debug.tests.launching.AcceleratorSubstitutionTests;
-import org.eclipe.debug.tests.launching.LaunchConfigurationTests;
-import org.eclipe.debug.tests.launching.LaunchHistoryTests;
-import org.eclipe.debug.tests.launching.LaunchManagerTests;
-import org.eclipe.debug.tests.launching.RefreshTabTests;
-import org.eclipe.debug.tests.view.memory.MemoryRenderingTests;
-import org.eclipe.debug.tests.viewer.model.ChildrenUpdateTests;
-import org.eclipe.debug.tests.viewer.model.FilterTransformTests;
-import org.eclipe.debug.tests.viewer.model.JFaceViewerCheckTests;
-import org.eclipe.debug.tests.viewer.model.JFaceViewerContentTests;
-import org.eclipe.debug.tests.viewer.model.JFaceViewerDeltaTests;
-import org.eclipe.debug.tests.viewer.model.JFaceViewerSelectionTests;
-import org.eclipe.debug.tests.viewer.model.JFaceViewerStateTests;
-import org.eclipe.debug.tests.viewer.model.JFaceViewerUpdateTests;
-import org.eclipe.debug.tests.viewer.model.PresentationContextTests;
-import org.eclipe.debug.tests.viewer.model.VirtualViewerDeltaTests;
-import org.eclipe.debug.tests.viewer.model.VirtualViewerLazyModeTests;
-import org.eclipe.debug.tests.viewer.model.VirtualViewerSelectionTests;
-import org.eclipe.debug.tests.viewer.model.VirtualViewerStateTests;
-import org.eclipe.debug.tests.viewer.model.VirtualViewerUpdateTests;
-import org.eclipse.debug.tests.statushandlers.StatusHandlerTests;
-
-/**
- * Tests for integration and nightly builds.
- *
- * @since 3.6
- */
-public class AutomatedSuite extends TestSuite {
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- *
- * @return the test suite
- */
- public static Test suite() {
- return new AutomatedSuite();
- }
-
- /**
- * Constructs the automated test suite. Adds all tests.
- */
- public AutomatedSuite() {
- // JFace viewer tests
- addTest(new TestSuite(JFaceViewerCheckTests.class));
- addTest(new TestSuite(JFaceViewerContentTests.class));
- addTest(new TestSuite(JFaceViewerDeltaTests.class));
- addTest(new TestSuite(JFaceViewerSelectionTests.class));
- addTest(new TestSuite(JFaceViewerStateTests.class));
- addTest(new TestSuite(JFaceViewerUpdateTests.class));
-
- // Virtual viewer tests
- addTest(new TestSuite(VirtualViewerDeltaTests.class));
- addTest(new TestSuite(VirtualViewerLazyModeTests.class));
- addTest(new TestSuite(VirtualViewerSelectionTests.class));
- addTest(new TestSuite(VirtualViewerStateTests.class));
- addTest(new TestSuite(VirtualViewerUpdateTests.class));
-
- // Viewer neutral tests
- addTest(new TestSuite(FilterTransformTests.class));
- addTest(new TestSuite(ChildrenUpdateTests.class));
- addTest(new TestSuite(PresentationContextTests.class));
-
- // Memory view
- addTest(new TestSuite(MemoryRenderingTests.class));
-
- // Launch framework
- addTest(new TestSuite(LaunchConfigurationTests.class));
- addTest(new TestSuite(AcceleratorSubstitutionTests.class));
- addTest(new TestSuite(LaunchHistoryTests.class));
- addTest(new TestSuite(LaunchManagerTests.class));
- addTest(new TestSuite(RefreshTabTests.class));
-
- // Status handlers
- addTest(new TestSuite(StatusHandlerTests.class));
- }
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java
deleted file mode 100644
index 98fcfaca9..000000000
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipe.debug.tests.viewer.model.JFaceViewerPerformanceTests;
-import org.eclipe.debug.tests.viewer.model.VirtualViewerPerformanceTests;
-
-/**
- * Tests for release builds.
- *
- * @since 3.6
- */
-public class PerformanceSuite extends TestSuite {
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- *
- * @return the test suite
- */
- public static Test suite() {
- return new PerformanceSuite();
- }
-
- /**
- * Constructs the automated test suite. Adds all tests.
- */
- public PerformanceSuite() {
- // JFace viewer tests
- addTest(new TestSuite(JFaceViewerPerformanceTests.class));
-
- // Virtual viewer tests
- addTest(new TestSuite(VirtualViewerPerformanceTests.class));
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java
deleted file mode 100644
index 6652d3339..000000000
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems 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:
- * Wind River Systems - initial API and implementation
- * IBM - ongoing enhancements
- *******************************************************************************/
-package org.eclipse.debug.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- *
- * @since 3.6
- */
-public class TestsPlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.debug.tests"; //$NON-NLS-1$
-
- // The shared instance
- private static TestsPlugin plugin;
-
- /**
- * The constructor
- */
- public TestsPlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static TestsPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the file corresponding to the specified path from within this bundle
- * @param path
- * @return the file corresponding to the specified path from within this bundle, or
- * <code>null</code> if not found
- */
- public File getFileInPlugin(IPath path) {
- try {
- Bundle bundle = getDefault().getBundle();
- URL installURL= new URL(bundle.getEntry("/"), path.toString());
- URL localURL= FileLocator.toFileURL(installURL);//Platform.asLocalURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException e) {
- return null;
- }
- }
-
- /**
- * Creates a new project with the specified name
- * @param projectName
- * @return a new project with the specified name
- * @throws CoreException
- */
- public static IProject createProject(String projectName) throws CoreException {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IProject project= root.getProject(projectName);
- if (!project.exists()) {
- project.create(null);
- } else {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- if (!project.isOpen()) {
- project.open(null);
- }
- return project;
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java
deleted file mode 100644
index 6315b43f1..000000000
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.debug.tests.statushandlers;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.debug.core.IStatusHandler;
-
-/**
- * Test status handler
- */
-public class StatusHandler implements IStatusHandler {
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
- */
- public Object handleStatus(IStatus status, Object source) throws CoreException {
- return null;
- }
-
-}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java
deleted file mode 100644
index bb002ca6e..000000000
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.debug.tests.statushandlers;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IStatusHandler;
-import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
-import org.eclipse.debug.internal.core.Preferences;
-import org.eclipse.debug.tests.TestsPlugin;
-
-/**
- * Tests status handlers
- */
-public class StatusHandlerTests extends TestCase {
-
- /**
- * Status for which a handler is registered.
- */
- public static final IStatus STATUS = new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID, 333,"", null);
-
- /**
- * Tests that a status handler extension exists
- */
- public void testStatusHandlerExtension() {
- IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(STATUS);
- assertNotNull("missing status handler extension", handler);
- assertTrue("Unexpected handler", handler instanceof StatusHandler);
- }
-
- /**
- * Tests that status handlers are not returned when preference is disabled
- */
- public void testDisableStatusHandlers() {
- try {
- Preferences.setBoolean(DebugPlugin.getUniqueIdentifier(), IInternalDebugCoreConstants.PREF_ENABLE_STATUS_HANDLERS, false, new InstanceScope());
- IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(STATUS);
- assertNull("status handler extension should be disabled", handler);
- } finally {
- Preferences.setBoolean(DebugPlugin.getUniqueIdentifier(), IInternalDebugCoreConstants.PREF_ENABLE_STATUS_HANDLERS, true, new InstanceScope());
- }
- }
-
-}

Back to the top