use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class ProjectFilesystemTest method testCreateZip.
@Test
public void testCreateZip() throws IOException {
tmp.newFolder("foo");
tmp.newFile("foo/bar.txt");
tmp.newFile("foo/baz.txt");
Path output = tmp.newFile("out.zip");
filesystem.createZip(ImmutableList.of(Paths.get("foo/bar.txt"), Paths.get("foo/baz.txt")), output);
ZipInspector zipInspector = new ZipInspector(output);
assertEquals(ImmutableSet.of("foo/bar.txt", "foo/baz.txt"), zipInspector.getZipFileEntries());
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testApkWithMdpiFilter.
@Test
public void testApkWithMdpiFilter() throws IOException {
String target = "//apps/sample:app_mdpi";
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target);
result.assertSuccess();
Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
ZipInspector zipInspector = new ZipInspector(apkFile);
if (isBuildToolsNew) {
zipInspector.assertFileExists("res/drawable-mdpi-v4/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-hdpi-v4/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-xhdpi-v4/app_icon.png");
} else {
zipInspector.assertFileExists("res/drawable-mdpi/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-hdpi/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-xhdpi/app_icon.png");
}
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testApkWithStringsAsAssetsAndResourceFilter.
@Test
public void testApkWithStringsAsAssetsAndResourceFilter() throws IOException {
String target = "//apps/sample:app_comp_str_xhdpi";
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(target);
result.assertSuccess();
Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
ZipInspector zipInspector = new ZipInspector(apkFile);
zipInspector.assertFileExists("assets/strings/fr.fbstr");
if (isBuildToolsNew) {
zipInspector.assertFileExists("res/drawable-xhdpi-v4/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-hdpi-v4/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-mdpi-v4/app_icon.png");
} else {
zipInspector.assertFileExists("res/drawable-xhdpi/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-hdpi/app_icon.png");
zipInspector.assertFileDoesNotExist("res/drawable-mdpi/app_icon.png");
}
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testApkWithoutResourceFilter.
@Test
public void testApkWithoutResourceFilter() throws IOException {
String target = "//apps/sample:app";
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target);
result.assertSuccess();
Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
ZipInspector zipInspector = new ZipInspector(apkFile);
if (isBuildToolsNew) {
zipInspector.assertFileExists("res/drawable-mdpi-v4/app_icon.png");
zipInspector.assertFileExists("res/drawable-hdpi-v4/app_icon.png");
zipInspector.assertFileExists("res/drawable-xhdpi-v4/app_icon.png");
} else {
zipInspector.assertFileExists("res/drawable-mdpi/app_icon.png");
zipInspector.assertFileExists("res/drawable-hdpi/app_icon.png");
zipInspector.assertFileExists("res/drawable-xhdpi/app_icon.png");
}
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testModifyingImageRebuildsResourcesFilter.
@Test
public void testModifyingImageRebuildsResourcesFilter() throws IOException {
String target = "//apps/sample:app_mdpi";
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(target);
result.assertSuccess();
Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
String iconPath = isBuildToolsNew ? "res/drawable-mdpi-v4/app_icon.png" : "res/drawable-mdpi/app_icon.png";
long firstImageCrc = new ZipInspector(apkFile).getCrc(iconPath);
workspace.copyFile("res/com/sample/base/res/drawable-hdpi/app_icon.png", "res/com/sample/base/res/drawable-mdpi/app_icon.png");
workspace.resetBuildLogFile();
result = workspace.runBuckBuild(target);
result.assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally(target);
apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
long secondImageCrc = new ZipInspector(apkFile).getCrc(iconPath);
assertNotEquals(firstImageCrc, secondImageCrc);
}
Aggregations