use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BuildBundleCommandTest method runsBundleFilesValidator_rogueFileInModuleRoot_throws.
// Tests bellow validate that specific validators are run for the input modules. For the lack
// of better options, for each validator there is a single test that is most representative of
// the validator.
@Test
public void runsBundleFilesValidator_rogueFileInModuleRoot_throws() throws Exception {
Path module = new ZipBuilder().addFileWithContent(ZipPath.create("rogue.txt"), "".getBytes(UTF_8)).addFileWithProtoContent(ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME)).writeTo(tmpDir.resolve("base.zip"));
BuildBundleCommand command = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(module)).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, command::execute);
assertThat(exception).hasMessageThat().contains("Module files can be only in pre-defined directories");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class WearApkLocatorTest method xmlDescriptionFileNotParseable_throws.
@Test
public void xmlDescriptionFileNotParseable_throws() {
ResourceTable resourceTable = buildResourceTableForEmbeddedWearApk(wearableApkPath);
AndroidManifest androidManifest = buildAndroidManifestForWearApk(resourceTable);
ImmutableList<ModuleEntry> entries = ImmutableList.of(createModuleEntryForFile(WEAR_DESC_XML_RES_PATH, "RandomText".getBytes(UTF_8)));
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' could not be parsed.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class WearApkLocatorTest method embeddedWearApkNotAtDesignedLocation_throws.
@Test
public void embeddedWearApkNotAtDesignedLocation_throws() {
ResourceTable resourceTable = buildResourceTableForEmbeddedWearApk(wearableApkPath);
AndroidManifest androidManifest = buildAndroidManifestForWearApk(resourceTable);
ImmutableList<ModuleEntry> entries = ImmutableList.of(createModuleEntryForFile(WEAR_DESC_XML_RES_PATH, createEmbeddedWearableAppXmlDescription(WEAR_APK_RES_NAME).toByteArray()));
ModuleSplit moduleSplit = createModuleSplit(androidManifest, resourceTable, entries);
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> WearApkLocator.findEmbeddedWearApkPaths(moduleSplit));
assertThat(exception).hasMessageThat().isEqualTo("Wear APK expected at location 'res/raw/wear.apk' but was not found.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class WearApkLocatorTest method resourceReferencedInMetadataDoesNotExist_throws.
@Test
public void resourceReferencedInMetadataDoesNotExist_throws() {
ResourceTable resourceTable = new ResourceTableBuilder().addPackage(PACKAGE_NAME).build();
AndroidManifest androidManifest = AndroidManifest.create(androidManifest(PACKAGE_NAME, withMetadataResource(WEAR_APK_1_0_METADATA_KEY, 0x7F000000)));
ImmutableList<ModuleEntry> entries = buildEntriesForEmbeddedWearApk(wearableApkPath);
ModuleSplit moduleSplit = createModuleSplit(androidManifest, resourceTable, entries);
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> WearApkLocator.findEmbeddedWearApkPaths(moduleSplit));
assertThat(exception).hasMessageThat().isEqualTo("Resource 0x7f000000 is referenced in the manifest in the " + "'com.google.android.wearable.beta.app' metadata, but was not found in the " + "resource table.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class WearApkLocatorTest method xmlDescriptionResourceNotPointingAtFile_throws.
@Test
public void xmlDescriptionResourceNotPointingAtFile_throws() {
ResourceTable resourceTable = new ResourceTableBuilder().addPackage(PACKAGE_NAME).addResource(XML_TYPE, WEAR_DESC_XML_RES_NAME, ConfigValue.newBuilder().setValue(newStringValue(WEAR_DESC_XML_RES_PATH)).build()).addFileResource(RAW_TYPE, WEAR_APK_RES_NAME, WEAR_APK_RES_PATH).build();
AndroidManifest androidManifest = buildAndroidManifestForWearApk(resourceTable);
ImmutableList<ModuleEntry> entries = buildEntriesForEmbeddedWearApk(wearableApkPath);
ModuleSplit moduleSplit = createModuleSplit(androidManifest, resourceTable, entries);
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> WearApkLocator.findEmbeddedWearApkPaths(moduleSplit));
assertThat(exception).hasMessageThat().isEqualTo("No XML description file path found for Wear APK.");
}
Aggregations