use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class ApkMatcherTest method apkMatch_withModuleTypeFiltering_splitApks_installTimeModules.
@Test
public void apkMatch_withModuleTypeFiltering_splitApks_installTimeModules() {
DeviceSpec device = deviceWithSdk(21);
ZipPath baseApk = ZipPath.create("master-base.apk");
ZipPath onDemandFeatureApk = ZipPath.create("master-feature1.apk");
ZipPath installTimeFeatureApk = ZipPath.create("master-feature2.apk");
ZipPath fastFollowFeatureApk = ZipPath.create("master-feature3.apk");
BuildApksResult buildApksResult = buildApksResult(createVariant(VariantTargeting.getDefaultInstance(), splitApkSet(/* moduleName= */
"base", splitApkDescription(ApkTargeting.getDefaultInstance(), baseApk)), splitApkSet(/* moduleName= */
"onDemandFeature", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), splitApkDescription(ApkTargeting.getDefaultInstance(), onDemandFeatureApk)), splitApkSet(/* moduleName= */
"installTimeFeature", INSTALL_TIME, /* moduleDependencies= */
ImmutableList.of(), splitApkDescription(ApkTargeting.getDefaultInstance(), installTimeFeatureApk)), splitApkSet(/* moduleName= */
"fastFollowFeature", /* deliveryType= */
DeliveryType.FAST_FOLLOW, /* moduleDependencies= */
ImmutableList.of(), splitApkDescription(ApkTargeting.getDefaultInstance(), fastFollowFeatureApk))));
// By default only install-time module are matched.
Optional<ImmutableSet<String>> allModules = Optional.empty();
assertThat(createMatcher(device, allModules).getMatchingApks(buildApksResult)).containsExactly(matchedApk(baseApk, /* moduleName=*/
"base", INSTALL_TIME), matchedApk(installTimeFeatureApk, /* moduleName=*/
"installTimeFeature", INSTALL_TIME));
Optional<ImmutableSet<String>> baseModuleOnly = Optional.of(ImmutableSet.of("base"));
assertThat(createMatcher(device, baseModuleOnly).getMatchingApks(buildApksResult)).containsExactly(matchedApk(baseApk, /* moduleName=*/
"base", INSTALL_TIME), matchedApk(installTimeFeatureApk, /* moduleName=*/
"installTimeFeature", INSTALL_TIME));
Optional<ImmutableSet<String>> installTimeModuleOnly = Optional.of(ImmutableSet.of("installTimeFeature"));
assertThat(createMatcher(device, installTimeModuleOnly).getMatchingApks(buildApksResult)).containsExactly(matchedApk(baseApk, /* moduleName=*/
"base", INSTALL_TIME), matchedApk(installTimeFeatureApk, /* moduleName=*/
"installTimeFeature", INSTALL_TIME));
Optional<ImmutableSet<String>> onDemandModuleOnly = Optional.of(ImmutableSet.of("onDemandFeature"));
assertThat(createMatcher(device, onDemandModuleOnly).getMatchingApks(buildApksResult)).containsExactly(matchedApk(baseApk, /* moduleName=*/
"base", INSTALL_TIME), matchedApk(onDemandFeatureApk, /* moduleName=*/
"onDemandFeature", ON_DEMAND), matchedApk(installTimeFeatureApk, /* moduleName=*/
"installTimeFeature", INSTALL_TIME));
Optional<ImmutableSet<String>> fastFollowModuleOnly = Optional.of(ImmutableSet.of("fastFollowFeature"));
assertThat(createMatcher(device, fastFollowModuleOnly).getMatchingApks(buildApksResult)).containsExactly(matchedApk(baseApk, /* moduleName=*/
"base", INSTALL_TIME), matchedApk(fastFollowFeatureApk, /* moduleName=*/
"fastFollowFeature", FAST_FOLLOW), matchedApk(installTimeFeatureApk, /* moduleName=*/
"installTimeFeature", INSTALL_TIME));
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class DeviceAnalyzerTest method deviceId_multipleConnectedDevices_match.
@Test
public void deviceId_multipleConnectedDevices_match() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(createUsbEnabledDevice("a"), createUsbEnabledDevice("b", /* sdkVersion= */
23, /* locale= */
"pt-BR")));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.of("b"));
assertThat(spec.getScreenDensity()).isEqualTo(480);
assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
assertThat(spec.getSdkVersion()).isEqualTo(23);
assertThat(spec.getSupportedLocalesList()).containsExactly("pt-BR");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class DeviceAnalyzerTest method extractsGlExtensions.
@Test
public void extractsGlExtensions() {
FakeDevice fakeDevice = FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(density(240), locales("en-US"), abis("x86"), sdkVersion(21), glExtensions("GL_EXT_extension1", "GL_EXT_extension2")));
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(fakeDevice));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
DeviceSpec deviceSpec = analyzer.getDeviceSpec(Optional.empty());
assertThat(deviceSpec.getGlExtensionsList()).containsExactly("GL_EXT_extension1", "GL_EXT_extension2");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class DeviceAnalyzerTest method noDeviceId_oneConnectedDevice_sdk21_fine.
@Test
public void noDeviceId_oneConnectedDevice_sdk21_fine() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(createUsbEnabledDevice("a", /* sdkVersion= */
21, "fr-CA")));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.empty());
assertThat(spec.getScreenDensity()).isEqualTo(480);
assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
assertThat(spec.getSdkVersion()).isEqualTo(21);
assertThat(spec.getSupportedLocalesList()).containsExactly("fr-CA");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class DeviceAnalyzerTest method noDeviceId_oneConnectedDevice_sdk19_fallBack.
@Test
public void noDeviceId_oneConnectedDevice_sdk19_fallBack() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(createDeviceWithNoProperties("a", /* sdkVersion= */
19, /* locale= */
"de-DE")));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.empty());
assertThat(spec.getScreenDensity()).isEqualTo(480);
assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
assertThat(spec.getSdkVersion()).isEqualTo(19);
// We couldn't detect locale so we expect to fallback to en-US.
assertThat(spec.getSupportedLocalesList()).containsExactly("en-US");
}
Aggregations