forked from eclipse-cdt/cdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 421544 - When searching for the target file for Toggle Source/Hea…
…der, prefer files closer to the origin file in the directory structure Change-Id: I82a3c1dc3f09cecb69e07511dd5b8bed62676b6a Signed-off-by: Nathan Ridge <[email protected]>
- Loading branch information
1 parent
91f4a98
commit 5623c39
Showing
4 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/editor/EditorTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015 Nathan Ridge. | ||
* 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: | ||
* Nathan Ridge - initial implementation | ||
*******************************************************************************/ | ||
package org.eclipse.cdt.ui.tests.editor; | ||
|
||
import junit.framework.TestSuite; | ||
|
||
/** | ||
* Tests for functionality in the package org.eclipse.cdt.internal.ui.editor. | ||
*/ | ||
public class EditorTestSuite extends TestSuite { | ||
|
||
public static TestSuite suite() { | ||
return new EditorTestSuite(); | ||
} | ||
|
||
public EditorTestSuite() { | ||
super(EditorTestSuite.class.getName()); | ||
addTest(SourceHeaderPartnerFinderTest.suite()); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...clipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/editor/SourceHeaderPartnerFinderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015 Nathan Ridge. | ||
* 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: | ||
* Nathan Ridge - initial implementation | ||
*******************************************************************************/ | ||
package org.eclipse.cdt.ui.tests.editor; | ||
|
||
import junit.framework.TestSuite; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
|
||
import org.eclipse.cdt.core.dom.IPDOMManager; | ||
import org.eclipse.cdt.core.model.CoreModel; | ||
import org.eclipse.cdt.core.model.ICProject; | ||
import org.eclipse.cdt.core.model.ITranslationUnit; | ||
import org.eclipse.cdt.core.testplugin.CProjectHelper; | ||
import org.eclipse.cdt.ui.tests.BaseUITestCase; | ||
|
||
import org.eclipse.cdt.internal.ui.editor.SourceHeaderPartnerFinder; | ||
|
||
/** | ||
* Tests for org.eclipse.cdt.internal.ui.editor.SourceHeaderPartnerFinder. | ||
*/ | ||
public class SourceHeaderPartnerFinderTest extends BaseUITestCase { | ||
|
||
public static TestSuite suite() { | ||
return suite(SourceHeaderPartnerFinderTest.class); | ||
} | ||
|
||
protected static IProgressMonitor NPM= new NullProgressMonitor(); | ||
|
||
private ICProject fCProject; | ||
|
||
public SourceHeaderPartnerFinderTest(String name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
fCProject= CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", | ||
IPDOMManager.ID_FAST_INDEXER); | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
if (fCProject != null) { | ||
CProjectHelper.delete(fCProject); | ||
} | ||
super.tearDown(); | ||
} | ||
|
||
public void testFilesWithSameNameInSubdirectory_421544() throws Exception { | ||
IProject project = fCProject.getProject(); | ||
IFile originFile = createFile(project, "code.cc", ""); | ||
IFile expectedTargetFile = createFile(project, "code.h", ""); | ||
createFile(project, "sub/code.cc", ""); | ||
createFile(project, "sub/code.h", ""); | ||
ITranslationUnit originTU = (ITranslationUnit) CoreModel.getDefault().create(originFile); | ||
ITranslationUnit targetTU = SourceHeaderPartnerFinder.getPartnerTranslationUnit(originTU); | ||
IFile targetFile = (IFile) targetTU.getResource(); | ||
assertEquals(expectedTargetFile, targetFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters