use of org.eclipse.search.ui.ISearchQuery in project eclipse.platform.text by eclipse.
the class QueryManagerTest method testRemoveQuery.
@Test
public void testRemoveQuery() {
ISearchQuery query = new NullQuery();
InternalSearchUI.getInstance().addQuery(query);
InternalSearchUI.getInstance().removeQuery(query);
ISearchQuery[] all = InternalSearchUI.getInstance().getQueries();
for (int i = 0; i < all.length; i++) {
if (query == all[i])
assertTrue(false);
}
}
use of org.eclipse.search.ui.ISearchQuery in project eclipse.platform.text by eclipse.
the class QueryManagerTest method testAddQuery.
@Test
public void testAddQuery() {
ISearchQuery query = new NullQuery();
InternalSearchUI.getInstance().addQuery(query);
ISearchQuery[] all = NewSearchUI.getQueries();
for (int i = 0; i < all.length; i++) {
if (query == all[i])
return;
}
assertTrue(false);
}
use of org.eclipse.search.ui.ISearchQuery in project eclipse.platform.text by eclipse.
the class TestSearchResult method testAddMatches.
@Test
public void testAddMatches() {
ISearchQuery query = new NullQuery();
AbstractTextSearchResult result = (AbstractTextSearchResult) query.getSearchResult();
// $NON-NLS-1$
String object = "object";
Match match1 = new Match(object, 0, 0);
Match match2 = new Match(object, 0, 0);
result.addMatches(new Match[] { match1, match2 });
assertEquals(result.getMatchCount(), 2);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 2);
}
use of org.eclipse.search.ui.ISearchQuery in project eclipse.platform.text by eclipse.
the class TestSearchResult method testAddMatchDifferentStartInOrder.
@Test
public void testAddMatchDifferentStartInOrder() {
ISearchQuery query = new NullQuery();
AbstractTextSearchResult result = (AbstractTextSearchResult) query.getSearchResult();
// $NON-NLS-1$
String object = "object";
Match match1 = new Match(object, 0, 0);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 1);
Match match2 = new Match(object, 1, 1);
result.addMatch(match2);
Match match3 = new Match(object, 2, 2);
result.addMatch(match3);
Match[] matches = result.getMatches(object);
assertTrue("matches[0]", matches[0] == match1);
assertTrue("matches[1]", matches[1] == match2);
assertTrue("matches[2]", matches[2] == match3);
}
use of org.eclipse.search.ui.ISearchQuery in project eclipse.platform.text by eclipse.
the class TestSearchResult method testBatchedMatchEvent.
@Test
public void testBatchedMatchEvent() {
final boolean[] wasAdded = { false };
final boolean[] wasRemoved = { false };
ISearchQuery query = new NullQuery();
AbstractTextSearchResult result = (AbstractTextSearchResult) query.getSearchResult();
result.addListener(new ISearchResultListener() {
@Override
public void searchResultChanged(SearchResultEvent e) {
if (e instanceof MatchEvent) {
MatchEvent evt = (MatchEvent) e;
if (evt.getKind() == MatchEvent.ADDED) {
wasAdded[0] = true;
} else {
wasRemoved[0] = true;
}
}
}
});
// $NON-NLS-1$
String object = "object";
Match match1 = new Match(object, 0, 0);
result.addMatches(new Match[] { match1 });
assertTrue(wasAdded[0]);
wasAdded[0] = false;
result.addMatches(new Match[] { match1 });
assertFalse(wasAdded[0]);
Match match2 = new Match(object, 0, 0);
result.addMatches(new Match[] { match2 });
assertTrue(wasAdded[0]);
wasAdded[0] = false;
result.removeMatches(new Match[] { match2 });
assertTrue(wasRemoved[0]);
wasRemoved[0] = false;
result.removeMatches(new Match[] { match2 });
assertFalse(wasRemoved[0]);
}
Aggregations