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.");
}
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'.");
}
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'?");
}
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'");
}
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'");
}
Aggregations