Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2009-11-19 13:10:03 +0000
committerAnton Leherbauer2009-11-19 13:10:03 +0000
commit44a799e535bee5e97a271cbad0b5572ca2d3ac3e (patch)
treef00c865e05a19d6ff5b58defb13e347bd551aeb2 /core/org.eclipse.cdt.core.tests
parent1ba9b90d8f20cd688ff92dcb7b75407a72dbae5f (diff)
downloadorg.eclipse.cdt-44a799e535bee5e97a271cbad0b5572ca2d3ac3e.tar.gz
org.eclipse.cdt-44a799e535bee5e97a271cbad0b5572ca2d3ac3e.tar.xz
org.eclipse.cdt-44a799e535bee5e97a271cbad0b5572ca2d3ac3e.zip
Test case for bug 179474 - src-exclusion filters are not updated correctly for project sub-folders/files
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java86
1 files changed, 85 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java
index 414fec75928..0b52ede6046 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java
@@ -13,6 +13,7 @@ package org.eclipse.cdt.core.model.tests;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
@@ -321,7 +322,7 @@ public class CModelTests extends TestCase {
sourceRoot = (ISourceRoot) cSourceRoots.get(0);
- cContainers = sourceRoot .getChildrenOfType(ICElement.C_CCONTAINER);
+ cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
assertEquals(1, cContainers.size());
assertEquals("test", cContainers.get(0).getElementName());
@@ -344,4 +345,87 @@ public class CModelTests extends TestCase {
catch (CoreException e) {}
}
+
+ // bug 179474
+ public void testSourceExclusionFilters_179474() throws Exception {
+ ICProject testProject;
+ testProject=CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER);
+ if (testProject==null)
+ fail("Unable to create project");
+
+ IFolder subFolder = testProject.getProject().getFolder("sub");
+ subFolder.create(true, true, monitor);
+ IFile fileA = testProject.getProject().getFile("a.cpp");
+ fileA.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+ IFile fileB = subFolder.getFile("b.cpp");
+ fileB.create(new ByteArrayInputStream(new byte[0]), true, monitor);
+
+ List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cSourceRoots.size());
+ assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
+
+ ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0);
+
+ List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cContainers.size());
+ assertEquals(subFolder.getName(), cContainers.get(0).getElementName());
+
+ ICContainer subContainer = (ICContainer) cContainers.get(0);
+
+ List<ICElement> tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(1, tUnits.size());
+ assertEquals(fileB.getName(), tUnits.get(0).getElementName());
+
+ tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(1, tUnits.size());
+ assertEquals(fileA.getName(), tUnits.get(0).getElementName());
+
+ ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
+ ICConfigurationDescription activeCfg= prjDesc.getActiveConfiguration();
+ assertNotNull(activeCfg);
+
+ // add filter to source entry
+ ICSourceEntry[] entries = activeCfg.getSourceEntries();
+ final String sourceEntryName = entries[0].getName();
+ final IPath[] exclusionPatterns = new IPath[] { new Path("**/*.cpp") };
+
+ ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags());
+ activeCfg.setSourceEntries(new ICSourceEntry[] {entry});
+
+ // store the changed configuration
+ CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc);
+
+ testProject.close();
+
+ cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cSourceRoots.size());
+ assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName());
+
+ sourceRoot = (ISourceRoot) cSourceRoots.get(0);
+
+ cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER);
+ assertEquals(1, cContainers.size());
+ assertEquals(subFolder.getName(), cContainers.get(0).getElementName());
+
+ subContainer = (ICContainer) cContainers.get(0);
+
+ tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(0, tUnits.size());
+
+ tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT);
+ assertEquals(0, tUnits.size());
+
+ Object[] nonCResources = subContainer.getNonCResources();
+ assertEquals(1, nonCResources.length);
+ assertEquals(fileB, nonCResources[0]);
+
+ nonCResources = sourceRoot.getNonCResources();
+ assertTrue(Arrays.asList(nonCResources).contains(fileA));
+
+ try {
+ testProject.getProject().delete(true,true,monitor);
+ }
+ catch (CoreException e) {}
+
+ }
}

Back to the top