1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-10-06 20:16:13 -07:00
parent 9fc84c15c8
commit 32b06b4c26
2 changed files with 20 additions and 33 deletions

View file

@ -112,7 +112,7 @@ public class BasicSearchTest extends BaseUITestCase {
ISearchResultViewPart vp= NewSearchUI.getSearchResultView(); ISearchResultViewPart vp= NewSearchUI.getSearchResultView();
ISearchResultPage page= vp.getActivePage(); ISearchResultPage page= vp.getActivePage();
assertTrue(""+page, page instanceof CSearchViewPage); assertTrue(String.valueOf(page), page instanceof CSearchViewPage);
CSearchViewPage pdomsvp= (CSearchViewPage) page; CSearchViewPage pdomsvp= (CSearchViewPage) page;
StructuredViewer viewer= pdomsvp.getViewer(); StructuredViewer viewer= pdomsvp.getViewer();
@ -221,9 +221,7 @@ public class BasicSearchTest extends BaseUITestCase {
coreTestIndexerInProgress(true); coreTestIndexerInProgress(true);
} }
/**
*
*/
private void coreTestIndexerInProgress(boolean expectComplete) { private void coreTestIndexerInProgress(boolean expectComplete) {
// open a query // open a query
CSearchQuery query= makeProjectQuery("data*"); CSearchQuery query= makeProjectQuery("data*");
@ -231,10 +229,11 @@ public class BasicSearchTest extends BaseUITestCase {
final int maximumHits = INDEXER_IN_PROGRESS_FILE_COUNT * INDEXER_IN_PROGRESS_STRUCT_COUNT; final int maximumHits = INDEXER_IN_PROGRESS_FILE_COUNT * INDEXER_IN_PROGRESS_STRUCT_COUNT;
Object[] elements = result.getElements(); Object[] elements = result.getElements();
if (expectComplete) if (expectComplete) {
assertEquals(maximumHits, elements.length); assertEquals(maximumHits, elements.length);
else } else {
assertTrue(maximumHits >= elements.length); // >= because may still be done assertTrue(maximumHits >= elements.length); // >= because may still be done
}
ISearchResultViewPart vp= NewSearchUI.getSearchResultView(); ISearchResultViewPart vp= NewSearchUI.getSearchResultView();
ISearchResultPage page= vp.getActivePage(); ISearchResultPage page= vp.getActivePage();
@ -269,14 +268,11 @@ public class BasicSearchTest extends BaseUITestCase {
assertFalse(firstRootNode instanceof IStatus); assertFalse(firstRootNode instanceof IStatus);
} }
} }
/** /**
* Run the specified query, and return the result. When tehis method returns the * Runs the specified query, and returns the result. When this method returns,
* search page will have been opened. * the search page will have been opened.
* @param query
* @return
*/ */
protected CSearchResult runQuery(CSearchQuery query) { protected CSearchResult runQuery(CSearchQuery query) {
final ISearchResult result[]= new ISearchResult[1]; final ISearchResult result[]= new ISearchResult[1];
@ -306,6 +302,17 @@ public class BasicSearchTest extends BaseUITestCase {
return (CSearchResult) result[0]; return (CSearchResult) result[0];
} }
private CSearchQuery makeProjectQuery(String pattern) {
String scope1= "Human Readable Description";
return new CSearchPatternQuery(new ICElement[] {fCProject}, scope1, pattern, true, CSearchQuery.FIND_ALL_OCCURRENCES | CSearchPatternQuery.FIND_ALL_TYPES);
}
private void assertOccurrences(CSearchQuery query, int expected) {
query.run(npm());
CSearchResult result= (CSearchResult) query.getSearchResult();
assertEquals(expected, result.getMatchCount());
}
// void foo() {} // void foo() {}
// void bar() { // void bar() {
@ -350,17 +357,6 @@ public class BasicSearchTest extends BaseUITestCase {
assertOccurrences(query, 3); assertOccurrences(query, 3);
} }
private CSearchQuery makeProjectQuery(String pattern) {
String scope1= "Human Readable Description";
return new CSearchPatternQuery(new ICElement[] {fCProject}, scope1, pattern, true, CSearchQuery.FIND_ALL_OCCURRENCES | CSearchPatternQuery.FIND_ALL_TYPES);
}
private void assertOccurrences(CSearchQuery query, int expected) {
query.run(npm());
CSearchResult result= (CSearchResult) query.getSearchResult();
assertEquals(expected, result.getMatchCount());
}
// template<typename T> class CT {}; // template<typename T> class CT {};
// template<typename T> class CT<T*> {}; // template<typename T> class CT<T*> {};
// template<typename T> void f(T) {}; // template<typename T> void f(T) {};
@ -383,5 +379,4 @@ public class BasicSearchTest extends BaseUITestCase {
query= makeProjectQuery("f"); query= makeProjectQuery("f");
assertOccurrences(query, 6); assertOccurrences(query, 6);
} }
} }

