1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

Bug 488348 - fix target remove.

Change-Id: I50d08fcfc46d723aa59fc6cc2f909de73f74d3de
This commit is contained in:
Doug Schaefer 2016-05-05 11:35:59 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent c6eca5a103
commit 91be36a418
2 changed files with 50 additions and 1 deletions

View file

@ -214,7 +214,7 @@ public class LaunchTargetManager implements ILaunchTargetManager {
String typeId = target.getTypeId();
Map<String, ILaunchTarget> type = targets.get(typeId);
if (type != null) {
type.remove(target);
type.remove(target.getId());
if (type.isEmpty()) {
targets.remove(target.getTypeId());
}

View file

@ -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));
}
}