blob: aba4fcc0586288c33fe62d286fdae749d46b93d7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.internal.ui.text.FileSearchQuery;
import org.eclipse.search.tests.ResourceHelper;
public class ResultUpdaterTest {
private FileSearchQuery fQuery1;
private IProject fProject;
private static final String PROJECT_TO_MODIFY= "ModifiableProject";
@Before
public void setUp() throws Exception {
// create a own project to make modifications
fProject= ResourceHelper.createJUnitSourceProject(PROJECT_TO_MODIFY);
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { fProject }, fileNamePatterns, false);
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
@After
public void tearDown() throws Exception {
ResourceHelper.deleteProject(PROJECT_TO_MODIFY);
}
@Test
public void testRemoveFile() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
Object[] elements= result.getElements();
int fileCount= result.getMatchCount(elements[0]);
int totalCount= result.getMatchCount();
ResourceHelper.delete((IFile)elements[0]);
assertEquals(totalCount-fileCount, result.getMatchCount());
assertEquals(0, result.getMatchCount(elements[0]));
}
@Test
public void testRemoveProject() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
ResourceHelper.delete(fProject);
assertEquals(0, result.getMatchCount());
}
}
|