本文整理汇总了Java中com.android.builder.testing.api.DeviceConnector类的典型用法代码示例。如果您正苦于以下问题:Java DeviceConnector类的具体用法?Java DeviceConnector怎么用?Java DeviceConnector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeviceConnector类属于com.android.builder.testing.api包,在下文中一共展示了DeviceConnector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SimpleTestCallable
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
public SimpleTestCallable(
@NonNull DeviceConnector device,
@NonNull String projectName,
@NonNull String flavorName,
@NonNull File testApk,
@NonNull List<File> testedApks,
@NonNull File adbExec,
@NonNull TestData testData,
@NonNull File resultsDir,
@NonNull File coverageDir,
int timeoutInMs,
@NonNull Collection<String> installOptions,
@NonNull ILogger logger) {
this.projectName = projectName;
this.device = device;
this.flavorName = flavorName;
this.resultsDir = resultsDir;
this.coverageDir = coverageDir;
this.testApk = testApk;
this.testedApks = testedApks;
this.testData = testData;
this.adbExec = adbExec;
this.timeoutInMs = timeoutInMs;
this.installOptions = installOptions;
this.logger = logger;
}
示例2: deviceConnectors
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
public static List<? extends DeviceConnector> deviceConnectors(int timeoutMs, ILogger logger)
throws DeviceException {
if(deviceProvider==null) {
File adbFile = SdkHelper.getAdb();
System.out.println("adb: " + adbFile.getAbsolutePath());
deviceProvider =
new ConnectedDeviceProvider(adbFile, timeoutMs, logger);
deviceProvider.init();
}
return deviceProvider.getDevices();
}
示例3: runInstr2
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
private static void runInstr2() throws Exception {
List<? extends DeviceConnector> devs = Nuts.deviceConnectors(timeoutInMs,logger);
for (DeviceConnector dev : devs) {
SimpleTestCallable testCallable = new SimpleTestCallable(
dev, projectName, variantName,testData.getTestApk(),
ImmutableList.<File>of(testedApk), testData,
resultsDir, coverageDir, timeoutInMs, installOptions, logger);
testCallable.call();
}
}
示例4: initDevices2
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
private static void initDevices2() throws Exception {
List<? extends DeviceConnector> devs = Nuts.deviceConnectors(timeoutInMs,logger);
for (DeviceConnector dev : devs) {
System.out.println("DEVICE: " + dev);
dev.uninstallPackage(testApk.getAbsolutePath(), timeoutInMs, logger);
dev.uninstallPackage(testedApk.getAbsolutePath(), timeoutInMs, logger);
}
}
示例5: uninstall
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
@TaskAction
public void uninstall() throws DeviceException {
final Logger logger = getLogger();
final String applicationId = variant.getApplicationId();
logger.info("Uninstalling app: {}", applicationId);
final ILogger lifecycleLogger = new LoggerWrapper(getLogger(), LogLevel.LIFECYCLE);
final DeviceProvider deviceProvider =
new ConnectedDeviceProvider(getAdbExe(), lifecycleLogger);
deviceProvider.init();
final List<? extends DeviceConnector> devices = deviceProvider.getDevices();
for (DeviceConnector device : devices) {
device.uninstallPackage(applicationId, getTimeOutInMs(), getILogger());
logger.lifecycle(
"Uninstalling {} (from {}:{}) from device '{}' ({}).",
applicationId, getProject().getName(),
variant.getVariantConfiguration().getFullName(),
device.getName(), device.getSerialNumber());
}
int n = devices.size();
logger.quiet("Uninstalled {} from {} device{}.",
applicationId, n, n == 1 ? "" : "s");
}
示例6: getDevices
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
@Override
@NonNull
public List<? extends DeviceConnector> getDevices() {
try {
List<String> deviceListData = commandHelper.runCommand(null, "list");
Map<String, DeviceData> deviceDataMap = new ListParser().parseDevices(deviceListData);
Collection<String> deviceIds = manymoExtension.getDevices();
if (deviceIds.isEmpty()) {
deviceIds = deviceDataMap.keySet();
}
List<ManymoDeviceConnector> devices = Lists.newArrayListWithCapacity(deviceIds.size());
for (String deviceId : deviceIds) {
DeviceData deviceData = deviceDataMap.get(deviceId);
if (deviceData == null) {
throw new RuntimeException("Failed to find device: " + deviceId);
}
ManymoDeviceConnector device = new ManymoDeviceConnector(deviceId, deviceData,
commandHelper, bridge);
devices.add(device);
}
return devices;
} catch (InterruptedException ignored) {
}
return Collections.emptyList();
}
示例7: getDevices
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
@Override
public List<? extends DeviceConnector> getDevices() {
return devices;
}
示例8: checkDeviceApiLevel
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
/**
* Checks whether a device is compatible with a given app minSdkVersion value.
* @param device the device
* @param appMinSdkVersion the minSdkVersion of the app
* @param logger a logger object
* @param projectName the project name for logging
* @param variantName the variant name for logging
* @return true if the device can run the app
*/
public static boolean checkDeviceApiLevel(
@NonNull DeviceConnector device,
@NonNull ApiVersion appMinSdkVersion,
@NonNull ILogger logger,
@NonNull String projectName,
@NonNull String variantName) {
int deviceApiLevel = device.getApiLevel();
if (deviceApiLevel == 0) {
logger.info("Skipping device '%1$s' for '%2$s:%3$s': Unknown API Level",
device.getName(), projectName, variantName);
return false;
}
int minSdkVersion = appMinSdkVersion.getApiLevel();
// Convert codename to API version.
if (appMinSdkVersion.getCodename() != null) {
String deviceCodeName = device.getApiCodeName();
if (deviceCodeName != null) {
if (!deviceCodeName.equals(appMinSdkVersion.getCodename())) {
logger.info(
"Skipping device '%1$s', due to different API preview '%2$s' and '%3$s'",
device.getName(), deviceCodeName, appMinSdkVersion.getCodename());
return false;
}
} else {
minSdkVersion = SdkVersionInfo.getApiByBuildCode(
appMinSdkVersion.getCodename(), true);
}
}
if (minSdkVersion > deviceApiLevel) {
logger.info(
"Skipping device '%s' for '%s:%s': minSdkVersion [%s] > deviceApiLevel [%d]",
device.getName(), projectName, variantName, appMinSdkVersion.getApiString(),
deviceApiLevel);
return false;
} else {
return true;
}
}
示例9: getDevices
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
@Override
@NonNull
public List<? extends DeviceConnector> getDevices() {
return localDevices;
}
示例10: runTests
import com.android.builder.testing.api.DeviceConnector; //导入依赖的package包/类
/**
* Returns true if the tests succeeded.
*
* @param projectName
* @param variantName
* @param testApk
* @param testData
* @param deviceList
* @param maxThreads the max number of threads to run in parallel. 0 means unlimited.
* @param timeoutInMs time out in milliseconds
* @param installOptions parameters passed to the pm install command.
* @param resultsDir
* @param coverageDir
* @param logger
* @return true if the test succeed
*
* @throws TestException
* @throws InterruptedException
*/
boolean runTests(
@NonNull String projectName,
@NonNull String variantName,
@NonNull File testApk,
@NonNull TestData testData,
@NonNull List<? extends DeviceConnector> deviceList,
int maxThreads,
int timeoutInMs,
@NonNull Collection<String> installOptions,
@NonNull File resultsDir,
@NonNull File coverageDir,
@NonNull ILogger logger)
throws TestException, NoAuthorizedDeviceFoundException, InterruptedException;