Search in sources :

Example 1 with AndroidProjectStub

use of com.android.tools.idea.gradle.stubs.android.AndroidProjectStub in project android by JetBrains.

the class GradleRenderErrorContributorTest method setUpAndroidFacetWithGradleModelWithIssue.

private void setUpAndroidFacetWithGradleModelWithIssue() {
    ApplicationManager.getApplication().runWriteAction(() -> {
        FacetManager.getInstance(myModule).addFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
    });
    AndroidFacet facet = AndroidFacet.getInstance(myModule);
    assertThat(facet).isNotNull();
    File root = Projects.getBaseDirPath(myProject);
    AndroidProjectStub androidProject = TestProjects.createBasicProject();
    // The problematic plugin version.
    // https://code.google.com/p/android/issues/detail?id=170841
    androidProject.setModelVersion("1.2.2");
    AndroidModuleModel model = new AndroidModuleModel(androidProject.getName(), root, androidProject, "debug");
    facet.setAndroidModel(model);
    model = AndroidModuleModel.get(myModule);
    assertThat(model).isNotNull();
    assertThat(model.getFeatures().isLayoutRenderingIssuePresent()).isTrue();
}
Also used : AndroidProjectStub(com.android.tools.idea.gradle.stubs.android.AndroidProjectStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) File(java.io.File) MockPsiFile(com.intellij.mock.MockPsiFile) PsiFile(com.intellij.psi.PsiFile) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 2 with AndroidProjectStub

use of com.android.tools.idea.gradle.stubs.android.AndroidProjectStub in project android by JetBrains.

the class EncodingValidationStrategyTest method testValidate.

public void testValidate() {
    String modelEncoding = "UTF-8";
    AndroidModuleModel androidModel = mock(AndroidModuleModel.class);
    when(androidModel.getModelVersion()).thenReturn(GradleVersion.parse("1.2.0"));
    AndroidProjectStub androidProject = new AndroidProjectStub("app");
    androidProject.getJavaCompileOptions().setEncoding(modelEncoding);
    when(androidModel.getAndroidProject()).thenReturn(androidProject);
    myStrategy.validate(mock(Module.class), androidModel);
    assertEquals(modelEncoding, myStrategy.getMismatchingEncoding());
}
Also used : AndroidProjectStub(com.android.tools.idea.gradle.stubs.android.AndroidProjectStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) Module(com.intellij.openapi.module.Module)

Example 3 with AndroidProjectStub

use of com.android.tools.idea.gradle.stubs.android.AndroidProjectStub in project android by JetBrains.

the class ProjectResourceRepositoryTest method addArchiveLibraries.

private void addArchiveLibraries() {
    // Add in some Android projects too
    // make it a Gradle project
    myFacet.getProperties().ALLOW_USER_CONFIGURATION = false;
    AndroidProjectStub androidProject = TestProjects.createFlavorsProject();
    VariantStub variant = androidProject.getFirstVariant();
    assertNotNull(variant);
    File rootDir = androidProject.getRootDir();
    AndroidModuleModel androidModel = new AndroidModuleModel(androidProject.getName(), rootDir, androidProject, variant.getName());
    myFacet.setAndroidModel(androidModel);
    File bundle = new File(rootDir, "bundle.aar");
    File libJar = new File(rootDir, "bundle_aar" + File.separatorChar + "library.jar");
    AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar);
    variant.getMainArtifact().getDependencies().addLibrary(library);
}
Also used : AndroidProjectStub(com.android.tools.idea.gradle.stubs.android.AndroidProjectStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) VariantStub(com.android.tools.idea.gradle.stubs.android.VariantStub) AndroidLibraryStub(com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Aggregations

AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)3 AndroidProjectStub (com.android.tools.idea.gradle.stubs.android.AndroidProjectStub)3 PsiFile (com.intellij.psi.PsiFile)2 File (java.io.File)2 AndroidLibraryStub (com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub)1 VariantStub (com.android.tools.idea.gradle.stubs.android.VariantStub)1 MockPsiFile (com.intellij.mock.MockPsiFile)1 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1