Search in sources :

Example 76 with ZipPath

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

the class ZipUtilsTest method allFileEntries_multipleFiles.

@Test
public void allFileEntries_multipleFiles() throws Exception {
    try (ZipFile zipFile = createZipFileWithFiles("a", "b", "c")) {
        ImmutableList<ZipPath> files = ZipUtils.allFileEntriesPaths(zipFile).collect(toImmutableList());
        assertThat(files.stream().map(ZipPath::toString).collect(toList())).containsExactly("a", "b", "c");
    }
}
Also used : ZipFile(java.util.zip.ZipFile) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 77 with ZipPath

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

the class ZipUtilsTest method getPath_deepResourcePath.

@Test
public void getPath_deepResourcePath() {
    ZipPath path = ZipUtils.convertBundleToModulePath(ZipPath.create("/module2/assets/en-gb/text.txt"));
    assertThat(path.toString()).isEqualTo("assets/en-gb/text.txt");
}
Also used : ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 78 with ZipPath

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

the class ZipUtilsTest method allFileEntriesPaths_emptyZip.

@Test
public void allFileEntriesPaths_emptyZip() throws Exception {
    try (ZipFile zipFile = createZipFileWithFiles()) {
        ImmutableList<ZipPath> files = ZipUtils.allFileEntriesPaths(zipFile).collect(toImmutableList());
        assertThat(files).isEmpty();
    }
}
Also used : ZipFile(java.util.zip.ZipFile) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 79 with ZipPath

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

the class ZipUtilsTest method convertBundleToModulePath_pathPreservesAllDirectories.

@Test
public void convertBundleToModulePath_pathPreservesAllDirectories() {
    ZipPath path = ZipPath.create("/resource1");
    assertThat(path.toString()).isEqualTo("resource1");
}
Also used : ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 80 with ZipPath

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

the class TargetedDirectoryTest method simpleDirectory_tokenization.

@Test
public void simpleDirectory_tokenization() {
    ZipPath path = ZipPath.create("assets/texture#tcf_etc2");
    TargetedDirectory actual = TargetedDirectory.parse(path);
    assertThat(actual.getPathSegments()).hasSize(2);
    assertThat(actual.getPathSegments().get(0).getName()).isEqualTo("assets");
    assertThat(actual.getPathSegments().get(0).getTargeting()).isEqualTo(AssetsDirectoryTargeting.getDefaultInstance());
    assertThat(actual.getPathSegments().get(1).getName()).isEqualTo("texture");
    assertThat(actual.getPathSegments().get(1).getTargeting()).isEqualTo(assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC2)));
}
Also used : ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Aggregations

ZipPath (com.android.tools.build.bundletool.model.ZipPath)194 Test (org.junit.Test)154 BuildApksResult (com.android.bundle.Commands.BuildApksResult)106 Path (java.nio.file.Path)55 DeviceSpec (com.android.bundle.Devices.DeviceSpec)44 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)23 ImmutableSet (com.google.common.collect.ImmutableSet)23 ModuleEntry (com.android.tools.build.bundletool.model.ModuleEntry)19 Variant (com.android.bundle.Commands.Variant)16 ApksArchiveHelpers.createVariant (com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createVariant)15 BundleModule (com.android.tools.build.bundletool.model.BundleModule)13 ImmutableList (com.google.common.collect.ImmutableList)12 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)11 ApksArchiveHelpers.standaloneVariant (com.android.tools.build.bundletool.testing.ApksArchiveHelpers.standaloneVariant)10 Theory (org.junit.experimental.theories.Theory)10 AdbServer (com.android.tools.build.bundletool.device.AdbServer)9 IOException (java.io.IOException)9 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)8 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)8 UncheckedIOException (java.io.UncheckedIOException)8