Search in sources :

Example 1 with GradleInvocationResult

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();
}
Also used : GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) Test(org.junit.Test)

Example 2 with GradleInvocationResult

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");
}
Also used : GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with GradleInvocationResult

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();
}
Also used : GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) Ignore(org.junit.Ignore) Test(org.junit.Test) RunIn(com.android.tools.idea.tests.gui.framework.RunIn)

Example 4 with GradleInvocationResult

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()));
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Example 5 with GradleInvocationResult

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"));
}
Also used : Iterables(com.google.common.collect.Iterables) java.util(java.util) SdkConstants(com.android.SdkConstants) StringUtil(com.intellij.openapi.util.text.StringUtil) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) AndroidLibrary(com.android.builder.model.AndroidLibrary) Collectors(java.util.stream.Collectors) File(java.io.File) Predicate(com.google.common.base.Predicate) PROJECT_WITH_DATA_BINDING(com.android.tools.idea.testing.TestProjectPaths.PROJECT_WITH_DATA_BINDING) Message(com.android.ide.common.blame.Message) org.jetbrains.org.objectweb.asm(org.jetbrains.org.objectweb.asm) GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) AndroidGradleTestCase(com.android.tools.idea.testing.AndroidGradleTestCase) com.intellij.psi(com.intellij.psi) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) NotNull(org.jetbrains.annotations.NotNull) ZipEntry(java.util.zip.ZipEntry) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState) Joiner(com.google.common.base.Joiner) IOException(java.io.IOException) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState) GradleInvocationResult(com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

GradleInvocationResult (com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult)9 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)3 File (java.io.File)3 IOException (java.io.IOException)3 NotNull (org.jetbrains.annotations.NotNull)3 Test (org.junit.Test)3 SdkConstants (com.android.SdkConstants)2 GradleBuildInvoker (com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 RunIn (com.android.tools.idea.tests.gui.framework.RunIn)2 Project (com.intellij.openapi.project.Project)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Nullable (org.jetbrains.annotations.Nullable)2 Ignore (org.junit.Ignore)2 AndroidLibrary (com.android.builder.model.AndroidLibrary)1 Message (com.android.ide.common.blame.Message)1 TestUtils.getSdk (com.android.testutils.TestUtils.getSdk)1 TestUtils.getWorkspaceFile (com.android.testutils.TestUtils.getWorkspaceFile)1 IdeInfo (com.android.tools.idea.IdeInfo)1