use of com.android.tools.build.bundletool.testing.FakeDevice in project bundletool by google.
the class InstallApksCommandTest method moduleDependencies_diamondGraph.
@Test
@Theory
public void moduleDependencies_diamondGraph(@FromDataPoints("apksInDirectory") boolean apksInDirectory) throws Exception {
BuildApksResult tableOfContent = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(VariantTargeting.getDefaultInstance(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))), createSplitApkSet(/* moduleName= */
"feature1", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature1-master.apk"))), createSplitApkSet(/* moduleName= */
"feature2", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of("feature1"), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature2-master.apk"))), createSplitApkSet(/* moduleName= */
"feature3", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of("feature1"), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature3-master.apk"))), createSplitApkSet(/* moduleName= */
"feature4", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of("feature2", "feature3"), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature4-master.apk"))))).build();
Path apksFile = createApks(tableOfContent, apksInDirectory);
List<Path> installedApks = new ArrayList<>();
FakeDevice fakeDevice = FakeDevice.fromDeviceSpec(DEVICE_ID, DeviceState.ONLINE, lDeviceWithLocales("en-US"));
AdbServer adbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(fakeDevice));
fakeDevice.setInstallApksSideEffect((apks, installOptions) -> installedApks.addAll(apks));
InstallApksCommand.builder().setApksArchivePath(apksFile).setAdbPath(adbPath).setAdbServer(adbServer).setModules(ImmutableSet.of("feature4")).build().execute();
assertThat(getFileNames(installedApks)).containsExactly("base-master.apk", "feature1-master.apk", "feature2-master.apk", "feature3-master.apk", "feature4-master.apk");
}
use of com.android.tools.build.bundletool.testing.FakeDevice in project bundletool by google.
the class InstallMultiApksCommandTest method execute_timeout_androidS_success.
@Test
public void execute_timeout_androidS_success() throws Exception {
FakeDevice sDevice = FakeDevice.fromDeviceSpec(DEVICE_ID, DeviceState.ONLINE, mergeSpecs(qDeviceWithLocales("en-US"), sdkVersion(ANDROID_S_API_VERSION)));
// GIVEN a fake .apks file with an .apex file.
BuildApksResult toc = fakeTableOfContents(PKG_NAME_1);
Path apksPath = createApksArchiveFile(toc, tmpDir.resolve("package1.apks"));
// GIVEN an install command with the --staged flag...
InstallMultiApksCommand command = InstallMultiApksCommand.builder().setAdbServer(fakeServerOneDevice(sDevice)).setDeviceId(DEVICE_ID).setAdbPath(adbPath).setTimeout(Duration.ofSeconds(20)).setApksArchivePaths(ImmutableList.of(apksPath)).setAapt2Command(createFakeAapt2Command(ImmutableMap.of(PKG_NAME_1, 1L))).setAdbCommand(// EXPECT the --staged flag to be included.
createFakeAdbCommand(expectedInstallApks(PKG_NAME_1, toc), /* expectedStaged= */
false, /* expectedEnableRollback= */
false, /* expectedTimeout= */
Optional.of(Duration.ofSeconds(20)), Optional.of(DEVICE_ID))).build();
givenEmptyListPackages(sDevice);
command.execute();
assertAdbCommandExecuted();
}
use of com.android.tools.build.bundletool.testing.FakeDevice in project bundletool by google.
the class ActivityManagerRunnerTest method pixelDevice_detectsFeatures.
@Test
public void pixelDevice_detectsFeatures() {
FakeDevice device = FakeDevice.fromDeviceSpec(SERIAL_NUMBER, DeviceState.ONLINE, mergeSpecs(sdkVersion(27), locales("en-US"), density(560), abis("armv64-v8a")));
device.injectShellCommandOutput("am get-config", () -> Joiner.on('\n').join(ImmutableList.of("abi: arm64-v8a,armeabi-v7a,armeabi", "config: mcc234-mnc15-en-rGB,in-rID,pl-rPL-ldltr-sw411dp-w411dp-h746dp-" + "normal-long-notround-lowdr-widecg-port-notnight-560dpi-finger-" + "keysexposed-nokeys-navhidden-nonav-v27")));
ActivityManagerRunner runner = new ActivityManagerRunner(device);
assertThat(runner.getDeviceLocales()).containsExactly("en-GB", "in-ID", "pl-PL").inOrder();
assertThat(runner.getDeviceAbis()).containsExactly("arm64-v8a", "armeabi-v7a", "armeabi").inOrder();
}
use of com.android.tools.build.bundletool.testing.FakeDevice in project bundletool by google.
the class DeviceAnalyzerTest method activityManagerFails_noProperties_defaultLocaleFallback.
@Test
public void activityManagerFails_noProperties_defaultLocaleFallback() {
// It creates no properties, hence locale fetch via properties should also fall back.
FakeDevice fakeDevice = createDeviceWithNoProperties("a", /* sdkVersion= */
26, /* locale= */
"de-DE");
fakeDevice.injectShellCommandOutput("am get-config", () -> "error");
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(fakeDevice));
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(26);
// We couldn't detect locale so we expect to fallback to en-US.
assertThat(spec.getSupportedLocalesList()).containsExactly("en-US");
}
use of com.android.tools.build.bundletool.testing.FakeDevice in project bundletool by google.
the class DeviceAnalyzerTest method prefersAbisLocalesViaActivityManager.
@Test
public void prefersAbisLocalesViaActivityManager() {
FakeDevice fakeDevice = FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(sdkVersion(27), locales("en-US"), density(560), abis("armv64-v8a")));
fakeDevice.injectShellCommandOutput("am get-config", () -> Joiner.on('\n').join(ImmutableList.of("abi: arm64-v8a,armeabi-v7a,armeabi", "config: mcc234-mnc15-en-rGB,in-rID,pl-rPL-ldltr-sw411dp-w411dp-h746dp-" + "normal-long-notround-lowdr-widecg-port-notnight-560dpi-finger-" + "keysexposed-nokeys-navhidden-nonav-v27")));
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.getSupportedAbisList()).containsExactly("arm64-v8a", "armeabi-v7a", "armeabi").inOrder();
assertThat(deviceSpec.getSupportedLocalesList()).containsExactly("en-GB", "in-ID", "pl-PL").inOrder();
}
Aggregations