use of com.intellij.psi.PsiField in project android by JetBrains.
the class AndroidResourceUtilTest method testFindResourceFieldsWithInheritance.
/** Tests that "inherited" resource references are found (R fields in generated in dependent modules). */
public void testFindResourceFieldsWithInheritance() throws Exception {
myFixture.copyFileToProject("R.java", "gen/p1/p2/R.java");
Module libModule = myAdditionalModules.get(0);
// Remove the current manifest (has wrong package name) and copy a manifest with proper package into the lib module.
deleteManifest(libModule);
myFixture.copyFileToProject("util/lib/AndroidManifest.xml", "additionalModules/lib/AndroidManifest.xml");
// Copy an empty R class with the proper package into the lib module.
myFixture.copyFileToProject("util/lib/R.java", "additionalModules/lib/gen/p1/p2/lib/R.java");
// Add some lib string resources.
myFixture.copyFileToProject("util/lib/strings.xml", "additionalModules/lib/res/values/strings.xml");
AndroidFacet facet = AndroidFacet.getInstance(libModule);
assertThat(facet).isNotNull();
PsiField[] fields = AndroidResourceUtil.findResourceFields(facet, "string", "lib_hello", false);
Set<String> dirNames = Sets.newHashSet();
for (PsiField field : fields) {
assertEquals("lib_hello", field.getName());
dirNames.add(field.getContainingFile().getContainingDirectory().getName());
}
assertEquals(ImmutableSet.of("p2", "lib"), dirNames);
assertEquals(2, fields.length);
}
Aggregations