View file

@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text; package org.eclipse.cdt.ui.tests.text;
import java.util.Iterator; import java.util.Iterator;
@ -58,14 +57,12 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
import org.eclipse.cdt.internal.ui.viewsupport.ISelectionListenerWithAST; import org.eclipse.cdt.internal.ui.viewsupport.ISelectionListenerWithAST;
import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager; import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
/** /**
* Tests the C/C++ Editor's occurrence marking feature. * Tests the C/C++ Editor's occurrence marking feature.
* *
* @since 5.0 * @since 5.0
*/ */
public class MarkOccurrenceTest extends BaseUITestCase { public class MarkOccurrenceTest extends BaseUITestCase {
private static final String PROJECT = "MarkOccurrenceTest"; private static final String PROJECT = "MarkOccurrenceTest";
private static final String OCCURRENCE_ANNOTATION= "org.eclipse.cdt.ui.occurrences"; private static final String OCCURRENCE_ANNOTATION= "org.eclipse.cdt.ui.occurrences";
@ -92,11 +89,13 @@ public class MarkOccurrenceTest extends BaseUITestCase {
public MarkOccurrenceTestSetup(Test test) { public MarkOccurrenceTestSetup(Test test) {
super(test); super(test);
} }
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
fCProject= EditorTestHelper.createCProject(PROJECT, "resources/ceditor", false, true); fCProject= EditorTestHelper.createCProject(PROJECT, "resources/ceditor", false, true);
} }
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
if (fCProject != null) if (fCProject != null)
@ -160,9 +159,6 @@ public class MarkOccurrenceTest extends BaseUITestCase {
SelectionListenerWithASTManager.getDefault().addListener(fEditor, fSelWASTListener); SelectionListenerWithASTManager.getDefault().addListener(fEditor, fSelWASTListener);
} }
/*
* @see junit.framework.TestCase#tearDown()
*/
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
@ -585,8 +581,6 @@ public class MarkOccurrenceTest extends BaseUITestCase {
/** /**
* Returns the occurrence annotation color. * Returns the occurrence annotation color.
*
* @return the occurrence annotation color
*/ */
private static RGB getHighlightRGB() { private static RGB getHighlightRGB() {
AnnotationPreference annotationPref= EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(OCCURRENCE_ANNOTATION); AnnotationPreference annotationPref= EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(OCCURRENCE_ANNOTATION);
@ -599,8 +593,6 @@ public class MarkOccurrenceTest extends BaseUITestCase {
/** /**
* Returns the write occurrence annotation color. * Returns the write occurrence annotation color.
*
* @return the write occurrence annotation color
*/ */
private static RGB getWriteHighlightRGB() { private static RGB getWriteHighlightRGB() {
AnnotationPreference annotationPref= EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(WRITE_OCCURRENCE_ANNOTATION); AnnotationPreference annotationPref= EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(WRITE_OCCURRENCE_ANNOTATION);