mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix JUnit tests
This commit is contained in:
parent
518b582cd0
commit
36b57b7212
4 changed files with 24 additions and 21 deletions
|
@ -77,13 +77,15 @@ public class BasicCEditorTest extends BaseUITestCase {
|
||||||
private TestDocListener fDocListener= new TestDocListener();
|
private TestDocListener fDocListener= new TestDocListener();
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new TestSuite(BasicCEditorTest.class);
|
return new TestSuite(BasicCEditorTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown () throws Exception {
|
protected void tearDown () throws Exception {
|
||||||
EditorTestHelper.closeEditor(fEditor);
|
EditorTestHelper.closeEditor(fEditor);
|
||||||
if (fCProject != null)
|
if (fCProject != null)
|
||||||
|
@ -185,6 +187,7 @@ public class BasicCEditorTest extends BaseUITestCase {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
public void testEditNewTranslationUnit() throws Exception {
|
public void testEditNewTranslationUnit() throws Exception {
|
||||||
fCProject= EditorTestHelper.createCProject("ceditor", "resources/ceditor", false, false);
|
fCProject= EditorTestHelper.createCProject("ceditor", "resources/ceditor", false, false);
|
||||||
IFile newFile= createFile(fCProject.getProject(), "Point.cpp", "");
|
IFile newFile= createFile(fCProject.getProject(), "Point.cpp", "");
|
||||||
|
@ -222,7 +225,7 @@ public class BasicCEditorTest extends BaseUITestCase {
|
||||||
setUpEditor(newFile);
|
setUpEditor(newFile);
|
||||||
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
||||||
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
||||||
content= fDocument.get();
|
content= fDocument.get().trim();
|
||||||
assertEquals("Save failed", newContent, content);
|
assertEquals("Save failed", newContent, content);
|
||||||
// check reconciler
|
// check reconciler
|
||||||
ITranslationUnit tUnit= (ITranslationUnit)fEditor.getInputCElement();
|
ITranslationUnit tUnit= (ITranslationUnit)fEditor.getInputCElement();
|
||||||
|
@ -352,6 +355,7 @@ public class BasicCEditorTest extends BaseUITestCase {
|
||||||
fAccessor.invoke("handleKeyDown", new Object[] {event});
|
fAccessor.invoke("handleKeyDown", new Object[] {event});
|
||||||
|
|
||||||
new DisplayHelper() {
|
new DisplayHelper() {
|
||||||
|
@Override
|
||||||
protected boolean condition() {
|
protected boolean condition() {
|
||||||
return fDocListener.fDocChanged;
|
return fDocListener.fDocChanged;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,13 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
//
|
//
|
||||||
//extern C1* gfC1();
|
//extern C1* gfC1();
|
||||||
//C2* gfC2();
|
//C2* gfC2();
|
||||||
//
|
//
|
||||||
//enum E1 {e11, e12};
|
//enum E1 {e11, e12};
|
||||||
//
|
//
|
||||||
//class C1 {
|
//class C1 {
|
||||||
//public:
|
//public:
|
||||||
// enum E2 {e21, e22};
|
// enum E2 {e21, e22};
|
||||||
//
|
//
|
||||||
// C1* fMySelf;
|
// C1* fMySelf;
|
||||||
// void iam1();
|
// void iam1();
|
||||||
//
|
//
|
||||||
|
@ -117,7 +117,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
//
|
//
|
||||||
// C3* m123();
|
// C3* m123();
|
||||||
// C3* m13();
|
// C3* m13();
|
||||||
//
|
//
|
||||||
// template<typename T> T tConvert();
|
// template<typename T> T tConvert();
|
||||||
//private:
|
//private:
|
||||||
// void m3private();
|
// void m3private();
|
||||||
|
@ -395,14 +395,14 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
"T1", "T2", "T3", "TClass"
|
"T1", "T2", "T3", "TClass"
|
||||||
};
|
};
|
||||||
assertCompletionResults(fCursorOffset, expected,
|
assertCompletionResults(fCursorOffset, expected,
|
||||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//namespace ns {void nsfunc(){C/*cursor*/
|
//namespace ns {void nsfunc(){C/*cursor*/
|
||||||
public void testTypes_NamespaceScope() throws Exception {
|
public void testTypes_NamespaceScope() throws Exception {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
"C1", "C2", "C3", "CNS"
|
"C1", "C2", "C3", "CNS"
|
||||||
};
|
};
|
||||||
assertCompletionResults(fCursorOffset, expected,
|
assertCompletionResults(fCursorOffset, expected,
|
||||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||||
|
@ -422,7 +422,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
"e11", "e12", "E1"
|
"e11", "e12", "E1"
|
||||||
};
|
};
|
||||||
assertCompletionResults(fCursorOffset, expected,
|
assertCompletionResults(fCursorOffset, expected,
|
||||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
"e11", "e12", "e21", "e22", "E1", "E2"
|
"e11", "e12", "e21", "e22", "E1", "E2"
|
||||||
};
|
};
|
||||||
assertCompletionResults(fCursorOffset, expected,
|
assertCompletionResults(fCursorOffset, expected,
|
||||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,7 +703,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
//#i/*cursor*/
|
//#i/*cursor*/
|
||||||
public void testCompletePreprocessorDirective() throws Exception {
|
public void testCompletePreprocessorDirective() throws Exception {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
"#if ", "#ifdef ", "#ifndef ", "#include "
|
"#if", "#ifdef", "#ifndef", "#include"
|
||||||
};
|
};
|
||||||
assertCompletionResults(fCursorOffset, expected,
|
assertCompletionResults(fCursorOffset, expected,
|
||||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||||
|
@ -830,7 +830,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
// } my_struct;
|
// } my_struct;
|
||||||
//
|
//
|
||||||
// void func(my_struct s);
|
// void func(my_struct s);
|
||||||
//
|
//
|
||||||
// void test() {
|
// void test() {
|
||||||
// fun/*cursor*/
|
// fun/*cursor*/
|
||||||
public void testFunctionWithTypedefToAnonymousType_bug192787() throws Exception {
|
public void testFunctionWithTypedefToAnonymousType_bug192787() throws Exception {
|
||||||
|
@ -847,7 +847,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
public void testBindingsWithoutDeclaration() throws Exception {
|
public void testBindingsWithoutDeclaration() throws Exception {
|
||||||
// gC1all, gStruct, gnsClass, gnsStruct: fix for 214146, type from a source file is not proposed.
|
// gC1all, gStruct, gnsClass, gnsStruct: fix for 214146, type from a source file is not proposed.
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
"gC1", "gC2", "gfC1()", "gfC2()",
|
"gC1", "gC2", "gfC1()", "gfC2()",
|
||||||
"gns::", "gnsFunc()", "gnsTemp",
|
"gns::", "gnsFunc()", "gnsTemp",
|
||||||
"gFunc()", "gTemp"
|
"gFunc()", "gTemp"
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,6 @@ import junit.framework.Assert;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
@ -89,6 +88,7 @@ public class DocCommentHighlightingTest extends BaseUITestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
fCProject= EditorTestHelper.createCProject(PROJECT, LINKED_FOLDER);
|
fCProject= EditorTestHelper.createCProject(PROJECT, LINKED_FOLDER);
|
||||||
|
@ -97,10 +97,10 @@ public class DocCommentHighlightingTest extends BaseUITestCase {
|
||||||
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
||||||
// source positions depend on Windows line separator
|
// source positions depend on Windows line separator
|
||||||
adjustLineSeparator(fSourceViewer.getDocument(), "\r\n");
|
adjustLineSeparator(fSourceViewer.getDocument(), "\r\n");
|
||||||
fEditor.doSave(new NullProgressMonitor());
|
|
||||||
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown () throws Exception {
|
protected void tearDown () throws Exception {
|
||||||
EditorTestHelper.closeAllEditors();
|
EditorTestHelper.closeAllEditors();
|
||||||
|
|
||||||
|
|
|
@ -83,9 +83,8 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
||||||
Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
|
Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
|
||||||
|
|
||||||
for(String keyword : languageKeywords.getPreprocessorKeywords()) {
|
for(String keyword : languageKeywords.getPreprocessorKeywords()) {
|
||||||
keyword = keyword + ' ';
|
if (keyword.startsWith(prefix) && keyword.length() > prefixLength) {
|
||||||
String repString = keyword;
|
String repString = keyword + ' ';
|
||||||
if (repString.startsWith(prefix) && keyword.length() > prefixLength) {
|
|
||||||
int repLength = prefixLength;
|
int repLength = prefixLength;
|
||||||
int repOffset = context.getInvocationOffset() - repLength;
|
int repOffset = context.getInvocationOffset() - repLength;
|
||||||
if (prefix.charAt(0) == '#') {
|
if (prefix.charAt(0) == '#') {
|
||||||
|
@ -99,7 +98,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
||||||
proposals.add(new CCompletionProposal(repString, repOffset,
|
proposals.add(new CCompletionProposal(repString, repOffset,
|
||||||
repLength, image, keyword, relevance, context.getViewer()));
|
repLength, image, keyword, relevance, context.getViewer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isValidContext(completionNode))
|
if (!isValidContext(completionNode))
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -150,7 +149,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
||||||
* Test whether the invocation offset is inside or before the preprocessor directive keyword.
|
* Test whether the invocation offset is inside or before the preprocessor directive keyword.
|
||||||
*
|
*
|
||||||
* @param context the invocation context
|
* @param context the invocation context
|
||||||
* @return <code>true</code> if the invocation offset is inside or before the directive keyword
|
* @return <code>true</code> if the invocation offset is inside or before the directive keyword
|
||||||
*/
|
*/
|
||||||
private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
|
private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
|
||||||
IDocument doc = context.getDocument();
|
IDocument doc = context.getDocument();
|
||||||
|
|
Loading…
Add table
Reference in a new issue