mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
1. Fix for [Bug 188764]
It should NOT be possible to apply the CProjectDescription with no configurations 2. test-case
This commit is contained in:
parent
b4934e9a27
commit
825e48a310
6 changed files with 78 additions and 1 deletions
|
@ -28,6 +28,7 @@ public class AllCProjectDescriptionTests {
|
|||
suite.addTest(CfgSettingsTests.suite());
|
||||
suite.addTest(ProjectCreationStateTests.suite());
|
||||
suite.addTest(BackwardCompatibilityTests.suite());
|
||||
suite.addTest(CProjectDescriptionBasicTests.suite());
|
||||
return suite;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.settings.model;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||
private static final String PROJ_NAME_PREFIX = "CProjectDescriptionBasicTests_";
|
||||
IProject p1;
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(CProjectDescriptionBasicTests.class, "_");
|
||||
}
|
||||
|
||||
public void testSetInvalidDescription() throws Exception {
|
||||
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||
IWorkspaceRoot root = wsp.getRoot();
|
||||
|
||||
p1 = root.getProject(PROJ_NAME_PREFIX + "1");
|
||||
p1.create(null);
|
||||
p1.open(null);
|
||||
|
||||
CProjectHelper.addNatureToProject(p1, CProjectNature.C_NATURE_ID, null);
|
||||
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
|
||||
ICProjectDescription des = mngr.createProjectDescription(p1, false);
|
||||
|
||||
assertFalse(des.isValid());
|
||||
|
||||
boolean failed = false;
|
||||
try {
|
||||
mngr.setProjectDescription(p1, des);
|
||||
} catch (CoreException e){
|
||||
failed = true;
|
||||
}
|
||||
|
||||
assertTrue(failed);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
p1.getProject().delete(true, null);
|
||||
} catch (CoreException e){
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
|
@ -417,7 +417,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
|||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return fProject.exists() && fCfgMap.size() > 0;
|
||||
return /*fProject.exists() &&*/ fCfgMap.size() > 0;
|
||||
}
|
||||
|
||||
public void updateChild(CDataProxy child, boolean write) {
|
||||
|
|
|
@ -1159,6 +1159,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
}
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
if(!des.isValid())
|
||||
throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName()); //$NON-NLS-1$
|
||||
|
||||
if(!checkFlags(flags, SET_FORCE) && !des.isModified())
|
||||
return;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
|||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.internal.core.model.CModelOperation;
|
||||
import org.eclipse.cdt.internal.core.model.CModelStatus;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.CompositeWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
@ -40,6 +41,10 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
|
|||
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||
ICProject cProject = (ICProject)getElementToProcess();
|
||||
final IProject project = cProject.getProject();
|
||||
|
||||
if(!fSetDescription.isValid())
|
||||
throw new CModelException(ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName())); //$NON-NLS-1$
|
||||
|
||||
CProjectDescription fOldDescriptionCache = (CProjectDescription)mngr.getProjectDescription(project, false);
|
||||
|
||||
CProjectDescriptionEvent event = mngr.createAboutToApplyEvent(fSetDescription, fOldDescriptionCache);
|
||||
|
|
|
@ -35,6 +35,7 @@ CProjectDescriptionManager.13=Refreshing the project settings
|
|||
CProjectDescriptionManager.14=workspace info element does not exist
|
||||
CProjectDescriptionManager.15=Preference Configuration
|
||||
CProjectDescriptionManager.16=attempt to set description for the non-openned project
|
||||
CProjectDescriptionManager.17=unable to apply the invalid project description for project
|
||||
CFolderDescription.0=data was not created
|
||||
CFolderDescription.1=expected proxy of type ICLanguageSetting, but was
|
||||
CFolderDescription.2=data was not created
|
||||
|
|
Loading…
Add table
Reference in a new issue