Search in sources :

Example 91 with AppBundleBuilder

use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.

the class AppBundleTest method targetedAbis_abiInSomeModules.

@Test
public void targetedAbis_abiInSomeModules() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().addModule("base", baseModule -> baseModule.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT)).addModule("detail", module -> module.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT).addFile("lib/arm64-v8a/libbar.so", DUMMY_CONTENT).addFile("lib/x86/libbar.so", DUMMY_CONTENT).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/arm64-v8a", nativeDirectoryTargeting(AbiAlias.ARM64_V8A)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(AbiAlias.X86))))).build();
    assertThat(appBundle.getTargetedAbis()).containsExactly(toAbi(AbiAlias.X86), toAbi(AbiAlias.ARM64_V8A));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 92 with AppBundleBuilder

use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.

the class AppBundleTest method storeArchiveEnabled_false.

@Test
public void storeArchiveEnabled_false() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().setBundleConfig(BundleConfigBuilder.create().setStoreArchive(false).build()).addModule("base", builder -> builder.setManifest(MANIFEST)).build();
    assertThat(appBundle.storeArchiveEnabled()).isFalse();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 93 with AppBundleBuilder

use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.

the class AppBundleTest method targetedAbis_abiInAllModules.

@Test
public void targetedAbis_abiInAllModules() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().addModule("base", baseModule -> baseModule.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT).addFile("lib/x86_64/libfoo.so", DUMMY_CONTENT).addFile("lib/armeabi/libfoo.so", DUMMY_CONTENT).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(AbiAlias.X86_64)), targetedNativeDirectory("lib/armeabi", nativeDirectoryTargeting(AbiAlias.ARMEABI))))).addModule("detail", module -> module.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT).addFile("lib/x86_64/libbar.so", DUMMY_CONTENT).addFile("lib/armeabi/libbar.so", DUMMY_CONTENT).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(AbiAlias.X86_64)), targetedNativeDirectory("lib/armeabi", nativeDirectoryTargeting(AbiAlias.ARMEABI))))).build();
    assertThat(appBundle.getTargetedAbis()).containsExactly(toAbi(AbiAlias.ARMEABI), toAbi(AbiAlias.X86_64));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 94 with AppBundleBuilder

use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.

the class AppBundleTest method targetedAbis_noNativeCode.

@Test
public void targetedAbis_noNativeCode() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().addModule("base", baseModule -> baseModule.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT)).addModule("detail", module -> module.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT)).build();
    assertThat(appBundle.getTargetedAbis()).isEmpty();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 95 with AppBundleBuilder

use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.

the class AppBundleTest method storeArchiveEnabled_notPresent_false.

@Test
public void storeArchiveEnabled_notPresent_false() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().setBundleConfig(BundleConfigBuilder.create().build()).addModule("base", builder -> builder.setManifest(MANIFEST)).build();
    assertThat(appBundle.storeArchiveEnabled()).isFalse();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Aggregations

AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)155 Test (org.junit.Test)153 AppBundle (com.android.tools.build.bundletool.model.AppBundle)134 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)123 Truth.assertThat (com.google.common.truth.Truth.assertThat)123 RunWith (org.junit.runner.RunWith)123 Path (java.nio.file.Path)113 ZipFile (java.util.zip.ZipFile)113 Before (org.junit.Before)113 Rule (org.junit.Rule)113 TemporaryFolder (org.junit.rules.TemporaryFolder)113 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)112 AppBundleSerializer (com.android.tools.build.bundletool.io.AppBundleSerializer)105 ImmutableList (com.google.common.collect.ImmutableList)102 BuildApksResult (com.android.bundle.Commands.BuildApksResult)101 Variant (com.android.bundle.Commands.Variant)94 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)91 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)88 ApkDescription (com.android.bundle.Commands.ApkDescription)87 BundleConfig (com.android.bundle.Config.BundleConfig)87