mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-06 07:45:50 +02:00
Bug 488348 - fix target remove.
Change-Id: I50d08fcfc46d723aa59fc6cc2f909de73f74d3de
This commit is contained in:
parent
c6eca5a103
commit
91be36a418
2 changed files with 50 additions and 1 deletions
|
@ -214,7 +214,7 @@ public class LaunchTargetManager implements ILaunchTargetManager {
|
||||||
String typeId = target.getTypeId();
|
String typeId = target.getTypeId();
|
||||||
Map<String, ILaunchTarget> type = targets.get(typeId);
|
Map<String, ILaunchTarget> type = targets.get(typeId);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
type.remove(target);
|
type.remove(target.getId());
|
||||||
if (type.isEmpty()) {
|
if (type.isEmpty()) {
|
||||||
targets.remove(target.getTypeId());
|
targets.remove(target.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 QNX Software 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
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.launchbar.core.internal;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||||
|
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public class LaunchTargetTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveLaunchTarget() throws CoreException {
|
||||||
|
ILaunchTargetManager manager = Activator.getLaunchTargetManager();
|
||||||
|
// Account for pre-populated targets
|
||||||
|
int baseSize = manager.getLaunchTargets().length;
|
||||||
|
ILaunchTarget target1 = manager.addLaunchTarget("mytype", "target1");
|
||||||
|
ILaunchTarget target2 = manager.addLaunchTarget("mytype", "target2");
|
||||||
|
Set<ILaunchTarget> targetSet = new HashSet<>(Arrays.asList(manager.getLaunchTargets()));
|
||||||
|
assertEquals(baseSize + 2, targetSet.size());
|
||||||
|
assertTrue(targetSet.contains(target1));
|
||||||
|
assertTrue(targetSet.contains(target2));
|
||||||
|
manager.removeLaunchTarget(target2);
|
||||||
|
targetSet = new HashSet<>(Arrays.asList(manager.getLaunchTargets()));
|
||||||
|
assertEquals(baseSize + 1, targetSet.size());
|
||||||
|
assertTrue(targetSet.contains(target1));
|
||||||
|
assertFalse(targetSet.contains(target2));
|
||||||
|
manager.removeLaunchTarget(target1);
|
||||||
|
targetSet = new HashSet<>(Arrays.asList(manager.getLaunchTargets()));
|
||||||
|
assertEquals(baseSize, targetSet.size());
|
||||||
|
assertFalse(targetSet.contains(target1));
|
||||||
|
assertFalse(targetSet.contains(target2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue