@Override public Boolean call() { return extension.getTestOptions().getUnitTests().isReturnDefaultValues(); } });
protected void configureTestData(AbstractTestDataImpl testData) { testData.setAnimationsDisabled( getGlobalScope().getExtension().getTestOptions().getAnimationsDisabled()); } }
@Override public void execute(@NonNull AndroidReportTask task) { task.setGroup(JavaBasePlugin.VERIFICATION_GROUP); task.setDescription((taskKind == TaskKind.CONNECTED) ? "Installs and runs instrumentation tests for all flavors on connected devices.": "Installs and runs instrumentation tests using all Device Providers."); task.setReportType(ReportType.MULTI_FLAVOR); final String defaultReportsDir = scope.getReportsDir().getAbsolutePath() + "/" + FD_ANDROID_TESTS; final String defaultResultsDir = scope.getOutputsDir().getAbsolutePath() + "/" + FD_ANDROID_RESULTS; final String subfolderName = taskKind == TaskKind.CONNECTED ? "/connected/" : "/devices/"; ConventionMappingHelper.map(task, "resultsDir", (Callable<File>) () -> { final String dir = scope.getExtension().getTestOptions().getResultsDir(); String rootLocation = dir != null && !dir.isEmpty() ? dir : defaultResultsDir; return scope.getProject().file(rootLocation + subfolderName + FD_FLAVORS_ALL); }); ConventionMappingHelper.map(task, "reportsDir", (Callable<File>) () -> { final String dir = scope.getExtension().getTestOptions().getReportDir(); String rootLocation = dir != null && !dir.isEmpty() ? dir : defaultReportsDir; return scope.getProject().file(rootLocation + subfolderName + FD_FLAVORS_ALL); }); } }
@Override public File call() { String rootLocation = scope.getGlobalScope().getExtension().getTestOptions().getResultsDir(); if (rootLocation == null) { rootLocation = scope.getGlobalScope().getBuildDir() + "/" + FD_OUTPUTS + "/" + FD_ANDROID_RESULTS; } return scope.getGlobalScope().getProject().file(rootLocation + subFolder); } });
@NonNull public File getMockableAndroidJarFile() { if (mockableAndroidJarFile == null) { // Since the file ends up in $rootProject.buildDir, it will survive clean // operations - projects generated by AS don't have a top-level clean task that // would delete the top-level build directory. This means that the name has to // encode all the necessary information, otherwise the task will be UP-TO-DATE // even if the file should be regenerated. That's why we put the SDK version and // "default-values" in there, so if one project uses the returnDefaultValues flag, // it will just generate a new file and not change the semantics for other // sub-projects. There's an implicit "v1" there as well, if we ever change the // generator logic, the names will have to be changed. String fileExt; if (getExtension().getTestOptions().getUnitTests().isReturnDefaultValues()) { fileExt = ".default-values.jar"; } else { fileExt = ".jar"; } File outDir = new File( getProject().getRootProject().getBuildDir(), AndroidProject.FD_GENERATED); CharMatcher safeCharacters = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf("-.")); String sdkName = safeCharacters.negate().replaceFrom( getExtension().getCompileSdkVersion(), '-'); mockableAndroidJarFile = new File(outDir, "mockable-" + sdkName + fileExt); } return mockableAndroidJarFile; }
@Override public File call() { String rootLocation = scope.getGlobalScope().getExtension().getTestOptions() .getResultsDir(); if (rootLocation == null) { rootLocation = scope.getGlobalScope().getBuildDir() + "/" + FD_OUTPUTS + "/" + FD_ANDROID_RESULTS; } return scope.getGlobalScope().getProject().file(rootLocation + subFolder); } });
@Override public File call() { String rootLocation = scope.getGlobalScope().getExtension().getTestOptions() .getReportDir(); if (rootLocation == null) { rootLocation = scope.getGlobalScope().getBuildDir() + "/" + FD_REPORTS + "/" + FD_ANDROID_TESTS; } return scope.getGlobalScope().getProject().file(rootLocation + subFolder); } });
@Override public File call() { String rootLocation = scope.getGlobalScope().getExtension().getTestOptions().getReportDir(); if (rootLocation == null) { rootLocation = scope.getGlobalScope().getBuildDir() + "/" + FD_REPORTS + "/" + FD_ANDROID_TESTS; } return scope.getGlobalScope().getProject().file(rootLocation + subFolder); } });
.getTestOptions() .getUnitTests() .applyConfiguration(runTestsTask);
@Override public void execute(@NonNull final MockableAndroidJarTask task) { task.setGroup(TaskManager.BUILD_GROUP); task.setDescription( "Creates a version of android.jar that's suitable for unit tests."); task.setReturnDefaultValues( scope.getExtension().getTestOptions().getUnitTests().isReturnDefaultValues()); ConventionMappingHelper.map(task, "androidJar", new Callable<File>() { @Override public File call() throws Exception { checkNotNull(scope.getAndroidBuilder().getTarget(), "ensureTargetSetup not called"); return new File( scope.getAndroidBuilder().getTarget().getPath(IAndroidTarget.ANDROID_JAR)); } }); task.setOutputFile(scope.getMockableAndroidJarFile()); } }
extension.getTestOptions().getUnitTests().applyConfiguration(runTestsTask);