use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class AndroidManifestValidatorTest method base_withFusingConfigTrue_ok.
@Test
public void base_withFusingConfigTrue_ok() throws Exception {
BundleModule module = new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withFusingAttribute(true))).build();
new AndroidManifestValidator().validateModule(module);
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class AndroidManifestValidatorTest method bundleModules_sameVersionCode_ok.
@Test
public void bundleModules_sameVersionCode_ok() throws Exception {
ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest("com.test", withVersionCode(2))).build(), new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest("com.test", withVersionCode(2))).build());
new AndroidManifestValidator().validateAllModules(bundleModules);
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class AndroidManifestValidatorTest method nonBase_withFusingConfigTrue_ok.
@Test
public void nonBase_withFusingConfigTrue_ok() throws Exception {
BundleModule module = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withOnDemandAttribute(true), withFusingAttribute(true))).build();
new AndroidManifestValidator().validateModule(module);
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class LanguageResourcesSplitterTest method resourcesPinnedToMasterSplit_mixedWithDefaultStrings.
@Test
public void resourcesPinnedToMasterSplit_mixedWithDefaultStrings() throws Exception {
ResourceTable resourceTable = new ResourceTableBuilder().addPackage("com.test.app").addStringResource("default_label", "label").addStringResourceForMultipleLocales("pinned_label", ImmutableMap.of("en", "yes")).addStringResourceForMultipleLocales("split_label", ImmutableMap.of("en", "no")).build();
BundleModule module = new BundleModuleBuilder("testModule").setResourceTable(resourceTable).setManifest(androidManifest("com.test.app")).build();
ModuleSplit baseSplit = ModuleSplit.forResources(module);
LanguageResourcesSplitter languageSplitter = new LanguageResourcesSplitter(// pinned_label
resource -> resource.getResourceId().getFullResourceId() == 0x7f010001);
Collection<ModuleSplit> languageSplits = languageSplitter.split(baseSplit);
assertThat(languageSplits).hasSize(2);
ModuleSplit masterSplit = languageSplits.stream().filter(split -> split.isMasterSplit()).collect(onlyElement());
assertThat(masterSplit.getResourceTable()).hasValue(new ResourceTableBuilder().addPackage("com.test.app").addStringResource("default_label", "label").addStringResourceForMultipleLocales("pinned_label", ImmutableMap.of("en", "yes")).build());
ModuleSplit configSplit = languageSplits.stream().filter(split -> !split.isMasterSplit()).collect(onlyElement());
assertThat(configSplit.getApkTargeting()).isEqualTo(apkLanguageTargeting("en"));
assertThat(configSplit.getResourceTable()).hasValue(getStringResourceTable("split_label", 0x02, ImmutableList.of(value("no", locale("en")))));
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class LanguageResourcesSplitterTest method resourcesPinnedToMasterSplit_emptySplitsNotCreated.
@Test
public void resourcesPinnedToMasterSplit_emptySplitsNotCreated() throws Exception {
ResourceTable resourceTable = getStringResourceTable("welcome_label", ImmutableList.of(value("hello", locale("en")), value("bienvenue", locale("fr"))), "text2", ImmutableList.of(value("no worries", locale("en")), value("de rien", locale("fr"))));
BundleModule module = new BundleModuleBuilder("testModule").setResourceTable(resourceTable).setManifest(androidManifest("com.test.app")).build();
ModuleSplit baseSplit = ModuleSplit.forResources(module);
LanguageResourcesSplitter languageSplitter = new LanguageResourcesSplitter(resource -> true);
Collection<ModuleSplit> languageSplits = languageSplitter.split(baseSplit);
assertThat(languageSplits).hasSize(1);
assertThat(Iterables.getOnlyElement(languageSplits).getResourceTable().get()).isEqualTo(resourceTable);
}
Aggregations