Search in sources :

Example 1 with MockProgressIndicator

use of com.intellij.mock.MockProgressIndicator in project intellij-community by JetBrains.

the class CodeInsightTestFixtureImpl method getGotoClassResults.

@NotNull
@Override
public List<Object> getGotoClassResults(@NotNull String pattern, boolean searchEverywhere, @Nullable PsiElement contextForSorting) {
    final ChooseByNameBase chooseByNamePopup = getMockChooseByNamePopup(contextForSorting);
    final ArrayList<Object> results = new ArrayList<>();
    chooseByNamePopup.getProvider().filterElements(chooseByNamePopup, chooseByNamePopup.transformPattern(pattern), searchEverywhere, new MockProgressIndicator(), new CommonProcessors.CollectProcessor<>(results));
    return results;
}
Also used : MockProgressIndicator(com.intellij.mock.MockProgressIndicator) ChooseByNameBase(com.intellij.ide.util.gotoByName.ChooseByNameBase) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MockProgressIndicator

use of com.intellij.mock.MockProgressIndicator in project android by JetBrains.

the class ResourceFolderRepositoryFileCacheTest method testPruneResourceCachesInProject.

public void testPruneResourceCachesInProject() throws IOException {
    ResourceFolderRepositoryFileCache cache = ResourceFolderRepositoryFileCacheService.get();
    VirtualFile resourceDir = getResourceDir();
    File resourceCacheDir = cache.getResourceDir(getProject(), resourceDir);
    assertNotNull(resourceCacheDir);
    FileUtil.ensureExists(resourceCacheDir);
    // Add a dummy directories alongside the real cache directory.
    File dummyDirectory = new File(resourceCacheDir.getParent(), "dummyResDirCache");
    FileUtil.ensureExists(dummyDirectory);
    assertTrue(dummyDirectory.exists());
    // Now prune.
    PruneTask pruneTask = new PruneTask(getProject());
    pruneTask.performInDumbMode(new MockProgressIndicator());
    assertFalse(dummyDirectory.exists());
    assertTrue(resourceCacheDir.exists());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PruneTask(com.android.tools.idea.res.ResourceFolderRepositoryFileCacheImpl.PruneTask) MockProgressIndicator(com.intellij.mock.MockProgressIndicator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with MockProgressIndicator

use of com.intellij.mock.MockProgressIndicator in project android by JetBrains.

the class ResourceFolderRepositoryFileCacheTest method testCacheVersionCheck.

public void testCacheVersionCheck() throws IOException {
    ResourceFolderRepositoryFileCacheImpl cache = (ResourceFolderRepositoryFileCacheImpl) ResourceFolderRepositoryFileCacheService.get();
    // Creating the root dir the first time gives us a stamp file.
    File rootDir = cache.getRootDir();
    assertNotNull(rootDir);
    assertTrue(cache.isVersionSame(rootDir));
    // If we delete the cache, it'll be empty without a stamp file.
    cache.delete();
    assertFalse(rootDir.exists());
    assertFalse(cache.isVersionSame(rootDir));
    // If we imagine a situation before the stamp file was introduced into the codebase
    // (root dir is made and it has content, but no stamp file) it is not valid.
    assertTrue(rootDir.mkdirs());
    List<File> files = addProjectDirectories(3, 0);
    for (File file : files) {
        assertTrue(file.exists());
    }
    assertFalse(cache.isVersionSame(rootDir));
    assertFalse(cache.isValid());
    // Now try setting up the correct version and a few directories (stamping happens automatically).
    cache.delete();
    files = addProjectDirectories(3, 0);
    for (File file : files) {
        assertTrue(file.exists());
    }
    assertTrue(cache.isVersionSame(rootDir));
    assertTrue(cache.isValid());
    // Now try overwriting version stamp with a too old version.
    cache.stampVersion(rootDir, ResourceFolderRepositoryFileCacheImpl.EXPECTED_CACHE_VERSION - 1);
    assertFalse(cache.isVersionSame(rootDir));
    assertFalse(cache.isValid());
    // The management task should clean up old files if the version is invalid.
    ManageLruProjectFilesTask task = new ManageLruProjectFilesTask(getProject());
    task.performInDumbMode(new MockProgressIndicator());
    assertFalse(rootDir.exists());
    for (File file : files) {
        assertFalse(file.exists());
    }
    assertFalse(cache.isVersionSame(rootDir));
    // However, once anything grabs the root dir again, it is stamped and valid again.
    rootDir = cache.getRootDir();
    assertNotNull(rootDir);
    assertTrue(cache.isVersionSame(rootDir));
    assertTrue(cache.isValid());
}
Also used : ManageLruProjectFilesTask(com.android.tools.idea.res.ResourceFolderRepositoryFileCacheImpl.ManageLruProjectFilesTask) MockProgressIndicator(com.intellij.mock.MockProgressIndicator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

MockProgressIndicator (com.intellij.mock.MockProgressIndicator)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 ManageLruProjectFilesTask (com.android.tools.idea.res.ResourceFolderRepositoryFileCacheImpl.ManageLruProjectFilesTask)1 PruneTask (com.android.tools.idea.res.ResourceFolderRepositoryFileCacheImpl.PruneTask)1 ChooseByNameBase (com.intellij.ide.util.gotoByName.ChooseByNameBase)1 NotNull (org.jetbrains.annotations.NotNull)1