use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class MiniAaptTest method testInvalidItemResource.
@Test(expected = ResourceParseException.class)
public void testInvalidItemResource() throws IOException, ResourceParseException {
ImmutableList<String> lines = ImmutableList.<String>builder().add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<resources>", "<item name=\"number\">100</item>", "</resources>").build();
filesystem.writeLinesToPath(lines, Paths.get("values.xml"));
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
aapt.processValuesFile(filesystem, Paths.get("values.xml"));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class MiniAaptTest method testParsingCustomDrawables.
@Test
public void testParsingCustomDrawables() throws IOException, ResourceParseException {
ImmutableList<String> lines = ImmutableList.<String>builder().add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<app-network xmlns:android=\"http://schemas.android.com/apk/res/android\">", " xmlns:fbui=\"http://schemas.android.com/apk/res-auto\"", " fbui:imageUri=\"http://facebook.com\"", " android:width=\"128px\"", " android:height=\"128px\"", " fbui:density=\"160\"", " >", "</app-network>").build();
filesystem.writeLinesToPath(lines, Paths.get("custom_drawable.xml"));
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
aapt.processDrawables(filesystem, Paths.get("custom_drawable.xml"));
Set<RDotTxtEntry> definitions = aapt.getResourceCollector().getResources();
assertThat(definitions, IsEqual.equalToObject(ImmutableSet.<RDotTxtEntry>of(new FakeRDotTxtEntry(IdType.INT, RType.DRAWABLE, "custom_drawable", RDotTxtEntry.CustomDrawableType.CUSTOM))));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class MiniAaptTest method testParsingGrayscaleImage.
@Test
public void testParsingGrayscaleImage() throws IOException, ResourceParseException {
ImmutableList<String> lines = ImmutableList.<String>builder().add("").build();
filesystem.writeLinesToPath(lines, Paths.get("fbui_tomato.png"));
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of(), /* resourceUnion */
false, /* isGrayscaleImageProcessingEnabled */
true);
aapt.processDrawables(filesystem, Paths.get("fbui_tomato.g.png"));
Set<RDotTxtEntry> definitions = aapt.getResourceCollector().getResources();
assertThat(definitions, IsEqual.equalToObject(ImmutableSet.<RDotTxtEntry>of(new FakeRDotTxtEntry(IdType.INT, RType.DRAWABLE, "fbui_tomato", RDotTxtEntry.CustomDrawableType.GRAYSCALE_IMAGE))));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class MiniAaptTest method testInvalidResourceType.
@Test(expected = ResourceParseException.class)
public void testInvalidResourceType() throws IOException, ResourceParseException {
ImmutableList<String> lines = ImmutableList.<String>builder().add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<resources>", "<resourcetype name=\"number\">100</resourcetype>", "</resources>").build();
filesystem.writeLinesToPath(lines, Paths.get("values.xml"));
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
aapt.processValuesFile(filesystem, Paths.get("values.xml"));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class MiniAaptTest method testFindingResourceIdsInXml.
@Test
public void testFindingResourceIdsInXml() throws IOException, XPathExpressionException, ResourceParseException {
filesystem.writeLinesToPath(RESOURCES, Paths.get("resource.xml"));
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
ImmutableSet.Builder<RDotTxtEntry> references = ImmutableSet.builder();
aapt.processXmlFile(filesystem, Paths.get("resource.xml"), references);
Set<RDotTxtEntry> definitions = aapt.getResourceCollector().getResources();
assertEquals(definitions, ImmutableSet.<RDotTxtEntry>of(new FakeRDotTxtEntry(IdType.INT, RType.ID, "button1"), new FakeRDotTxtEntry(IdType.INT, RType.ID, "button3")));
assertEquals(references.build(), ImmutableSet.<RDotTxtEntry>of(new FakeRDotTxtEntry(IdType.INT, RType.DRAWABLE, "some_image"), new FakeRDotTxtEntry(IdType.INT, RType.STRING, "text"), new FakeRDotTxtEntry(IdType.INT, RType.STYLE, "Buck_Theme"), new FakeRDotTxtEntry(IdType.INT, RType.ID, "button2")));
}
Aggregations