use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AarWithLibsIntegrationTest method testLibsInAarAreIncludedInApk.
@Test
public void testLibsInAarAreIncludedInApk() throws IOException {
AssumeAndroidPlatform.assumeSdkIsAvailable();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_project", tmp);
workspace.setUp();
// More importantly, the content of the libs/ should end up in the .apk of an android_binary()
// that transitively includes //:aar, but this is easier to test.
Path output = workspace.buildAndReturnOutput("//java/com/example/aar:extract-classes-dex");
String smali = new String(Files.readAllBytes(output), UTF_8);
String primaryClass = MorePaths.pathWithPlatformSeparators("com/example/PrimaryClass.smali");
String dependency = MorePaths.pathWithPlatformSeparators("com/example/dependency/Dependency.smali");
assertThat("A class from the classes.jar in the .aar should make it into the APK.", smali, containsString(primaryClass));
assertThat("A class from a jar in the libs directory in the .aar should make it into the APK.", smali, containsString(dependency));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AndroidBuildConfigIntegrationTest method testBuildConfigWithValuesFile.
@Test
public void testBuildConfigWithValuesFile() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "build_config", tmp);
workspace.setUp();
workspace.runBuckCommand("run", "//:main_values_file_test").assertSuccess();
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AndroidAarIntegrationTest method testCxxLibraryDependent.
@Test
public void testCxxLibraryDependent() throws IOException {
AssumeAndroidPlatform.assumeNdkIsAvailable();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_aar_native_deps/cxx_deps", tmp);
workspace.setUp();
String target = "//:app";
workspace.runBuckBuild(target).assertSuccess();
Path aar = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), AndroidAar.AAR_FORMAT));
ZipInspector zipInspector = new ZipInspector(aar);
zipInspector.assertFileExists("AndroidManifest.xml");
zipInspector.assertFileExists("classes.jar");
zipInspector.assertFileExists("R.txt");
zipInspector.assertFileExists("res/");
zipInspector.assertFileExists("jni/armeabi/libdep.so");
zipInspector.assertFileExists("jni/armeabi/libnative.so");
zipInspector.assertFileExists("jni/armeabi-v7a/libdep.so");
zipInspector.assertFileExists("jni/armeabi-v7a/libnative.so");
zipInspector.assertFileExists("jni/x86/libdep.so");
zipInspector.assertFileExists("jni/x86/libnative.so");
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AndroidAarIntegrationTest method testBuildAndroidAar.
@Test
public void testBuildAndroidAar() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_aar_build/caseA", tmp);
workspace.setUp();
String target = "//:app";
workspace.runBuckBuild(target).assertSuccess();
Path aar = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), AndroidAar.AAR_FORMAT));
ZipInspector zipInspector = new ZipInspector(aar);
zipInspector.assertFileExists("AndroidManifest.xml");
zipInspector.assertFileExists("classes.jar");
zipInspector.assertFileExists("R.txt");
zipInspector.assertFileExists("assets/a.txt");
zipInspector.assertFileExists("assets/b.txt");
zipInspector.assertFileExists("res/raw/helloworld.txt");
zipInspector.assertFileExists("res/values/values.xml");
zipInspector.assertFileContents("res/values/values.xml", workspace.getFileContents("res/values/A.xml").trim());
Path contents = tmp.getRoot().resolve("aar-contents");
Unzip.extractZipFile(aar, contents, Unzip.ExistingFileMode.OVERWRITE);
try (JarFile classes = new JarFile(contents.resolve("classes.jar").toFile())) {
assertThat(classes.getJarEntry("com/example/HelloWorld.class"), Matchers.notNullValue());
}
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AndroidAarIntegrationTest method testResultIsRecorded.
@Test
public void testResultIsRecorded() throws IOException, InterruptedException {
AssumeAndroidPlatform.assumeNdkIsAvailable();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_project", tmp);
workspace.setUp();
workspace.enableDirCache();
workspace.runBuckBuild("//apps/sample:nearly_empty_aar").assertSuccess();
workspace.runBuckCommand("clean");
Path result = workspace.buildAndReturnOutput("//apps/sample:nearly_empty_aar");
assertThat(workspace.asCell().getFilesystem().exists(result), Matchers.is(true));
}
Aggregations