Search in sources :

Example 51 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class WearApkLocatorTest method xmlDescriptionFileNotFound_throws.

@Test
public void xmlDescriptionFileNotFound_throws() {
    ResourceTable resourceTable = new ResourceTableBuilder().addPackage(PACKAGE_NAME).addXmlResource(WEAR_DESC_XML_RES_NAME, WEAR_DESC_XML_RES_PATH).addFileResource(RAW_TYPE, WEAR_APK_RES_NAME, wearableApkPath.toString()).build();
    AndroidManifest androidManifest = buildAndroidManifestForWearApk(resourceTable);
    // No description XML file in the entries.
    ImmutableList<ModuleEntry> entries = ImmutableList.of(createModuleEntryForFile(wearableApkPath.toString(), TestData.readBytes("testdata/apk/com.test.app.apk")));
    ModuleSplit moduleSplit = createModuleSplit(androidManifest, resourceTable, entries);
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> WearApkLocator.findEmbeddedWearApkPaths(moduleSplit));
    assertThat(exception).hasMessageThat().isEqualTo("Wear APK XML description file expected at 'res/xml/wearable_app_desc.xml' but was not " + "found.");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) ResourceTable(com.android.aapt.Resources.ResourceTable) Test(org.junit.Test)

Example 52 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class WearApkLocatorTest method xmlDescriptionFileDoesNotDescribeWearApk_throws.

@Test
public void xmlDescriptionFileDoesNotDescribeWearApk_throws() {
    ResourceTable resourceTable = buildResourceTableForEmbeddedWearApk(wearableApkPath);
    AndroidManifest androidManifest = buildAndroidManifestForWearApk(resourceTable);
    ImmutableList<ModuleEntry> entries = ImmutableList.of(createModuleEntryForFile(WEAR_DESC_XML_RES_PATH, createWearableAppXmlDescription(XmlNode.getDefaultInstance()).toByteArray()));
    ModuleSplit moduleSplit = createModuleSplit(androidManifest, resourceTable, entries);
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> WearApkLocator.findEmbeddedWearApkPaths(moduleSplit));
    assertThat(exception).hasMessageThat().isEqualTo("The wear APK description file 'res/xml/wearable_app_desc.xml' does not contain " + "'unbundled' or 'rawPathResId'.");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ResourceTable(com.android.aapt.Resources.ResourceTable) Test(org.junit.Test)

Example 53 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class TargetingGeneratorTest method generateTargetingForNativeLibraries_abiBaseNamesDisallowed.

@Test
public void generateTargetingForNativeLibraries_abiBaseNamesDisallowed() throws Exception {
    String directoryName = "lib/ARM64-v8a";
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> generator.generateTargetingForNativeLibraries(ImmutableList.of(directoryName)));
    assertThat(exception).hasMessageThat().containsMatch("Expecting ABI name in file or directory 'lib/ARM64-v8a', but found 'ARM64-v8a' " + "which is not recognized. Did you mean 'arm64-v8a'?");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 54 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class BundleFilesValidatorTest method validateLibFile_directoryStructureTooShallow_throws.

@Test
public void validateLibFile_directoryStructureTooShallow_throws() throws Exception {
    ZipPath libFileDirectlyInLib = ZipPath.create("lib/libX.so");
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleFilesValidator().validateModuleFile(libFileDirectlyInLib));
    assertThat(e).hasMessageThat().contains("paths in form 'lib/<single-directory>/<file>.so'");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 55 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class BundleFilesValidatorTest method validateManifestDirectory_otherFile_throws.

@Test
public void validateManifestDirectory_otherFile_throws() throws Exception {
    ZipPath nonPbFile = ZipPath.create("manifest/AndroidManifest.dat");
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleFilesValidator().validateModuleFile(nonPbFile));
    assertThat(e).hasMessageThat().contains("Only 'AndroidManifest.xml' is accepted under directory 'manifest/' but found file " + "'manifest/AndroidManifest.dat'");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Aggregations

InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)188 Test (org.junit.Test)188 BundleModule (com.android.tools.build.bundletool.model.BundleModule)106 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)69 ZipPath (com.android.tools.build.bundletool.model.ZipPath)28 AppBundle (com.android.tools.build.bundletool.model.AppBundle)17 XmlNode (com.android.aapt.Resources.XmlNode)14 Path (java.nio.file.Path)14 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)12 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)10 ResourceTable (com.android.aapt.Resources.ResourceTable)9 ZipFile (java.util.zip.ZipFile)9 ZipBuilder (com.android.tools.build.bundletool.io.ZipBuilder)8 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)8 ApexImages (com.android.bundle.Files.ApexImages)6 NativeLibraries (com.android.bundle.Files.NativeLibraries)6 BundleConfigBuilder (com.android.tools.build.bundletool.testing.BundleConfigBuilder)6 Truth.assertThat (com.google.common.truth.Truth.assertThat)6 IOException (java.io.IOException)6 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)6