Search in sources :

Example 6 with AppBundle

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

the class BundleConfigValidatorTest method compression_invalidGlob_throws.

@Test
public void compression_invalidGlob_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearCompression().addUncompressedGlob("res/raw\\"));
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(e).hasMessageThat().contains("Invalid uncompressed glob: 'res/raw\\'.");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 7 with AppBundle

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

the class BundleConfigValidatorTest method optimizations_uniqueSplitDimensions_ok.

@Test
public void optimizations_uniqueSplitDimensions_ok() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.Value.ABI).addSplitDimension(SplitDimension.Value.SCREEN_DENSITY));
    new BundleConfigValidator().validateBundle(appBundle);
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) Test(org.junit.Test)

Example 8 with AppBundle

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

the class BundleConfigValidatorTest method optimizations_tcfDimensionSuffixStrippingWithoutDefault_ok.

@Test
public void optimizations_tcfDimensionSuffixStrippingWithoutDefault_ok() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.newBuilder().setValueValue(Value.TEXTURE_COMPRESSION_FORMAT_VALUE).setSuffixStripping(SuffixStripping.newBuilder().setEnabled(true)).build()));
    new BundleConfigValidator().validateBundle(appBundle);
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) Test(org.junit.Test)

Example 9 with AppBundle

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

the class BundleConfigValidatorTest method version_missing_ok.

@Test
public void version_missing_ok() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearVersion());
    new BundleConfigValidator().validateBundle(appBundle);
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) Test(org.junit.Test)

Example 10 with AppBundle

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

the class BundleConfigValidatorTest method masterResources_undefinedResourceId_throws.

@Test
public void masterResources_undefinedResourceId_throws() throws Exception {
    ResourceTable resourceTable = new ResourceTableBuilder().addPackage("com.test.app").addStringResource("label", "Hello World").build();
    int nonExistentResourceId = ResourcesUtils.entries(resourceTable).findFirst().get().getResourceId().getFullResourceId() + 1;
    AppBundle appBundle = createAppBundleBuilder(BundleConfigBuilder.create().addResourcePinnedToMasterSplit(nonExistentResourceId)).addModule("feature", module -> module.setResourceTable(resourceTable).setManifest(androidManifest("com.test.app"))).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(e).hasMessageThat().contains("The Master Resources list contains resource IDs not defined in any module. " + "For example: 0x7f010001");
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) SuffixStripping(com.android.bundle.Config.SuffixStripping) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) Value(com.android.bundle.Config.SplitDimension.Value) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) IOException(java.io.IOException) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) BundleConfig(com.android.bundle.Config.BundleConfig) ResourcesUtils(com.android.tools.build.bundletool.model.utils.ResourcesUtils) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) SplitDimension(com.android.bundle.Config.SplitDimension) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ResourceTable(com.android.aapt.Resources.ResourceTable) AppBundle(com.android.tools.build.bundletool.model.AppBundle) 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)

Aggregations

AppBundle (com.android.tools.build.bundletool.model.AppBundle)205 Test (org.junit.Test)193 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)137 ZipFile (java.util.zip.ZipFile)136 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)112 Truth.assertThat (com.google.common.truth.Truth.assertThat)112 Path (java.nio.file.Path)112 RunWith (org.junit.runner.RunWith)112 BuildApksResult (com.android.bundle.Commands.BuildApksResult)106 AppBundleSerializer (com.android.tools.build.bundletool.io.AppBundleSerializer)104 ImmutableList (com.google.common.collect.ImmutableList)102 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)101 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)100 Before (org.junit.Before)100 Rule (org.junit.Rule)100 TemporaryFolder (org.junit.rules.TemporaryFolder)100 Variant (com.android.bundle.Commands.Variant)98 IOException (java.io.IOException)94 ApkDescription (com.android.bundle.Commands.ApkDescription)90 ApkSetUtils.extractTocFromApkSetFile (com.android.tools.build.bundletool.testing.ApkSetUtils.extractTocFromApkSetFile)87