use of com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult in project android by JetBrains.
the class GuiTestRuleTest method makeSimpleApplication.
@Test
public void makeSimpleApplication() throws Exception {
GradleInvocationResult result = guiTest.importSimpleApplication().invokeProjectMake();
assertThat(result.isBuildSuccessful()).named("Gradle build successful").isTrue();
}
use of com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult in project android by JetBrains.
the class MultipleModuleTypeCompilationTest method testAssembleTaskIsNotInvokedForLocalAarModule.
@Ignore("failed in http://go/aj/job/studio-ui-test/345 and from IDEA")
@Test
public void testAssembleTaskIsNotInvokedForLocalAarModule() throws IOException {
guiTest.importProjectAndWaitForProjectSyncToFinish("MultipleModuleTypes");
GradleInvocationResult result = guiTest.ideFrame().invokeProjectMake();
assertTrue(result.isBuildSuccessful());
List<String> invokedTasks = result.getTasks();
assertThat(invokedTasks).containsExactly(":app:compileDebugSources", ":app:compileDebugAndroidTestSources", ":javaLib:compileJava");
}
use of com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult in project android by JetBrains.
the class GradleBuildTest method compileWithJack.
/**
* Verifies that a simple app is configured to build using Jack and Jill.
* <p>
* This is run to qualify releases. Please involve the test team in substantial changes.
* <p>
* TR ID: C14581579
* <p>
* <pre>
* Test Steps:
* 1. Import the JackAndJillApp project.
* 2. Build the project.
* Verify:
* The project builds.
* </pre>
* <p>
* This test does not try and run the project.
*/
@Ignore("https://code.google.com/p/android/issues/detail?id=226797")
@RunIn(TestGroup.QA)
@Test
public void compileWithJack() throws IOException {
GradleInvocationResult buildResult = guiTest.importProjectAndWaitForProjectSyncToFinish("JackAndJillApp").invokeProjectMake();
assertThat(buildResult.isBuildSuccessful()).named("Gradle build successful").isTrue();
}
use of com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult in project android by JetBrains.
the class DataBindingScopeTest method testAccessFromInaccessibleScope.
public void testAccessFromInaccessibleScope() throws Exception {
loadProject(PROJECT_WITH_DATA_BINDING_AND_SIMPLE_LIB);
// temporary fix until test model can detect dependencies properly
GradleInvocationResult assembleDebug = invokeGradleTasks(getProject(), "assembleDebug");
GradleSyncState syncState = GradleSyncState.getInstance(getProject());
assertFalse(syncState.isSyncNeeded().toBoolean());
assertTrue(myAndroidFacet.isDataBindingEnabled());
assertTrue(myModules.hasModule("lib"));
assertTrue(myModules.hasModule("lib2"));
// app depends on lib depends on lib2
// trigger initialization
myAndroidFacet.getModuleResources(true);
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(getProject());
String appBindingClassName = "com.android.example.appwithdatabinding.databinding.ActivityMainBinding";
assertNotNull(javaPsiFacade.findClass(appBindingClassName, myAndroidFacet.getModule().getModuleWithDependenciesScope()));
assertNull(javaPsiFacade.findClass(appBindingClassName, myModules.getModule("lib").getModuleWithDependenciesScope()));
assertNull(javaPsiFacade.findClass(appBindingClassName, myModules.getModule("lib2").getModuleWithDependenciesScope()));
// only exists in lib
String libLayoutBindingClassName = "com.foo.bar.databinding.LibLayoutBinding";
assertNotNull(javaPsiFacade.findClass(libLayoutBindingClassName, myAndroidFacet.getModule().getModuleWithDependenciesScope()));
assertNotNull(javaPsiFacade.findClass(libLayoutBindingClassName, myModules.getModule("lib").getModuleWithDependenciesScope()));
assertNull(javaPsiFacade.findClass(libLayoutBindingClassName, myModules.getModule("lib2").getModuleWithDependenciesScope()));
// only exists in lib2
String lib2LayoutBindingClassName = "com.foo.bar2.databinding.Lib2LayoutBinding";
assertNotNull(javaPsiFacade.findClass(lib2LayoutBindingClassName, myAndroidFacet.getModule().getModuleWithDependenciesScope()));
assertNotNull(javaPsiFacade.findClass(lib2LayoutBindingClassName, myModules.getModule("lib").getModuleWithDependenciesScope()));
assertNotNull(javaPsiFacade.findClass(lib2LayoutBindingClassName, myModules.getModule("lib2").getModuleWithDependenciesScope()));
}
use of com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult in project android by JetBrains.
the class GeneratedCodeMatchTest method testGeneratedCodeMatch.
public void testGeneratedCodeMatch() throws Exception {
loadProject(PROJECT_WITH_DATA_BINDING);
// temporary fix until test model can detect dependencies properly
GradleInvocationResult assembleDebug = invokeGradleTasks(getProject(), "assembleDebug");
assertTrue(StringUtil.join(assembleDebug.getCompilerMessages(Message.Kind.ERROR), "\n"), assembleDebug.isBuildSuccessful());
GradleSyncState syncState = GradleSyncState.getInstance(getProject());
assertFalse(syncState.isSyncNeeded().toBoolean());
assertTrue(myAndroidFacet.isDataBindingEnabled());
// trigger initialization
myAndroidFacet.getModuleResources(true);
File classesOut = new File(getProject().getBaseDir().getPath(), "/app/build/intermediates/classes/debug");
//noinspection unchecked
Collection<File> classes = FileUtils.listFiles(classesOut, new String[] { "class" }, true);
assertTrue("if we cannot find any class, something is wrong with the test", classes.size() > 0);
ClassReader viewDataBindingClass = findViewDataBindingClass();
Set<String> baseClassInfo = collectDescriptionSet(viewDataBindingClass, new HashSet<>());
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(getProject());
Set<String> missingClasses = new HashSet<>();
Map<String, ClassReader> klassMap = classes.stream().map((file) -> {
try {
return new ClassReader(FileUtils.readFileToByteArray(file));
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
return null;
}).filter(kls -> kls != null).collect(Collectors.toMap(kls -> kls.getClassName(), kls -> kls));
Map<ClassReader, ClassReader> superClassLookup = klassMap.values().stream().filter(kls -> klassMap.containsKey(kls.getSuperName())).collect(Collectors.toMap(kls -> kls, kls -> klassMap.get(kls.getSuperName())));
int verifiedClassCount = 0;
for (ClassReader classReader : klassMap.values()) {
if (!shouldVerify(viewDataBindingClass, classReader, superClassLookup)) {
continue;
}
verifiedClassCount++;
String className = classReader.getClassName();
PsiClass psiClass = javaPsiFacade.findClass(className.replace("/", "."), myAndroidFacet.getModule().getModuleWithDependenciesAndLibrariesScope(false));
if (psiClass == null) {
missingClasses.add(className);
continue;
}
assertNotNull(psiClass);
String asmInfo = collectDescriptions(classReader, baseClassInfo);
String psiInfo = collectDescriptions(psiClass);
assertEquals(className, asmInfo, psiInfo);
}
assertTrue("test sanity, should be able to find some data binding generated classes", verifiedClassCount > 3);
assertEquals("These classes are missing", "", StringUtil.join(missingClasses, "\n"));
}
Aggregations