use of com.intellij.util.concurrency.SequentialTaskExecutor in project android by JetBrains.
the class ResourceFolderRepositoryTest method testInitFromHelperThread.
public void testInitFromHelperThread() throws Exception {
// By default, unit tests run from the EDT thread, which automatically have read access. Try loading a repository from a
// helper thread that doesn't have read access to make sure we grab the appropriate read locks.
// Use a data binding file, which we currently know uses a PsiDataBindingResourceItem.
VirtualFile file1 = myFixture.copyFileToProject(LAYOUT_WITH_DATA_BINDING, "res/layout-land/layout_with_data_binding.xml");
final PsiFile psiFile1 = PsiManager.getInstance(getProject()).findFile(file1);
assertNotNull(psiFile1);
VirtualFile file2 = myFixture.copyFileToProject(VALUES_WITH_DUPES, "res/values-en/values_with_dupes.xml");
ExecutorService executorService = new SequentialTaskExecutor("", PooledThreadExecutor.INSTANCE);
Future<ResourceFolderRepository> loadJob = executorService.submit(new Callable<ResourceFolderRepository>() {
@Override
public ResourceFolderRepository call() throws Exception {
return createRepository();
}
});
final ResourceFolderRepository resources = loadJob.get();
assertNotNull(resources);
AndroidFacet facet = resources.getFacet();
assertEquals(1, resources.getDataBindingResourceFiles().size());
assertEquals("land", getOnlyItem(resources, ResourceType.LAYOUT, "layout_with_data_binding").getQualifiers());
ResourceItem dupedStringItem = resources.getResourceItem(ResourceType.STRING, "app_name").get(0);
assertNotNull(dupedStringItem);
assertEquals("en", dupedStringItem.getQualifiers());
}
Aggregations