From d065bc268ebf47a20bfda56f36fee0c6821412c9 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 13 Nov 2007 09:55:04 +0000 Subject: [PATCH] JUnit tests for F3 on includes. --- .../CPPSelectionTestsAnyIndexer.java | 24 +++++++++++++++++++ .../selection/CSelectionTestsAnyIndexer.java | 23 ++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java index b61c98caf60..218a6efc32b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java @@ -14,6 +14,10 @@ import java.io.IOException; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -940,4 +944,24 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde decl = testF3(file, offset1); assertNode("MY_MACRO", offset0, decl); } + + // int wurscht; + + // #include "aheader.h" + public void testIncludeNavigation() throws Exception { + StringBuffer[] buffers= getContents(2); + String hcode= buffers[0].toString(); + String scode= buffers[1].toString(); + IFile hfile = importFile("aheader.h", hcode); + IFile file = importFile("includenavi.cpp", scode); + TestSourceReader.waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME); + IASTNode decl; + int offset0, offset1; + + offset1 = scode.indexOf("aheader.h"); + testF3(file, offset1); + IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + IEditorInput input = part.getEditorInput(); + assertEquals("aheader.h", ((FileEditorInput)input).getFile().getName()); + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java index d33372660f9..6dcffcb3604 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java @@ -15,6 +15,10 @@ import java.io.IOException; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -475,4 +479,23 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe assertNode("MY_MACRO", offset0, decl); } + // int wurscht; + + // #include "aheader.h" + public void testIncludeNavigation() throws Exception { + StringBuffer[] buffers= getContents(2); + String hcode= buffers[0].toString(); + String scode= buffers[1].toString(); + IFile hfile = importFile("aheader.h", hcode); + IFile file = importFile("includenavi.c", scode); + TestSourceReader.waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME); + IASTNode decl; + int offset0, offset1; + + offset1 = scode.indexOf("aheader.h"); + testF3(file, offset1); + IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + IEditorInput input = part.getEditorInput(); + assertEquals("aheader.h", ((FileEditorInput)input).getFile().getName()); + } }