use of com.facebook.buck.android.aapt.MiniAapt.ResourceParseException in project buck by facebook.
the class MiniAaptTest method testInvalidDefinition.
@Test
public void testInvalidDefinition() throws XPathExpressionException, IOException {
ImmutableList<String> lines = ImmutableList.<String>builder().add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<LinearLayout>", "<Button android:id=\"@+string/button1\" ", "android:layout_toLeftOf=\"@id/button2\" ", "android:text=\"@string/text\" />", "</LinearLayout>").build();
Path resource = Paths.get("resource.xml");
filesystem.writeLinesToPath(lines, resource);
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
try {
aapt.processXmlFile(filesystem, resource, ImmutableSet.builder());
fail("MiniAapt should throw parsing '@+string/button1'");
} catch (ResourceParseException e) {
assertThat(e.getMessage(), containsString("Invalid definition of a resource"));
}
}
use of com.facebook.buck.android.aapt.MiniAapt.ResourceParseException in project buck by facebook.
the class MiniAaptTest method testInvalidReference.
@Test
public void testInvalidReference() throws IOException, XPathExpressionException {
ImmutableList<String> lines = ImmutableList.<String>builder().add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<LinearLayout>", "<Button android:id=\"@+id/button1\" ", "android:layout_toLeftOf=\"@someresource/button2\" ", "android:text=\"@string/text\" />", "</LinearLayout>").build();
Path resource = Paths.get("resource.xml");
filesystem.writeLinesToPath(lines, resource);
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
try {
aapt.processXmlFile(filesystem, resource, ImmutableSet.builder());
fail("MiniAapt should throw parsing '@someresource/button2'");
} catch (ResourceParseException e) {
assertThat(e.getMessage(), containsString("Invalid reference '@someresource/button2'"));
}
}
Aggregations