use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BundleFilesValidatorTest method validateOtherFile_inUnknownDirectory_throws.
@Test
public void validateOtherFile_inUnknownDirectory_throws() throws Exception {
ZipPath otherFile = ZipPath.create("unrecognized/path.txt");
InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleFilesValidator().validateModuleFile(otherFile));
assertThat(e).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 BundleFilesValidatorTest method validateDexFile_nonDexExtension_throws.
@Test
public void validateDexFile_nonDexExtension_throws() throws Exception {
ZipPath nonDexFile = ZipPath.create("dex/classes.dat");
InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleFilesValidator().validateModuleFile(nonDexFile));
assertThat(e).hasMessageThat().contains("Files under dex/ must have .dex extension, found 'dex/classes.dat'.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BundleZipValidatorTest method validateBundleZipEntry_directory_throws.
@Test
public void validateBundleZipEntry_directory_throws() throws Exception {
Path bundlePath = new ZipBuilder().addDirectory(ZipPath.create("directory")).writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
ArrayList<? extends ZipEntry> entries = Collections.list(bundleZip.entries());
// Sanity check.
assertThat(entries).hasSize(1);
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new BundleZipValidator().validateBundleZipEntry(bundleZip, entries.get(0)));
assertThat(exception).hasMessageThat().contains("zip file contains directory zip entry");
}
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class DeviceTierParityValidatorTest method tierNumbersNotContiguous_throws.
@Test
public void tierNumbersNotContiguous_throws() {
BundleModule moduleA = new BundleModuleBuilder("a").addFile("assets/img1#tier_0/image.jpg").addFile("assets/img1#tier_2/image.jpg").setManifest(androidManifest("com.test.app")).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new DeviceTierParityValidator().validateAllModules(ImmutableList.of(moduleA)));
assertThat(exception).hasMessageThat().contains("All modules with device tier targeting must support the same contiguous" + " range of tier values starting from 0, but module 'a' supports [0, 2].");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class TextureCompressionFormatParityValidatorTest method tcfsWithNoFallbackAndNoConfig_throws.
@Test
public void tcfsWithNoFallbackAndNoConfig_throws() throws Exception {
BundleModule moduleA = new BundleModuleBuilder("a").addFile("assets/textures#tcf_astc/level1.assets").addFile("assets/textures#tcf_etc2/level1.assets").setManifest(androidManifest("com.test.app")).build();
BundleModule moduleB = new BundleModuleBuilder("b").addFile("assets/other_textures#tcf_astc/astc_file.assets").addFile("assets/other_textures#tcf_etc2/etc2_file.assets").setManifest(androidManifest("com.test.app")).build();
AppBundle appBundle = new AppBundleBuilder().addModule(moduleA).addModule(moduleB).setBundleConfig(BundleConfigBuilder.create().addSplitDimension(Value.TEXTURE_COMPRESSION_FORMAT, /* negate= */
false).build()).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new TextureCompressionFormatParityValidator().validateBundle(appBundle));
assertThat(exception).hasMessageThat().contains("When a standalone or universal APK is built, the fallback texture folders (folders" + " without #tcf suffixes) will be used, but module 'a' has no such folders." + " Instead, it has folder(s) targeted for formats [ASTC, ETC2] (without fallback" + " directories). Either add missing folders or change the configuration for the" + " TEXTURE_COMPRESSION_FORMAT optimization to specify a default suffix" + " corresponding to the format to use in the standalone and universal APKs.");
}
Aggregations